akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

ll in(){
	ll x;
	scanf("%lld",&x);
	return x;
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

//素因数分解をして配列で返します
vector<pair<long long,long long>> prime_factorize(ll x){
	using P = pair<long long,long long>;
	vector<P> res;
	for(int i=2;i*i<=x;++i){
		int cnt = 0;
		while(x%i==0){
			x /= i;
			++cnt;
		}
		if(cnt){
			res.emplace_back(i,cnt);
		}
	}
	if(x>1)res.emplace_back(x,1);
	return res;
}

int main(){
	ll n;
	cin >> n;
	cout << n << ":";
	vector<pll> ans = prime_factorize(n);
	foreach(i,ans){
		rep(j,i.second){
			cout << " " << i.first;
		}
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 3112
import java.util.Scanner;

class Main{
    public static void main(String[] a){

		Scanner scanner = new Scanner(System.in);
		int array[] = new int[10];
		int cnt = 0;
		
		while(cnt < 10) {
			int num = scanner.nextInt();
			array[cnt] = num;
			cnt++;
		}
		
		scanner.close();
		
		for(int i = 0; i < array.length - 1; i++) {
			for(int j = 0; j < array.length - 1; j++) {
				if(array[j] < array[j+1]) {
					int max = array[j];
					array[j] = array[j+1];
					array[j+1] = max;
				}
			}
		}
		
		for(int i = 0; i < 3; i++) {
			System.out.println(array[i]);
		}
		
    }
}


Measured memory_bytes: 26264
#include<iostream>
#include <numeric>
using namespace std;
#define N 100
#define M 100
int t[N+1];
int n, m;

int main() {
    cin >> n;
    for(int i=0; i<n; ++i){
        cin >> t[i];
    }
    cin >> m;
    int p, x, temp=0;
    
    for(int i=0; i<m; ++i){
        int sum=0;
        cin >> p >> x;
        temp = t[p-1];
        t[p-1]=x;
        for(int j=0; j<n; ++j){
            sum += t[j];
        }
        cout << sum << endl;
        t[p-1] = temp;
    }
	return 0;
}

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

int main() {
    ll n, t = 1, a = 1;
    cin >> n;
    for(int i=0;i<n;i++){
        ll x, y, k;
        cin >> x >> y;
        k = max((t-1)/x+1, (a-1)/y+1);
        t = k*x;
        a = k*y;
    }
    cout << a+t << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int N = 1e5 + 10;

int a[N];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int Max = 0;
    int cnt = 1;
    for (int i = 1; i <= n - 1; i++)
    {
        if (a[i] >= a[i + 1]) cnt++;
        else
        {
            Max = max(cnt, Max);
            cnt = 1;
        }
    }
    Max = max(cnt, Max);
    cout << Max  - 1<< endl;
    return 0;
}

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;

ll n,k,cnt[50],best[50],pcbest[50];
ll pow2[50];

ll lg(ll a){
    if (a==0) return -1;
    return log2(a);
}

ll sol(ll a){
    if (a==0) return 0;
    ll tm=lg(a),res=best[tm];

    a-=pow2[tm];
    for (ll i=lg(a)+1;i<tm;i++) res+=cnt[i];

    return max(pcbest[tm-1]+cnt[tm],res+sol(a));

}

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

    for (ll i=0;i<50;i++){
        cnt[i]=0;
        pow2[i]=((ll)1 << i);
    }

    cin >> n >> k;
    for (ll i=0;i<n;i++){
        ll tm;
        cin >> tm;
        for (ll j=0;j<50;j++){
        //    cerr << (tm&pow2[j]) << " ";
            if ((tm&pow2[j])>0) cnt[j]++;
        //    cerr << cnt[j] << " ";
        }
    //    cerr << el;
    }

    for (ll i=0;i<50;i++){
    //    cerr << cnt[i] << " ";
        best[i]=max(cnt[i],n-cnt[i])*pow2[i];
        cnt[i]*=pow2[i];
    }
    pcbest[0]=best[0];
    for (ll i=1;i<50;i++){
        pcbest[i]=pcbest[i-1]+best[i];
    }

    ll tot=0;
    for (ll i=lg(k)+1;i<50;i++) tot+=cnt[i];
    cout << tot+sol(k) << el;

    return 0;
}

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

long long int N, K;

int main(void) {

	cin >> N >> K;

	long long int tmp = N / K;
	long long int ans = N;

	long long int cur = N - tmp*K;

	ans = min(ans, cur);

	cur = abs(K - cur); ans = min(ans, cur);

	cur = abs(K - cur); ans = min(ans, cur);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);
//#define mod 100000007

#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 

bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
 
    return false;
 }
//me
ll const mod = 1e9+7;
ll const inf = 1e6+2;
ll fact[inf];
void factfill()
{
    fact[0]=1;
    for(ll i=1; i<inf; i++)
        fact[i] = ( fact[i-1]*i ) % mod;
}

ll powmod(ll a, ll b)
{
    ll res = 1;
    while(b){
        if(b%2) res = ( res*a )%mod;
        a = (a*a)%mod;
        b/=2;
    }
    return res;
}

ll inv(ll x)
{
    return powmod(x,mod-2) % mod;
}

ll choose(ll n, ll r)
{
    return ( (fact[n]* inv(fact[n-r] ) )%mod *inv(fact[r]))%mod;
}
void solve()
{   

   ll n,d; cin >> n >> d;

   vector<double> dis;
   f(i,0,n){
    ll x,y; cin >> x >> y;

    dis.pb( sqrt(x*x + y*y) );

   }

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

   auto ind = upper_bound(dis.begin(), dis.end(),d)-dis.begin();
   //ind--;

   cout << ind;


}

int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/


        //factfill();
        ll t;
        /**/t=1;
        /*/cin>>t;/**/
        f(testcases,0,t){
            solve();
        }
 
 
 
 
    return 0;
}

Measured memory_bytes: 5336
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int a, b, m; cin >> a >> b >> m;
    vint va(a); vin(va);
    vint vb(b); vin(vb);
    vector<pint> xy(m);
    vint c(m);
    rep(i, m) {
        int x, y; cin >> x >> y >> c[i];
        xy[i].first = x - 1;
        xy[i].second = y - 1;
    }
    int ans = *min_element(all(va)) + *min_element(all(vb));
    rep(i, m) {
        int x = xy[i].first, y = xy[i].second;
        chmin(ans, va[x] + vb[y] - c[i]);
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,x,y; cin>>n>>x>>y;
  vector<int> a(n,0);
  for(int i=1; i<=n; ++i) for(int j=i+1; j<=n; ++j){
    int d=min(j-i,abs(x-i)+abs(y-j)+1);
    ++a[d];
  }
  for(int i=1; i<n; ++i) cout<<a[i]<<endl;
  return 0;
}


Measured memory_bytes: 3572
/*
    NEVER GIVE UP!
    THE EXPERT IN ANYTHING WAS ONCE A BEGINNER
*/

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;


void solve()
{
    string sa,sb;
    cin >> sa >> sb;
    cout << sb << sa ;
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
 
ll gcd(ll x, ll y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}
 
ll lcm(ll x, ll y){
	return (x*y/gcd(x,y));
}
 
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n;
	cin >> n;
	double x;
	string u;
	double ans=0;
	REP(i,n){
		cin >> x >> u;
		if(u=="JPY") ans+=x;
		else ans+=x*380000.0;
	}	
	cout << ans << endl;
/////////////////////////////////////////////
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int N(18), maxn(1 << 17), Mod(1e9 + 7);
inline void Add(int &x, int y) { x = (x + y) % Mod; }
int bin[N], fac[maxn], inv[maxn], n, m, ans, f[N][maxn], cnt[maxn], A[N];
inline int C(int n, int m) { return n < m ? 0 : 1ll * fac[n] * inv[m] % Mod * inv[n - m] % Mod; }
int fastpow(int x, int y)
{
	int ans = 1;
	for (; y; y >>= 1, x = 1ll * x * x % Mod)
		if (y & 1) ans = 1ll * ans * x % Mod;
	return ans;
}

int main()
{
	n = read(), m = read(), cnt[0] = bin[0] = fac[0] = inv[0] = 1;
	for (int i = 1; i <= n; i++) bin[i] = bin[i - 1] << 1;
	for (int i = 1; i <= bin[n]; i++) fac[i] = 1ll * fac[i - 1] * i % Mod;
	inv[bin[n]] = fastpow(fac[bin[n]], Mod - 2);
	for (int i = bin[n] - 1; i; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % Mod;
	for (int i = 1; i <= bin[n]; i++) cnt[i] = (i & 1) ? Mod - cnt[i >> 1] : cnt[i >> 1];
	for (int i = 1; i <= m; i++) A[i] = read(); std::sort(A + 1, A + m + 1);
	f[m + 1][0] = 1;
	for (int i = m; i; i--) for (int S = 0; S < bin[n]; S++) if (f[i + 1][S])
	{
		Add(f[i][S], f[i + 1][S]); int t = (bin[n] - 1) ^ S;
		for (int j = 0; j < n; j++) if (!(S & bin[j]))
			Add(f[i][S | bin[j]], 1ll * C(t - A[i] + 1, bin[j] - 1) *
					f[i + 1][S] % Mod * fac[bin[j]] % Mod);
	}
	for (int i = 0; i < bin[n]; i++)
		Add(ans, 1ll * f[1][i] * fac[bin[n] - 1 - i] % Mod * cnt[i] % Mod);
	ans = 1ll * ans * bin[n] % Mod; printf("%d\n", ans);
	return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  cout << ((n+1)/2) - 1 << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;


int main()
{
    int n;cin >> n;
    vector<int> v(n);
    vector<int> res;

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

    while(v.size()>0){
        bool flg = true;

        for(int i=v.size()-1;i>=0;i--){
            if(i+1==v[i]){
                res.push_back(i+1);
                v.erase(v.begin()+i);
                flg=false;
                break;
            }
        }

        if(flg){
            p(-1)
            return 0;
        }
    }

    for(int i=res.size()-1;i>=0;i--){
        p(res[i]);
    }

} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <numeric>
#include <queue>
#include <set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  ll n, L;
  cin >> n >> L;
  ll wa = 0;

  for (ll i = 1; i <= n; i++)
  {
    wa += L + i - 1;
  }
  ll res = 1e10;
  ll j = -1;
  for (ll i = 1; i <= n; i++)
  {
    if (res > abs((L + i - 1)))
    {
      res = abs((L + i - 1));
      j = i;
    }
  }
  cout << wa - (L + j - 1) << endl;
  return 0;
}


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

    class Program
    {
        static void Main(string[] args)
        {
            //input
            int input = int.Parse(Console.ReadLine());

            if (1 <= input && input <= 9)
            {
                Console.WriteLine(input);
                return;
            }
            var cnt = 9;
            var a = new List<decimal>();
            for (int i = 1; i <= 9; i++)
            {
                a.Add(i);
            }
            while (cnt < input)
            {
                var na = new List<decimal>();
                foreach (var x in a)
                {
                    for (int i = -1; i <= 1; i++)
                    {
                        decimal d = x % 10 + i;
                        if (d < 0 || d > 9) continue;
                        decimal nx = x * 10 + d;
                        na.Add(nx);
                        cnt++;
                        if (cnt == input)
                        {
                            Console.WriteLine(nx.ToString());
                            return;
                        }
                    }
                }
                a = new List<decimal>(na);
            }
        }

    }

Measured memory_bytes: 15712
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            String str = sc.next();
            String[] str1 = str.split(",");
            for(int i = 0; i < str1.length; i++){
              System.out.print(str1[i] + " ");
            }
        System.out.println("");
          }
}

Measured memory_bytes: 23252
N,K=map(int,input().split())
A=list(map(int,input().split()))

if (A.index(1)+1)>=K and (N-A.index(1))>=K:
  ans=-(-A.index(1))//(K-1)-(-N+A.index(1)+1)//(K-1)
else:
  ans=1-(-N+K)//(K+1)
print(ans)

Measured memory_bytes: 14008
def gcd(x,y):
    r = x % y
    while r != 0:
        x,y = y,r
        r = x % y
    return(y)

summ = 0
K = int(input())
for a in range(1,K+1):
    for b in range(1,a+1):
        for c in range(1,b+1):
            if a == b:
                if b == c:
                    summ += gcd(gcd(a,b),c)
                else:
                    summ += 3 * gcd(gcd(a,b),c)
            elif a == c or b == c:
                summ += 3*gcd(gcd(a,b),c)
            else:
                summ += 6*gcd(gcd(a,b),c)
print(summ)





Measured memory_bytes: 9236
N, M = map(int, input().split())
S = []
for i in range(M):
    k = list(map(int, input().split()))
    S.append(k[1:])
P = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):
    a = 0
    for j in range(M):
        t = 0
        for s in S[j]:
            t += (i >> (s - 1)) & 1
        if t % 2 == P[j]: a += 1
    if a == M: ans += 1
print(ans)


Measured memory_bytes: 3064
// Author: Tyler Wang

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

using namespace std;

template <class Fun>
class y_combinator_result {
 public:
  template <class T>
  explicit y_combinator_result(T&& fun) : fun_(std::forward<T>(fun)) {}

  template <class... Args>
  decltype(auto) operator()(Args&&... args) {
    return fun_(std::ref(*this), std::forward<Args>(args)...);
  }

 private:
  Fun fun_;
};

template <class Fun>
decltype(auto) y_combinator(Fun&& fun) {
  return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.precision(12);
  std::cerr.precision(12);
  std::mt19937 rng((std::uint_fast32_t)std::chrono::high_resolution_clock::now()
                       .time_since_epoch()
                       .count());
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> dp(k + 1, -1);
  auto solve = y_combinator([&](auto self, int y) -> int {
    if (dp[y] != -1) {
      return dp[y];
    }
    dp[y] = 0;
    for (int x : a) {
      if (y - x >= 0) {
        dp[y] = max(dp[y], 1 - self(y - x));
      }
    }
    return dp[y];
  });
  cout << (solve(k) == 1 ? "First" : "Second") << '\n';
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    ll n; cin>>n;
    ll m=n%10;
    if(m==3) cout<<"bon"<<endl;
    else if(m==0 || m==1 || m==6 || m==8) cout<<"pon"<<endl;
    else cout<<"hon"<<endl;
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int64 x;
	cin >> x;
	int64 time = 1, p = 100;
	while (true) {
		int64  I = p * (1.0 / 100);
		p += I;
		if (p >= x) {
			cout << time;
			return 0;
		}
		time ++;
	}
	
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  
  int left = 0, right = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '(') left++;
    else if (s[i] == ')') {
      if (left > 0) left--;
      else right++;
    }
  }
  int ans_left = right;
  
  left = 0; right = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == ')') right++;
    else if (s[i] == '(') {
      if (right > 0) right--;
      else left++;
    }
  }
  int ans_right = left;
  
  for (int i = 0; i < ans_left; i++) cout << '(';
  cout << s;
  for (int i = 0; i < ans_right; i++) cout << ')';
  cout << endl;
}

Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
tans = 1000
nans = 0
for i in range(N):
    ans = abs(A - (T - (H[i] * 0.006)))
    if ans == 0:
        print(i+1)
        exit()
    elif ans < tans:
        tans = ans
        nanns = i
print(nanns+1)


Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N;cin>>N;
    int ans=0;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        if(((i%2)==0)&&((a%2)==1))ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3620
use strict;
use warnings;
use utf8;
use feature qw/say/;
use POSIX qw/ceil/;
my $n = <STDIN>;
chomp($n);

my %exists;
my $cnt = 0;
for (1..$n) {
    chomp(my $word = <STDIN>);
    unless (exists $exists{$word}) {
        $exists{$word} = 1;
        $cnt++;
    }
}
say $cnt;


Measured memory_bytes: 32464
def solve():
    N, K = [int(n) for n in input().split()]

    nums = [2*i+1 for i in range(K)]
    if nums[-1] <= N:
        return "YES"
    else:
        return "NO"


def main():
    ans = solve()
    print(ans)


if __name__ == '__main__':
    main()

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

int main()
{
	int a, b;
	
	cin >> a >> b;
	
	a = a+b;
	
	if(a%2) cout << "IMPOSSIBLE" << "\n";
	else cout << a/2 << "\n";
	
	return 0;
}


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

# import numpy as np
# import math

s = input()
n = len(s)-1

ss = []
for l in s:
    ss.append(l)
    ss.append('')
s_list = ss[:-1]
s_list_tmp = s_list.copy()

d = 0

for i in range(1<<n):
    s_list_tmp = s_list.copy()
    for k in range(n): # 桁数でループ
        if i>>k&1:
            # print(bin(i), k)
            s_list_tmp[2*k+1] = '_'
    s_str = ''.join(s_list_tmp)
    p_str = s_str.split('_')
    p_list = list(map(int, p_str))
    d += sum(p_list)

print(d)




# A, B = map(int, input().split())
# L = list(map(int, input().split()))




# print(ans)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

int ans[100010];

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    int left = 1, right = N / 2;
    int a[100010];
    rep(i, N) cin >> a[i];
    RREP(i, N - 1, N / 2) {
        ans[0] += a[i];
    }
    rep(i, (N + 1) / 2) {
        ans[i + 1] = ans[i] - a[N / 2 + i] + a[i * 2 + (N + 1) % 2];
    }
    //rep(i, (N + 1) / 2) cout << ans[i] << " ";
    //cout << endl;
    vector<int> v;
    left -= N % 2;
    rep(i, ((N + 1) / 2) - 1) {
        //cout << a[left] << " " << a[right] << "->" << ((a[right] + a[left]) / 2) << endl;
        v.push_back(((a[right] + a[left]) / 2));
        right++;
        left += 2;
    }
    rep(i, Q) {
        int X; cin >> X;
        auto it = lower_bound(v.begin(), v.end(), X);
        cout << ans[it - v.begin()] << endl;

    }

    return 0;
}


Measured memory_bytes: 3448
#include<iostream>
#include<cmath>

const int digit = 3;

int main() {
	int num,tmp,change=0;
	std::cin >> num;

	tmp = num;

	for (int i = 0;i<digit; i++) {
		change+=(tmp % 10)*std::pow(10,digit-i-1); //std::pow()遅そう
		tmp=tmp / 10;
	}
	
	std::cout << (num == change ? "Yes" : "No") << std::endl;

	return 0;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



void solve(int testCase){

    string s;
    cin >> s;

    int n = s.length();

    int ans = 0;
    for(int i = 0 ; i < n/2 ; i ++){
            ans += (s[i] != s[n-i-1]);
    }
    printf("%d\n" , ans);
}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-3;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int h, w;
char mp[1002][1002];
void init() {
	rep(i, h + 2) {
		mp[i][0] = mp[i][w + 1] = '#';
	}
	rep(j, w + 2) {
		mp[0][j] = mp[h + 1][j] = '#';
	}
}
ll dp[1002][1002];
int main() {
	cin >> h >> w;
	init();
	dp[1][1] = 1;
	rep1(i, h) {
		rep1(j, w) {
			cin >> mp[i][j];
		}
	}
	rep1(i, h) {
		rep1(j, w) {
			if (mp[i][j] == '#')continue;
			(dp[i + 1][j] += dp[i][j]) %= mod;
			(dp[i][j + 1] += dp[i][j]) %= mod;
		}
	}
	cout << dp[h][w] << endl;
	//stop
	return 0;
}

Measured memory_bytes: 9088
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    map<int, int> m;
    auto prime_factorize = [&](int a) -> void {
        for (int i = 2; i*i <= n; i++)
        {
            if (a%i != 0) continue;
            int b = 0;
            while (a%i == 0) {
                a/=i;
                b++;
            }
            m[i] += b;
        }
        if (a != 1) m[a]++;
    };
    for (int i = 1; i <= n; i++)
    {
        prime_factorize(i);
    }

    auto rec = [&](auto &&rec, auto p, int k) -> int {
        if (p == m.end()) {
            if (k == 1) return 1;
            return 0;
        }

        int res = 0;
        for (int i = 0; i <= p->second; i++)
        {
            if (k%(i+1) != 0) continue;
            res += rec(rec, ++p, k/(i+1));
            p--;
        }
        return res;        
    };
    cout << rec(rec, m.begin(), 75) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
 int a,b;
 char op;
 scanf("%d %c %d", &a, &op, &b);
 while( !(op=='?')){if ( op=='+' ){
  printf("%d\n",a+b);}
   else if ( op =='-' ){
   printf("%d\n",a-b);}
 else if ( op=='*' ){
printf("%d\n",a*b);}
 else if ( op=='/' ){
 printf("%d\n",a/b);} 
  else {}
  scanf("%d %c %d", &a, &op, &b);}
  return 0;}

Measured memory_bytes: 600
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int x = sc.nextInt();
		int n = sc.nextInt();
		int[] p = new int[n];
		for(int i = 0; i < n; i++){
		    p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		
		// 計算
		int result = 0;
		int abs = 1000;
		loop:
		for(int i = 0; i <= 1000; i++){
		    for(int j = 0; j < n; j++){
		        if(p[j] == i) continue loop;
		    }
		    if(abs > abs(x-i)){
		        result = i;
		        abs = abs(x-i);
		    }
		}
		
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


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

int main() {
  int n;
  cin >> n;
  int a[n];
  int rating[9] = {};
  int i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    rating[min(a[i] / 400, 8)]++;
  }

  int result[2] = {};
  for (i = 0; i < 8; i++) {
    if (rating[i]) {
      result[0]++;
    }
  }
  result[1] = result[0] + rating[8];
  result[0] = max(result[0], 1);
  
  cout << result[0] << ' ' << result[1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int N;
  std::cin >> N;
  std::vector<long long> A(N + 1);
  std::vector<long long> B(N + 1, 0);
  for (int i = 0; i < N + 1; ++i)
    std::cin >> A[i];
  for (int i = 0; i < N; ++i)
    std::cin >> B[i];

  // Main
  long long res = 0;
  long long rem = 0;
  for (int i = 0; i < N + 1; ++i) {
    // rem で賄える場合
    if (rem >= A[i]) {
      res += A[i];
      rem = B[i];
    } else {
      // rem で賄えない場合
      A[i] -= rem;
      res += rem;
      // B[i] で賄える場合
      if (B[i] >= A[i]) {
        res += A[i];
        rem = B[i] - A[i];
      } else {
        // B[i] で賄えない場合
        res += B[i];
        rem = 0;
      }
    }
  }

  // Output
  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 1920
#include<stdio.h>

typedef struct{
  int parent;
  int left;
  int right;
} DATA;

#define MAX 1000000
#define NIL -1

DATA array[MAX];

int main(){
  int i;
  int id;
  int j;
  int n;
  int k;
  int count[100000];
  int hukasa = 0;
  int num;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    array[i].parent = NIL;
    array[i].left = NIL;
    array[i].right = NIL;
  }
  for(i = 0;i < n;i++){
    scanf("%d%d",&id,&k);
    for(j = 0;j < k;j++){
      scanf("%d",&count[j]);
      if(j == 0){
        array[count[0]].parent = id;
        array[id].left = count[0];
      }
      else{
        array[count[j]].parent = id;
        array[count[j - 1]].right = count[j];
      }
    }
  }

  for(i = 0;i < n;i++){
    printf("node %d: parent = %d, ",i,array[i].parent);
    num = i;
    while(array[num].parent != NIL){
      hukasa++;
      num = array[num].parent;
    }
    printf("depth = %d,",hukasa);
    hukasa = 0;
    if(array[i].parent == NIL && array[i].left == NIL){
      printf(" root, []\n");
    }
    else if(array[i].parent == NIL && array[i].left != NIL){
      printf(" root, [%d",array[i].left);
      for(j = array[array[i].left].right;j != NIL;j = array[j].right){
        printf(", %d",j);
      }
      printf("]\n");
    }
    else if(array[i].left != NIL){
      printf(" internal node, [%d",array[i].left);
      for(j = array[array[i].left].right;j != NIL;j = array[j].right){
        printf(", %d",j);
      }
      printf("]\n");
    }
    else{
      printf(" leaf, []\n");
    }
  }
  return 0;
}



Measured memory_bytes: 3292
import itertools
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
A = B = 0
for i,v in enumerate(list(itertools.permutations(range(1,N+1))), 1):
    if list(v) == P:
        A = i
    elif list(v) == Q:
        B = i
        continue
print(abs(A-B) if A != 0 and B != 0 else 0)

Measured memory_bytes: 46064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }


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


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,x;cin >> n >> x;
	vector<int> a(n + 1);
	rep(i,n) cin >> a.at(i);
	a.at(n) = x;
	sort(all(a));
	vector<int> b(n);
	rep(i,n) b.at(i) = a.at(i + 1) - a.at(i);
	int g = b.at(0);
	rep(i,n) g = gcd(g, b.at(i));
	cout << g << endl;
}


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

using namespace std;

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

  int N,K; cin>>N>>K;
  int R,S,P; cin>>R>>S>>P;
  string T; cin>>T;

  int ans = 0;
  auto win = [&](char c) {
    switch (c) {
      case 'r':
        ans += P;
        break;
      case 's':
        ans += R;
        break;
      case 'p':
        ans += S;
        break;
      default:
        break;
    }
  };
  int i = 0;
  vector<bool> won(N);
  for (; i < K; i++) {
    win(T[i]);
    won[i] = true;
  }
  for (; i < T.size(); i++) {
    if (!won[i-K] or T[i-K] != T[i]) {
      win(T[i]);
      won[i] = true;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	cout << n * n*n << endl;
	return 0;
}

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

#define sz(x) (int((x).size()))

typedef vector<int> VI;
const int MX = 1005;
int an, bn;
VI adj[MX];
int ab[MX], ba[MX];
int vis[MX], T;

bool DFS(int u) {
	int i, v;	
	for (i = sz(adj[u]) - 1; i >= 0; i--) {
		v = adj[u][i];
		if (vis[v] == T) continue;
		vis[v] = T;
		if (ba[v] == -1 || DFS(ba[v])) {
			ab[u] = v, ba[v] = u;
			return 1;
		}
	}
	return 0;
}

int max_matching() {
	int u, m;
	
	fill_n(ab, an, -1);
	fill_n(ba, bn, -1);
	m = 0;
	for (u = 0; u < an; u++) {
		T++;
		m += DFS(u);
	}
	return m;
}

int a[MX], b[MX], c[MX], d[MX];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
	for (int i = 0; i < n; i++) cin >> c[i] >> d[i];
	an = bn = n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) if (a[i] < c[j] && b[i] < d[j]) adj[i].push_back(j);
	}
	cout << max_matching() << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
using namespace std;

void printarray(int a[], int n){
	for (int i=0; i<n; i++){
		if (i==n-1){
			cout << a[i] << endl;
		}
		else{
			cout << a[i] << ' ';
		}
	}

}

void insertionsort(int a[], int n){
	for (int i=0; i<n; i++){
		int v = a[i];
		int j = i-1;
		while (j >= 0 && a[j] > v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
		printarray(a,n);
	}
}

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

bool prime(int n){
	if (n==2){
		return true;
	}
	else{
		int lim;
		lim = int(pow(n,0.5))+1;
		for (int i=2; i<lim; i++){
			if (n % i == 0){
				return false;
			}
		}
		return true;
	}
}

void bubblesort(int a[], int n, int& cnt){
	bool flag = true;
	while (flag){
		flag = false;
		for (int j=n-1; j>=0; j--){
			if (a[j]<a[j-1]){
				int tmp = a[j];
				a[j] = a[j-1];
				a[j-1] = tmp;
				cnt++;
				flag = true;

			}
		}
	}

}

void selectionsort(int a[], int n, int& cnt){
	for (int i=0; i<n; i++){
		int minj = i;
		for (int j=i; j<n; j++){
			if (a[j]<a[minj]){
				minj = j;
			}
		}
		if (minj != i){
			int tmp = a[i];
			a[i] = a[minj];
			a[minj] = tmp;
			cnt++;
		}
	}
}


int main(){
	int n;
	cin >> n;
	int cnt = 0;
	int a[n];
	for (int i=0; i<n; i++){
		int tmp;
		cin >> tmp;
		a[i] = tmp;
	}

	selectionsort(a,n,cnt);
	printarray(a,n);
	cout << cnt << endl;


	return 0;
}



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

int Gcd(int a, int b) {
  if (b == 0)
    return a;
  return Gcd(b, a % b);
}

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

  vector<int> L(N), R(N);
  L[1] = A[0], R[N - 2] = A[N - 1];
  for (int i = 2; i < N; i++)
    L[i] = Gcd(L[i - 1], A[i - 1]);
  for (int i = N - 3; i >= 0; i--)
    R[i] = Gcd(R[i + 1], A[i + 1]);
  L[0] = R[0], R[N - 1] = L[N - 1];

  int ans = 0;
  for (int i = 0; i < N; i++)
    ans = max(Gcd(L[i], R[i]), ans);

  cout << ans << endl;
}


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

int main(void){
    string S;
    cin>>S;
    
    int N=S.size();
    int zero=0,one=0;
    
    for(int i=0;i<N;i++){
        if(S[i]=='0')zero++;
        else one++;
    }
    
    cout<<N-abs(one-zero)<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

int n;

int main() {
  cin >> n;
  int p[n], min_[n];
  rep(i, n) cin >> p[i];

  min_[0] = p[0];
  int counter = 1;
  rep1(i, n) {
    min_[i] = min(min_[i-1], p[i]);
    if (min_[i] == p[i]) counter++;
  }
  
  cout << counter;
}


Measured memory_bytes: 1792
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

l,r=get_i
mod=2019
if r-l>=2019
  puts 0
else
  ans=10**9
  for i in l..r-1
    for j in i+1..r
      val=((i%mod)*(j%mod))%mod
      ans=val if ans>val
      break if ans.zero?
    end
  end
  puts ans
end

Measured memory_bytes: 1788
#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    
    int m;
    scanf("%d", &m);
    
    int l = 1;
    int r = n;
    
    for (int i = 1; i <= m; i++) {
        int tl;
        scanf("%d", &tl);
        
        int tr;
        scanf("%d", &tr);
        
        if (l < tl) l = tl;
        if (tr < r) r = tr;
    }
    
    if (r < l) {
        printf("0\n");
    } else {
        printf("%d", r - l + 1);
    }
    
    return 0;
}

Measured memory_bytes: 128
/*ex7_3 hightierra*/
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int row,col,i,j;
    int *rowjudge;
    int *coljudge;
    char **matrix;
    scanf("%d %d",&row,&col);

    // 各行の配列へのメモリ領域の確保
    matrix = (char**)calloc(row, sizeof(char*));
    if(matrix == NULL){
        exit(1);
    }
    // 各行のメモリ領域の確保
    for(i = 0; i < row; i++){
        matrix[i] = (char*)calloc(col, sizeof(char));
        if(matrix[i] == NULL){
            exit(1);
        }
    }

    // 各メモリの確保
    rowjudge = (int*)calloc(row, sizeof(int));
    if(rowjudge == NULL){
        exit(1);
    }

    coljudge = (int*)calloc(col, sizeof(int));
    if(coljudge == NULL){
        exit(1);
    }

    // 入力
    for(i=0; i<row; i++){
        for(j=0; j<col; j++){
            scanf(" %c",&matrix[i][j]);
        }
    }

    // 各行、各列に黒が１つでもあるかを判別
    for(i=0; i<row; i++){
        for(j=0; j<col; j++){
            if(matrix[i][j]=='#'){
                rowjudge[i]=1;
            }
        }
    }
    for(j=0; j<col; j++){
        for(i=0; i<row; i++){
            if(matrix[i][j]=='#'){
                coljudge[j]=1;
            }
        }
    }

    // 黒が１つでもある行と列の重なる要素のみを出力
    for(i=0; i<row; i++){
        for(j=0; j<col; j++){
            if(rowjudge[i]==1 && coljudge[j]==1){
                printf("%c",matrix[i][j]);
            }
        }
        if(rowjudge[i]==1){
            printf("\n");
        }
    }
 
    // 各メモリの開放
    for(i=0; i<row; i++){
        free(matrix[i]);
    }
    free(matrix);

    free(rowjudge);
    free(coljudge);

    return 0;
}

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

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    long long a,b,c,d;
    queue<long long> x[11];
    cin>>a>>b;
    for(int i=0;i<b;i++){
        int z=1;
        for(int j=1;j<=a;j++){
            if(x[j].size()<x[z].size()){
                z=j;
        }
        }
        cin>>c>>d;
        if(c==1){
            x[z].push(d);
        }
        else{
            cout<<x[d].front()<<"\n";
            x[d].pop();
        }
    }
    return(0);
}    


Measured memory_bytes: 3248
import numpy as np
from operator import mul
from functools import reduce

N, M, C = [int(x) for x in input().split()]
B = np.array([int(x) for x in input().split()])
#A = np.array([[0]*M,N])
A = np.empty((N,M))

result = np.array([])
count = 0

for n in range(N):
    A[n] = [int(m) for m in input().split()]
    #result = A[n] * B
    if sum(A[n] * B)+C > 0:
        count +=1
print(count)


Measured memory_bytes: 21076