akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[200000+5],b[200000+5],f[200000+5];
ll n,k,sum,ans;

bool cmp(ll a,ll b)
{
	return a>b;
}

bool Check(ll x)
{
	for(int i=1;i<=n;i++)
		b[i]=x/f[i];
	ll res=0;
	for(int i=1;i<=n;i++)
		res+=max(0ll,a[i]-b[i]);
	return res<=k;
}
ll ju()
{
	ll l=0,r=(ll)1e12;
	while(l+1<=r)
	{

		ll mid=(l+r)>>1; 

		if(Check(mid))

			r=mid;

		else

			l=mid+1;

	}

	return r;
}

int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		sum+=a[i];
	}

	for(int i=1;i<=n;i++)
		scanf("%lld",&f[i]);

	if(sum<=k)
	{
		printf("0\n");
		return 0;
	}
	sort(a+1,a+n+1);
	sort(f+1,f+n+1,cmp);
	printf("%lld\n",ju());
	return 0;

}


Measured memory_bytes: 4992
#include <stdio.h>

int main(void){
	
	int i,to;
	char num[1001];

	while(1){
		scanf("%s",num);
		if(num[0]=='0')break;
		to=0;
		for(i=0;num[i]!='\0';i++){
			to+=num[i]-'0';
		}
		printf("%d\n",to);
	}

	return 0;
}

Measured memory_bytes: 536
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class DRoadToMillionaire {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> A(N);
        REP(i, N) cin >> A[i];

        set<int> s;
        int cur = 1000;
        REP(i, N) {
            int val = A[i];
            if (!s.empty()) {
                int sell = *s.begin();
                if (val > sell) {
                    int num = cur / sell;
                    cur += (val - sell) * num;
                    s.clear();
                }
            }
            s.insert(val);
        }
        cout << cur << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DRoadToMillionaire solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	vector<int64_t> height(n);
	for (int i = 0; i < n; i++)cin >> height.at(i);
	vector<int64_t> height_copy = height;
	int64_t ans = 1000000000000000000;
	//処理 見たい建物をbitsetにしちゃうn-1^2.(一番左は無条件で見れる)→お金を出力
	for (int bit = 0; bit < (1 << n - 1); bit++) {
		vector<int> want(n, 0);
		want.at(0) = 1;
		for (int i = 0; i < n - 1; i++) {
			if (bit & (1 << i))want.at(i+1)++;
		}
		int ank = 0;
		for (int i = 0; i < n; i++)if (want.at(i)==1)ank++;
		if (ank != k)continue;
		int64_t res = 0;
		//処理
		int64_t high = height.at(0);
		for (int i = 1; i < n; i++) {
			if(want.at(i)){
				if (high < height.at(i))high = height.at(i);
				else {
					res += high - height.at(i) + 1;
					height.at(i) = high + 1;
					high++;
				}
			}
			else{
				if (high < height.at(i))high = height.at(i);
			}
		}
		if (ans > res)ans = res;
		height = height_copy;
	}
	cout << ans << endl;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, M; cin >> N >> M;
    vector<ll> A(N); rep(i, N) cin >> A[i];
    sort(A.rbegin(), A.rend());
    ll ok = 0, ng = A[0]*2+1;
    ll m = (ok+ng)/2;
    while(abs(ok-ng) > 1){
        //mを超えるような握手は何通りあるか
        ll res = 0;
        rep(i, N){
            ll key = m-A[i];
            ll left = -1, right = N;
            ll mid = (left+right)/2;
            while(abs(left-right) > 1){
                if(A[mid] >= key) left = mid;
                else right = mid;
                mid = (left+right)/2;
            }
            res += left+1;
        }
        if(res >= M) ok = m;
        else ng = m;
        m = (ok+ng)/2;
    }
    //ok*M + はみ出し分が答え
    ll ans = ok*M;
    vector<ll> ruiseki(N+1, 0);
    rep(i, N) ruiseki[i+1] = ruiseki[i] + A[i];
    rep(i, N){
        //A[i]+A[j] >= ok -> A[i]+A[j]-okを足す
        ll key = ok-A[i]; //key=5で[7,7,6,5,5,4,...]のときはruiseki[5]-key*5を足す
        ll left = -1, right = N;
        ll mid = (left+right)/2;
        while(abs(left-right) > 1){
            if(A[mid] >= key) left = mid;
            else right = mid;
            mid = (left+right)/2;
        }
        ans += ruiseki[left+1] - (left+1)*key;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define fi first
#define se second
using namespace std;
typedef long long LL;

const int MAXN = 2e2+5;
const LL MOD = 1e9+7;

int main()
{
    LL a, b, c; cin>>a>>b>>c;
    LL tmp = a + b;
    LL ans = b;
    ans += min(tmp+1, c);
    cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
program main
  implicit none
  integer :: i, n
  integer, allocatable :: a(:) 
  logical :: judge

  read *, n
  allocate(a(n))
  read *, a

  do i = 1, n
    judge = (mod(a(i), 2) /= 0 .or. mod(a(i), 3) == 0 .or. mod(a(i), 5) == 0)
    if (.not. judge) exit
  end do
  if (judge) then
    print '(a)', "APPROVED"
  else
    print '(a)', "DENIED"
  end if

end program

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = 1
if min(a) == 0:
    print(0)
else:
    for i in range(n):
        ans *= a[i]
        if ans > 10**18:
            ans = 0
    print(ans if ans != 0 else -1)

Measured memory_bytes: 21788
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<string>
#include<utility>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cctype>
using namespace std;


int main(){
	int n;
	double a,b;
	map<int,double> data;
	
	while(scanf("%d,%lf,%lf",&n,&a,&b) != EOF){
		data[n] = a/pow(b,2);
	}
	
	for(map<int,double>::iterator it = data.begin();it!=data.end();++it){
		if( it->second >= 25.0){
			printf("%d\n",it->first);
		}
	}

}

Measured memory_bytes: 1212
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>
#include <ctime>
#define rep(i,m,n) for(i=m;i<=(int)n;i++)
#define mod 998244353
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
#define ls rt<<1
#define rs rt<<1|1
#define all(x) x.begin(),x.end()
const int maxn=2e5+10;
const int N=5e4+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t;
int main()
{
    int i,j=0;
    scanf("%d",&n);
    rep(i,1,n)
    {
        scanf("%d",&m);
        if(m%4==0)k++;
        else if(m&1)t++;
        else j++;
    }
    puts((t==k+1&&j==0)||t<k+1?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  char s[14] = { '\0' };
  scanf("%12s", s);
  for(int i = 11; i >= 4; i--){
    s[i + 1] = s[i];
  }
  s[4] = ' ';
  printf("%s\n", s);
  return 0;
}

Measured memory_bytes: 128
#include<stdlib.h>
p(int*a,int*b){return*a-*b;}c,V,i,d,f[999];main(){for(;f[1]=scanf("%d%d",&V,&d)+1;printf("%d\n",c)){for(f[0]=i=2;i<V;i++)f[i]=(f[i-1]+f[i-2])%1001;qsort(f,V,4,p);for(i=c=1;i<V;f[i]-f[i++-1]<d?:c++);}return 0;}

Measured memory_bytes: 636
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <map>

using namespace std;
const int MAXN = 100010;

int n, a[MAXN], b[MAXN];

void input() {
	scanf( "%d", &n );
	a[0] = b[0] = 0;
	for( int i = 1; i <= n; ++i ) {
		scanf( "%d", a+i );
		a[0] ^= a[i];
	}
	for( int i = 1; i <= n; ++i ) {
		scanf( "%d", b+i );
		b[0] ^= b[i];
	}
}

int ta[MAXN], tb[MAXN];
bool check() {
	for( int i = 0; i <= n; ++i )
		ta[i] = a[i], tb[i] = b[i];
	sort( ta, ta+n+1 );
	sort( tb, tb+n+1 );
	for( int i = 0; i <= n; ++i )
		if( ta[i] != tb[i] ) return false;
	for( int i = 0; i <= n; ++i ) {
		a[i] = lower_bound( ta, ta+n+1, a[i] ) - ta;
		b[i] = lower_bound( tb, tb+n+1, b[i] ) - tb;
	}
	return true;
}

namespace Graph {
	int head[MAXN], nxt[MAXN<<1], to[MAXN<<1], eidx = 0;
	void init() {
		memset( head, -1, sizeof(head) );
	}
	void adde( int u, int v ) {
		to[eidx] = v, nxt[eidx] = head[u], head[u] = eidx++;
		to[eidx] = u, nxt[eidx] = head[v], head[v] = eidx++;
	}
}

bool exist[MAXN] = {0}, vis[MAXN] = {0};
void dfs( int u ) {
	using namespace Graph;
	vis[u] = 1;
	for( int i = head[u]; ~i; i = nxt[i] ) {
		int v = to[i];
		if( vis[v] ) continue;
		dfs(v);
	}
}
void solve() {
	Graph::init();
	int ans = 0;
	for( int i = 0; i <= n; ++i ) {
		if( !i || a[i] != b[i] ) {
			exist[a[i]] = exist[b[i]] = 1;
			if( a[i] != b[i] && i ) {
				Graph::adde( b[i], a[i] );
				++ans;
			}
		}
	}
	for( int i = 0; i <= n; ++i )
		if( exist[i] && !vis[i] )
			dfs(i), ++ans;
	printf( "%d\n", ans-1 );
}

int main() {
	input();
	if( !check() ) {
		puts("-1");
		return 0;
	}
	solve();
	return 0;
}


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

// #define TEST

#ifdef TEST
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
#else
#define d(x) 
#define dd(x, y) 
#define ddd(x, y, z) 
#define dump(v) 
#define ddump(v) 
#define damp(m) 
#define dpair(p) 
#endif

// iterate
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define all(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> v(n, 0);
    rep(i,n)cin >> v[i];
    vector<int> p1(n+1,1);
    rep(i,n+1){
        if(i%2==0) p1[i]*=-1;
    }
    dump(v)

    ll c[2];
    vector<ll>sum_until(n+1,0);
    ll cnt =0;
    
    
    
    dump(p1)
    // pat1
    for(int i=1; i<=n; i++){
        sum_until[i] = 0ll + sum_until[i-1] + v[i-1];
        // dump(sum_until)
        if(sum_until[i]*p1[i] < 0){
            int plus = abs(sum_until[i]);
            sum_until[i] += plus*p1[i] + p1[i];
            cnt += abs(plus*p1[i]) +1;
        }
        else if(sum_until[i] == 0){
            sum_until[i] = p1[i];
            cnt += 1;
        }
    }
    dump(sum_until)
    c[0] = cnt;

    d("next")


    fill(all(sum_until), 0ll);
    cnt = 0;
    rep(i,n+1){
        if(i%2==1) p1[i]=-1;
        else p1[i]=1;
    }
    dump(p1)
    for (int i = 1; i <= n; i++)
    {
        sum_until[i] = sum_until[i - 1] + v[i - 1];
        // dump(sum_until)
        if (sum_until[i] * p1[i] < 0)
        {
            int plus = abs(sum_until[i]);
            sum_until[i] += plus * p1[i] + p1[i];
            cnt += abs(plus * p1[i]) + 1;
        }
        else if (sum_until[i] == 0)
        {
            sum_until[i] = p1[i];
            cnt += 1;
        }
    }
    dump(sum_until)
    c[1] = cnt;
    dd(c[0], c[1])


    cout << min(c[1], c[0]) << endl;

    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
using namespace std;
#define mod 1000000007
#define p make_pair
using ll=long long;

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


int main()
{
    int N,K;cin >> N>>K;
    ll ans=0;
    vector<pair<ll,ll>> su(20000000,p(0,0));
    for (ll i=K;i<N+2;i++)
    {
        
        su[i-K]=p(i*(i-1)%mod*modinv(2,mod)%mod,i*N%mod-i*(i-1)%mod*modinv(2,mod)%mod);
        if (su[i-K].first>su[i-K].second || su[i-K].second<0) su[i-K].second+=mod;
    } 
    for (int i=K;i<N+2;i++)
    {
        ans=(ans+(su[i-K].second-su[i-K].first+1)%mod)%mod;
    }
    cout << ans << endl;
return 0;
}

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

long long kaidan(long long k){
    long long sum = 0;
    for (long long i= 1; i < k; i++)
    {
        sum += i;
    }
    return sum;
}
long long sosuu=1000000007;
int main(){
  int N;
  long long K;
  vector<int> A;
  long long slip=0;
  long long slipb=0;
  cin>>N>>K;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    A.push_back(a);
  }
    vector<int> B(A.size());
    copy(A.begin(),A.end(),B.begin());
    sort(B.begin(), B.end(),greater<int>() );

  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      if(A[i]>A[j]){
        slip++;
      }
    }
  }
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      if(B[i]>B[j]){
        slipb++;
      }
    }
  }


  //cout<<"slip:"<<slip<<endl;
  //cout<<K<<"の階段:"<<kaidan(K)<<endl;
  cout<<((slip%sosuu)*(K%sosuu)+(slipb%sosuu)*((kaidan(K))%sosuu))%sosuu<<endl;


return 0;
}

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

#define INF 1e18
#define PI 3.141592653589793238
typedef long long ll;
#define N 200010

int main() {
    string s,t;cin>>s>>t;
    int ans=t.length();
    for(int i=0; i<=s.length()-t.length(); i++){
        int tmp=0;
        for(int j=0; j<t.length(); j++){
            if(t[j]!=s[i+j]) tmp++;
        }
        ans = min(ans, tmp);
    }

    cout<<ans<<endl;


    return 0;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);


int main(){
    int N;
    cin >> N;

    map<vector<char>,int> S;

    rep(i,N) {
        string s;
        cin >> s;
        vector<char> tmp;
        rep(j,s.size()) {
            tmp.push_back(s[j]);
        }
        sort(tmp.begin(),tmp.end());
        S[tmp]++;
    }
    ll ans = 0;

    for (auto p:S) {
        ll n = p.second;

        if (n>=2) {
            ans += n*(n-1)/2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 14516
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors


N = int(input())
divs = make_divisors(N)
ans = 0
for d in divs:
    m = N // d - 1
    if 0 < m and N // m == N % m:
       ans += m
print(ans)

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

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

    vector <int> v(n+1,0);
    ll res=1;
    for (int i=2; i<=n; i++){
          for (int j=i+i; j<=n; j+=i){
               v[j]++;
          }
       } 
    
    for (int i=2; i<=n; i++){
         res=res+(ll)i*(v[i]+2);
     } 
    cout<<res;
    return 0;
}

Measured memory_bytes: 42240
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var sol = new Solve();
        sol.Exec();
    }
}

class Solve
{
    public void Exec()
    {
        var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int N = l[0], M = l[1], K = l[2];
        var uf = new UnionFind(N);
        var friend = new int[N];

        for (var i = 0; i < M; i++)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            ab[0]--;
            ab[1]--;
            friend[ab[0]]++;
            friend[ab[1]]++;
            uf.Merge(ab[0], ab[1]);
        }

        var block = new List<List<int>>();
        for (var i = 0; i < N; i++) block.Add(new List<int>());
        for (var i = 0; i < K; i++)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            ab[0]--;
            ab[1]--;
            block[ab[0]].Add(ab[1]);
            block[ab[1]].Add(ab[0]);
        }

        var ans = new List<int>();
        for (var i = 0; i < N; i++)
        {
            var t = uf.Size(i) - friend[i] - 1;
            foreach (var b in block[i])
            {
                if (uf.IsSame(i, b)) t--;
            }

            ans.Add(t);
        }

        Console.WriteLine(string.Join(" ", ans));
    }
}

class UnionFind
{
    List<int> par;

    public UnionFind(int n)
    {
        par = Enumerable.Repeat(-1, n).ToList();
    }

    public int Root(int x)
    {
        if (par[x] < 0) return x;
        else return par[x] = Root(par[x]);
    }

    public bool IsSame(int x, int y)
    {
        return Root(x) == Root(y);
    }

    public bool Merge(int x, int y)
    {
        x = Root(x);
        y = Root(y);

        if (x == y) return false;
        if (par[x] > par[y]) Swap(ref x, ref y);

        par[x] += par[y];
        par[y] = x;

        return true;
    }

    public int Size(int x)
    {
        return -par[Root(x)];
    }

    public void Swap(ref int a, ref int b)
    {
        var tmp = a;
        a = b;
        b = tmp;
    }
}


Measured memory_bytes: 36308
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	string str;
	cin >> str;
	vector<int> hist(26,0);
	int size = str.size();
	for(int i=0;i<size;++i){
		int res = str[i]-'a';
		hist[ res ]++;
		if( hist[res] > 1 ){
			cout << "no" << endl;
			return;
		}
	}
	cout << "yes" << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
import java.util.*;

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

        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (n * a > b)
            System.out.println(b);
        else
            System.out.println(a * n);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;

double calc(double x, double y){
    double ret;
    ret = pow(x, 2) + pow(y, 2);
    ret = sqrt(ret);
    return ret;
}

int main(){
    int n, d;
    cin >> n >> d;
    // vector<int> x(n), y(n);
    int ans = 0;
    rep(i, n){
        // cin >> x[i] >> y[i];
        double x, y;
        cin >> x >> y;
        double tp;
        tp = calc(x, y);
        if(tp <= d) ans++;
    }

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


Measured memory_bytes: 3800
n, m, x, y = map(int, input().split())

x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))

if max(x_list) < min(y_list) and x < min(y_list) and max(x_list) < y:
    print("No War")
else:
    print("War")


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

vector<ll> divisor(ll n){
    vector<ll> v;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){v.push_back(i);v.push_back(n/i);}
    }
    sort(v.rbegin(),v.rend());
    return v;
}


int main(){
    int n;cin>>n;
    ll k;cin>>k;
    vector<ll> v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    ll sum=accumulate(v.begin(),v.end(),0ll);
    vector<ll> di=divisor(sum);
    for(int i=0;i<di.size();i++){
        ll cur=0;
        vector<ll> res;
        for(int j=0;j<n;j++){
            cur+=v[j]%di[i];
           if(v[j]%di[i]) res.push_back(v[j]%di[i]);
        }
        if(cur%di[i]==0){
            int yay=cur/di[i];
            sort(res.rbegin(),res.rend());
            ll ss=0;
            for(int kk=0;kk<yay;kk++)ss+=di[i]-res[kk];
           if(ss<=k){ cout<<di[i]<<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 rep2(i,n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
using vi = vector<int>;
template <class T>
using Grid = vector<vector<T>>;

int main(){
    int N, M;
    cin >> N >> M;
    vector<tuple<int, int, int>> v; // pref, year, city
    v.reserve(M);
    rep(i, M) {
        int p,y;
        cin >> p >> y;
        v.emplace_back(p, y, i);
    }
    sort(v.begin(), v.end());
    int prevpref = -1;
    int count;
    vector<tuple<int, int, int>> ans; // city, pref, num
    ans.reserve(M);
    for (auto x : v) {
        if (get<0>(x) != prevpref)
            count = 0;
        prevpref = get<0>(x);
        count++;
        ans.emplace_back(get<2>(x), prevpref, count);
    }
    sort(ans.begin(), ans.end());
    for (auto x : ans) {
        printf("%06d%06d\n", get<1>(x), get<2>(x));
    }
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i=0;i<n;++i)
        cin >> h[i];
    
    int cnt = 1;
    int max_h = h[0];
    for(int i=1;i<n;++i)
    {
        if(h[i] >= max_h)
        {
            cnt++;
            max_h = h[i];
        }
    }

    cout << cnt << endl;
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

const double pi = 2 * asin (1.0);

int n;
int m;
int x[100];
int y[100];

int main () {
	scanf ("%d", &n);
	for (int i = 0; i < n; i++)
		scanf ("%d%d", &x[i], &y[i]);
	for (int i = 0; i < n; i++) {
		vector<double> v;
		for (int j = 0; j < n; j++)
			if (i != j)
				v.pb (atan2 (y[j] - y[i], x[j] - x[i]));
		sort (all (v));
		double cur = 0;
		if (sz (v) == 1) cur = 0.5; else {
			v.pb (v[0] + 2 * pi);
			for (int j = 0; j < n - 1; j++)
				if (v[j + 1] - v[j] > pi)
					cur += v[j + 1] - v[j] - pi;
			cur /= 2 * pi;
		}
		printf ("%.10f\n", cur);
	}
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

ll gcd(ll a, ll b)
{
    for (ll i=a; i>0; i--) {
        if (a % i == 0 && b % i == 0) return i;
    }
    return 0;
}

int main(){
    int a, b;
    cin >> a >> b;
    ll ans = ll(a) * b / gcd(a, b);
    cout << ans << endl;
    return 0;
}



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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

map<int, int> m;

void prime_factor(int n) {
    for (int i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            m[i]++;
            n /= i;
        }
    }

    if (n != 1) {
        m[n]++;
    }

    return;
}

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    ll ans = 1;
    for (int i = 1; i <= N; i++) {
        prime_factor(i);
    }

    for (int i = 1; i <= N; i++) {
        ans = ans*(m[i]+1) % MOD;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}



int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    string y="Yes",n="No";
    int s=0;
    while(a >= b){
        b *= 2;
        s ++;
    }
    while(b >= c){
        c *= 2;
        s ++;
    }
    if(s <= k){
        cout << y << endl;
    }else{
        cout << n << endl;
    }



    return 0;
}


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

using namespace std;

const int MOD = 1e9 + 7;

// dp[決まった段数][どの列にいるか]
int dp[110][10];

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  k--;
  dp[0][0] = 1;

  for (int y = 0; y < h; y++) {
    for (int bit = 0; bit < (1 << (w - 1)); bit++) {
      bool ng = false;
      for (int i = 0; i + 2 < w; i++) {
        if ((bit >> i) % 4 == 3) ng = true;
      }
      if (ng) continue;
      vector<int> id(w);
      for (int i = 0; i < w; i++) {
        id[i] = i;
      }
      for (int i = 0; i + 1 < w; i++) {
        if (bit >> i & 1) swap(id[i], id[i + 1]);
      }
      for (int i = 0; i < w; i++) {
        dp[y + 1][id[i]] += dp[y][i];
        dp[y + 1][id[i]] %= MOD;
      }
    }
  }
  cout << dp[h][k] << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    ll x,y;
    cin >> x >> y;
    ll z=x,ans=0;
    while (z <= y)
    {
        z *= 2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



int main(){
   int n; cin >> n;
   vector<ll> a(n);
   rep(i,n) cin >> a[i];

    //累積和
    vector<ll> sum(n+1);
    rep(i,n){
        sum.at(i+1) = sum.at(i) + a.at(i);
    }

    //sumの値が同じになるペアが求めたい区間になる
    map<ll,ll> nums;
    rep(i,n+1) nums[sum[i]] ++;

    //集計処理
    ll ans=0;
    for(auto it:nums){
        ll num = it.second; //it.firstがit.second個ある
        ans += num*(num-1)/2;  //nC2  例えばsum[i]=3が4箇所あったら選び方は4C2になる
    }
    cout << ans << endl;
}

Measured memory_bytes: 18748
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := ReadInt()
	happiness := make([][3]int, N)
	for i := 0; i < N; i++ {
		copy(happiness[i][:], ReadInts(3))
	}
	dp := make([][3]int, N)
	dp[0] = happiness[0]
	for i := 1; i < N; i++ {
		dp[i][0] = happiness[i][0] + Max(dp[i-1][1], dp[i-1][2])
		dp[i][1] = happiness[i][1] + Max(dp[i-1][0], dp[i-1][2])
		dp[i][2] = happiness[i][2] + Max(dp[i-1][0], dp[i-1][1])
	}
	fmt.Println(Max(dp[N-1][:]...))
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

func ReadInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = ReadInt()
	}
	return ret
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	v, e := strconv.Atoi(Read())
	if e != nil {
		panic(e.Error())
	}
	return v
}


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

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];

  set<P> ball;
  rep(i, n) ball.insert(make_pair(x[i], y[i]));

  int ans = n;
  rep(i, n) rep(j, n) {
    if (i >= j) continue;
    int p = x[j] - x[i];
    int q = y[j] - y[i];
    map<P, bool> visited;
    int cost = 0;
    rep(k, n) {
      if (visited[make_pair(x[k], y[k])]) continue;
      visited[make_pair(x[k], y[k])] = true;
      int t = 1;
      while (1) {
        P to = make_pair(x[k] + t*p, y[k] + t*q);
        if (ball.find(to) == ball.end()) break;
        visited[to] = true;
        ++t;
      }
      t = -1;
      while (1) {
        P to = make_pair(x[k] + t*p, y[k] + t*q);
        if (ball.find(to) == ball.end()) break;
        visited[to] = true;
        --t;
      }
      ++cost;
    }
    ans = min(ans, cost);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3512
import scala.io.StdIn

object Main {

  def main(args: Array[String]): Unit = {
    val s = StdIn.readLine().toList.map(_.asDigit)
    println(solve(s))
  }

  def solve(s: List[Int]): Int = {
    def solveRec(s: List[Int], acc: Int): Int = {
      s match {
        case x :: (t @ y :: z :: _) =>
          val cand = (x * 100 + y * 10 + z - 753).abs
          solveRec(t, acc min cand)
        case _ => acc
      }
    }
    solveRec(s, 1000)
  }

}


Measured memory_bytes: 25544
from sys import stdin
import fractions


n,x = [int(x) for x in stdin.readline().rstrip().split()]

li = list(map(int,stdin.readline().rstrip().split()))
lin = []
for i in range(len(li)):
    lin.append(abs(li[i]-x))
poi = lin[0]
for i in range(len(lin)-1):
    poi = fractions.gcd(poi,lin[i+1])

print(poi)

Measured memory_bytes: 88172
gets;

a = ARGF.map {|s|a=s.split;[a[0],a[1].to_i]}.each_with_index.to_a

a.sort {|a,b| [a[0][0],b[0][1]] <=> [b[0][0],a[0][1]]}.each{|a|print a[1]+1,"\n"}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll cnt = 0;

void merge(vl& A, ll left, ll mid, ll right) {
    ll n1 = mid - left, n2 = right - mid;
    vl L(n1 + 1), R(n2 + 1);
    rep(i, n1) L[i] = A[left + i];
    rep(i, n2) R[i] = A[mid + i];
    L[n1] = INF, R[n2] = INF;

    ll li = 0, ri = 0;
    repe(k, left, right){
        if (L[li] <= R[ri])
            A[k] = L[li], li++;
        else
            A[k] = R[ri], ri++;
        cnt++;
    }
};

void mergeSort(vl& A, ll left, ll right){
    if(left + 1 < right){
        ll mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
};

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

    mergeSort(A, 0, N);

    rep(i, N) cout << A[i] << (i == N - 1 ? '\n' : ' ');
    cout << cnt << endl;
}


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

bool check(vector<int> A, vector<int> B){
for(int i=0, l=A.size(); i<l; i++){ if(A[i]!=B[i]){ return false; } }
return true;
}
int main(){
int i, N; cin >> N; vector<int> P(N), Q(N), ar(N);
for(i=0; i<N; i++){ cin >> P[i]; }
for(i=0; i<N; i++){ cin >> Q[i]; }
for(i=0; i<N; i++){ ar[i]=i+1; }
int a=0, b=0; bool p=true, q=true;
do{
  if(p){ a++; if(check(P, ar)){ p=false; } }
  if(q){ b++; if(check(Q, ar)){ q=false; } }
}
while(next_permutation(ar.begin(), ar.end()));
cout << abs(b-a) << "\n";
}

Measured memory_bytes: 256
//Head File
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#include<ctime>
#include<set>
#include<cstdlib>
#include<vector>
#include<cassert>
#include<cmath>
#include<queue>
#include<iostream>
using namespace std;

//Stand
#define il inline
#define ll long long

//Debug
#define B cerr<<"Break Point"<<endl;
#define P(x) cerr<<#x<<' '<<"="<<' '<<(x)<<endl;
#define p(x) cerr<<#x<<' '<<"="<<' '<<(x)<<' ';

//File
void fio()
{
    #ifndef ONLINE_JUDGE
    freopen("sample.in","r",stdin);
    freopen("sample.out","w",stdout);
    #endif
}
void pti()
{
    double timeuse = clock()*1000.0/CLOCKS_PER_SEC;
    cerr<<"Timeuse "<<timeuse<<"ms"<<endl;
}
void end()
{
    #ifndef ONLINE_JUDGE
    pti();
    #endif
    exit(0);
}

//IO
#define pc(s) putchar(s)
#define say(s) cout<<s<<endl
namespace io
{
    const int SIZ=55;int que[SIZ],op,qr;char ch;
    template<class I>
    il void gi(I &w)
    {
        ch=getchar(),op=1,w=0;
	    while(!isdigit(ch)){if(ch=='-') op=-1;ch=getchar();}
        while(isdigit(ch)){w=w*10+ch-'0';ch=getchar();}w*=op;
    }
    template<typename T,typename... Args>
    il void gi(T& t,Args&... args){gi(t);gi(args...);}
    template<class I>
    il void print(I w)
    {
        qr=0;if(!w) putchar('0');if(w<0) putchar('-'),w=-w;
	    while(w) que[++qr]=w%10+'0',w/=10;
        while(qr) putchar(que[qr--]);
    }
}
using io::gi;
using io::print;

ll n,x,d;
map<ll,vector<pair<ll,ll>>>c;
vector<pair<ll,ll>>v;

ll pre(ll k)
{
    return k*(k-1)/2;
}
ll suf(ll k)
{
    return n*(n-1)/2-(n-k)*(n-k-1)/2;
}
int main()
{
    gi(n,x,d);
    if(!d)
    {
        if(!x) print(1);
        else print(n+1);
        end();
    }
    if(d<0) x+=(n-1)*d,d=-d;
    for(ll i=0;i<=n;++i)
    {
        ll j=n-i;
        ll up=suf(i)-pre(j),dn=pre(i)-suf(j);
        ll tmp=x*(i-j)+dn*d;
        ll id=tmp%(2*d);
        if(id<0) id+=(2*d);
        ll l=(tmp-id)/(2*d),r=l+(up-dn)/2;
        c[id].push_back(make_pair(l,r));
    }
    ll ans=0;
    for(map<ll,vector<pair<ll,ll>>>::iterator it=c.begin();it!=c.end();++it)
    {
        v=it->second;
        sort(v.begin(),v.end());
        ll w=-1e18;
        for(auto i:v)
        {
            w=max(w,i.first);
            ans+=max(0ll,i.second-w+1);
            w=max(w,i.second+1);
        }
    }
    print(ans);
    end();
}


Measured memory_bytes: 22144
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
typedef pair<int, int> P;

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

Measured memory_bytes: 256
defmodule Main do
  def main do
	[n, k] = IO.read(:line)
      |> String.trim()
      |> String.split()
      |> Enum.map(&String.to_integer/1)
      ans = if rem(n,k) === 0 do
    	0
      else
        1
      end
	IO.puts ans
  end
end


Measured memory_bytes: 30768
#include <stdio.h>
#include <string.h>
int main()
{
    char s[1002],h,m;
    int i,len,j,n;

        scanf("%s",s);
        n=0;
        len=strlen(s);
        for(j=0;j<len;j++){
            if(j ==0){
                m=s[j];
            }
            else if(j==len-1){
                h=s[j];
            }
        }
        printf("%c%d%c\n",m,len-2,h);

    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long n = sc.nextLong();
		long x = (long)Math.min(b - 1, n);
		int res = (int)(a * x / b);
		System.out.println(res);
    }
}

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

int main() {
	int N, M; 
	cin >> N >> M;

	vector<vector<int> > vec(M);

	for (int i = 0; i < M; ++i) {
		int k; 
		cin >> k;
		vec[i].resize(k);
		for (int j = 0; j < k; ++j) {
			cin >> vec[i][j];
			--vec[i][j];
		}
	}

	vector<int> p(M);
	for (int i = 0; i < M; ++i) cin >> p[i];

	int ans = 0;
	for (int i = 0; i < (1 << N); ++i) {
		bool ok = true;
		for (int j = 0; j < M; ++j) {
			int c = 0;
			for (int id=0 ;id<vec[j].size();id++) {
				if ((i >> vec[j][id]) & 1) {
					++c;
				}
			}
			c %= 2;
			if (c != p[j]) {
				ok = false;
			}
		}
		if (ok) {
			++ans;
		}
	}

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

Measured memory_bytes: 256
def main():
    n, K = map(int, input().split())
    h = list(map(int, input().split()))
    inf = 10**10
    dp = [inf]*n
    dp[0] = 0
    for i, (di, hi) in enumerate(zip(dp[1:], h[1:]), 1):
        num = max(i-K, 0)
        for dk, hk in zip(dp[num:i], h[num:i]):
            a = dk+abs(hi-hk)
            if di > a:
                di = a
        dp[i] = di
    print(dp[n-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 13928
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		int a = 0;
		for(int i=1; i<=N; i++) {
			if(i%2==1) a++;
		}
		System.out.println(a);
	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;
typedef pair<int, int> pi;

vector<vector<ll>> c;

int main(){
    int K, N;
    cin >> N >> K;
    vector<int> xs(N, 0);
    vector<int> ys(N, 0);
    vector<pi> ps;


    rep(i, N){
        cin >> xs[i];
        cin >> ys[i];
        pi p = {xs[i], ys[i]};
        ps.push_back(p);
    }

    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    vector<vector<int>> cnts(N, vector<int>(N, 0));
    // cnts[i][j]はp.first <= x_i && p.second <= y_jの数.
    rep(i, N){
        rep(j, N){
            int x = xs[i];
            int y = ys[j];
            rep(k, N){
                pi p = ps[k];
                if(p.first <= x && p.second <= y){
                    cnts[i][j] ++;
                }
            }
        }
    }


    ll ans = 4e18;

    for(int i = 0; i < N - 1; i ++){
        for(int j = i + 1; j < N ; j ++){
            int r = xs[j];
            int l = xs[i];

            for(int k = 0; k < N - 1; k ++){
                for(int m = k + 1; m < N; m ++){
                    int t = ys[m];
                    int b = ys[k];
                    int cnt = cnts[j][m];
                    if(i > 0 && k > 0){
                        cnt += cnts[i - 1][k - 1];
                    }
                    if(i > 0){
                        cnt -= cnts[i - 1][m];
                    }
                    if(k > 0){
                        cnt -= cnts[j][k - 1];
                    }
                    if(cnt >= K){
                        ans = min(ans, (ll)(r - l) * (t - b));
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
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();
    if (a==b){
      if (a==5 && c==7){
        System.out.println("YES");
        System.exit(0);
      }
    } else if (a==c) {
      if (a==5 && b==7){
        System.out.println("YES");
        System.exit(0);
      }
    } else if (b==c) {
      if (b==5 && a==7){
        System.out.println("YES");
        System.exit(0);
      }
    }
    System.out.println("NO");
  }
}


Measured memory_bytes: 21844
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val ss = next()

    var first = -1
    var last = -1

    ss.forEachIndexed() { index,  s ->
        if (first == -1 && s == 'A') first = index
        if (s == 'Z') last = index
    }

    println(last - first + 1)
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 32468
import numpy as np
from functools import reduce
from operator import add,sub,mul,truediv
from fractions import gcd


n = int(input())

a = list(map(int,input().split()))

a = np.array(a)

a = np.insert(a,0,0)
a = np.append(a,0)

org = 0
dis = []
for i in range(1,n+2):
    org += abs(a[i]-a[i-1])
    dis.append(abs(a[i]-a[i-1]))

#print(org)
#print(dis)


for i in range(1,n+1):
    print(org - dis[i-1]-dis[i]+abs(a[i+1]- a[i-1]))


Measured memory_bytes: 24152
#pragma GCC optimize("Ofast",3,"inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1<<18;
int n;
vector<int> e[MAXN];
int cnt[MAXN];
vector<int> vct;
int first;
void dfs(int v,int pr){
	cnt[v]=1;
	vct.push_back(v);
	if(v==n-1){
		first=vct[((int) vct.size()+1)/2];
	}
	for(int to:e[v]){
		if(to==pr) continue;
		dfs(to,v);
		cnt[v]+=cnt[to];
	}
	vct.pop_back();
}

int main(){
	ios_base::sync_with_stdio(false);
	while(scanf("%d",&n)==1){
		for(int i=0;i<n;i++){
			e[i].clear();
		}
		for(int i=0;i<n-1;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			u--;
			v--;
			e[u].push_back(v);
			e[v].push_back(u);
		}
	}
	first=-1;
	dfs(0,0);
	bool win=cnt[first]*2<n;
	//优秀判断 
	string ans=win?"Fennec":"Snuke";
	cout<<ans; 
	return 0;
}


Measured memory_bytes: 16632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
const int maxn=310;
int t[maxn][maxn];
int cho[maxn];
int c[maxn];
int ans=0x3f3f3f3f;

int check()
{
	memset(c,0,sizeof(c));
	int temp[maxn]={0};
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++)
			if(!cho[t[i][j]]){
				c[t[i][j]]++;
				temp[i]=1;
				break;
			}
		if(temp[i]=0)
			return 0;
	}
	int id=0;
	for(int i=1;i<=m;i++){
		if(c[i]>c[id])
			id=i;
	}
	if(id!=0)
	ans=min(ans,c[id]);
	return id;
}

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("B.in","r",stdin);
    //freopen("B.out","w",stdout);
#endif
	cin >> n >> m;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin >> t[i][j];
	int id=0;
	while((id=check())!=0){
		cho[id]=1;
		id=0;
	}
	cout << ans <<endl;

	return 0;
}


Measured memory_bytes: 640
N,K = map(int,input().split())
min = 0
max = 0
ans = 0
for i in range(K,N+2):
    min = i*(i-1)//2
    max = i*(2*N-i+1)//2
    ans += max-min+1
    ans %= (10**9+7)

print(int(ans))


Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned long;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    void Solve() {
        UL N, M; scanf("%d%d", &N, &M);
        UL arr[100][100]; rep(i, N) rep(j, M) scanf("%d", &arr[i][j]);
        UL vec[100]; rep(j, M) scanf("%d", &vec[j]);
        UL ans[100] = {};
        rep(i, N) {
            rep(j, M) {
                ans[i] += arr[i][j] * vec[j];
            }
        }
        rep(i, N) printf("%d\n", ans[i]);
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}



Measured memory_bytes: 3300
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int N, M;
int h[100000];
bool ok[100000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> M;
    for(int i = 0; i  < N; i++) {
        cin >> h[i];
        ok[i] = true;
    }
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(h[a] >= h[b]) ok[b] = false;
        if(h[b] >= h[a]) ok[a] = false;
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(ok[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4140