akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
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; }
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

map<ll,ll> prime_factor(ll n){
    map<ll,ll> mp;
    for(ll i=2; i*i<=n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    return mp;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll h,n,ans=0;
    cin >> h >> n;
    for (ll i=0;i<n;i++){
        ll a;
        cin >> a;
        h-=a;
        
    }
    if (h>0){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0;
}






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

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  for(int i=0;i<M;i++){
    int A,B;
    cin >> A >> B;
    G.at(A-1).push_back(B-1);
    G.at(B-1).push_back(A-1);
  }
  for(int i=0;i<N;i++){
    cout << G.at(i).size() << endl;
  }
}
  
    
    

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
     ll n,i;
     cin>>n;

     map<string,ll>mp;
     for(i=0;i<n;i++)
     {
         string s;
         cin>>s;
         mp[s]++;
     }
     ll mx=-1;
     for(auto it:mp)
     {
         if(it.second>mx)
         {
             mx=it.second;
         }
     }

     for(auto it:mp)
     {
         if(it.second==mx)
         {
             cout<<it.first<<endl;
         }
     }

}


Measured memory_bytes: 25216
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
vector<vector<int> > g;
int n;

void dfs(int x,int pre,int d,vector<ll>&p){
    if(d==0){
        if(pre!=-1){
            p[d] = max(p[d],(ll)g[x].size()-1);
        }else{
            p[d] = max(p[d],(ll)g[x].size());
        }
    }else{
        p[d] = max(p[d],(ll)g[x].size()-1);
    }
    for(auto s:g[x]){
        if(s!=pre){
            dfs(s,x,d+1,p);
        }
    }
}

pair<ll,ll> solve(int s){
    vector<ll> p(n);
    dfs(s,-1,0,p);
    pair<ll,ll> res=MP(0,1);
    rep(i,n){
        if(p[i]==0)break;
        res.first = i+2;
        res.second *= p[i];
    }
    //cerr << s << " " << res.first << " " << res.second << endl;
    return res;
}

pair<ll,ll> solve(pair<int,int> w){
    vector<ll> p(n);
    int s = w.first;
    int t = w.second;
    dfs(s,t,0,p);
    dfs(t,s,0,p);
    pair<ll,ll> res=MP(0,1);
    rep(i,n){
        if(p[i]==0)break;
        res.first = i+2;
        res.second *= p[i];
    }
    res.second *= 2;
    //cerr << s << " " << t << " " << res.first << " " << res.second << endl;
    return res;


}

int main(){
    cin >> n;   
    g.resize(n);
    vector<pair<int,int> > s; 
    
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
        s.push_back(MP(a,b));
    }
    if(n==2){
        cout << 1 << " " << 2 << endl;
        return 0;
    }
    pair<ll,ll> res=MP(inf,inf);
    rep(i,n){
        pair<ll,ll> k = solve(i);
        res = min(res,k);
    }
    for(auto x:s){
        pair<ll,ll> k = solve(x);
        res = min(res,k);
    }
    cout << res.first << " " << res.second << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
int n,m;
ll a[N];
ll mp[N];
 
bool cmp(ll x,ll y){
	return abs(x)<abs(y);
}

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
  	cin>>n>>m;
  	for(int i=1;i<=n;++i){
  		cin>>a[i];
  		if(a[i]>=0) mp[1]++;
  		else mp[2]++; 
  	}
  	int l=1,r=n;
  	ll ans=1;
  	if(mp[1]==0 && m%2==1){
  		sort(a+1,a+1+n,cmp);
  		for(int i=1;i<=m;++i){
  			ans=a[i]*ans%mod;
  		}
  	}
  	else{
  		sort(a+1,a+1+n,greater<int>());
  		while(m>0){
  			if(m%2==1) ans=ans*a[l++]%mod,m--;
  			else if(m>=2){
  				if(a[l]*a[l+1]>=a[r]*a[r-1]){
  					ans=ans*a[l]%mod*a[l+1]%mod;
  					l+=2;
  					m-=2;
  				}
  				else{
  					ans=ans*a[r-1]%mod*a[r]%mod;
  					r-=2;
  					m-=2;
  				}
  			} 
  		}
  	}

  	cout<<(ans%mod+mod)%mod<<endl;

    return 0;
}


Measured memory_bytes: 5212
package main

import (
        "bytes"
        "fmt"
)

func main() {
        var s string
        fmt.Scan(&s)
        buf := bytes.NewBuffer([]byte{})
        for i := 0; i < len(s); i++ {
                if i%2 == 0 {
                        buf.Write([]byte{s[i]})
                }
        }
        fmt.Println(buf.String())
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n);
	std::vector<int> vec, a(n), b(n);
	for(int i = 0; i < n; i++) {
		scanf("%d%d", &a[i], &b[i]);
		
		vec.push_back(a[i]);
		vec.push_back(b[i]);
	}
	sort(begin(vec), end(vec)); vec.erase(unique(begin(vec), end(vec)), end(vec));
	
	std::vector<int> latte(vec.size() + 1, 0);
	for(int i = 0; i < n; i++) {
		int tap = lower_bound(begin(vec), end(vec), a[i]) - begin(vec);
		int ris = upper_bound(begin(vec), end(vec), b[i]) - begin(vec);
		
		latte[tap]++;
		latte[ris]--;
	}
	for(int i = 0; i < latte.size() - 1; i++) latte[i + 1] += latte[i];
	
	int ans = 0;
	for(auto v : latte) ans = std::max(ans, v);
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 5468
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
using namespace std;
int inf = 1ll<<30;

int main(){
    int h,w;
    cin >> h >> w;
    char g[55][55];
    for(int i=0;i<h;i++)for(int j=0;j<w;j++) cin >> g[i][j];
    vector<vector<int>> count(h,vector<int>(w));
    count[0][0] = 1;

    queue<P>que;
    que.push(P{0,0});
    int dx[4] = {1,0,-1,0};
    int dy[4] = {0,1,0,-1};
    
    while(!que.empty()){
        P p = que.front();que.pop();
        int nx,ny;
        for(int i=0;i<4;i++){
            nx = p.first + dx[i];
            ny = p.second + dy[i];
            if(!(0 <=nx && 0 <= ny && h > nx && w > ny)) continue;
            if(g[nx][ny] == '#') continue;
            if(count[nx][ny])continue;
            count[nx][ny] = count[p.first][p.second] + 1;
            que.push(P{nx,ny});
        }
    }

    if(count[h-1][w-1] == 0){
        cout << "-1" << endl;
        return 0;
    }

    int sum = 0;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
        if(g[i][j] == '.') sum++;
    }

    cout << sum - count[h-1][w-1] << endl;

}

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

int main() {
	string W, T;
	cin >> W;
	for (int i = 0; i < W.size(); i++) {
		W[i] = toupper(W[i]);
	}
	
	int c = 0;
	while (1) {
		cin >> T;
		if (T == "END_OF_TEXT") break;

		for (int i = 0; i < T.size(); i++) {
			T[i] = toupper(T[i]);
		}
		if (W == T) c++;
	}

	cout << c << endl;

	return 0;
}


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

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

int main(){
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  ll sum = 0;
  if(k > a){
    k-=a;
    sum += a;
  }else{
    cout << k << endl;
    return 0;
  }

  if(k > b){
    k-=b;
  }else{
    cout << sum << endl;
    return 0;
  }

  sum -= k;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int fac[10000005],invfac[10000005];
int dp[2005][2005],N,K,sum[2005];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
int C(int n,int m) {
    if(n < m) return 0;
    return mul(fac[n],mul(invfac[m],invfac[n - m]));
}
int Query(int n,int m) {
    return C(n + m - 1,m - 1);
}
int fpow(int x,int c) {
    int res = 1,t = x;
    while(c) {
	if(c & 1) res = mul(res,t);
	t = mul(t,t);
	c >>= 1;
    }
    return res;
}
void Solve() {
    read(N);read(K);
    if(K == 1) {puts("1");return;}
    fac[0] = 1;
    for(int i = 1 ; i <= 10000000 ; ++i) fac[i] = mul(fac[i - 1],i);
    invfac[10000000] = fpow(fac[10000000],MOD - 2);
    for(int i = 9999999 ; i >= 0 ; --i) invfac[i] = mul(invfac[i + 1],i + 1);
    dp[1][0] = 1;
    for(int i = 2 ; i <= N ; ++i) {
	int t = (i - 1) * K;
	for(int j = N ; j >= 0 ; --j) sum[j] = inc(sum[j + 1],dp[i - 1][j]);
	for(int j = 0 ; j <= i ; ++j) {
	    update(dp[i][j],mul(sum[max(0,j - 1)],Query(K - 2,t - j + 1)));
	}
    }
    int ans = 0;
    for(int j = 0 ; j <= N ; ++j) update(ans,mul(dp[N][j],fac[N]));
    out(ans);enter;
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}

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

using namespace std;

using u32 = uint32_t;
using u64 = uint64_t;

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

  int x, y, z;
  cin >> x >> y >> z;

  cout << z << ' ' << x << ' ' << y;
}


Measured memory_bytes: 256
//Be Name Khoda, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>

using namespace std;
 
const int N = 1e5 + 5;
int n, ind;
int a[N];
 
int main() 
{
	cin >> n;
 
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	if (n == 1) 
	{
		if (a[0] % 2 == 1)
		{
			cout << "Second" << endl;
		}
		else
		{
			cout << "First" << endl; 
		}	
		return 0;
	}
	sort(a, a + n);
	reverse(a, a + n);
	if (a[0] == 1) 
	{
		if (n % 2 == 1)
		{
			cout << "Second" << endl; 
		}
		else
		{
			cout << "First" << endl; 
		}
		return 0;
	}
	ind = n;
	for (int i = 1; i < n; i++) 
	{
		if (a[i - 1] >= i && a[i] <= i) 
		{
			ind = i;
			break;
		}
	}
	ind--;
	if ((a[ind] - ind) % 2 == 0) 
	{
		cout << "First" << endl;
		return 0;
	}
	int cnt = 0;
	int tmp = ind + 1;
	while (tmp < n && a[tmp] == ind + 1) 
	{
		tmp++;
		cnt++;
	}
	if (cnt % 2 == 1) 
	{
		cout << "First" << endl;
	}
	else
	{
		cout << "Second" << endl;
	}
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    ll n, m;
    cin >> n >> m;
    ce((n - 1) * (m - 1));
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
const int E=1e9+7;
#define F first
#define S second
#define MK make_pair




int main(){
    int dp[1000000];
    fill(dp,&dp[1000000],E);
    dp[0]=0;
    for(int i=0;i<1000000;i++){
        dp[i+1]=min(dp[i+1],dp[i]+1);
        int r=6;
        while(i+r<1000000){
            dp[i+r]=min(dp[i+r],dp[i]+1);
            r*=6;
        }
        r=9;
        while(i+r<1000000){
            dp[i+r]=min(dp[i+r],dp[i]+1);
            r*=9;
        }
    }
    int n;
    cin>>n;
    cout<<dp[n]<<endl;
    
    return 0;
}

Measured memory_bytes: 4096
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int[] digits(int n) {
    return n.to!string.map!(c => cast(int)c - '0').array;
}

void calc(int n) {
    auto ds = digits(n);

    if (ds.all!(e => e <= ds[0])) {
        for (int i = 0; i < ds.length; i++)
            write(ds[0]);
        writeln();
    }
    else {
        int x = min(ds[0] + 1, 9);
        for (int i = 0; i < ds.length; i++)
            write(x);
        writeln();
    }
}

void main() {
    int n = readint;
    calc(n);
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define re register
struct tur{
    int x,y;
}q[100001];
int c[501],n,m,ans,T,a[401][401];
inline int read() {
	char c=getchar();int x=0;while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-48,c=getchar();return x;
}
inline int check(int x,int y) {
	if(a[x][y]) return 0;
    ++T;c[x]=c[y]=T;
    for(re int i=m; i>=1; i--){
        if (c[q[i].x]==T&&c[q[i].y]==T) return 0;
        if (c[q[i].x]==T) c[q[i].y]=T;
        else if (c[q[i].y]==T) c[q[i].x]=T;
    }
    return 1;
}
int main(){
    n=read(),m=read();
    for(re int i=1; i<=m; i++)
        q[i].x=read(),q[i].y=read(),a[q[i].x][q[i].y]=a[q[i].y][q[i].x]=1;
    for(re int i=1; i<=n; i++)
        for(re int j=i+1; j<=n; j++)
            if(check(i,j)) ans++;
    printf("%d\n",ans);
    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

bool sort_fn(Pll &a, Pll &b) {
  return a.second < b.second;
}

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

  vector<Pll> x(n);
  for (ll i = 0; i < n; ++i) {
    ll xi;
    cin >> xi;
    x[i] = mkp(i, xi);
  }
  sort(x.begin(), x.end(), sort_fn);

  vector<Pll> ans(n);
  for (ll i = 0; i < n; ++i) {
    ll idx = (n-1)/2;
    if (i < n/2) {
      idx++;
    }
    ans[i] = mkp(x[i].first, x[idx].second);
  }
  sort(ans.begin(), ans.end());

  for (ll i = 0; i < n; ++i) {
    cout << ans[i].second << endl;
  }

  return 0;
}

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

int n;
vector<ll> adj;
vi power, sum_rest;

int res;

void dfs(int v, int sum, ll used, ll disabled){
    if(v == n){
        res = max(res, sum);
        return;
    }
    if(sum + sum_rest[v] < res) return;

    int nv = v + 1;

    dfs(nv, sum, used, disabled);

    if(not(disabled & (1LL << v))){
        dfs(nv, sum + power[v], used & (1LL << v), disabled | adj[v]);
    }
}

int main(void){
    for(; cin >> n, n;){
        res = 0;

        power = sum_rest = vi(n);
        adj = vector<ll>(n);

        vector<vector<string>> d_str(n);
        map<string, int> s2i;

        int sum = 0;
        rep(i, n){
            string name;
            int p, m; cin >> name >> p >> m;
            d_str[i] = vector<string>(m);
            for(auto & ee : d_str[i]) cin >> ee;

            s2i[name] = i;
            power[i] = p;

            sum += p;
        }

        sum_rest[0] = sum;
        rep(i, n - 1){
            sum_rest[i + 1] = sum_rest[i] - power[i];
        }

        rep(i, n){
            ll vec = 0;
            for(auto & e : d_str[i]){
                int idx = s2i[e];
                vec |= (1LL << idx);
            }
            adj[i] = vec;
        }

        dfs(1, power[0], 1LL, adj[0]);
        cout << res << endl;
    }

	return 0;
}

Measured memory_bytes: 3284
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		int n=sc.nextInt();
		long x=sc.nextLong();
		long l[]=new long[n+1];
		long p[]=new long[n+1];
		for(int i=1;i<=n;i++) {
			l[i]=(long)Math.pow(2,i+2)-3;
			p[i]=(long)Math.pow(2,i+1)-1;
		}
		long ans=0;
		int now=n;
		boolean fin=false;
			while(!fin) {
				if(now==1) {
					if(x<=4) {
						ans+=x-1;
					}
					else if(x==5) {
						ans+=3;
					}
					fin=true;
					break;
				}
					
				if(x==1) {
					ans+=0;
					fin=true;
					break;
				}
				else if(x==l[now]) {
					ans+=p[now];
					fin=true;
					break;
				}
				else if(x==(l[now]+1)/2) {
					ans+=p[now-1]+1;
					fin=true;
					
					break;
				}
				else if(x<(l[now]+1)/2) {
					now--;
					x--;
				}
				else if(x>(l[now]+1)/2) {
					ans+=p[now-1]+1;
					x-=(l[now]+1)/2;
					now--;
				}
		
			}
		System.out.println(ans);
	}
		
	//-----------http://codeforces.com/blog/entry/7018---------------------------------
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	//--------------------------------------------------------

}





Measured memory_bytes: 21332
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		sc.close();

		int ans = 0;
		int sum1 = A*X + B*Y;
		int sum2 = 0;
		if(X > Y) {
			sum2 += (2*C*Y) + (A*(X - Y));
		}else {
			sum2 += (2*C*X) + (B*(Y - X));
		}
		int sum3 = X > Y ? 2*C*X : 2*C*Y;
		ans = Math.min(sum1, sum2);
		ans = Math.min(ans, sum3);
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
def LI(): return list(map(int, input().split()))
def LS(): return input().split()
def I(): return int(input())
def S(): return input()

n, c = LI()
l = []
for i in range(n):
    l.append(LI())

#チャンネル見る必要がある
#同じチャンネルで連続しているものはくっつける
la = [[[], []] for i in range(c)]
for i in l:
    la[i[2] - 1][0].append(i[0])
    la[i[2] - 1][1].append(i[1])

starts = []
ends = []
for s, e in la:
    wa = set(s).union(set(e))
    seki = set(s).intersection(set(e))
    a = list(wa.difference(seki))
    a.sort()
    for i, j in zip(a[0::2], a[1::2]):
        starts.append(i)
        ends.append(j)

s = min(starts)
e = max(ends)

imos = [0 for i in range(s,e + 2)]
for i, j in zip(starts, ends):
    imos[i - s] += 1
    imos[j - s + 1] -= 1
for i in range(len(imos) - 1):
    imos[i + 1] += imos[i]

print(max(imos))


Measured memory_bytes: 52088
import sys

sys.setrecursionlimit(10 ** 7)
# import bisect
# import numpy as np
# from collections import deque
from collections import deque
# map(int, sys.stdin.read().split())
import itertools
import heapq


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    H =list(map(int,input().split()))
    off = 0
    flag =1
    for i in range(N-1,0,-1):
        if H[i] - off >=H[i-1]:
            off =0
            continue
        elif H[i]-off +1 == H[i-1]:
            off =1
        else:
            print("No")
            exit()

    print("Yes")




if __name__ == "__main__":
    main()


Measured memory_bytes: 83520
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int[] a = new int[10];
			int[] b = new int[10];
			for(int i=0;i<10;i++){
				a[i] = sc.nextInt();
			}
			for(int i=0;i<10;i++){
				b[i] = sc.nextInt();
			}
			Arrays.sort(a);
			Arrays.sort(b);
			
			System.out.print(a[9]+a[8]+a[7] + " ");
			System.out.println(b[9]+b[8]+b[7]);
		}
	
	}	
}

Measured memory_bytes: 17176
N = sorted([(input())for i in range(5)],key=lambda x:x[-1])
S = list(map(int,N))
#合計時間
num = 0
key = 0
for x in S:
  if x % 10 == 0:
    num += x
  elif key == 0 and x % 10 != 0:
    num += x 
    key = 1
  else:
    num += x + 10 - int(str(x)[-1])
print(num) 

Measured memory_bytes: 3068
<?php
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner();
$x = $sc->nextInt();
$a = $sc->nextInt();

if($x < $a){out::println(0);}
else {out::println(10);}

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

int main(){
	
	int n;
	cin>>n;
	if(n%1000==0){
		cout<<"0"<<endl;
	}
	else{
		int x = n/1000+1;
		 cout<<abs(n-1000*x)<<endl;
	}
}

Measured memory_bytes: 3548
N,X,Y = map(int,input().split())

def f(i,j):
  if j <= X:
    return j-i
  elif Y <= i:
    return j-i
  elif X <= i and j <= Y:
    return min(j-i,(i-X)+1+(Y-j))
  elif i <= X and Y <= j:
    return (X-i)+1+(j-Y)
  elif i <= X and X <= j and j <= Y:
    return (X-i)+min(j-X,1+(Y-j))
  else:
    return (j-Y)+min(Y-i,(i-X)+1)

A = [0]*(N-1)

for k in range(1,N,1):
  for l in range(k+1,N+1,1):
    A[f(k,l)-1] += 1

for k in range(1,N,1):
  print(A[k-1])

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

int main()
{
	int a,b,c,d,e;
	int k=0;
	bool flag = false;
	cin >> a >> b >> c >> d >> e>>k;

		if (k >= (e-a)) {
			flag = true;
	}
	if (flag == true) cout << "Yay!" << endl;
	else if (flag == false)cout << ":(" << endl;
		return 0;
}

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

int main() {
    string s;
    cin >> s;
    if (s[0] == s[1] or s[1] == s[2] or s[2] == s[3]) {
        cout << "Bad" << endl;
    }
    else {
        cout << "Good" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+3;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	int ans=0;
	map<int,int> ma;
	for(int i=0;i<n;i++)
	{
		ans+=ma[a[i]];
		ma[a[i]]++;
	}
	for(int i=0;i<n;i++)
	{
		cout<<ans-(ma[a[i]]-1)<<"\n";
	}
}
// Don't be afraid to fail. Be afraid not to try.
// "Become grindian instead of greendian" - aryanc403
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

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

  
int main() {
   
    int N;
    cin >> N;
   
    vector<ll> A(N);
    for(int i=0; i<N; i++){
        cin>>A[i];
    }
   
    sort(A.begin(), A.end(), greater<ll>());
   
    ll ans = A[0];
   
    queue<ll> Q;
    for (int i = 0; i < 2; i++) Q.push(A[1]);
   
    for (int i = 2; i < N; i++) {
        ans += Q.front();
        Q.pop();
        for (int j = 0; j < 2; j++) {
            Q.push(A[i]);
        }
    }
    cout << ans << endl;
   return 0;
}

Measured memory_bytes: 6396
#include <iostream>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
using namespace std;
typedef long long ll;
const ll LINF = 1e18;

vector<ll> dp;
vector<int> H;

ll rec(int i, int K) {
    if (i==0) return dp[0] = 0;
    if (dp[i] < LINF) return dp[i];

    ll cost = LINF;
    for(int k=1; k<K+1; k++) {
        if(i>=k) {
            chmin(cost, rec(i-k, K) + abs(H[i] - H[i-k]));
        }
    }

    return dp[i]=cost;
}

int main() {
    int N, K; cin >> N >> K;
    dp.resize(N, LINF);
    H.resize(N, 0);
    REP(i, N) cin >> H[i];

    cout << rec(N-1, K) << endl;

    return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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;}


signed main(void) {
    string s;
    int a,b,c;
    cin >> a >> b >> c;
    cout << max(0LL,c-(a-b)) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    int k;
    string s;
    cin>>k>>s;

    if(s.length()<=k) cout<<s<<endl;
    else cout<<s.substr(0,k)<<"..."<<endl;
}

Measured memory_bytes: 3628
N=int(input())
A=[int(i) for i in input().split()]
X=[-1,-1,-1]
ans=1
mod=10**9+7
for i in range(N):
    tmp=0
    if A[i]>i:
        ans=0
    for j in range(3):
        if X[j]==A[i]-1:
            tmp+=1
    for j in range(3):
        if X[j]==A[i]-1 or tmp==0:
            ans=tmp*ans
            ans%=mod
            X[j]+=1
            break
print(ans)


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

int main() {

	long double a, b, c;
	cin >> a >> b >> c;

	long double s = a+b+sqrtl(a)*sqrtl(b)+sqrtl(a)*sqrtl(b);

	if(s < c) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}


	return 0;
}


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

using namespace std;

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

  vector<long long> t(5);

  for(int i=0;i<5;i++){
    cin>>t.at(i);
  }

sort(t.begin(),t.end());

long long v = n/t.at(0);

if(t.at(0)==1){
  v--;
}

cout<<v+5<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;     
int n,sum=0,ans=0;
string s;
int main()   
{           
    cin>>n;
    cin>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='I')
		{
			sum++;
		}
		if(s[i]=='D')
		{
			sum--;
		}
		ans=max(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
p=[]
for i in range(m):
    p.append(list(map(int,input().split())))
g=[[] for i in range(n+1)]
for pi in p:
    g[pi[0]].append(pi[1])
    g[pi[1]].append(pi[0])
def dfs(v,visited,g):
     for v2 in g[v]:
         if visited[v2]==0:
             visited[v2]=1
             dfs(v2,visited,g)

c=0
for pi in p:
    g[pi[0]].remove(pi[1])
    g[pi[1]].remove(pi[0])
    visited=[0]*(n+1)
    visited[0]=1
    visited[1]=1
    dfs(1,visited,g)
    if 0 in visited:
        c+=1
    g[pi[0]].append(pi[1])
    g[pi[1]].append(pi[0])
print(c)


Measured memory_bytes: 41452
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
static const int M = 10000;

int n;
vector<pair<int,int> > a[M];

void dijkstra(void);

int main(){
  int x,y,z,w,i,j;

  cin >> n;
  for(i = 0;i < n;i++){
    cin >> x >> y;
    for(j = 0;j < y;j++){
      cin >> z >> w;
      a[x].push_back(make_pair(z,w));
    }
  }
  dijkstra();

  return 0;
}

void dijkstra(void){
  priority_queue<pair<int,int> > PQ;
  int color[M],d[M],i,j,x,z;

  for(i = 0;i < n;i++){
    d[i] = 10000000;
    color[i] = 0; //0=white
  }
  d[0] = 0;
  PQ.push(make_pair(0,0));
  color[0] = 1; //1=gray

  while(!PQ.empty()){
    pair<int,int>f = PQ.top(); PQ.pop();
    x = f.second;
    color[x] = 2; //2=black
    if(d[x] < f.first * (-1)) continue;

    for(j = 0;j < a[x].size();j++){
      z = a[x][j].first;
      if(color[z] == 2) continue;
      if(d[z] > d[x] + a[x][j].second){
	d[z] = d[x] + a[x][j].second;
	PQ.push(make_pair(d[z] * (-1),z));
	color[z] = 1;
      }
    }
  }
  for(i = 0;i < n;i++){
    cout << i << " " << (d[i] == 10000000 ? -1 : d[i]) << endl;
  }
}



Measured memory_bytes: 8008
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using Debug = System.Diagnostics.Debug;
using System.Runtime.CompilerServices;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        var qhsd = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int one = Min(Min(qhsd[0] * 4, qhsd[1] * 2), qhsd[2]);
        int two = qhsd[3];
        long n = int.Parse(Console.ReadLine());
        Console.WriteLine(Min(n / 2 * two + (n % 2) * one, n * one));
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
typedef struct test{
    int i,j,k,r;
}test;
int main(){
    while (1) {
        int a,b,c,n,i,part[300],flag=1;
        test t[1000];
        scanf("%d%d%d",&a,&b,&c);
        if (a==0&&b==0&&c==0) {
            return 0;
        }
        for (i=0; i<300; i++) {
            part[i]=2;
        }
        scanf("%d",&n);
        for (i=0; i<n; i++) {
            scanf("%d%d%d%d",&t[i].i,&t[i].j,&t[i].k,&t[i].r);
            if (t[i].r) {
                part[t[i].i-1]=part[t[i].j-1]=part[t[i].k-1]=1;
            }
        }
        while (flag) {
            flag=0;
            for (i=0; i<n; i++) {
                if (!t[i].r) {
                    if (part[t[i].i-1]==1&&part[t[i].j-1]==1) {
                        part[t[i].k-1]=0;
                    }else if (part[t[i].j-1]==1&&part[t[i].k-1]==1){
                        part[t[i].i-1]=0;
                    }else if (part[t[i].k-1]==1&&part[t[i].i-1]==1){
                        part[t[i].j-1]=0;
                    }
                }
            }
        }
        for (i=0; i<a+b+c; i++) {
            printf("%d\n",part[i]);
        }
    }
}

Measured memory_bytes: 616
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int X,Y;
    cin >> X >> Y;
    bool f=false;
    for(int i=0;i<=X;i++){
        if(2*i+4*(X-i)==Y){
            f=true;
        }
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3648
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
f = int(input())
x = a + b + c + d + e + f
y = 100000
for i in (a,b,c,d):
    if y > i : y = i
z = 0
if e < f : z = e
else : z = f
print (x - y - z)

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

int f(int x){
  int res = 0;
  while(x > 0){
    res += x%10;
    x /= 10;
  }
  return res;
}

int main(){
  int n;
  cin >> n;
  if(n % f(n) == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
x = int(input())
ans = []
arr = []
for i in range(1000):
    arr.append(i**5)
for i in range(1000):
    for j in range(i,1000):
        if arr[j] + arr[i] == x:
            ans.append(j)
            ans.append(i * -1)
        if arr[j] - arr[i] == x:
            ans.append(j)
            ans.append(i)
print(*ans[0:2])

Measured memory_bytes: 9212
function main(){
  var i = 0;
  while(true){
    var fieldInfo = input[i].split(' ');
    var width = fieldInfo[0] - 0;//toInt
    var height = fieldInfo[1] - 0;//toInt

    // 0 0が入力された
    if(!width && !height){
      break;
    }

    var start;
    var goal;
    var elem = [[],[],[],[],[]];
    for(var ei = 0;ei < 5; ei++){
      elem[ei].length = 0;
    }
    
    for(var y = 0; y < height; y++){
      i++;//1行進める
      for(var x = 0; x < width; x++){
        var c = input[i][x];

        switch(c){
        case 'S':
          start = new Pos(x, y);
          break;
        case 'G':
          goal = new Pos(x, y);
          break;
        case '.':
          break;
        default : // 入力値が正しいので、絶対に属性
          elem[c - 1].push(new Pos(x, y));
          break;
        }
      }
    }

    
    var bestElement = -1;
    var distance = Infinity;
    
    // 属性ごとにループ
    for (var startElem = 0; startElem < 5; startElem++) {
      // DPの初期化 DP[属性][同じ属性内の連番]
      var dp = [[],[],[],[],[]];
      for(var h = 0; h < 5; h++){
        var hLength = elem[h].length;
        dp[h].length = hLength;
        for(var hidx = 0; hidx < hLength; hidx++){
          dp[h][hidx] = Infinity;
        }
      }
      
      // 最初に選んだパチモンから次に捕まえられる属性番号
      var first = (startElem + 1) % 5;

      var firstLength = elem[first].length;
      for (var j = 0; j < firstLength; j++) {
        // s→e1を計算
        dp[first][j] = dist(start, elem[first][j]);
      }
      
      // s->1->2->3->4->g
      // なので、ループは間の-> * 3分まわす
      for (var e = 0; e < 3; e++) {
        // ex->e(x+1)
        var now = (first + e) % 5;
        var next = (now + 1) % 5;
        var nowLength = elem[now].length;
        var nextLength = elem[next].length;
        for (var j = 0; j < nowLength; j++) {
          for (var k = 0; k < nextLength; k++) {
            dp[next][k] = Math.min(
              dp[next][k],
              dp[now][j] + 
                  dist(elem[now][j], elem[next][k]));
          }
        }
      }
      
      var last = (first + 3) % 5;
      var lastLength = elem[last].length;
      for (var j = 0; j < lastLength; j++) {
        // e4->g
        var d = dp[last][j] + 
                    dist(elem[last][j], goal);
        
        if (d !== undefined && d < distance) {
          distance = d;
          bestElement = startElem + 1;
        }
        
      }
      
    }
    
    if (distance == Infinity) {
      console.log("NA");
    } else {
      console.log(bestElement + " " + distance);
    }

    i++;
  }
  

}

function dist(from, to){
  return Math.abs(from.x - to.x) + Math.abs(from.y - to.y)
}

function Pos(a, b){
  this.x = a;
  this.y = b;
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

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

using namespace std;

char s[55];
int k;
int n;

int main()
{
    scanf("%d%d",&n,&k);
    scanf("%s",s);
    s[k - 1] = s[k - 1] + 'a' - 'A';
    printf("%s\n",s);
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    Set<String> set= new HashSet<>();
    for(int i=0;i<n;i++)set.add(sc.next());
    System.out.println(set.size());
  }
}


Measured memory_bytes: 77012
n = int(input())
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
m=0
as1 = [0 for i in range(n)]
as2 = [0 for i in range(n)]
for i in range(n):
    if  i==0:
        as1[i] = a1[i]
        as2[n-i-1] = a2[n-i-1]
    else:
        as1[i] = a1[i] + as1[i-1]
        as2[n-i-1] = a2[n-i-1] + as2[n-i]
for i in range(n):
    m = max(m,as1[i]+as2[i])
print(m)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl
int n,a[100000],b[100000],c[100000];
ll upper_count(ll b){
  return n+c-upper_bound(c,c+n,b);
}

ll lower_count(ll b){
  return lower_bound(a,a+n,b)-a;
}

int main(){
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n){
    cin>>b[i];
  }
  rep(i,n){
    cin>>c[i];
  }
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  ll ans=0;
  rep(i,n){
    ll x=upper_count(b[i]);
    ll y=lower_count(b[i]);
    ans+=x*y;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1408
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kishan Sairam Adapa
 */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ll long long int
#define MOD ((int)(1e9) + 7)

using namespace std;

class BCountingRoads {
public:
    void solve(istream& cin, ostream& cout) {
        int n, m;
        cin >> n >> m;
        vector<int> st(n+1, 0);
        for(int i=0; i<m; i++) {
            int a, b;
            cin >> a >> b;
            st[a]++; st[b]++;
        }
        for(int i=1; i<=n; i++) {
            cout << st[i] << '\n';
        }
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    BCountingRoads solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

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

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

void Main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans;
  ans = n/(a+b) * a;
  ans += min(n - (n/(a+b))*(a+b), a);
  cout << ans << endl;
}

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


Measured memory_bytes: 256
def main():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))

    min_t = 10 ** 15
    b = [10 ** 10 for i in range(n)]
    for i in range(n):
        t = i * x
        for j in range(n):
            b[j] = min(b[j], a[(j-i) % n])
            t += b[j]

        min_t = min(min_t, t)

    print(min_t)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long[] a = new long[3];
        a[0] = in.nextLong(); a[1] = in.nextLong(); a[2] = in.nextLong();
        int k = in.nextInt();
        Arrays.sort(a);
        a[2] = a[2] * (long)Math.pow(2, k);
        System.out.println(a[0] + a[1] + a[2]);
    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<vector<pint>> vvpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }

// ll get_pow(ll x, ll y){
//   ll ret=0;
//   ll temp = y;
//   while(true){
//     if(x<=temp) break;
//     ret++;
//     temp *= 2;
//   }
//   return ret;
// }



int main() {
   cout<<fixed<<setprecision(10);

   ll N;cin>>N;
   vvpint edge(N, vpint());
   rep(i,N-1){
       ll u,v,w;
       cin>>u>>v>>w;
       u--;v--;
       edge[u].pb(mp(v,w));
       edge[v].pb(mp(u,w));
   }

   vint ans(N, -1);

   stack<int> s;
   s.push(0);
   ans[0] = 0;

   while(!s.empty()){
       ll temp = s.top();
       s.pop();

       for(pint p : edge[temp]){
           ll v = p.fi;
           ll w = p.se;
           if(ans[v]<0){
               s.push(v);
               ans[v] = (ans[temp]+w)%2;
           }
       }
   }


   rep(i,N){
       cout << ans[i] << endl;
   }

}

















//


Measured memory_bytes: 9600
import java.util.*;


class Main {
  private static long gcd(long m, long n) {
      if(m < n) return gcd(n, m);
      if(n == 0) return m;
      return gcd(n, m % n);
  }

  private static long lcm(long m, long n) {
      return m * n / gcd(m, n);
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println(lcm(a, b));
  }
}

Measured memory_bytes: 23764