akhauriyash/Code-Regression huggingface dataset:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)


n, m = map(int, input().split())
uf = UnionFind(n + m)

for i in range(n):
    k, *L = map(int, input().split())
    for l in L:
        uf.union(l - 1, m + i)

for i in range(n - 1):
    if not uf.same(m + i, m + i + 1):
        print("NO")
        break
else:
    print("YES")


Measured memory_bytes: 65624
from copy import deepcopy as dcopy


def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort(reverse=True)

    p = 0
    q = 0
    pre = A[0]
    for a in range(1, len(A)):
        bpre = dcopy(pre)
        pre = A[a]
        if A[a] == bpre:
            if p == 0:
                p = A[a]
                pre = 0
            else:
                q = A[a]
                break

    print(p*q)

        
if __name__ == "__main__":
    main()


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

using ll = long long;

const ll MOD = 1e9 + 7;
const int MAX_N = 200000;
map<pair<int, int>, int> mp;
//mp[make_pair(i, j)] iから見てjの先にあるnodeの数
vector<int> edge[MAX_N];
int N;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int nodes(int i, int j) {
    pair<int, int> k = make_pair(i, j);
    if (mp.find(k) != mp.end()) return mp[k];
    if (edge[j].size() == 1) {
        mp[k] = 1;
        mp[make_pair(j, i)] = N - 1;
        return 1;
    }
    int ret = 1;
    rep(l, edge[j].size()) {
        if (edge[j][l] == i) continue;
        ret += nodes(j, edge[j][l]);
    }
    mp[k] = ret;
    mp[make_pair(j, i)] = N - ret;
    return ret;
}

int main() {
    int A, B;
    cin >> N;
    rep(i, N - 1) {
        cin >> A >> B;
        A--;
        B--;
        edge[A].push_back(B);
        edge[B].push_back(A);
    }
    /*
    rep(i, N) {
        rep(j, edge[i].size()) {
            cout << "nodes[" << i << "," << edge[i][j] << "]=" << nodes(i, edge[i][j]) << endl;
        }
    }
    */
    ll ans = 0;
    rep(i, N) {
        ans = (ans + mod_pow(2, N - 1, MOD) - 1) % MOD;
        rep(j, edge[i].size()) {
            ans = (ans - mod_pow(2, nodes(i, edge[i][j]), MOD) + 1 + MOD) % MOD;
        }
    }
    cout << (ans * mod_pow(mod_pow(2, N, MOD), MOD - 2, MOD)) % MOD << "\n";
}

Measured memory_bytes: 54016
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,dp[li],say,kon,dp1[li];
int cev;
string s;
multiset<int> st;
vector<int> v;

int main(void){
	fio();
	cin>>n>>k>>s;
	if(s[n]=='1'){cout<<"-1\n";return 0;}
	reverse(s.begin(),s.end());
	for(int i=0;i<=n;i++){
		if(s[i]=='1')say++;
		else{say=0;kon=i;}
		dp[i]=kon;
		if(say>=k){cout<<"-1\n";return 0;}
	}
	for(int i=n+1;i<=n+k+1;i++)dp[i]=kon;
	for(int i=n;i>=1;i--){
		if(s[i]=='0')kon=i;
		dp1[i]=kon;
	}
	cev=0;
	int ind=0;
	while(ind<n){
		v.pb(dp[ind+k]-ind);
		ind=dp[ind+k];
		cev++;
		
	}
	reverse(v.begin(),v.end());
	for(int i=0;i<(int)v.size();i++)cout<<v[i]<<" ";
	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=998244353;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=4000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll nHk(ll n,ll k){
	return nCk(n+k-1,k);
}

int n,m;

int main(){
	Init();
	cin>>n>>m;
	ll res=nHk(n,3*m);
	for(int i=m+1;i<=min(3*m,n);i++) if((3*m-i)%2==0) res=(res-nHk(n,(3*m-i)/2)*nCk(n,i)%mod+mod)%mod;
	for(int i=2*m+1;i<=3*m;i++) res=(res-n*nHk(n-1,3*m-i)%mod+mod)%mod;
	cout<<res<<endl;
}

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

int main(){
	int n, cou;
	while(1){
		cou = 0;
		cin >>n;
		if(n == 0) break;
		while(n != 1){
			if(n % 2 == 0){
				n /= 2;
			} else{
				n *= 3;
				n += 1;
			}
			cou++;
		}
		cout <<cou <<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int> cost = {0,2,5,5,4,5,6,3,7,6};
int n,m;
vector<int> vet;
const int inf = (1 << 28);
int dp[11][100009];

int solve(int id, int P){
	if(id == m)
		if(P == 0)
			return 0;
		else
			return -inf; 
	
	int &ans = dp[id][P];
	if(~ans)
		return ans;
	ans = -inf;
	int p = cost[vet[id]];
	
	if(P-p>=0)
		ans = max(ans,1 + solve(id,P-p));
	ans = max(ans, solve(id+1,P));
	
	return ans; 	
}

void recovery(int id, int P){
	if(id == m)
		return ;
	int ans = dp[id][P];
	int p = cost[vet[id]];
	
	if(P -p >= 0 and (solve(id, P-p)+1 == ans)){
		cout<<vet[id];
		//cout<<(P-p)<<" "<<vet[id]<<" "<<ans<<endl;
		
		recovery(id,P-p);
	}else
		recovery(id+1,P);

}
main(){
	cin >> n >> m;
	vet.resize(m);
	memset(dp, -1,sizeof(dp));
	for(int i  = 0;i<m;i++) cin >> vet[i];
	sort(vet.begin(),vet.end(),greater<int>());
	solve(0,n);
	recovery(0,n);
}

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

int N, p[10];

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i){
      cin >> p[i];
    }

    sort(p, p + N);

    int ans = p[N-1]/2;
    for (int i = 0; i < N-1; ++i){
        ans += p[i];
    }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort()
a.reverse()
oktwo = 0
skip = 0
for i in range(1,n):
  if skip == 1:
    skip = 0
    continue
  if a[i-1] == a[i]:
    if oktwo != 0:
      print(oktwo*a[i])
      break
    else:
      oktwo = a[i]
      danger = 1
      skip = 1
else:
  print(0)

Measured memory_bytes: 14252
/*
Author : N_o_o_B
Created : December 22 2019 17:32:40 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    ll a,b;
    cin >> a >> b;
    cout << a*b/__gcd(a,b) << endl;



    time_taken();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

string Action(const string &buf)
{
    string str = "";
    stringstream ss(str);
    char a = 0;
    int r = 0;
    for (int i = 0; i < buf.length(); ++i) {
        if (a == buf.at(i)) {
            ++r;
        } else {
            if (a != 0) { ss << r << a; }
            a = buf.at(i);
            r = 1;
        }
    }
    if (a != 0) { ss << r << a; }
    return ss.str();
}

string MultiAction(string &buf, const int n)
{
    for (int i = 0; i < n; ++i) {
        buf = Action(buf);
    }
    return buf;
}

int main(const int argc, const char *argv[])
{
    string buf = "";
    int n = 0;
    int count = 0;
    vector<string> out;
    while (1) {
        cin >> buf;
        if (buf == "0") break;
        if (count % 2 == 0) {
            n = atoi(buf.c_str());
        } else {
            out.emplace_back(MultiAction(buf, n));
        }
        ++count;
    }
    for (auto itr = out.begin(); itr != out.end(); ++itr) {
        cout << *itr << endl;
    }
}

Measured memory_bytes: 3260
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
typedef queue<int> qii;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;
vi a;

void SieveOfEratosthenes(int n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
            a.pb(p);
} 

void solve(){
    SieveOfEratosthenes(1e5+5);
    int x;
    cin>>x;
    rep(i,0,a.size()){
        if(a[i]>=x){
            cout<<a[i]<<'\n';
            break;
        }
    }
}
    
int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    // fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

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

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

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

vector<bool> IsPrime;

void sieve(size_t max){
    IsPrime.assign(max + 1, true);
    IsPrime[0] = false;
    IsPrime[1] = false;
    for(int i = 2; i*i <= max; i++){
        if(IsPrime[i])for(int j = 2; i*j <= max; j++) IsPrime[i*j] = false;
    }
}

int main(){
    sieve(55555);
    int cnt;
    vector<int> ans;
    for(int i = 1; i<= 55555; i++){
        if(i%5 == 1 && IsPrime[i] == true)ans.push_back(i);
    }
    int N; cin >> N;
    rep(i, N) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main (){
    int a[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            scanf("%d", &a[i][j]);
        }
    }
    int ce[3][3] = {};
    int n;
    scanf("%d", &n);
    int x;
    for(int i = 0; i < n; i++){
        scanf("%d", &x);
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(x == a[j][k]){
                    ce[j][k]++;
                    if((ce[0][0] > 0 && ce[0][1] > 0 && ce[0][2] > 0) || (ce[1][0] > 0 && ce[1][1] > 0 && ce[1][2] > 0) || (ce[2][0] > 0 && ce[2][1] > 0 && ce[2][2] > 0) || (ce[0][0] > 0 && ce[1][0] > 0 && ce[2][0] > 0) || (ce[0][1] > 0 && ce[1][1] > 0 && ce[2][1] > 0) || (ce[0][2] > 0 && ce[1][2] > 0 && ce[2][2] > 0) || (ce[0][2] > 0 && ce[1][1] > 0 && ce[2][0] > 0) || (ce[0][0] > 0 && ce[1][1] > 0 && ce[2][2] > 0)){
                        puts("Yes");
                        return 0;
                    } 
                }
            }
        }
    }
    puts("No");    


    return 0;
}

Measured memory_bytes: 1624
import math
from collections import defaultdict,deque
#from itertools import permutations
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

a,b=ml()
ans=0
for i in range(a):
    x,y=ml()
    x*=x
    y*=y
    k=math.sqrt(x+y)
    if(k<=b):
        ans+=1
print(ans)        

Measured memory_bytes: 70260
#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;
    int ans = n % 100 % 10;
    if(ans == 2 || ans ==4 || ans == 5 || ans == 7 || ans == 9){
        cout << "hon" << endl;
    }else if(ans == 0 || ans == 1 || ans == 6 || ans == 8){
        cout << "pon" << endl;
    }else{
        cout << "bon" << endl;
    }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int a,b,c;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>a>>b>>c;
	for(int i=1;i<=1e6;i++){
		if((b*i+c)%a==0){
			cout<<"YES";
			re 0;
		}
	}
	cout<<"NO";
	re 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<set>

using namespace std;
int main()
{

    int n,y;
    cin >> n >>y;
    bool end = false;
    int i,j;

    for(i=0;i<=n;i++){
        for(j=0;j<=n-i;j++){
            if(10000*i+5000*j+1000*(n-i-j)==y){
                end = true;
                break;
            }
            if(end) break;
        }
        if(end) break;
    }

    if(end) cout << i << " "<<j<<" "<<n-i-j;
    else cout << "-1 -1 -1";

    return 0;

}

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

template<class T> ostream& operator<<(ostream &os, vector<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T> ostream& operator<<(ostream &os, set<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){
	os << "[ ";
	for(auto v  : V) os << "(" << v.first << ":" << v.second << ")";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){
	return os << "(" << V.first << "," << V.second << ")";
}

#define cerr cout
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    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...);
    }
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif
/*---------------------------Defines----------------------*/
typedef long long int ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vbl vector<bool>
#define vvll vector<vll>
#define vld vector<ld>
#define vb vector<bool>
#define vc vector<char>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
/*-----------------------Modular Arithmetic---------------*/
inline ll add(ll x,ll y,ll mod){x+=y; if(x>=mod) return x-mod; return x;}
inline ll sub(ll x,ll y,ll mod){x-=y; if(x<0) return x+mod; return x;}
inline ll mul(ll x,ll y,ll mod){return (x*1ll*y)%mod;}
inline ll power(ll x,ll y,ll mod){ll ans=1; while(y){if(y&1) ans=mul(ans,x,mod); x=mul(x,x,mod); y>>=1;} return ans;}
inline ll inv(ll x,ll mod){return power(x,mod-2,mod);}
/*-----------------------------Code begins----------------------------------*/

const ll INF = 1e18;

void solve(){
    ll n;cin>>n;
    vll a(n),b(n);
    for(ll i=0;i<n;i++) cin>>a[i]>>b[i];
    sort(all(a));sort(all(b));
    if(n%2){
        cout<<b[n/2]-a[n/2]+1<<"\n";
    }else{
        cout<<(b[n/2]+b[n/2-1]-(a[n/2]+a[n/2-1])+1)<<"\n";
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<fixed<<setprecision(25);
    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6416
#include<stdio.h>

int main(){
  int n;
  int i;
 
  for(i = 0 ; i < 10000; i++){
    scanf("%d", &n);
    if(n == 0) break;

    printf("Case %d: %d\n", i+1, n);
  }

  return 0;
}



Measured memory_bytes: 2032
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>

typedef std::map<std::string, std::vector<int> > index_t;
typedef std::pair<std::string, std::vector<int> > info_t;

index_t index;

std::string word;
int page_num;
bool get_input()
{
	return (std::cin >> word >> page_num);
}

int main()
{
	index_t::iterator word_itr;
	while (get_input()) {
		word_itr = index.find(word);
		if (word_itr == index.end()) {
			std::vector<int> page_nums;
			page_nums.push_back(page_num);
			info_t info(word, page_nums);
			index.insert(info);
		} else {
			word_itr->second.push_back(page_num);
		}
	}
	for (index_t::iterator i = index.begin(); i != index.end(); i++) {
		std::cout << i->first << std::endl;
		std::sort(i->second.begin(), i->second.end());
		for (std::vector<int>::iterator j = i->second.begin(); j != i->second.end(); j++) {
			if (j != i->second.end() -1) {
				std::cout << *j << " ";
			} else {
				std::cout << *j;
			}
		}
		std::cout << std::endl;
	}
	return 0;
}

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

void inp(vector<int> &t, int N){
  for(int i = 0; i < N; i++){
    cin >> t[i];
  }
  sort(t.begin(), t.end());
}

int main(){
  int N; cin >> N;
  vector<int> a(N, 0), b(N, 0), c(N, 0), bp(N, 0);
  inp(a, N); inp(b, N); inp(c, N);
  
  int acn = 0;
  int bcn = 0;
  
  while(a[0] >= b[bcn] && bcn < N) {
    bcn++;
  }
  if(bcn == N) {cout << 0 << endl; return 0;}
  
  for(; bcn < N; bcn++){
    while(a[acn] < b[bcn] && acn < N) acn++;
    bp[bcn] = acn;
  }
  
  bcn = 0;
  int ccn = 0;
  while(b[0] >= c[ccn] && ccn < N) {
    ccn++;
  }
  if(ccn == N) {cout << 0 << endl; return 0;}
  
  long long ans = 0LL;
  long long bsum = 0LL;
  for(; ccn < N; ccn++){
    while(b[bcn] < c[ccn] && bcn < N) {
      bsum += bp[bcn];
      bcn++;
    }
    ans += bsum;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long

int main() {
    int a,b,c;
    while(cin >> a >> b >> c) {
        if(a != b && a != c && b != c || a == b && b == c) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

k = inp[0]
sum = -1
que = [0,1,2,3,4,5,6,7,8,9,1e20]
keta = 1
kac =10
while true
  #p que
  #p sum
  a = que.shift()
  if a== 1e20
    keta += 1
    kac *= 10
    que.push(1e20)
    que.sort!
    next
  end
  x = a.to_s[0].to_i
  l = a.to_s.size
  unless a.to_s.size != keta
    sum += 1
  else
    x = 0

  end
  if(sum == k)
    puts a
    exit
  end
  (big(x-1,0)..small(x+1,9)).each do |d|
    rec = a+d*kac
    que.push((rec))
  end
end


Measured memory_bytes: 5204
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

int D;
int c[32];
int s[512][32];
int ans[512];

void inp(){
    cin>>D;
    for(int i=1;i<=26;i++){
        cin>>c[i];
    }
    for(int i=1;i<=D;i++){
        for(int j=1;j<=26;j++){
            cin>>s[i][j];
        }
    }
}

void ans_inp(){
    for(int i=1;i<=D;i++){
        cin>>ans[i];
    }
}

void ans_ran(){
    for(int i=1;i<=D;i++){
        ans[i]=rand()%26+1;
    }
}

int man_calc(bool disp){
    int l[32]={0};
    int man=0;
    for(int i=1;i<=D;i++){
        int n=ans[i];
        l[n]=i;
        man+=s[i][n];
        for(int j=1;j<=26;j++){
            man-=c[j]*(i-l[j]);
        }
        if(disp) cout<<man<<endl;
    }
    return man;
}

void ans_disp(){
    for(int i=1;i<=D;i++){
        cout<<ans[i]<<endl;
    }
}

int change_ans(int i,int n,bool f){
    int ret=0;
    if(f){
        int fr=ans[i];
        ret+=s[i][n];
        ret-=s[i][fr];

        //cout<<ret<<endl;
        int fl=0;
        for(int j=1;j<=i-1;j++){
            if(ans[j]==fr) fl=0;
            else fl++;
        }
        for(int j=i;j<=D;j++){
            if(ans[j]==fr&&j!=i) break;
            ret-=c[fr]*(fl+1);
        }
        //cout<<ret<<endl;
        int tl=0;
        for(int j=1;j<=i-1;j++){
            if(ans[j]==n) tl=0;
            else tl++;
        }
        for(int j=i;j<=D;j++){
            if(ans[j]==n) break;
            ret+=c[n]*(tl+1);
        }
        //cout<<ret<<endl;
    }
    ans[i]=n;
    //cout<<ret<<endl;
    return ret;
}

void solve_C(){
    int M;
    cin>>M;
    int man=man_calc(false);
    //cout<<man<<endl;
    for(int i=0;i<M;i++){
        int from,to;
        cin>>from>>to;
        int cng=change_ans(from,to,true);
        man+=cng;
        cout<<man<<endl;
    }
}

void random_solve(){
    int seed=1234;
    int cnt=1000000;
    srand(seed);
    ans_ran();
    for(int i=0;i<=cnt;i++){
        int bef=man_calc(false);
        int ci=rand()%D+1;
        int tn=rand()%26+1;
        int fn=ans[ci];
        int cng=change_ans(ci,tn,true);
        if(cng<0){
            change_ans(ci,fn,false);
        }
    }
    ans_disp();
    //cout<<man_calc(false)<<endl;
}

signed main(){
    inp();
    //ans_inp();
    //solve_C();
    random_solve();
    return 0;
}



Measured memory_bytes: 3280
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    import heapq
    import itertools

    def dijkstra(s, n):
        hq = [(0, s)]
        heapq.heapify(hq)  # リストを優先度付きキューに変換
        cost = [float('inf')] * n  # 行ったことのないところはinf
        cost[s] = 0  # 開始地点は0
        while hq:
            c, v = heapq.heappop(hq)
            if c > cost[v]:  # コストが現在のコストよりも高ければスルー
                continue
            for d, u in e[v]:
                tmp = d + cost[v]
                if tmp < cost[u]:
                    cost[u] = tmp
                    heapq.heappush(hq, (tmp, u))
        return cost



    N, M, R = MI()
    r = LI()
    e = [[]for _ in range(N)]
    dis_list = [[]for _ in range(N)]
    for i in range(M):
        a, b, c = MI()
        a, b = a - 1, b - 1
        e[a].append((c, b))
        e[b].append((c, a))
    for r_ in r:
        dis_list[r_ - 1] = dijkstra(r_ - 1, N)

    Ans_list = []
    P = itertools.permutations(r)
    for p in P:
        dis = 0
        for i in range(R - 1):
            dis += dis_list[p[i] - 1][p[i + 1] - 1]
        Ans_list.append(dis)
    ans = min(Ans_list)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 79872
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

A.sort()
sum = sum(A)
if sum%10!=0:
    print(sum)
else:
    for i in range(N):
        min = A[i]
        if min%10!=0:
            print(sum-min)
            break
        elif i==N-1:
            print(0)



Measured memory_bytes: 3064
n,k=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7
A.sort()
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
N = 10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
ans,bns=0,0
for j in range(n-k+1):
  ans=(ans+(A[n-j-1]-A[j])*cmb(n-j-1,k-1,mod))%mod
print(ans%mod)

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

int main(void){
  int n, k;
  vector<int> h;
  cin >> n >> k;
  for(int i = 0; i < n; i ++){
    int temp;
    cin >> temp;
    h.push_back(temp);
  }

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

  int min = 1000000001;
  for(int i = 0; i < n-k+1; i ++){
    int hmin = h.at(i);
    int hmax = h.at(i+k-1);

    if(min > (hmax - hmin)) min = hmax - hmin;
  }

  cout << min << endl;

  return 0;
}


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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,r,n) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
    cin >> n >> k >> s;
         if (s[k-1] == 'A') s[k-1] = 'a';
    else if (s[k-1] == 'B') s[k-1] = 'b';
    else  					s[k-1] = 'c';
  
    cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e6+26;

//write function from here ...


int ft [maxx][26];

int n ;

void update( int i , int val , int j ){
	
	for ( ++i ; i <= n ; i+=( i &-i))
	{
		ft[i][j]+=val;
		
	}
}

vector < int > qry( int i  ){
	
	vector < int > alp(26,0);
	
	
	for ( ; i ; i -= ( i&-i ) ){
		
		for(int j =0 ; j < 26;j++){
			
			if( ft[i][j] > 0 ){
				alp[j]+= ft[i][j] ;
			}
		}
		
	}
	
	
	
	
	return alp ;
}




int Main(){




cin>>n;
string s;
cin>>s;

for ( int i =0 ; i < n;i++){
	
	update( i , 1 , s[i]-'a');
}


int q;
cin>>q;
while(q--){
	
	
	int a;
	cin>>a;
	
	if(a== 1){
		int i ;
		char  c;
		cin>>i;
		i--;
		cin>>c;
		
		
		update(i  , -1, s[i]-'a');
		update(i , 1, c-'a');
		s[i] = c;
		
	}
	else
	{
		
		
		
		
		int l , r;
		cin>>l>>r;
		
		vector < int > ans1 = qry(r) , ans2 =  qry(l-1);
		int ans =0 ;
		////int alp [26];
		//memset(alp,0,sizeof(alp));
		for( int i =0 ; i < 26;i++){
			
			if(ans1[i]>ans2[i])
			ans++;
			
		}
		cout<<ans<<endl;
		
		
		
	}
	
	
	
}


return 0;

}






int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 54696
import numpy as np
n, m = (int(i) for i in input().split())
a = np.sort(np.array([int(i) for i in input().split()], dtype='int64'))
b, c = np.zeros(m, dtype='int64'), np.zeros(m, dtype='int64')
for i in range(m):
    b[i], c[i] = (int(i) for i in input().split())

b = b[np.argsort(-c)]
c = c[np.argsort(-c)]
i = 0
for bb, cc in zip(b, c):
    for cnt in range(bb):
        if a[i] < cc:
            a[i] = cc
        else:
            break
        i = i + 1
        if i >= len(a):
            break
    else:
        continue
    break
print(int(sum(a)))

Measured memory_bytes: 23320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

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

    // sum[0] > 0
    ll cnt1 = 0;
    if(A[0] > 0){
        sum[0] = A[0];
    }else{
        sum[0] = 1;
        cnt1 += abs(1-A[0]);
    }
    rep(i, 1, n){
        if(sum[i-1] > 0){
            if(sum[i-1] + A[i] < 0){
                sum[i] = sum[i-1] + A[i];
            }else{
                sum[i] = -1;
                cnt1 += abs(sum[i-1] + A[i] - (-1));
            }
        }else{
            if(sum[i-1] + A[i] > 0){
                sum[i] = sum[i-1] + A[i];
            }else{
                sum[i] = 1;
                cnt1 += abs(1 - (sum[i-1] + A[i]));
            }

        }
    }

    // sum[0] < 0
    ll cnt2 = 0;
    if(A[0] < 0){
        sum[0] = A[0];
    }else{
        sum[0] = -1;
        cnt2 += abs(A[0]-(-1));
    }
    rep(i, 1, n){
        if(sum[i-1] > 0){
            if(sum[i-1] + A[i] < 0){
                sum[i] = sum[i-1] + A[i];
            }else{
                sum[i] = -1;
                cnt2 += abs(sum[i-1] + A[i] - (-1));
            }
        }else{
            if(sum[i-1] + A[i] > 0){
                sum[i] = sum[i-1] + A[i];
            }else{
                sum[i] = 1;
                cnt2 += abs(1 - (sum[i-1] + A[i]));
            }

        }
    }
    
    cout << min(cnt1, cnt2) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif



static void A_task();

int main()
{
	A_task();
	
	fflush(stdout);
	return 0;
}

static void A_task()
{
	int N;
	scanf(" %d", &N);

	printf("%d\n", (N - 2) * 180);
}


Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll a, b, k;
	cin >> a >> b >> k;
	if(a >= k) coVec({a-k, b});
	else if(a+b >= k) coVec({0, a+b-k});
	else coVec({0, 0});

	return 0;
}


Measured memory_bytes: 256
import collections
n = int(input())
v_ = list(map(int,input().split()))
setv = set(v_)
if len(setv) == 1:
    print(n//2)
else: 
    v1 = v_[::2]
    v2 = v_[1::2]
    v1com = collections.Counter(v1)
    v2com = collections.Counter(v2)
    v1com = v1com.most_common()
    v2com = v2com.most_common()
    if v1com[0][0] != v2com[0][0]:
        print(n-v1com[0][1]-v2com[0][1])
    else:
        print(n-v1com[0][1]-max(v1com[1][1],v2com[1][1]))

Measured memory_bytes: 24604
#import sys
#input = sys.stdin.readline

def main():
    s=list(input())
    r=s[:]
    r.reverse()
    ss,rr=[],[]
    n=int(input())
    flg=0
    for i in range(n):
        q=list(map(str,input().split()))
        if q[0]=='1':
            flg=(flg+1)%2
        else:
            f,c=q[1],q[2]
            if f=='1':
                if flg==0:
                    rr.append(c)
                else:
                    ss.append(c)
            else:
                if flg==0:
                    ss.append(c)
                else:
                    rr.append(c)
    if flg==1:
        ss.reverse()
        ans=''.join(ss+r+rr)
        print(ans)
    else:
        rr.reverse()
        ans=''.join(rr+s+ss)
        print(ans)
if __name__ == '__main__':
    main()

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

public class Main {
	static final int M = 1_000_000_007;

	void run() {
		int n = in.nextInt();
		int m = in.nextInt();
		int[] a = new int[n];
		int[] b = new int[m];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		for (int i = 0; i < m; i++) {
			b[i] = in.nextInt();
		}
		Arrays.sort(a);
		Arrays.sort(b);
		if (n < m) {
			int t = n; n = m; m = t;
			int[] tt = a; a = b; b = tt;
		}
		for (int i = 1; i < n; i++) {
			if (a[i] == a[i - 1]) {
				out.println(0);
				return;
			}
		}
		for (int i = 1; i < m; i++) {
			if (b[i] == b[i - 1]) {
				out.println(0);
				return;
			}
		}
		if (a[n - 1] != n * m || b[m - 1] != n * m) {
			out.println(0);
			return;
		}
		int i = n;
		int j = m;
		for (int v = n * m; v >= 1; v--) {
			if (i - 1 >= 0 && a[i - 1] >= v) {
				i--;
			}
			if (j - 1 >= 0 && b[j - 1] >= v) {
				j--;
			}
			if (a[i] == v && b[j] == v) {
				continue;
			}
			if (a[i] == v) {
				mul(m - j);
				continue;
			}
			if (b[j] == v) {
				mul(n - i);
				continue;
			}
			int free = (m - j) * (n - i) - (n * m - v);
			if (free <= 0) {
				out.println(0);
				return;
			}
			mul(free);
		}
		out.println(ans);
	}
	
	int ans = 1;
	
	void mul(int x) {
		ans = (int) ((ans * (long) x) % M);
	}

	static MyScanner in;
	static PrintWriter out;

	public static void main(String[] args) throws IOException {
		boolean stdStreams = true;
		String fileName = Main.class.getSimpleName().replaceFirst("_.*", "").toLowerCase();
		String inputFileName = fileName + ".in";
		String outputFileName = fileName + ".out";
		
		Locale.setDefault(Locale.US);
		BufferedReader br;
		if (stdStreams) {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		} else {
			br = new BufferedReader(new FileReader(inputFileName));
			out = new PrintWriter(outputFileName);
		}
		in = new MyScanner(br);
		int tests = 1;//in.nextInt();
		for (int test = 0; test < tests; test++) {
			//out.print("Case #" + (test + 1) + ": ");
			new Main().run();
		}
		br.close();
		out.close();
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		MyScanner(BufferedReader br) {
			this.br = br;
		}
		
		void findToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		
		String next() {
			findToken();
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 24404
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

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

Measured memory_bytes: 256
N=int(input())
Val=list(map(int,input().split()))
V=sorted(Val, reverse=True)
value=[]
for i in range(N-1):
    v=V[i]/(2**(i+1))
    value.append(v)
last=V[N-1]/(2**(N-1))
value.append(last)
print(sum(value))



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
struct UnionFind{
    vector<int> parent;

    UnionFind(int n) : parent(n){
        for (int i = 0; i < n; i++)parent[i] = i;
    }

    int find(int e){
        if (parent[e] == e) return e;
        else return parent[e] = find(parent[e]);
    }

    void unite (int a, int b) {
        a = find(a);
        b = find(b);
        if (a == b) return;
        parent[a] = b;
    }

    bool same(int a, int b){
        return find(a) == find(b);
    }
};

int main() {
    vector<tuple<int, int, int>> a;
    int n, t, ans = 0;
    cin >> n;
    UnionFind uf(n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> t;
            if (i <= j && t != -1) a.push_back(make_tuple(t,i,j));
        }
    }
    sort(a.begin(), a.end(), [](const tuple<int, int, int>& x, const tuple<int, int, int>& y) { return get<0>(x) < get<0>(y);} );
    for(auto e : a){
        if( !uf.same(get<1>(e), get<2>(e)) ){
            ans += get<0>(e);
            uf.unite(get<1>(e), get<2>(e));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3148
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int interval = sc.nextInt();
		int biscuit = sc.nextInt();
		int time = sc.nextInt();
		int count = time / interval;
		System.out.println(biscuit * count);
	}
}

Measured memory_bytes: 22612
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int a,c=0,d=0,i;
	int *b;
	scanf("%d",&a);
	b=(int *)malloc(a * sizeof(int));
	for(i=0;i<a;i++) scanf("%d",&b[i]);
	for(i=0;i<a-1;i++){
		if(b[i]>=b[i+1]) c++;
		else{
			if(d<c) d=c;
			c=0;
		}
	}
	if(d<c) d=c;
	printf("%d\n",d);
	free(b);
	return 0;
}

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

#define fi first
#define se second

const int N = 111100;
const int MAGIC = 1000;
const long long mod = 998244353;

using namespace std;

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        string s;
        cin >> s;
        int res = 0;
        for(char c: s){
                res += c == 'o';
        }
        res += 15 - s.size();
        if(res >= 8){
                cout << "YES" << "\n";
        } else{
                cout << "NO" << "\n";
        }
}


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

int main(void) {
  int N, X;
  int sum = 0;
  int min = 100001;
  int cnt = 0;
  int m;
  
  cin >> N >> X;
  
  for (int i = 0; i < N; ++i) {
    cin >> m;
    sum += m;
    if (m < min) min = m;
  }
  X -= sum;
  cnt = N + (X / min);
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<b)
    {
        while(b--)
        {
            cout<<a;
        }
    }else
    {
        while(a--)
        {
            cout<<b;
        }
    }
    cout<<endl;
}

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

long long n, k, a, b;
long long arr[100000] = {};

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        arr[a - 1] += b;
    }
    long long count = 0;
    for (int i = 0; i < 100000; i++) {
        count += arr[i];
        if (count >= k) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

int main() {
	int N,A,B;
	cin >> N >> A >> B;
	string S;
	cin >> S;
	int a=0;
	int b=0;
	vector<string> res(N);
	for (int i = 0; i < N; i++) {
		res[i] = "No";
		if (S[i] == 'a') {
			if (a < A + B) {
				a++;
				res[i] = "Yes";
			}
		}
		else if (S[i] == 'b') {
			if (a < A + B) {
				if (b < B) {
					a++;
					b++;
					res[i] = "Yes";
				}
			}
		}
	}
	
	for (int i = 0; i < N; i++) {
		cout << res[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 6144
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
int dx[4]={0,0,-1,1},dy[4]={1,-1,0,0};


int main(int argc, char const *argv[]) {
  int a,b,c;
  std::cin >> a >> b >> c;
  std::cout << min(c,b/a) << '\n';
  return 0;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int main(){
	int n;
	cin>>n;
	int a=0;
	string s=to_string(n);
	rep(i,s.size())a+=s[i]-'0';
	if(n%a)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}







Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	loopCount := nextInt()
	var maxCount int64
	var cnt int64
	var nowCountNumber int64
	var i int64
	var nextNumber int64

	nowCountNumber = nextInt()

	for i = 1; i < loopCount; i++ {
		nextNumber = nextInt()
		if nowCountNumber < nextNumber {
			if maxCount < cnt {
				maxCount = cnt
			}
			cnt = 0
		} else {
			cnt++
		}
		nowCountNumber = nextNumber
	}
	if maxCount < cnt {
		maxCount = cnt
	}
	fmt.Println(maxCount)
}


Measured memory_bytes: 2304