akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
const int N=200005,md=1000000007;
int n,x,y,mn,mn2,i,j,k,ans,jc[N],rjc[N],inv[N],c[N],w[N];
vector<int> vct[N];
bool ok[N];
int main()
{
	scanf("%d%d%d",&n,&x,&y);
	mn=mn2=1<<30;
	for(i=1;i<=n;++i)
	{
		scanf("%d%d",c+i,w+i);
		vct[c[i]].push_back(w[i]);
		if(w[i]<mn)
		{
			mn2=mn;
			mn=w[i];
		}
		else if(w[i]<mn2)
			mn2=w[i];
	}
	for(i=1;i<=n;++i)
		if(!vct[i].empty())
		{
			sort(vct[i].begin(),vct[i].end());
			j=vct[i][0];
			k=(j==mn?mn2:mn);
			while(!vct[i].empty()&&vct[i][vct[i].size()-1]+j>x&&vct[i][vct[i].size()-1]+k>y)
				vct[i].pop_back();
			if(j+mn<=y)
				ok[i]=true;
		}
	inv[1]=1;
	for(i=2;i<=n;++i)
		inv[i]=1ll*inv[md%i]*(md-md/i)%md;
	jc[0]=rjc[0]=1;
	for(i=1;i<=n;++i)
		jc[i]=1ll*jc[i-1]*i%md,rjc[i]=1ll*rjc[i-1]*inv[i]%md;
	ans=1;
	for(i=1,j=0;i<=n;++i)
		if(ok[i])
		{
			j+=vct[i].size();
			ans=1ll*ans*rjc[vct[i].size()]%md;
		}
	ans=1ll*ans*jc[j]%md;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 13440
#include<iostream>

using namespace std;

int main(){
  string s,t;
  cin>>s>>t;

  int f=0;
  for(int i=0;i<s.size();i++){
    if(s==t){
      f=1;
      break;
    } s=s.back()+s.substr(0,s.size()-1);
  }
  if (f==1) {
    cout<<"Yes"<<endl;
  }else {
    cout<<"No"<<endl;
  }return 0;
}


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	
	int a_2 = 1, b_2 = 1, c_2 = 1;
	rep(p,8){
		if(p!=0) a_2 *= 2;

		b_2 = 1;
		rep(q,8){
			if(q!=0) b_2 *= 2;

			c_2 = 1;
			rep(r,8){
				if(p+q+r > k) continue;
				if(r!=0) c_2 *= 2;
				if(a * a_2 < b * b_2 && b * b_2 < c * c_2){
					cout << "Yes" << endl;
					return;
				}
			}
		}
	}

	cout << "No" << endl;
}

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

Measured memory_bytes: 3636
d = int(input())
c = [int(i) for i in input().split()]
s = [[int(i) for i in input().split()] for j in range(d)]

t = [int(input()) for i in range(d)]

ans = 0
last = [0]*26

for i in range(1,d+1):
    ans += s[i-1][t[i-1]-1]
    last[t[i-1]-1] = i
    for j in range(26):
        ans -= (i-last[j])*c[j]
    print(ans)
    
    

Measured memory_bytes: 68448
#include "bits/stdc++.h"
// Custom Header <<<
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;
// >>>

signed main()
{
    int N;
    pii p[55];

    cin >> N;
    rep(i, 0, N) {
        int x, y;
        cin >> x >> y;
        p[i] = pii(x, y);
    }

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

    map<pii, int> d;

    rep(i, 0, N) {
        rep(j, 0, N) {
            if (i == j) continue;
            pii dif(p[i].first - p[j].first, p[i].second - p[j].second);
            d[dif] += 1;
        }
    }

    int maxv = 0;
    for (const auto &e : d) {
        chmax(maxv, e.second);
    }

    cout << (N - maxv) << endl;

    return 0;
}

/* vim:set foldmethod=marker foldmarker=<<<,>>> : */


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,m;
bool vis[N];
int main()
{
    scanf("%d%d",&n,&m);
    if(n&1)
    {
        for(int i=1,l=1,r=n;i<=m;i++)
        {
            printf("%d %d\n",l,r);
            l++;r--;
        }
    }
    else
    {
        int k=(n-1)/2;
        k=k/2+k%2;
        int l=1,r=n;
        while(k&&(m--))
        {
            printf("%d %d\n",l,r);
            l++;r--;
            k--;
        }
        r--;
        if(m<0) m=0;
        while(m--)
        {
            printf("%d %d\n",l,r);
            l++;r--;
        }
    }
}


Measured memory_bytes: 3804
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
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;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int h, w, k, dp[111][11], dp2[10];

int f(int n) {
	if (n<=0) return 1;
	return dp2[n];
}

signed main() {
	rep(i,10) {
		rep(j,1<<i) {
			vector<int> x;
			rep(k,i) if (j>>k&1) x.push_back(k);
			bool ok = 1;
			rep(k,(int)x.size()-1) if (x[k]+1==x[k+1]) ok = 0;
			dp2[i] += ok;
		}
	}
	cin >> h >> w >> k;
	if (w==1) return cout << 1 << endl, 0;
	dp[0][0] = 1;
	rep(i,h) rep(j,w) {
		if (j) (dp[i+1][j-1] += dp[i][j] * f(j-2) %mod * f(w-j-2)) %= mod;
		(dp[i+1][j] += dp[i][j] * f(j-1) %mod * f(w-j-2)) %= mod;
		if (j!=w-1) (dp[i+1][j+1] += dp[i][j] * f(j-1) %mod * f(w-j-3)) %= mod;
	}
	cout << dp[h][k-1] << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
from itertools import permutations
sys.setrecursionlimit(300000)


def solve(N: int, P: "List[int]", Q: "List[int]"):
    def equals(x, y):
        for i in range(len(x)):
            if x[i] != y[i] - 1:
                return False
        return True
    perm = list(permutations(list(range(N))))
    a = 0
    b = 0
    for i, p in enumerate(perm):
        if equals(p, P):
            a = i
        if equals(p, Q):
            b = i
    print(abs(a - b))
    return

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

if __name__ == '__main__':
    main()


Measured memory_bytes: 8052
program proA
  implicit none
  integer n,a,i

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

  do i=0,a
     if(i==mod(n,500)) then
        write(*,*) 'Yes'
        stop
     end if
  end do
  
  write(*,*) 'No'  
  
end program proA


Measured memory_bytes: 768
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n = II()
A = LI()

ans = 0
right = 0
num_xor = 0
num_and = 0
for left in range(n):
    while right < n and num_xor ^ A[right] == num_and + A[right]:
        num_xor ^= A[right]
        num_and += A[right]
        right += 1

    ans += right - left

    if left == right:
        right += 1
    else:
        num_xor ^= A[left]
        num_and -= A[left]

    # print(left, right, ans)

print(ans)


Measured memory_bytes: 23636
#include<iostream>
#include<string>
#include<cstdlib>
#include<ctime>

using namespace std;

struct dice{
  int u,n,e,s,w,d;
};

int main(){

  srand((unsigned)time(NULL));

  int n;
  dice d[100];
  int tmp;
  int q,a,b;
  int rn;
  int cnt=0;

  cin>>n;

  for(int i=0;i<n;i++){
    cin>>d[i].u>>d[i].s>>d[i].e>>d[i].w>>d[i].n>>d[i].d;
  }

  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      cnt=0;
      while(1){
	rn=rand()%4;
	if(rn==0){
	  tmp=d[i].u;
	  d[i].u=d[i].s;
	  d[i].s=d[i].d;
	  d[i].d=d[i].n;
	  d[i].n=tmp;
	}
	else if(rn==1){
	  tmp=d[i].u;
	  d[i].u=d[i].w;
	  d[i].w=d[i].d;
	  d[i].d=d[i].e;
	  d[i].e=tmp;
	}
	else if(rn==2){
	  tmp=d[i].u;
	  d[i].u=d[i].n;
	  d[i].n=d[i].d;
	  d[i].d=d[i].s;
	  d[i].s=tmp;
	}
	else if(rn==3){
	  tmp=d[i].u;
	  d[i].u=d[i].e;
	  d[i].e=d[i].d;
	  d[i].d=d[i].w;
	  d[i].w=tmp;
	}
	if(d[i].u==d[j].u&&d[i].w==d[j].w&&d[i].e==d[j].e&&d[i].s==d[j].s&&d[i].n==d[j].n&&d[i].d==d[j].d){
	  cout<<"No"<<endl;
	  return 0;
	}
	cnt++;
	if(cnt==10000 ){
	  break;
	}
      }
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int n,k,sz[2222],dp[2222][2222],ndp[2222][2222];
vector<int>adj[2222];
void dfs(int u,int p)
{
	sz[u]=1;
	dp[u][0]=1;
	ndp[u][0]=1;
	for(int h=0;h<adj[u].size();h++)
	{
		int v=adj[u][h];
		if(v!=p)
		{
			dfs(v,u);
			for(int i=0;i<sz[u];i++)
			{
				for(int j=0;j<sz[v] && i+j+1<=k;j++)
				{
					ndp[u][max(i,j+1)]=max(ndp[u][max(i,j+1)],dp[u][i]+dp[v][j]);
				}
			}
			sz[u]+=sz[v];
			for(int i=0;i<sz[u];i++)
			{
				dp[u][i]=ndp[u][i];
			}
		}
	}
}
int main()
{
	cin>>n>>k;
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs(1,1);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			ans=max(ans,dp[i][j]);
		}
	}
	cout<<n-ans<<endl;
	return 0;
}

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

int selectionSort(int A[], int N){
	int i, j, minj, sw=0;
	
	for(i = 0; i<N-1; i++){
		minj = i;
		for(j=i; j<N; j++){
			if(A[j] < A[minj]){
				minj = j;
			}
		}
		swap(A[i], A[minj]);
		if(i != minj) sw++;
	}
	//cout << sw <<endl;
	return sw;
}

int main(){
	int N, i, sw;
	int A[100];
	cin >> N;
	for(i=0; i<N; i++) cin >> A[i];

	sw = selectionSort(A, N);

	for(i=0; i<N;i++){
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;

	return 0;
}


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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

#define random_shuffle(...) shuffle(__VA_ARGS__, rng)
#define rand() rng()

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

const int N = 111;
int a[N][N];

int main() {
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	int n = nxt(), m = nxt();
	vector<multiset<int>> a(n);
	for (int i = 0; i < m; ++i) {
		int u = nxt() - 1, v = nxt() - 1;
		a[u].insert(v);
		a[v].insert(u);
	}

	bool all_even = true;
	for (const auto& v : a) {
		all_even &= (v.size() % 2 == 0);
	}

	if (!all_even) {
		puts("No");
		return 0;
	}

	set<pair<int, int>> S;
	for (int i = 0; i < n; ++i) {
		S.insert({(int)a[i].size(), i});
	}
	int num_cycles = 0;
	while (!S.empty() && S.begin()->first == 2) {
		auto p = *S.begin();
		S.erase(S.begin());
		int u = *a[p.second].begin();
		int v = *a[p.second].rbegin();
		// cerr << u + 1 << " -- " << p.second + 1 << " -- " << v + 1 << " -> " << u + 1 << " -- " << v + 1 << "\n";
		// for (auto p : S) {
		// 	cerr << p.first << " " << p.second + 1 << "\n";
		// }
		a[p.second].clear();
		m -= 1;
		a[u].erase(a[u].find(p.second));
		a[v].erase(a[v].find(p.second));
		if (u == v) {
			--m;
			S.erase({(int)a[u].size() + 2, u});
			S.insert({(int)a[u].size(), u});
			++num_cycles;
			continue;
		}
		a[u].insert(v);
		a[v].insert(u);
	}

	num_cycles += m / 2;

	puts(num_cycles >= 3 ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
double dp[3000][3000];
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    double p;
    int n;
    cin>>n;
    dp[0][0]=1.0;
    for(int i=0;i<n;i++){
        cin>>p;
        for(int j=0;j<=i;j++){
            dp[i+1][j+1]+=dp[i][j]*p;
            dp[i+1][j]+=dp[i][j]*(1.0-p);
        }
    } 
    double ans=0.0;
    for(int i=(n+1)/2;i<=n;i++){
        ans+=dp[n][i];
    }
    doublecout(ans);
    return 0;
}


Measured memory_bytes: 68864
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

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

    string s = "No";

    for(int i = 0; i < 26; i++){
        for(int d = 0; d < 15; d++){
            if(4*i + 7*d == N){
                s = "Yes";
                break;
            }
        
        }
        if(s == "Yes") break;
    
    }

    cout << s << endl;


}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long double pi=3.14159265358979323846;
#define x  first
#define y  second
#define deb(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

bool isPar(string s)
{
    ll n=s.size();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            return 0;
        }
    }
    return 1;
}

ll nOfD(ll n)
{
    ll d=0;
    ll i=1;
    while(i * i < n)
    {
        if(n%i ==0) d+=2;
        i++;
    }
    if(i * i == n)d++;
    return d;
}
ll sOfD(ll n)
{
    ll sum=0;
    ll i=1;
    while(i * i < n)
    {
        if(n%i ==0) sum+=i,sum+=n/i;
        i++;
    }
    if(i * i == n)sum+=i;
    return sum;
}
bool isP(ll x)
{
    if(x==2)return 1;
    if(x<2 || x%2==0)return 0;
    for(ll i=3;i * i <= x;i+=2)
    {
        if(x%i==0)return 0;
    }
    return 1;
}
ll lcm(ll a, ll b)
{
    return (a / __gcd(a, b) * b);
}

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    ///freopen("ss.txt","r",stdin);
    ///freopen("out.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
       int n;
       cin>>n;
       cout<<(n>=30? "Yes":"No");
    }
    return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    string s;
    cin >> s;
    ll ans = 0;
    for (int i = 0; i < (1 << (s.size() - 1)); ++i) {
        ll sum = 0;
        ll t = 0;
        int p = i | (1 << (s.size() - 1));
        for (int j = 0; j < s.size(); ++j) {
            t *= 10;
            t += s[j] - '0';

            if (p >> j & 1) {
                sum += t;
                t = 0;
            }
        }
        ans += sum;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[][] matrix_A = new int[n][m];
		int[] matrix_B = new int[m];
		int[] matrix_C = new int[n];
		for(int i = 0; i<n; i++){
			for(int j = 0;j<m;j++){
				int matrix_element = scan.nextInt();
				matrix_A[i][j] = matrix_element;
			}
		}

		for(int i=0;i<m;i++){
			int matrix_element2 = scan.nextInt();
			matrix_B[i] = matrix_element2;
		}

		for(int i = 0;i<n; i++){
			for(int j = 0; j<m; j++){
				matrix_C[i] += matrix_A[i][j] * matrix_B[j];
			}
		}

		for(int i = 0; i<matrix_C.length; i++){
			System.out.println(matrix_C[i]);
		}  
	}
}

Measured memory_bytes: 40600
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read(){
	int ret=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-f;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		ret=ret*10+ch-'0';
		ch=getchar();
	}
	return ret*f;
}
int main(){
	int n=read(),a=read(),b=read();
	int d=(b-a)&1;
	n++;
	if(d)printf("Borys\n");
	else printf("Alice\n");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<pair<int,int>>p(n);
  for (int i=0; i<n; i++){
    cin >> p[i].first;
    p[i].second = i+1;
  }
  sort(p.begin(), p.end());
  for (int i=0; i<n; i++) cout << p[i].second << " ";
}

Measured memory_bytes: 3928
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=10000;
const ll INF=1000000010;
const ll LINF=1000000000000000010;
const int MAX=200010;
int dx[8]={0,1,0,-1,1,-1,1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
int main(){
    int a,b,ab,x,y;
    cin>>a>>b>>ab>>x>>y;
    int ans=0;
    if(a+b>ab*2){
        ans+=ab*2*min(x,y);
        if(x<y){
            ans+=(y-x)*min(ab*2,b);
        }else{
            ans+=(x-y)*min(ab*2,a);
        }
    }else{
        ans+=a*x+b*y;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
S = input()

S = list(S)

S[K-1] = S[K-1].lower()

print("".join(S))


Measured memory_bytes: 5456
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  int32_t main()
  {        

      IOS

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

    int ans=0;
    int ans1=0;

    for(int i = 0;i < n-1;i++)
    {
      //cerr << i << ans << ans1 <<endl;
      if(h[i] >= h[i+1])
      {
        ans1++;
      }
      else
      {

        ans=max(ans1,ans);
         ans1=0;
      }
    }
    ans=max(ans,ans1);
    cout<<ans;

    return 0;
 
     }

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
main()
{int a, n;
cin>>n;
	vector <int> m;
	for(int i=1;i<n;i++)
	{
		cin>>a;
		m.push_back(a);
	}
	unordered_map<int,int> mp;
	for(int i=0;i<m.size();i++)
	{
		mp[m[i]]=mp[m[i]]+1;
	}
	for(int i=1;i<=n;i++)
	{
		if(mp[i]>0)
		{
			cout<<mp[i]<<endl;
		}
		else{
			cout<<0<<endl;
		}
	}
		
}

Measured memory_bytes: 12268
import numpy as np


def submit():
    n = int(input())
    alist = list(map(int, input().split()))

    while True:
        curr_idx = np.argmin(alist)
        curr_min = alist[curr_idx]

        surplus_sum = 0
        for i in range(len(alist)):
            if i == curr_idx:
                continue
            alist[i] %= curr_min
            surplus_sum += alist[i]

        if surplus_sum == 0:
            print(curr_min)
            break

        alist = [a for a in alist if a]
    

if __name__ == "__main__":
    submit()

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

int n, a[110], i, j, t;

void bubblesort() {
	for (i = 0; i < n; i++) {
		for (j=n-1; j>=i+1; j--) {
			if (a[j]<a[j-1]) {
				swap (a[j], a[j-1]);
				t++;
			}
		}
	}
}

int main () {
	cin>>n;
		for (int i=0; i<n; i++) cin>>a[i];
		bubblesort();
		for (i=0; i<n-1; i++) cout<<a[i]<< " ";
		cout<<a[n-1]<<endl;
		cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}



int main()
{
    fastio();
    int a[10];
    rep(i,1,5) cin>>a[i];
    rep(i,1,5) if(a[i]==0) cout<<i<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
typedef long long LL;

const int N = 200010;
int st[30][N], k[30], n;
int T[N];
bool vis[N];
char s[N];

inline void update(int k, int v){ for(; k; k -= k&-k) T[k] += v; }

inline int getsum(int k){ int ret = 0; for(; k <= n; k += k&-k) ret += T[k]; return ret; }

int main()
{
	scanf("%s", s+1); n = strlen(s+1);
	for(int i = 1; i <= n; i ++) st[s[i]-'a'][++ k[s[i]-'a']] = i;
	int cnt = 0;
	for(int i = 0; i < 26; i ++) cnt += k[i]&1;
	if(cnt > 1) { puts("-1"); return 0; }
	for(int i = 1; i <= n; i ++) update(i, 1);
	int sum = 0;
	LL ans = 0;
	for(int i = 1; i <= n; i ++) if(!vis[i]) {
		int last = st[s[i]-'a'][k[s[i]-'a'] --];
		if(last == i) {
			sum ++; ans += (n-sum)/2;
			update(i, -1); vis[i] = 1;
		} else {
			sum += 2; ans += getsum(last+1);
			update(i, -1); update(last, -1);
			vis[i] = 1; vis[last] = 1;
		}
		if(sum == n) break;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 22016
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 N;
	cin >> N;
	cout << (N<1000 ? "ABC" : "ABD") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<cstdio>
#define mxn 1000010
using namespace std;
const int inf=1e9,mod=998244353;
int n,sl,fh,top,ans,s[mxn],stk[mxn],cnt[mxn];
char a[mxn];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
void upd(int &x,int y) {x+=y; if(x>=mod) x-=mod;}
bool check(int x)
{
	for(int b=1,j=1,i=x+1;i<=n;++i,j=j%x+1,b^=(j==1))
		if(a[i]>(a[j]^b)) return 1;
		else if(a[i]<(a[j]^b)) return 0;
	return 1;
}
int main()
{
	n=rd();scanf("%s",a+1);
	for(int i=1;i<=n;++i) s[i]=(2ll*s[i-1]+(a[i]=='1'))%mod;
	for(int i=1;i<=n;++i)
		if(n%i==0&&((n/i)&1))
		{
			stk[++top]=i;
			upd(cnt[i],s[i]+check(i));
			for(int j=i+i;j<=n;j+=i)
				if(n%j==0&&((n/j)&1))
					upd(cnt[j],mod-cnt[i]);
		}
	for(int i=1;i<=top;++i) ans=(ans+2ll*stk[i]*cnt[stk[i]])%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4480
import sys

A,B,C,X,Y=list(map(int,input().split()))


cost=0
if 2*C<A+B:
	mini=min([X,Y])
	cost+=mini*C*2
	X-=mini
	Y-=mini
	if not X==0:
		if 2*C<A:
			cost+=2*C*X
			X=0
	elif not Y==0:
		if 2*C<B:
			cost+=2*C*Y
			Y=0



cost+=X*A+Y*B

print(cost)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.lang.Math;

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init(InputStream input) {
        reader = new BufferedReader(new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            tokenizer = new StringTokenizer(reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static String nextLine() throws IOException {
        return reader.readLine();
    }

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

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

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

    static char nextChar() throws IOException {
        return next().charAt(0);
    }
}

public class Main{
    public static void main(String[] args) throws IOException {
        Reader.init(System.in);
        int n=Reader.nextInt();
        String s=Reader.next();
        String p=Reader.next();
        int c=0,mod=1000000007;
        long ans=1;
        for(int i=0;i<n;){
            if(c==0){
                ans*=3;
                if(s.charAt(i)==p.charAt(i)){
                    i++;
                    c=1;
                }
                else{
                    ans*=2;
                    i+=2;
                    c=2;
                }
            }
            else if(c==1){
                if(s.charAt(i)==p.charAt(i)){
                    ans*=2;
                    i++;
                    c=1;
                }
                else {
                    ans*=2;
                    i+=2;
                    c=2;
                }
            }
            else{
                if(s.charAt(i)==p.charAt(i)){
                    i++;
                    c=1;
                }
                else{
                    ans*=3;
                    i+=2;
                    c=2;
                }
            }
            ans=ans%mod;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

ll mod = 998244353;
int mxn = 2e5+5;
vector<ll> fac(mxn), inv(mxn);

ll power(ll x, ll y)
{
	ll ans = 1;
	while (y>0) {
		if (y&1) {
			ans = (ans*x)%mod;
		}
		y /= 2;
		x = (x*x)%mod;
	}
	return ans;
}

ll inverse(ll n)
{
	return power(n, mod-2);
}

ll choose(ll n, ll r)
{
	if (r>n or r<0) {
		return 0;
	}
	return fac[n] * inv[r] % mod * inv[n-r] % mod;
}

void solve()
{
	ll n,m,k;
	cin>>n>>m>>k;
	ll ans = 0;
	fac[0] = 1;
	for (int i=1; i<mxn; i++) {
		fac[i] = fac[i-1] * i % mod;
	}
	inv[mxn-1] = inverse(fac[mxn-1]);
	for (int i=mxn-2; i>=0; i--) {
		inv[i] = inv[i+1]*(i+1) % mod;
	}
	for (int i=0; i<=k; i++) {
		ans = (ans + (((choose(n-1, i)*m)%mod)*power(m-1, n-1-i))%mod) % mod;
	}
	cout << ans << "\n";
}

int main()
{
	fastIO;
	int t=1;
	// cin>>t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 6280
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#define T 10000
#define inf 0x7fffffff
using namespace std;
int n,cnt=1,ans,s,head[10001],q[10001],to[10001],h[10001];
bool mark[10001];
struct data
{
	int to,next,v;
} e[200001];
void ins(int u,int v,int w)
{
	cnt++;
	e[cnt].to=v;
	e[cnt].v=w;
	e[cnt].next=head[u];
	head[u]=cnt;
}
void insert(int u,int v,int w)
{
	ins(u,v,w);
	ins(v,u,0);
}
bool bfs()
{
	int t=0,w=1,i,now;
	memset(h,-1,sizeof(h));
	h[0]=q[0]=0;
	while(t<w)
	{
		now=q[t];
		t++;
		i=head[now];
		while(i)
		{
			if(h[e[i].to]==-1&&e[i].v)
			{
				h[e[i].to]=h[now]+1;
				q[w++]=e[i].to;
			}
			i=e[i].next;
		}
	}
	if(h[T]==-1)return 0;
	return 1;
}
int dfs(int x,int f)
{
	if(x==T)return f;
	int i=head[x];
	int w,used=0;
	while(i)
	{
		if(e[i].v&&h[e[i].to]==h[x]+1)
		{
			w=f-used;
			w=dfs(e[i].to,min(w,e[i].v));
			e[i].v-=w;
			e[i^1].v+=w;
			used+=w;
			if(used==f)return f;
		}
		i=e[i].next;
	}
	if(!used)h[x]=-1;
	return used;
}
void dinic()
{
	while(bfs())ans-=dfs(0,inf);
}
int main()
{
	int x;
	cin>>x;
	int ans=0;
	int now=0;
	while(1)
	{
		now+=x;
		ans++;
		if(now>=360)
			now-=360;
		if(now==0)
			break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
from fractions import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
l = []
for xx in x:
    l.append(abs(xx - X))

g = l[0]

for i in range(1, len(l)):
    g = gcd(g, l[i])

print(g)

Measured memory_bytes: 16280
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 1e5+1;
typedef P<int, int> pii;
int n, m;
V<int> e[N];
bool z[N];
struct UnionFind{
  vector<int> p;
  void init(int n){
    p.assign(n, -1);
  }
  int find(int a){
    return p[a] < 0 ? a : p[a] = find(p[a]);
  }
  bool merge(int a, int b){
    a = find(a);
    b = find(b);
    if(a==b) return 0;
    if(p[a]>p[b]) swap(a, b);
    p[a] += p[b];
    p[b] = a;
    return 1;
  }
} uf;

void draw(int a, int b){
  printf("%d %d\n", a+1, b+1);
  z[a] ^= true;
}
void dfs(int a, int p){
  for(int b:e[a]) if(b!=p) dfs(b, a);
  z[a] ? draw(a, p) : draw(p, a);
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  scanf("%d %d", &n, &m);
  if(m%2){
    printf("-1\n");
    return 0;
  }
  uf.init(n);
  FOR(i, 0, m){
    int a, b;
    scanf("%d %d", &a, &b);
    a--; b--;
    if(uf.merge(a, b)){
      e[a].pb(b);
      e[b].pb(a);
    }else{
      draw(a, b);
    }
  }
  FOR(i, 0, n) if(sz(e[i])==1){
    dfs(e[i][0], i);
    return 0;
  }
}

Measured memory_bytes: 12032
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
int a[3],b[3],c[3][3];
signed main(){
	f(i,3)a[i]=INF,b[i]=INF;
	f(i,3){
		f(j,3){
			cin>>c[i][j];
			a[i]=min(a[i],c[i][j]);
		}
		f(j,3)c[i][j]-=a[i];
	}
	f(j,3){
		f(i,3){
			if(c[i][j]!=c[0][j]){
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <numeric>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

bool solve(int n, const vector<vector<bool>>& g, const vector<int>& p) {
    int me = 0;
    for (int i = 0; i < n - 1; i++) {
        if (!g[me][p[i]]) {
            return false;
        }
        me = p[i];
    }
    return true;
}

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

    vector<vector<bool>> g(n, vector<bool>(n));
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        g[a - 1][b - 1] = true;
        g[b - 1][a - 1] = true;
    }

    int cnt = 0;
    vector<int> p(n - 1);
    std::iota(p.begin(), p.end(), 1);
    do {
        if (solve(n, g, p)) {
            cnt++;
        }
    } while (std::next_permutation(p.begin(), p.end()));

    cout << cnt << endl;

    return 0;
}


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


Measured memory_bytes: 128
// 暴力即可
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		var V int
		fmt.Scan(&V)
		A[i] = V
	}
	ans := int(1e9)
	for i := -100; i <= 100; i++ {
		tmp := 0
		for _, a := range A {
			tmp += (a - i) * (a - i)
		}
		ans = min(ans, tmp)
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

int main() {
    int a, b;
    char op;
    int result;
    while(true) {
    cin >> a >> op >> b;
    if(op == '?') {
        break;
    }
    if(op == '+') {
        result = a + b;
    }
    if(op == '-') {
        result = a - b;
    }
    if(op == '*') {
        result = a * b;
    }
    if(op == '/') {
        result = a / b;
    }
    cout << result << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
// AOJ1051 Citation Format

#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n;
	int a[50];
	while(cin >> n, n){
		for(int i=0;i<n;i++) cin >> a[i];
		sort(a, a+n);
		for(int i=0;i<n; ){
			int j=i;
			while(j<n&&a[j]==a[i]+j-i) j++;
			if(i==j-1) cout << a[i] ;
			else       cout << a[i] << "-" << a[j-1] ;
			if(j!=n) cout << " " ;
			else     cout << endl;
			i=j;
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))
 

int main(){ 
	ll N,M,ans=0;
	cin >> N >> M;
	vector<P> AB(N);
	FOR(i,0,N){
		cin >> AB[i].first >> AB[i].second;
	}
	priority_queue<ll> pq;
	ll i = 0;
	SORT(AB);
	FOR(j,1,M+1){
		while(AB[i].first<=j && i<N){
			pq.push(AB[i].second);
			i++;
		}
		if(pq.size()){
			ans += pq.top();
			pq.pop();
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 2936
N = int(input())
S=[]
for i in range(N):
    A=list(input().split())
    #print(A)
    if A[1]=="JPY":
        S.append(int(A[0]))
    elif A[1]=="BTC":
        S.append(float(A[0])*380000)
print(sum(S))


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		WriteLine(GetInt() <= GetInt() ? "unsafe" : "safe");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 27544
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]

m=0

for j in range(n-1):
    for i in range(j+1,n):
        m+=((l[j][0]-l[i][0])**2+(l[j][1]-l[i][1])**2)**(1/2)

print(m*2/n)


Measured memory_bytes: 3060
# AGC034A - Kenken Race
def main():
    n, a, b, c, d = tuple(map(int, input().rstrip().split()))
    S = input().rstrip()
    flg1 = "##" not in S[a - 1 : c] and "##" not in S[b - 1 : d]
    flg2 = 1 if c < d else "..." in S[b - 2: d + 1]
    print("Yes" if flg1 and flg2 else "No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp6
{
	class Program
	{
		static void Main(string[] args)
		{
			int count = 1;

			while (true)
			{
				string num = Console.ReadLine();
				int i = int.Parse(num);
				
				if (i == 0)
					break;
				Console.WriteLine("Case {0}: {1}", count, i);

				count++;

			}
		}
	}
}



Measured memory_bytes: 17920
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

int N, i, ans;

int main(void) {
    scanf("%d %d", &N, &i);

    ans = N + 1 - i;
    
    printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<queue>
#include<cstdio>
#include<cmath>
#include<sstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<ctime>
#include<cstdlib>
#include<map>
#include<utility>
#include<iomanip>
#include<set>
#include<stack>
//#include<Windows.h>
using namespace std;
typedef long long ll;typedef pair<int,int> pii;
typedef pair<ll,ll> pll;typedef vector<string> vss;
typedef vector<int> vii;typedef vector<pii> vpi;
typedef vector<ll> vll;typedef vector<pll> vpl;
typedef unsigned long long ul;typedef queue<int> qii;typedef queue<pii> qpi;
//ll n;
int main()
{
	int n,a,k,ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a;
		ans+=2*(min(a,k-a));
	}cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;


public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt(), M = sc.nextInt();
        int[][] route = new int[M][2];
        for(int i=0;i<M;i++){
            route[i][0] = sc.nextInt()-1;   //最後に1を足せ
            route[i][1] = sc.nextInt()-1;
        }

        List<Integer>[] destination = new List[N];
        for(int i=0; i<destination.length; i++) {
            destination[i]= new ArrayList<Integer>();
        }
        for(int i=0; i<M; i++) {
            destination[route[i][0]].add(route[i][1]);
            destination[route[i][1]].add(route[i][0]);
        }

        int[] clear = new int[N];
        for(int i=0; i<clear.length; i++) {
            if(i!=0) {
                clear[i]=-1;
            }
        }

        Queue<Integer> queue = new ArrayDeque();
        queue.add(0);

        while(!queue.isEmpty()) {
            int x=queue.poll();
            for(int j: destination[x]) {
                if(clear[j]==-1) {
                    queue.add(j);
                    clear[j]=x;
                }
            }
        }
        for(int i=0; i<clear.length; i++) {
            if(clear[i]==-1) {
                System.out.println("No");
                break;
            }
        }
        System.out.println("Yes");
        for(int i=1; i<clear.length; i++) {
            System.out.println(clear[i]+1);
        }
    }

}


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

int main() {
  map<char, int> rbg;
  rbg['r'] = 0;
  rbg['b'] = 1;
  rbg['g'] = 2;

  string s;
  while (cin >> s && s[0] != '0') {
    int len = s.length();
    vector<string> goal(3);
    for (int i = 0; i < 3; ++i) {
      goal[i] = string(len, "rbg"[i]);
    }

    auto check = [&](string s) {
      for (int i = 0; i < 3; ++i) {
        if (goal[i] == s) return true;
      }
      return false;
    };
    int ans;
    bool ok = true;
    queue<P, deque<P>> que;
    map<string, bool> mp = {{s, true}};

    que.push({s, 0});
    while (ok) {
      tie(s, ans) = que.front(); que.pop();
      if (check(s)) break;

      for (int i = 0; i < len - 1; ++i) {
        if (s[i] == s[i + 1]) continue;
        string nxt = s;
        int n = 3 - rbg[s[i]] - rbg[s[i + 1]];
        nxt[i] = nxt[i + 1] = "rbg"[n];
        if (!mp[nxt]) {
          que.push({nxt, ans + 1});
          mp[nxt] = true;
        }
      }
      if (que.empty()) ok = false;
    }
    cout << ( (ok) ? to_string(ans) : "NA" ) << endl;
  }
  return 0;
}



Measured memory_bytes: 4956
#include<bits/stdc++.h>
#define eoi ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int main()
{
    eoi;
    string s;
    cin>>s;
    vector<int>v(26);
    for(int i=0;i<s.length();i++){
        v[s[i]-'a']++;
    }
    for(int z=0;z<v.size();z++){
        if(v[z]%2!=0){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}







Measured memory_bytes: 256
quit() = exit(0)
in_1(ch) = parse(Int, take!(ch))
in_a(ch) = parse.(Int, split(take!(ch)))

quit() = exit(0)
in_1() = parse(Int, readline())
in_a() = parse.(Int, split(readline()))

function main()
  K = in_1()
  s = 0
  for a in 1:K
    for b in 1:K
      gcd_ab = gcd(a, b)
      for c in 1:K
        s += gcd(a, b, c)
      end
    end
  end
  println(s)
end

isempty(ARGS) && main()


Measured memory_bytes: 159472
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val A, B, Q = sc.nextInt
    val INF = Math.pow(10, 12).toLong
    val s = -INF +: Array.fill[Long](A)(sc.nextLong) :+ INF
    val t = -INF +: Array.fill[Long](B)(sc.nextLong) :+ INF
    val x = Array.fill[Long](Q)(sc.nextLong)

    import java.util.Arrays.binarySearch
    import Math.{abs, min}
    for (i <- 0 until Q) {
      var result = Long.MaxValue
      val si = ~binarySearch(s, x(i))
      val ti = ~binarySearch(t, x(i))
      Array(s(si - 1), s(si)).foreach(s1 => {
        Array(t(ti - 1), t(ti)).foreach(t1 => {
          val d1 = abs(s1 - x(i)) + abs(s1 - t1)
          val d2 = abs(t1 - x(i)) + abs(s1 - t1)
          if (min(d1, d2) < result) {
            result = min(d1, d2)
          }
        })
      })
      println(result)
    }

  }
}

Measured memory_bytes: 110644