akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   ll n, ans = 0;
   string x;
   unordered_map <string, int> s;
   cin >> n;
   for (int i = 0; i < n; i++)
   {
      cin >> x;
      sort(x.begin(), x.end());
      ans += s[x];
      s[x]++;
   }
   cout << ans << endl;
   return 0;
}


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

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

    int n, k;
    cin >> n >> k;

    int count = 0;
    while (n) {
        n /= k;
        count++;
    }

    cout << count << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    double a,b;
    while(cin >> a >> b){
        int  x = a, y = b;
        printf("%d %d %.5f", x / y, x % y, a / b);
    }
}

Measured memory_bytes: 1236
import java.util.*;
class Main {
  public static void main (String[] args) throws Exception {
    
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    long x = sc.nextLong();
  
     
     
     long xi=0;
     //long x0=Math.abs(sc.nextLong()-x);
     
     long xf=0;
    
    for(int i=0; i<n; i++){
      xi = Math.abs(sc.nextLong()-x);
      
      xf =eu(Math.min(xi,xf),Math.max(xi, xf));
      
      }
      
    //long ans = eu(min1, min2);
    
    System.out.println(xf);

    
    }
    
    public static long eu(long  min1, long min2){
      //if(min1==1)return 1;
      //if(min2%min1==min1)return 1;
      if(min1==0){
        return min2;
        }
        return eu(Math.min(min2%min1,min1),Math.max(min2%min1,min1));
      }
}

Measured memory_bytes: 50440
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 100;
const int MAXV = 1000 * 100;
int poidsMin[MAXN + 1][MAXV + 1];
int32_t main()
{
	int nbPersonnes , poidsTotal;
	cin >> nbPersonnes >> poidsTotal;
	for (int i = 1 ; i <= MAXV ; i++)
	{
		poidsMin[0][i] = 2e9;
	}
	int solution = 0;
	for (int i = 0 ; i < nbPersonnes ; i++)
	{
		int poids , valeur;
		cin >> poids >> valeur;
		for (int j = 0 ; j <= MAXV ; j++)
		{
			poidsMin[i + 1][j] = poidsMin[i][j];
			if (j >= valeur)
			{
				poidsMin[i + 1][j] = min(poidsMin[i + 1][j] , poidsMin[i][j - valeur] + poids);
			}
			if (poidsMin[i + 1][j] <= poidsTotal)
			{
				solution = max(solution , j);
			}
		}
	}
	cout << solution << endl;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define in(x) scanf("%d" ,&x)
#define IN(x) scanf("%I64d" , &x)
#define ll long long
#define all(a) memset(a , 0 , sizeof a)
#define ull unsigned long long
#define pii pair<int , int>
const int mod = 1e9+7;
const int MAXN = 2e5 + 10;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd ( ll a, ll b ){ll c;  while ( a != 0 ) { c = a; a = b%a;  b = c;}return b;};
ll lcm ( ll a , ll b) {return a / gcd(a , b) * b;}
int main() {
    int n , x = 0;
    int a[111111];
    cin >> n;
    for(int i = 0; i < n; ++ i) {
        cin >> a[i];
        x += a[i] % 2;
    }
    if(x % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 640
from bisect import bisect_left
import sys
input = sys.stdin.readline

n, t = map(int, input().split())
ab = []
a0 = []
for i in range(n):
    a, b = map(int, input().split())
    if a == 0:
        a0.append(b)
    else:
        ab.append([(a / (b + 1)), a, b])
a0.sort()
ab.sort(reverse=True)

INF = 10 ** 12
N = 40
m = len(ab)
dp = [[INF for _ in range(N)] for _ in range(m+1)]
dp[0][0] = 0
for i in range(1, m+1):
    a, b = ab[i-1][1], ab[i-1][2]
    dp[i][0] = 0
    for j in range(1, N):
        tmp = 1 + dp[i-1][j-1]
        dp[i][j] = min(dp[i-1][j], tmp + (a * tmp + b))
ans = 0
for i in range(N):
    time = dp[-1][i]
    ans_tmp = i
    if time <= t:
        for v in a0:
            time += (1 + v)
            if time <= t:
                ans_tmp += 1
            else:
                break
        ans = max(ans, ans_tmp)

print(ans)


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    deque<pair<long, long>> eng(N);
    for(auto& i : eng)cin >> i.first >> i.second;
    auto d = static_cast<unsigned long>(partition(eng.begin(), eng.end(), [](auto i){return i.first == 0 ? i.second > 0 : i.first > 0;}) - eng.begin());
    for(unsigned long i = 0; i < d; ++i)eng.emplace_back(-eng[i].first, -eng[i].second);
    auto cmp = [](auto i, auto j){return i.first * j.second > i.second * j.first;};
    sort(eng.begin(), eng.begin() + d, cmp);
    sort(eng.begin() + d, eng.end(), cmp);

    long a{0}, b{0};
    unsigned long ans{0};
    for(unsigned long i = 0; i < N + d; ++i){
        a += eng[i].first;
        b += eng[i].second;
        ans = max<unsigned long>(ans, a * a + b * b);
    }
    for(unsigned long i = d; i < N + d; ++i){
        a -= eng[i].first;
        b -= eng[i].second;
        ans = max<unsigned long>(ans, a * a + b * b);
    }
    printf("%.12Lf\n", sqrt(static_cast<long double>(ans)));
    return 0;
}

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

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    String S = sc.next();
    
    int count = 1;
    for (int i = 0; i < N-1; i++) {
      if (S.charAt(i) != S.charAt(i+1)) {
        count++;
      }
    }
    
    System.out.println(count);
  }
}

Measured memory_bytes: 24904
#include <iostream>
using namespace std;
typedef long long int li;

li solve2(li N){
      li k=0, m=0;
      for(li i=1; i * i <= N ; i++){
            if(N%i ==0){
                 m=(N/i)-1;
                  if(m <= i)break;
                 k += m;
            }
      }
      return k;
} 



int main(){
      li i,N,m=0,k=0;
      cin >> N;
      
 //     for(int N = 1; N<= 10000; N++){
   //         if(solve1(N) != solve2(N)){
     //             cout << N << endl;
                  cout << solve2(N) << endl;
} 


Measured memory_bytes: 256
io = STDIN
n=io.gets.to_i
a=io.gets.split.map(&:to_i)
ans=0
n.times do |i|
  if a[i]==i+1
    if i==n-1
      a[i-1],a[i]=a[i],a[i-1]
    else
      a[i],a[i+1]=a[i+1],a[i]
    end
    ans+=1
  end
end
puts ans


Measured memory_bytes: 8068
import sys
import math
a, b, c, x = map(int, sys.stdin.read().split("\n")[:4])
r = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i + 100*j + 50*k == x:
        r += 1
print(r)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

const double PI=acos(-1.0);

vi v[100005];

int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    queue<P> q;
    q.push({0, 0});

    vi seen(n, 100100100), sign(n, -1);
    seen[0] = 0;
    while(!q.empty()) {
        int step = q.front().first;
        int prev = q.front().second;
        q.pop();
        //cout << step << " " << prev << endl;
        for(int p : v[prev]) {
            if(step + 1 < seen[p]) {
                seen[p] = step + 1;
                sign[p] = prev + 1;
                q.push({step + 1, p});
            }
        }
    }

    rep(i, n) {
        if(seen[i] == 100100100) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for(int i = 1; i < n; i++) {
        cout << sign[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 10816
#pragma GCC optimize("Ofast")
  #pragma GCC target("avx,avx2,fma")
  #pragma GCC optimization ("unroll-loops")
  #include <bits/stdc++.h>
  using namespace std;
  //---------------------------------//
  void __print(int x) {cerr << x;}
  void __print(long x) {cerr << x;}
  void __print(long long x) {cerr << x;}
  void __print(unsigned x) {cerr << x;}
  void __print(unsigned long x) {cerr << x;}
  void __print(unsigned long long x) {cerr << x;}
  void __print(float x) {cerr << x;}
  void __print(double x) {cerr << x;}
  void __print(long double x) {cerr << x;}
  void __print(char x) {cerr << '\'' << x << '\'';}
  void __print(const char *x) {cerr << '\"' << x << '\"';}
  void __print(const string &x) {cerr << '\"' << x << '\"';}
  void __print(bool x) {cerr << (x ? "true" : "false");}

  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
  void _print() {cerr << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
  #else
  #define deb(x...)
  #endif
 //------------------------------//

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  all(x)       (x).begin(), (x).end()
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;


  void solve(){
	int n;
	cin >> n;
	vi v(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	int mx = v[0];
	ll ans=0;
	for(int i=0;i<n;i++){
		ans += max(0,mx-v[i]);
		mx = max(mx,v[i]);
	}
	cout << ans;
  }

  int main(){
    IOS
    	solve();
    //cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying

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

#define pb push_back
#define sp " "
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (unsigned long long a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define bit(i,j) (i&(1<<j))
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e5+5,mod=998244353;
vi dp;
bool t;
stack<char> s;
void DFS(int u,int v)
{
	if (v==0) {
		vi aux;
		ll res,xd;
		res=0; xd=1;
		while (!s.empty()) {
			ll gg;
			gg=s.top();
			s.pop();
			res+=(gg-'0')*xd;
			xd*=10;
			aux.pb(gg);
		}
		rev(aux);
		tra(u,aux) s.push(u);
		dp.pb(res);
		if (dp.size()>150000) { t=true; return; }
		return;
	}
	if (u>0) {
		s.push(u-1+'0');
		DFS(u-1,v-1);
		s.pop();
	}
	s.push(u+'0');
	DFS(u,v-1);
	s.pop();
	if (u<9) {
		s.push(u+1+'0');
		DFS(u+1,v-1);
		s.pop();
	}
}
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int k;
	cin>>k;
	fo(i,1,9) dp.pb(i);
	fo(i,1,9) {
		while (!s.empty()) s.pop();
		fo(j,1,9) {s.push(j+'0');
	if (!t)	DFS(j,i); while (!s.empty()) s.pop(); }
	}
	
	cout<<dp[k-1];
	return 0;
}


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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

double a, b, x;

int main(void){
	cin>>a>>b>>x;

	double rad = 0.0;
	if (x > a * a * b / 2) {
		rad = atan(2 * (a * a * b - x) / (a * a * a));
	} else {
		rad = atan((a * b * b) / (2 * x));
	}

	double ans = rad * 180 / M_PI;

	printf("%.10f\n", ans);
	
	return 0;
}

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

using namespace std;

typedef long long int lli;

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

    int k, x;

    cin >> k >> x;

    for (int i=1; i<2*k; i++) {
        cout << x-k+i << ((i<2*k-1) ? ' ' : '\n');
    }

    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

ans = 0
for i in range(1, N+1, 2):
	tmp = 0
	for j in range(1, i+1):
		if i % j == 0:
			tmp += 1
	if tmp == 8:
		ans += 1
print(ans)


Measured memory_bytes: 5196
require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi

sum=0
1.upto n do |i|
  d=n/i
  sum+=((d+1)*d/2)*i
end

puts sum

Measured memory_bytes: 14464
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  ll a_pos = INF, z_pos = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'A')
      a_pos = min(a_pos, (ll)i);
    else if (s[i] == 'Z')
      z_pos = max(z_pos, (ll)i);
  }
  ll ans = z_pos - a_pos + 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3760
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pll;

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}


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

Measured memory_bytes: 256
/*
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;

int main()
{
    string s;
    cin>>s;
    reverse(all(s));
    while(s.size()){
        if     (s.substr(0,5)=="maerd"  ) s=s.substr(5);
        else if(s.substr(0,5)=="esare"  ) s=s.substr(5);
        else if(s.substr(0,7)=="remaerd") s=s.substr(7);
        else if(s.substr(0,6)=="resare" ) s=s.substr(6);
        else cout<<"NO\n",exit(0);
    }
    cout<<"YES\n";

    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#define ll long long

using namespace std;
const ll MAXN = 1e5+10;
const ll MOD = 1e9+7;
ll t[MAXN],pos[MAXN];

ll PowMod(ll a,ll b) {//快速幂：a的b次方 
	a%=MOD;
    ll res=1;
    while(b) {
        if(b&1)
			res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}


ll inv(ll m){
	return PowMod(m,MOD-2)%MOD;
}


ll c(int x,int h){
	if(h>x){
		return 0;
	}
	return ( pos[x] * inv(pos[h] ) % MOD * inv(pos[x-h]) % MOD ) %MOD;
} 

int main(){
	int n;
	scanf("%d",&n);
	//初始化 
	pos[0]=1;
	for(int i=1;i<=n+5;i++){
		pos[i]=pos[i-1]*i%MOD;
	}
	int x,d;
	for(int i=1;i<=n+1;i++){
		scanf("%d",&x);
		if(t[x]){//如果再次出现 
			d=(n+1)-(i-t[x]+1);//剩下的元素 
		}
		t[x]=i;//x出现在第i位 
	}
//	printf("d=%d\n",d);
	
	printf("%d\n",n);//i=1 
	for(int i=2;i<=n+1;i++){
		printf("%lld\n",(c(n+1,i)-c(d,i-1)+MOD)%MOD);//不重复的情况 
	}
    return 0;
} 


Measured memory_bytes: 2816
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=2e5+5;
int a[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=2;i<=n;i++){
		int temp;
		scanf("%d",&temp);
		a[temp]++;
	}
	for(int i=1;i<=n;i++){
		printf("%d\n",a[i]);
	}
}


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

int main() {
	int h,m,s;

	cin >> s;

	h = (s / 60) / 60;
	m = (s / 60) % 60;
	s = s % 60;

	cout << h <<":"<< m <<":"<< s << endl; // prints !!!Hello World!!!
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
long gcd(long a,long b){
  if(a%b == 0)return b;
  else{

    return gcd(b,a%b);
  }
}

int main(){
  long n;
  long m;
  cin >> n >> m;
  vector<long>a(n);
  int i;
  for(i=0;i<n;i++){
    cin >> a[i];
  }

  long tmp = a[0];
  for(i=1;i<n;i++){
    if(tmp >= a[i]){
      tmp = tmp/gcd(tmp,a[i])*a[i];
    }else{
      tmp = tmp/gcd(a[i],tmp)*a[i];
    }
  }
  int count2 = 0;
  while(a[0]%2==0){
    a[0]/=2;
    count2++;
  }
  int tmp2 = 0;
  int chk = 1;
  for(i=1;i<n;i++){
    tmp2 = 0;
    while(a[i]%2==0){
      a[i]/=2;
      tmp2++;
    }
    if(tmp2!=count2)chk=0;

  }
  if(chk==1)cout << 2*m/tmp - m/tmp<<endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

using namespace std;

typedef long long ll;

int a[123];
int ans = 0;

void get(int l, int r, int last) {
	if (l > r) return;
	int mn = l;
	for (int i = l; i <= r; i++) {
		if (a[i] < a[mn]) mn = i;
	}
	
	ans += (a[mn] - last);
	get(l, mn - 1, a[mn]);
	get(mn + 1, r, a[mn]);
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	get(0, n - 1, 0);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  swap(a,b);
  swap(a,c);
  cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	int n;
	int min = 1000000007, max = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a < min) {
			min = a;
		}
		if (a > max) {
			max = a;
		}
	}
	cout << max - min << endl;
	return 0;
}

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

int main() {
  int K;
  cin >> K;
  
  if(K == 1 || K == 2 ||K == 3 ||K == 5 ||K == 7 ||K == 11 ||K == 13 ||K == 15 ||K == 17 ||K == 19 ||K == 23 ||K == 29 ||K == 31){
    cout << "1" << endl;
  }
  
  if(K == 4 ||K == 6 ||K == 9 ||K == 10 ||K == 14 ||K == 21 ||K == 22 ||K == 25 ||K == 26){
    cout << "2" << endl;
  }
  if(K == 28 ||K == 30){
    cout << "4" << endl;
  }
  if(K == 8 ||K == 12 ||K == 18 ||K == 20 ||K == 27){
    cout << "5" << endl;
  }
  if(K == 16){
    cout << "14" << endl;
  }
  if(K == 24){
    cout << "15" << endl;
  }
  if(K == 32){
    cout << "51" << endl;
  }
  
  
}

  
    

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


int main() {
	ll n;
	double ans = 0;
	cin >> n;
	REP(i, n) {
		double a;
		cin >> a;
		a = (double)1 / a;
		ans += a;
	}
	cout << setprecision(10) << fixed << (double)1 / ans << endl;
}
	

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

const int MOD = 998244353;
const int MAXN = 3005;

int A, B, C, D;
long long dp[MAXN][MAXN][3];

int main(){
	scanf("%d %d %d %d", &A, &B, &C, &D);
	
	for(int i = A; i <= C; i++)
	for(int j = B; j <= D; j++){
		if(i == A && j == B){
			dp[i][j][0] = 1;
			dp[i][j][1] = 0;
			dp[i][j][2] = 0;
		}else if(i == A){
			dp[i][j][0] = dp[i][j - 1][0] * i % MOD;
			dp[i][j][1] = 0;
			dp[i][j][2] = 0;
		}else if(j == B){
			dp[i][j][0] = dp[i - 1][j][0] * j % MOD;
			dp[i][j][1] = 0;
			dp[i][j][2] = 0;
		}else{
			dp[i][j][0] = dp[i - 1][j - 1][0] * (i - 1) * (j - 1) % MOD;
			dp[i][j][0] = (dp[i][j][0] + dp[i][j - 1][1] * (i - 1) + dp[i][j - 1][0]) % MOD;
			dp[i][j][0] = (dp[i][j][0] + dp[i - 1][j][2] * (j - 1) + dp[i - 1][j][0]) % MOD;
			
			dp[i][j][1] = (dp[i][j - 1][0] + dp[i][j - 1][1] * (i - 1)) % MOD;
			dp[i][j][2] = (dp[i - 1][j][0] + dp[i - 1][j][2] * (j - 1)) % MOD;
		}
	}
	
	printf("%lld\n", dp[C][D][0]);
	
	return 0;
}


Measured memory_bytes: 214876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  int N,M;
  cin >> N >> M;
  int a[M],b[M];
  rep(i,M){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
  }
  int ans=0;
  rep(i,M){
    UnionFind uf(N);
    rep(j,M){
      if(j!=i){
	uf.unite(a[j],b[j]);
      }
    }
    rep(j,N)rep(k,N){
      if(uf.find(j)!=uf.find(k)){
	//cout << uf.find(j) << " " <<uf.find(k) << endl;
	ans++;
	k=N;j=N;
      }
    }
    //    cout << ans << endl;
  }
  cout << ans << endl;
 
  return 0;

}


Measured memory_bytes: 256
if __name__ == "__main__":
    frui = [True] * (10 ** 5 + 4)

    for i in range(2, 10 ** 5 + 4):
        tmp = i
        if frui[tmp]:
            for j in range(2*tmp, 10 ** 5 + 4, tmp):
                frui[j] = False
    
    x = int(input())


    ans = 0
    for i in range(x, 10 ** 5 + 4):
        if frui[i]:
            ans = i
            break
    print(ans)

Measured memory_bytes: 3828
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from scipy.sparse.csgraph import floyd_warshall
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush, heapify
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n = inp()
    ans = []
    flag = 0
    n -= 1
    while True:
        x = n%26
        n //= 26
        ans.append(chr(x+97))
        if n == 0:
            break
        n -= 1
    ans.reverse()
    print(''.join(ans))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 77284
from operator import itemgetter
N , M = map(int, input().split(' '))

city = []
for i in range(M):
    a, b = map(int, input().split(' '))
    city.append([a, b, i])

city_y = sorted(city, key = itemgetter(1))
city_num = [0 for _ in range(N+1)]
city_ID = {}

for i in range(M):
    city_num[city_y[i][0]] += 1
    city_ID[city_y[i][2]] = ("{:0=6}{:0=6}".format(city_y[i][0], city_num[city_y[i][0]]))

for i, j in sorted(city_ID.items()):
    print(j)

Measured memory_bytes: 45400
N = int(input())
h = list(map(int, input().split()))

mx = max(h)

h_list = [[0 for _ in range(mx)] for _ in range(N)]

for i in range(N):
    for j in range(h[i]):
        h_list[i][j] = 1

# print(h_list)
res = 0

for h in range(mx):
    i = 0
    while i < N:
        if h_list[i][h] == 0:
            i += 1
        else:
            res += 1
            while(i < N and h_list[i][h] == 1):
                i += 1
print(res)


Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<P> p(n);
  for(int i=0;i<n;++i) {
    cin >> p[i].first;
    p[i].second = i;
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  multiset<int> ms;
  ms.insert(-1);
  ms.insert(-1);
  ms.insert(n);
  ms.insert(n);
  ll su = 0;
  for(int i=0;i<n;++i) {
    ll val = p[i].first;
    int pos = p[i].second;
    auto it = ms.lower_bound(pos);
    int l1, l2, r1, r2;
    r1 = *it++;
    r2 = *it--;
    it--;
    l1 = *it--;
    l2 = *it;
    su += val * (l1 - l2) * (r1 - pos);
    su += val * (r2 - r1) * (pos - l1);
    ms.insert(pos);
  }
  cout << su << endl;
}


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

constexpr int si = 101 * 1002, si_log = 8 + 10 + 1, mod = static_cast<int>(1e9) + 7;
constexpr int shi = 101 * 1000;
int n, m;

int main() {
   ios_base::sync_with_stdio(0); cin.tie(0);
   string s;
   cin >> s;
   auto z = s;
   reverse(s.begin(), s.end());
   puts(z == s ? "Yes": "No");
   //while (2 == scanf("%d%d", &n, &m)) {
   //   
   //   //#ifndef _DEBUG
   //   break;
   //   //#endif
   //}
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
 
using namespace std;
 
int s[10]={0};
 
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        for(int i=0;i<10;i++)
            scanf("%d",&s[i]);
        int a=0,b=0;
        bool flag=0;
        for(int i=0;i<10;i++)
        {
            if(s[i]<a&&s[i]<b)
            {
                flag=1;
                break;
            }
            else if(s[i]<a&&s[i]>b)b=s[i];
            else if(s[i]>a&&s[i]<b)a=s[i];
            else
            {
                a=a>b?s[i]:a;
                b=a<b?s[i]:b;
                if(a==b)a=s[i];
            }
        }
        if(flag)printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}



Measured memory_bytes: 3064
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	k := scanInt()
	as := scanInts(n)

	sum := 0
	for i := 0; i < n; i++ {
		sum += as[i]
	}

	div := []int{}
	for i := 1; i*i <= sum; i++ {
		if sum%i == 0 {
			div = append(div, i, sum/i)
		}
	}

	ans := 0

	for _, e := range div {
		sumsum := 0
		m := make([]int, n)
		for i := 0; i < n; i++ {
			m[i] = as[i] % e
			sumsum += m[i]
		}
		sort.Ints(m)
		num := sumsum/e
		c := 0
		for i := 0; i < n-num; i++ {
			c += m[i]
		}

		if c <= k {
			ans = max(ans,e)
		}
		// debug(e,num,c,m)
	}

	fmt.Fprintln(wr, ans)
	// debug(div)
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll k;cin>>k;
    ll a,b;cin>>a>>b;
    bool f=0;
    REP(i,a,b+1){
        if(i%k==0)f=1;
    }
    cout<<(f?"OK":"NG")<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>

using namespace std;

int main() {
	string S, T;
	cin >> S >> T;
	T = T.erase(T.size()-1);
	if (S == T) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
static const int N=100;
static const int INFTY =(1<<21);

int n,M[N][N];
int d[N];//?????¢??§?¨??????¶???(color)???????????????

void bfs(int s){
	queue<int> q;
	q.push(s);
	for (int i = 0; i < n; ++i) {d[i]=INFTY;	}
	d[s]=0;
	int u;
	while(!q.empty()){
		u=q.front();q.pop();
		for (int v = 0; v < n; ++v) {
			if(M[u][v]==0)continue;
			if(d[v]!=INFTY)continue;
			d[v]=d[u]+1;
			q.push(v);
		}
	}
	for (int i = 0; i < n; ++i) {
		cout<<i+1<<" "<<((d[i]==INFTY)?(-1):d[i])<<endl;
	}
}

int main(){
	int u,k,v;
	cin>>n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			M[i][j]=0;
		}
	}
	for (int i = 0; i < n; ++i) {
		cin>>u>>k;
		u--;
		for (int j = 0; j < k; ++j) {
			cin>>v;
			v--;
			M[u][v]=1;
		}
	}
	bfs(0);
	return 0;
}

Measured memory_bytes: 3128
#!/usr/bin/env python3
import sys


def solve(K: int, N: int, A: "List[int]"):
    ans = A[N-1] - A[0]
    for i in range(1, N):
        if ans > (A[i-1] + K- A[i]):
            ans = A[i-1] + K - A[i]
    print(ans)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(K, N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 93800
rotate = lambda x,y: x[-y:] + x[:-y]
S = input()
mod = 13
amari = 5
dp_tmp = [0]*13
dp_tmp[0] = 1
mul = 1
for s in S[::-1]:
    dp = [0]*13
    if s == "?":
        for n in range(10):
            dp_tmp_roll = rotate(dp_tmp,n*mul%mod)
            for k in range(13):
                dp[k] += dp_tmp_roll[k]
    else:
        dp_tmp_roll = rotate(dp_tmp,int(s)*mul%mod)
        for k in range(13):
            dp[k] += dp_tmp_roll[k]
    for n in range(13):
        dp[n] = dp[n]%(10**9+7)
    dp_tmp = dp
    mul = mul*10%13
print(dp[amari])


Measured memory_bytes: 44268
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
//#include<array>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
//#include<bitset>
//#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//配列,座標
/*array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
array<int, 4>dir_x2 = { 0,0,1,-1 };
array<int, 4>dir_y2 = { 1,-1,0,0 };
char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };*/

//Union Find
class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

//最大公約数,最小公倍数
/*LLI gcd(LLI x, LLI y) {
	LLI  r;
	if (x < y) {
		swap(x, y);
	}
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}
LLI lcm(LLI x, LLI y) {
	return x / gcd(x, y) * y;
}*/

//組み合わせ
/*long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; i--) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; i++) {
		ans = ans / i;
	}
	return ans;
}
long nHr(int n, int r) {
	n = n + r - 1;
	return nCr(n, r);
}*/

//素数判定
/*bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}*/

//桁数
/*LLI GetDigit(LLI num) {
	LLI digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}*/

//サンプル
/*const int n_max = 8;
array<array<bool, n_max>, n_max>graph;
int dfs(int v,int N,array<bool,n_max>visited) {
	int ret = 0;
	bool all_visited = true;
	for (int i = 0; i < N;i++) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited) {
		return 1;
	}
	for (int i = 0; i < N;i++) {
		if (graph[v][i] == false) {
			continue;
		}
		if (visited[i] == true) {
			continue;
		}
		visited[i] = true;
		ret += dfs(i,N,visited);
		visited[i] = false;
	}
	return ret;
}*/

//サンプル
/*vector<vector<int>>sub;
int dfs(int id) {
	if (sub[id].size() == 0) {
		return 1;
	}
	int minP = (int)1e9;
	int maxP = 0;
	for (int i : sub[id]) {
		int P = dfs(i);
		minP = min(minP, P);
		maxP = max(maxP, P);
	}
	return minP + maxP + 1;
}*/

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl
//cout << "Yes" << endl;
//cout << "No" << endl;



int main(void) {
	vector<LLI>vec;
	LLI N;
	cin >> N;
	vector<LLI>vec2(N,0);

	for (int i = 0; i < N - 1;i++) {
		LLI a;
		cin >> a;
		vec.push_back(a);
	}

	for (int i = 0; i < N - 1;i++) {
		vec2[vec[i] - 1]++;
	}
	for (int i = 0; i < N;i++) {
		cout << vec2[i] << endl;
	}
}

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

ll n,W;

ll w[105],v[105];

ll cache[105][100005];
 
ll dp(ll ind,ll wt)
{
    if (wt>W)
        return -1e15;
    if (ind==n)
        return 0;
    if (cache[ind][wt]!=-1)
        return cache[ind][wt];
    cache[ind][wt]=max(dp(ind+1, wt), v[ind] + dp(ind+1, wt+w[ind]));
    return cache[ind][wt];
}
 
int main()
    {
        memset(cache,-1,sizeof(cache));
        
        cin>>n>>W;
        
        for (int i=0;i<n;i++)
            cin>>w[i]>>v[i];
            
        cout<<dp(0,0);
        
    return 0;
    }

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

int main(void) {
	int N, price, max_p, sum;

	cin >> N;

	sum = max_p = 0;
	for (int i = 0; i < N; ++i) {
		cin >> price;
		sum += price;
		if (price > max_p)
			max_p = price;
	}
	sum -= max_p / 2;

	cout << sum << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
#define rep(i,l,r) for(ll i=l;i<=r;i++)

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n,a,b;cin>>n>>a>>b;
    cout<<min(a,b)<<' '<<max(0,a+b-n)<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	string str;
	while (cin>>str) {
		int joi=0,ioi=0;
		for (int i=0; i<str.length(); i++) {
			if (str[i]=='J'&&i+2<str.length()&&str[i+1]=='O'&&str[i+2]=='I') {
				joi++;
			} else if (str[i]=='I'&&i+2<str.length()&&str[i+1]=='O'&&str[i+2]=='I') {
				ioi++;
			}
		}
		cout << joi << endl;
		cout << ioi << endl;
	}
}

Measured memory_bytes: 0
N = int(input())
a_list = [int(input()) for _ in range(N)]

button_history = [1]
current_button = 1
num_manipulation = -1

for i in range(1, N + 1):
    current_button = a_list[current_button - 1]
    if current_button == 2:
        num_manipulation = i
        break

print(num_manipulation)


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

#define lli long long int
#define endl "\n"
#define debug(n) cout<<n<<endl
#define debug2(a, b) cout<<a<<" "<<b<<endl;
#define forn(i, in, fin) for(int i = in; i<fin; i++)
#define all(v) v.begin(), v.end()
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

/*
lli MEX(set<int> check)
{
    for(int i = 0; ; i++)
    {
        if(check.find(i) == check.end())
        {
            return i;
        }
    }
}
*/


int main()
{
    fastIO();
    lli n, k; cin>>n>>k;
    vector<lli> poss(n);
    vector<lli> NIM(k+1);
    for(auto &x: poss)
    {
        cin>>x;
    }

    for(int i = 1; i<=k; i++)
    {
        set<int> check;
        lli j = 0;
        while(j < n  &&  (i - poss[j] >= 0))
        {
            if(NIM[i-poss[j]] == 0)   
            {
                NIM[i] = 1;
                break;
            }
            j++;
        }
        NIM[i] = NIM[i]==1?1:0;
    }
    
    if(NIM[k] == 0) cout<<"Second\n";
    else cout<<"First\n";

    return 0;
}

Measured memory_bytes: 1024
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

int64_t H, W, K;

void solve()
{
    std::cin >> H >> W >> K;
    boost::multi_array<char, 2> c(boost::extents[H][W]);
	for (int64_t i : boost::irange<int64_t>(0, H))
	{
		for (int64_t j : boost::irange<int64_t>(0, W))
		{
			std::cin >> c[i][j];
		}
	}

    int64_t ans = 0;
   	for (int64_t bit_H = 0; bit_H < (1 << H); bit_H++)
	{
        for (int64_t bit_W = 0; bit_W < (1 << W); bit_W++)
        {
            int64_t cnt = 0;
            for (int64_t i = 0; i < H; i++)
            {
                for (int64_t j = 0; j < W; j++)
                {
                    // 選んだマスが赤く塗られていない場合
                    if (((bit_H & (1 << i)) == 0) && ((bit_W & (1 << j)) == 0))
                    {
                        // 選んだマスが黒の場合
                        if (c[i][j] == '#') cnt++;
                    }
                }
            }
            if (cnt == K) ans++;
        }
	}

    std::cout << ans << std::endl;
}

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


Measured memory_bytes: 3640
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b && b==c)
		cout<<"1"<<endl;
	else if(a==b && b!=c)
		cout<<"2"<<endl;
	else if(a!=b && b==c)
		cout<<"2"<<endl;
	else if(a==c && b!=c)
		cout<<"2"<<endl;
	else
		cout<<"3"<<endl;
		
	return 0;
}
	

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int a[75];
bool cmp(int a,int b){
	return a>b;
}
int main(){
	int n,i,k,ans=0;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	std::sort(a+1,a+n+1,cmp);
	for(i=1;i<=k;i++) ans+=a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{	int n,i;
	cin>>n;
	for(i=0;i<=n/4;i++){
		if((n-4*i)%7==0){cout<<"Yes\n";break;}
	}
	 if(i>n/4)cout<<"No\n";
	return 0;
}

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

int main () {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int l, r;

    l = a + b;
    r = c + d;

    if (l == r) cout << "Balanced" << endl;
    else if (l < r) cout << "Right" << endl;
    else cout << "Left" << endl;

    return 0;
}

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

int main() {
  ll n,ans=0;
  cin >> n;
  vector<ll> v(n*3,0);
  r(i,n*3)cin >> v[i];
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  r(i,n){
    ans+=v[2*i+1];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    if(a*b % 2 == 0){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
as = []
bs = []
cs = []

dp = Array.new(n + 1).map{ Array.new(3, 0) }

n.times {
	a, b, c = gets.split.map &:to_i
	as << a
	bs << b
	cs << c
}

(0...n).each{ |i|
	dp_index = i + 1
	dp[dp_index][0] = [dp[dp_index - 1][1] + as[i], dp[dp_index - 1][2] + as[i]].max
	dp[dp_index][1] = [dp[dp_index - 1][0] + bs[i], dp[dp_index - 1][2] + bs[i]].max
	dp[dp_index][2] = [dp[dp_index - 1][0] + cs[i], dp[dp_index - 1][1] + cs[i]].max
}

puts dp.last.max


Measured memory_bytes: 12924
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI = 4.0 * atan(1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

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

    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}


Measured memory_bytes: 256
class Updatable_Binary_Heap
  def initialize(list: [])
    @a = [nil] + list.sort{ |a,b| (a <= b) ? -1 : 1 }.map.with_index{ |v,i| { i: i+1, v: v }  }
    @m = @a.size
  end

  def insert(x)
    node = { i: @m, v: x }
    case 
    when @m < @a.size
      @a[@m] = node
    else
      @a << node
    end
    up_heap(@m)
    @m += 1
    node
  end

  def up_heap(i)
    while (j = i >> 1) > 0
      break if @a[j][:v] <= @a[i][:v]
      swap_node(i,j)
      i = j
    end
    i
  end

  def head
    @a[@m > 1 ? 1 : 0]
  end

  def shift
    return nil if @m <= 1
    @m -= 1
    swap_node(1, @m)
    down_heap(1)
    @a[@m]
  end

  def down_heap(i)
    while (j = i << 1) < @m
      j |= ((j|1) < @m && @a[j][:v] > @a[j|1][:v]) ? 1 : 0
      break if (@a[i][:v] <= @a[j][:v])
      swap_node(i,j)
      i = j
    end
    i
  end

  def swap_node(i,j)
    ai = @a[i]; aj = @a[j]
    ai[:i], aj[:i] = aj[:i], ai[:i]
    @a[i], @a[j] = aj, ai
  end

  def update_node(node, x)
    i = node[:i]
    node[:v] = x
    down_heap(i) == i && up_heap(i)
  end

  def a
    @a[1...@m]
  end
end

N,M = gets.split.map &:to_i
ab = (0...N).map{ gets.split.map &:to_i }.sort_by{ |a,b| a }
st = Updatable_Binary_Heap.new()
D = 10000
ans = 0
(1..M).each{ |d|
  while ab.size > 0 && ab[0][0] <= d do
    a,b = ab.shift
    st.insert(-b)
  end
  b = st.shift
  next if !b
  ans -= b[:v]
}
p ans


Measured memory_bytes: 38440
import math
li = []
for i in range(5):
  n = int(input())
  li.append(n)

fl = False
idx = 0
ch = 10
for j in range(5):
  if li[j] % 10 != 0 and li[j] % 10 < ch:
    ch = li[j] % 10
    idx = j
    fl = True
#print('fl',fl)
#print('idx',idx)

if fl == False:
  print(sum(li))
  exit()

ans = 0
ln = 0
#print(li)
if fl == True:
  ln = li[idx]
  li.remove(li[idx])
  #print(li)
  for k in range(len(li)):
    c = math.ceil(li[k]/10)*10
    #print(c)
    ans += c
#print('ln',ln)
print(ans+ln)

Measured memory_bytes: 3064
import sys


def input() -> str:
    return sys.stdin.readline().rstrip("\r\n")


def main():
    # s = input()
    # if len(s) != 6:
    #     print('No')
    # elif s[-2] == s[-1] and s[2] == s[3]:
    #     print('Yes')
    x = int(input())
    print(x//500*1000 + (x%500)//5*5)

if __name__ == "__main__":

    main()


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

int main() {
	int a[5], k;
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	cin >> k;

	if (a[4] - a[0] > k) {
		cout << ":(" << endl;
		return 0;
	}

	else {
		cout << "Yay!" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int y, m, d;
    while(scanf("%d %d %d", &y, &m, &d) != EOF){
        if((y < 1868)||(y == 1868 && m < 9)||(y == 1868 && m == 9 && d < 8)){
            printf("pre-meiji\n");
        }else if((y < 1912)||(y == 1912 && m < 7)||(y == 1912 && m == 7 && d < 30)){
            printf("meiji %d %d %d\n", y+1-1868, m, d);
        }else if((y < 1926)||(y == 1926 && m < 12)||(y == 1926 && m == 12 && d < 25)){
            printf("taisho %d %d %d\n", y+1-1912, m, d);
        }else if((y < 1989)||(y == 1989 && m < 1)||(y == 1989 && m == 1 && d < 8)){
            printf("showa %d %d %d\n", y+1-1926, m, d);
        }else{
            printf("heisei %d %d %d\n", y+1-1989, m, d);
        }
    }
    return 0;
}
        
    

Measured memory_bytes: 1036