akhauriyash/Code-Regression huggingface dataset:
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll n, m, k; cin >> n >> m >> k;
	vector<ll> A(n), B(m);
	vector<ll> AS(n+1), BS(m+1);
	rep(i, n){
		cin >> A[i];
		AS[i+1] = AS[i] + A[i];
	}
	rep(i, m){
		cin >> B[i];
		BS[i+1] = BS[i] + B[i];
	}

	// print(AS);
	// print(BS);

	ll sum = 0;
	ll ans = 0;

	rep(i, n+1){
		sum = AS[i];
		ll num = k - sum;
		if(k - sum < 0) break;
		auto it = upper_bound(ALL(BS), num);
		ans = max(ans, (ll)(i + distance(BS.begin(), it) - 1));
		// print(num);
		// print(ans, i + distance(BS.begin(), it), i);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 9508
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs =(1..n).map { readLine()!!.split(" ").map { it.toLong() } }
                                .sortedByDescending { it[0] + it[1] }

    var ans = 0L
    for (i in 0 until n) {
        if (i % 2 == 0) {
            ans += xs[i][0]
        } else {
            ans -= xs[i][1]
        }
    }
    println(ans)
}

Measured memory_bytes: 64840
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);
        
        int n,m;
        
        n = sc.nextInt();
        m = sc.nextInt();
        
        int sum = (n -1) * (m - 1);
        
        System.out.print(sum);
    }
}

Measured memory_bytes: 23636
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
/*
90/8 + 90/4 + 90/2


*/
void mainmain(){
	string s;
	while(cin>>s,s!="#"){
		ll a=0,b=1;
		ll c=1;
		if(s.size()==5){
			cout<<0<<endl;
			continue;
		}
		while(s.size()){
			// cout<<a<<" "<<b<<endl;
			if(s[s.size()-1]=='h'){
				if(c==1){
					s=s.substr(0,s.size()-5);
					c*=2;
					continue;
				}
				a=c*a-b*90;
				b*=c;
				s=s.substr(0,s.size()-5);
			}
			else{
				a=c*a+b*90;
				b*=c;
				s=s.substr(0,s.size()-4);	
			}
			c*=2;
			ll m=__gcd(a,b);
			a/=m;
			b/=m;
			// if(m<=1) continue;
		}
		if(b==1){
			cout<<a<<endl;
		}
		else{
			cout<<a<<"/"<<b<<endl;
		}
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, l, r;
	cin >> n;

	int ans = 0;
	while(n--)
	{
		cin >> l >> r;
		ans += (r-l+1);
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vp;
typedef vector<vp> vpp;
typedef vector<vector<ll> > graph;
#define pb push_back
#define mp make_pair
#define endl '\n'
void set_val(vector<ll>& v, ll val){for(ll i=0;i<v.size();i++) v[i]=val;}

ll mod = pow(10,9) + 7;
ll modulo = 998244353;
double pi = 3.141592653589793238;
ll i_mov[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll j_mov[8] = {1, 1, 1, 0, -1, -1, -1, 0};


ll power(ll a, ll n)
{
    if(n==0)
    return 1;
    ll temp = power(a,n/2);
    if(n%2==0)
    return (temp*temp)%mod;
    return (((temp*temp)%mod)*a)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout<<setprecision(10);
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    priority_queue<pair<ll,ll>> pq;
    for(int i=0;i<a;i++)
    {
        int temp;
        cin>>temp;
        pq.push(mp(temp, 1));
    }
    for(int i=0;i<b;i++)
    {
        int temp;
        cin>>temp;
        pq.push(mp(temp, 2));
    }
    for(int i=0;i<c;i++)
    {
        int temp;
        cin>>temp;
        pq.push(mp(temp, 3));
    }
    ll ans = 0;
    int t = 0;
    int temp = x+y;
    while(t<temp)
    {
        pair<ll,ll> p = pq.top();
        pq.pop();
        // cout<<p.first<<" "<<p.second<<endl;
        if(p.second == 1 && x>0)
        {
            ans += p.first;
            temp--;
            x--;
        }
        else if(p.second == 2 && y>0)
        {
            ans += p.first;
            temp--;
            y--;
        }
        else if (p.second == 3)
        {
            ans += p.first;
            temp--;
        }
    }
    cout<<ans<<endl;
    
    
    
    
    
} 

Measured memory_bytes: 10604
import math
n, d = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]

cnt = 0
for i in range(n):
    for j in range(i+1,n):
        dd = 0
        for d_ in range(d):
            diff = x[i][d_] - x[j][d_]
            dd += diff**2
        if math.sqrt(dd).is_integer():
            cnt += 1
        

print(cnt)
        

Measured memory_bytes: 38384
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int n; readV(n);
  writeln(n/3);
}


Measured memory_bytes: 256
mod=10**9+7
L=input()
N=len(L)
ans=0
one=0
exp2=1
for i in range(N):
    if L[i]=="1":
        ans+=(pow(3,N-1-i,mod)*exp2)%mod
        ans%=mod
        exp2*=2
        exp2%=mod
        one+=1
ans+=pow(2,one,mod)
ans%=mod
print(ans)



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

class P
{
    static void Main()
    {
        Console.ReadLine();
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Dictionary<int, int> dict = new Dictionary<int, int>();

        foreach (var i in a)
        {
            if (!dict.ContainsKey(i - 1)) dict.Add(i - 1, 0);
            if (!dict.ContainsKey(i)) dict.Add(i,0);
            if (!dict.ContainsKey(i + 1)) dict.Add(i + 1, 0);
            dict[i - 1]++;
            dict[i]++;
            dict[i + 1]++;
        }
        Console.WriteLine(dict.Max(x => x.Value));
    }
}

Measured memory_bytes: 24288
N = int(input())
S = [int(input()) for _ in range(N)]

def f(current, rest):
    if current % 10: return current
    if not rest: return 0
    return max(
            f(current - rest[0], rest[1:]),
            f(current, rest[1:])
        )
print(f(sum(S), sorted(filter(lambda x: x % 10, S))))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

const int N_MAX = 51;

ll C[N_MAX][N_MAX]; // C[n][k] -> nCk

void comb_table(int N)
{
    rep(i, N + 1)
    {
        rep(j, i + 1)
        {
            if (j == 0 || j == i)
            {
                C[i][j] = 1;
            }
            else
            {
                C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
            }
        }
    }
}

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    comb_table(N);
    vector<ll> v(N);
    long double ans = 0;
    ll ans_cnt = 0;
    rep(i, N)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end(), greater<ll>());
    rep(i, A)
    {
        ans += v[i];
    }
    ans /= A;

    int x = 0, y = 0;
    rep(i, N)
    {
        if (v[i] == v[A - 1])
        {
            x++;
            if (i < A)
            {
                y++;
            }
        }
    }
    // cout << x << " " << y << endl;
    if (v[0] == v[A - 1])
    {
        for (y = A; y <= min(x, B); ++y)
        {
            ans_cnt += C[x][y];
        }
    }
    else
    {
        ans_cnt += C[x][y];
    }

    cout.precision(20);
    cout << fixed << ans << endl;
    cout << ans_cnt << endl;
    return 0;
}


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

using namespace std;

long long inf=1000000007;

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

	bool flag=true;
	for(int i=0;i<s.size();i++){
		if(s.at(i)!=t.at(i)) flag=false;
	}

	cout<<(flag ? "Yes" : "No")<<endl;

	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    long double r;
    cin >> r;
    cout << fixed << setprecision(6) << r*r*M_PI << ' ' << 2*r*M_PI << endl;
}


Measured memory_bytes: 3256
N = int(input())
a = list(map(int, input().split()))

a.sort()

count = 0

while a:
    k = a.pop(-1)
    k_count = 1
    while (len(a) > 0) and (a[-1] == k):
        a.pop(-1)
        k_count += 1
    if k_count < k:
        count += k_count
    else:
        count += k_count - k
print(count)


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

int main() {
  int N;
  cin >> N;
  int a[N], ans = 1e9;
  for (int i=0; i<N; i++)
    cin >> a[i];
  for (int i=-100; i<=100; i++) {
    int c = 0;
    for (int j=0; j<N; j++) {
      c += (a[j]-i)*(a[j]-i);
    }
    ans = min(c, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int a,b;cin>>a>>b;
  cout<<max(a+b,max(a-b,a*b))<<endl;
  return 0;
}


Measured memory_bytes: 256
cin = open(0).read().strip().split('\n')

from collections import deque

dx = [1, 0, -1, 0]
dy = [0, -1, 0, 1]

cnt = 0
while True:
    w,h = map(int, cin[cnt].split(' '))
    if w==0 and h==0: break

    var = [list(map(int, a.strip().split(' '))) for a in cin[cnt+1:cnt+1+(2*h-1):2]]
    hor = [list(map(int, a.split(' '))) for a in cin[cnt+2:cnt+2+(2*h-3):2]]

    q = deque()
    dist = [[0 for _ in range(w)] for _ in range(h)]
    dist[0][0] = 1
    q.append((0,0))
    while q:
        ph,pw = q.popleft()
        for dyi, dxi in zip(dy, dx):
            if ph+dyi>=h or ph+dyi<0: continue
            if pw+dxi>=w or pw+dxi<0: continue
            if dist[ph+dyi][pw+dxi] != 0: continue
            if (dyi==1 and hor[ph][pw] == 1) or (dyi==-1 and hor[ph+dyi][pw] == 1): continue
            if (dxi==1 and var[ph][pw] == 1) or (dxi==-1 and var[ph][pw+dxi] == 1): continue
            q.append((ph+dyi,pw+dxi))
            dist[ph+dyi][pw+dxi] = dist[ph][pw]+1
    print(dist[h-1][w-1])
    cnt += 2*h


Measured memory_bytes: 6728
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pil pair<int,along long>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define pb push_back
#define mk make_pair
#define maxn 100009
#define eps 1e-12
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> v;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		v.pb(x);
		cin>>x;
		v.pb(x);
	}
	ll ans=0;
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i+=2)
	{
		ans+=v[i];
	}
	cout<<ans<<"\n";
}

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

int B, C, num[12], b, c;

bool dfs(int b, int c, int i){
    if(i == 10) return true;
    if(b<num[i] && dfs(num[i], c, i+1)){
        return true;
    }
    if(c<num[i] && dfs(b, num[i], i+1)){
        return true;
    }
    return false;
}

int main(void){
  int N;
  cin >> N;
  for(int j=0; j<N; j++){
  B = 0;
  C = 0;
  for(int i=0; i<10; i++){
    cin >> num[i];
  }
  dfs(0, 0, 0);
  if(dfs(0, 0, 0))  cout << "YES" << endl;
  else cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 2984
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repr(i, a, b) for (int i = (int)a; i > (int)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 4e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    multiset<int> s;
    rep(i,1ll<<n){
        int si;
        cin >> si;
        s.insert(-si);
    }
    //-1をかけて同じことをする
    /*
    小さいほうからnowにいれて、slimeにいれる
    1以上大きい、できるだけ小さいスライムを生み出す。
    slimeも小さいほうからとるからOK
    */
    multiset<int> slime;
    auto ittr = s.begin();
    slime.insert(*(s.begin()));
    s.erase(s.begin());
    rep(i,n){
        multiset<int> now;
        for (auto itr = slime.begin(); itr != slime.end();itr++){
            auto x = s.lower_bound(*itr + 1);
            if (x==s.end()){
                cout << "No" << ENDL;
                return 0;
            }
            now.insert(*x);
            s.erase(x);
        }
        for (auto itr = now.begin(); itr != now.end();itr++){
            slime.insert(*itr);
        }
    }
    cout << "Yes" << ENDL;
}

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

int D;
const int M = 26;
vector<int> C;
vector<vector<int>> S;
vector<int> T;

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

std::mt19937 mt{ std::random_device{}() };

int randint(int lower, int upper)
{
    std::uniform_int_distribution<int> dist(lower, upper);
    return dist(mt);
}

int calc_score()
{
    int ans = 0;
    vector<int> last(M, -1);
    for(int i=0; i<D; i++)
    {
        ans += S[i][T[i]];
        last[T[i]] = i;
        for(int j=0; j<M; j++)
        {
            ans -= C[j] * (i - last[j]);
        }
    }
    return ans;
}

int main()
{
    int tstart = clock();
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> D;
    C.resize(M);
    for(int i=0; i<M; i++) cin >> C[i];
    S.resize(D);
    for(int i=0; i<D; i++)
    {
        S[i].resize(M);
        for(int j=0; j<M; j++)
        {
            cin >> S[i][j];
        }
    }

    T.resize(D);
    vector<int> CNT(D, 0);
    vector<vector<int>> Greater(D, vector<int>(M));
    for(int i=0; i<D; i++)
    {
        vector<int> minS = S[i];
        sort(minS.begin(), minS.end(), greater<int>());
        for(int j=0; j<M; j++)
        {
            int k=0;
            for(k=0; k<M; k++)
            {
                if(S[i][k] == minS[j]) break;
            }
            Greater[i][j] = k;
        }
        T[i] = Greater[i][0];
        CNT[i]++;
    }
    int score = calc_score();
    while(1.0 * (clock() - tstart) / CLOCKS_PER_SEC < 1.98)
    {
        // cout << 1.0 * (clock() - tstart) / CLOCKS_PER_SEC << endl;
        int H = randint(0, D-1);
        int Q = Greater[H][CNT[H]];
        if(CNT[H] < M - 1) CNT[H]++;
        int tmp = T[H];
        T[H] = Q;
        int nscore = calc_score();
        if(score < nscore)
        {
            score = nscore;
        }
        else
        {
            T[H] = tmp;
        }
    }
    for(int i=0; i<D; i++)
    {
        cout << T[i] + 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
int const N=333333;
int n,m,w,cntx[N],cnty[N],maxx,maxy;
vector<int>px,py;
map<pair<int,int>,bool>mp;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>m>>w;
	for(int i=1,x,y;i<=w;i++){
		cin>>x>>y;
		cntx[x]++;cnty[y]++;
		mp[make_pair(x,y)]=1;
	}
	for(int i=1;i<=n;i++)
	    if(cntx[i]>maxx)
		    px=vector<int>(),px.push_back(i),maxx=cntx[i];
		else if(cntx[i]==maxx)px.push_back(i);
	for(int i=1;i<=m;i++)
	    if(cnty[i]>maxy)
		    py=vector<int>(),py.push_back(i),maxy=cnty[i];
		else if(cnty[i]==maxy)py.push_back(i);
	int flg=1;
	for(int i=0;i<px.size();i++)
	    for(int j=0;j<py.size();j++)
	        if(!mp[make_pair(px[i],py[j])]){flg=0;break;}
	cout<<maxx+maxy-flg;
}

Measured memory_bytes: 45500
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
 
const double PI = acos(-1);
const int MAX = 100005;
//基本型のグローバル変数は0初期化されることが保証されている
ll X[MAX];

int main() {
    int a,n,q;
    vector<int> v;
    cin >> n;
    rep(i,n) {
        cin >> a;
        X[a]++;
    }
    cin >> q;
    vector<ll> sum(q+1);
  	sum[0] = 0;
    rep(i,MAX) {
        sum[0] += i * X[i];
    }
    for(int i = 1; i <= q; ++i) {
        int b,c;
        cin >> b >> c;
        ll tmp_b = X[b];
        X[b] = 0;
        X[c] += tmp_b;
        
        sum[i] = sum[i-1] - tmp_b*b + tmp_b*c;
    }
    
    for(int i = 1; i <= q; ++i) cout << sum[i] << "\n";
    return 0;
}

Measured memory_bytes: 4764
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,C,K;
    cin>>N>>C>>K;
    vint t(N);
    REP(i,N) cin>>t[i];
    sort(ALL(t));

    int cur=0,ans=0;
    while(cur<N){
        int nex=cur;
        while(nex<N and nex-cur+1<=C and t[nex]<=t[cur]+K) nex++;
        ans++; cur=nex;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1024
// 
	#include<bits/stdc++.h> 
	#include <sstream> 
	using namespace std; 
	typedef long long ll;
	inline bool cmp(pair< ll , ll > &a , pair< ll , ll >  &b){
		if(a.first != b.first)
			return a.first > b.first;
		else
			return a.second < b.second;
	}

	int main() 
	{ 
		ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    ll n , cnt;
	    cin >> n;
	    if(n % 2){
	    	cout << 0 << endl;
	    	return 0;
	    }
	    else{
	    	 cnt = 0;
	    	 cnt += (n/10);
	    	 n /= 10;
	    	while(n != 0){
	    		
	    			n/=5;
	    			cnt += n;
	    		
	    		
	    	}
	    }
	    cout << cnt << endl;
	}


Measured memory_bytes: 384
import Data.List
main :: IO ()
main = do
    n:p <- input <$> getContents
    let (a,b) = answer $ map snd $ sortOn fst $ zip p [1..]
    putStrLn $ showans a
    putStrLn $ showans b

input :: String -> [Int]
input = fmap read . words

answer :: [Int] -> ([Int],[Int])
answer p = let a = tail $ reverse $ foldl (\acc n -> ( (n + head acc):acc )) [0] p
               b = map (\n -> last a - n) $ take (length p) (0:a)
           in (a,b)

showans :: [Int] -> String
showans [] = ""
showans (x:xs) = (show x) ++ " " ++ (showans xs)


Measured memory_bytes: 11004
# 仕事を同時並行して進めることはできないし、順番によって必要時間がかかるわけではないから締め切りが近い順に貪欲？

n = int(input())

jobs = []

for i in range(n):
    a, b = map(lambda x:int(x), input().split())
    jobs.append([b, a])
jobs.sort()

job_count = 0
pass_time = 0

for j in jobs:
    if pass_time + j[1] <= j[0]:
        job_count += 1
        pass_time += j[1]
    else:
        break

if job_count == n:
    print("Yes")
else:
    print("No")

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b&&b==c){
    cout << 1 << endl;
  }
  else if(a==b||a==c||b==c){
    cout << 2 << endl;
  }
  else {
    cout << 3 << endl;
  }
}

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

int h,w;
int maps[50][50];
int dy[]={-1,-1,-1,0,0,0,1,1,1};
int dx[]={-1,0,1,-1,0,1,-1,0,1};

void dfs(int y,int x);

int main(){
  int cnt;
  while(cin >> w >> h,w|h){
    cnt = 0;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
	cin>>maps[i][j];
      }
    }
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
	if(maps[i][j] == 1){
	  cnt++;
	  dfs(i,j);
	}
      }
    }
    cout << cnt << endl;
  }
}

void dfs(int y,int x){
  maps[y][x] = 0;
  for(int i = 0; i < 9;i++){
    int sy = y + dy[i];
    int sx = x + dx[i];
    if(sy >= 0 && sy < h && sx >= 0 && sx < w && maps[sy][sx] == 1){
      dfs(sy,sx);
    }
  }
  return;
}

Measured memory_bytes: 1236
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;

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

/*
int N;
ll h[100010];

// DP テーブル
ll dp[100010];
*/

int main()
{
	int max_ = 0;
	int X;
	cin >> X;

	if (X < 4) {
		cout << 1 << endl;
		return 0;
	}

	for (int i = 2; i <= X; i++)
	{
		int j = 2;

		while (1)
		{
			int tmp = pow(i, j);

			if (tmp > X) break;

			max_ = max(max_, tmp);

			j++;
		}
	}

	cout << max_ << endl;
}


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

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

	vector<int> P(N),Q(N);
	rep(i,N){
		cin >> P.at(i);
	}
	rep(i,N){
		cin >> Q.at(i);
	}

	vector<int> tmp(N),bigger(N);
	tmp = min(P,Q);
	bigger = max(P,Q);

	int ans=0;
	while(true){
		if(tmp == bigger) break;
		next_permutation(tmp.begin(),tmp.end());
		ans++;
	}

	cout << ans << endl;
}



Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
	char name[100];
	int t
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
	Q[tail]=x;
	tail=(tail+1)%LEN;
	return 0;
}

P dequeue(){
	P x=Q[head];
	head=(head+1)%LEN;
	return x;
}

int min(int a,int b){return a<b?a:b;}

int main(void){
	int elaps=0,c;
	int i,q;
	P u;
	scanf("%d %d",&n,&q);
	for(i=1;i<=n;i++){
		scanf("%s",Q[i].name);
		scanf("%d",&Q[i].t);
	}
	
	head=1; tail=n+1;
	
	while(head !=tail){
		u=dequeue();
		c=min(q,u.t);
		u.t -=c;
		elaps +=c;
		if(u.t>0)enqueue(u);
		else{
			printf("%s %d\n",u.name,elaps);
		}
	
	}
	return 0;
}




Measured memory_bytes: 11852
#include<stdio.h>

int main(){
	int x,y,z;
	int i,j;
	int e;
	int tmp;

	while(scanf("%d",&e),e){
		j = e;
		for(z = 0;e >= z*z*z;z++){
			for(y = 0;e >= y*y;y++){
				//for(x = 0;e >= x;x++){
					//if(e == x + y*y + z*z*z){
						x = e - y*y - z*z*z;
						if(x < 0)continue;
						tmp = x + y + z;
						if(j > tmp)j = tmp;
						//break;
					//}
				//}
			}
		}


		printf("%d\n",j);
	}
	return 0;
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//切り上げ除算
long long cutup(long long a,long long b){return (a+b-1)/b;}

//累乗
template<typename t>
constexpr t my_pow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}
#define pow my_pow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin>>s;
    ll res=0;
    rep(i,Size(s)){
        if(s[i]=='0'&&i%2==0)res++;
        if(s[i]=='1'&&i%2==1)res++;
    }
    ll res2=0;
    rep(i,Size(s)){
        if(s[i]=='1'&&i%2==0)res2++;
        if(s[i]=='0'&&i%2==1)res2++;
    }
    cout<<min(res,res2)<<endl;
}

Measured memory_bytes: 3792
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int[] kokuban = new int[N];
		int counter = 0;

		for (int i = 0; i < N; i++) {
			kokuban[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			if (kokuban[i] % 2 == 1) {
				counter++;
			}
		}
		if (counter % 2 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 50312
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, m;
int a[100];

vector<int> solveA() {
	vector<int> b;
	int i;
	
	if (a[0] >= 2) {
		b.push_back(a[0] - 1);
	}
	for (i = 1; i < m; i++) {
		b.push_back(a[i]);
	}
	b.push_back(1);
	return b;
}

vector<int> solveB() {
	vector<int> b;
	int i;
	
	if (a[0] >= 2) {
		b.push_back(a[0] - 1);
	}
	for (i = 1; i < m; i++) {
		b.push_back(a[i]);
	}
	b.push_back(1);
	return b;
}

vector<int> solveC() {
	vector<int> b;
	int i;
	
	swap(a[1], a[m - 1]);
	
	if (a[0] >= 2) {
		b.push_back(a[0] - 1);
	}
	for (i = 1; i < m - 1; i++) {
		b.push_back(a[i]);
	}
	b.push_back(2);
	if (a[m - 1] >= 2) {
		b.push_back(a[m - 1] - 1);
	}
	return b;
}

int main() {
	int i;
	
	cin >> n >> m;
	rep(i, m) cin >> a[i];
	
	function<int(int, int)> comp = [](int x, int y) {
		if (x % 2 != y % 2) return x % 2 > y % 2;
		return x < y;
	};
	stable_sort(a, a + m, comp);
	
	if (m >= 3 && a[2] % 2 == 1) {
		cout << "Impossible" << endl;
		return 0;
	}
	
	vector<int> b;
	if (a[0] % 2 == 0) {
		b = solveA();
	}
	else if (m == 1 || a[1] % 2 == 0) {
		b = solveB();
	}
	else {
		b = solveC();
	}
	
	rep(i, m) {
		cout << a[i];
		if (i + 1 < m) cout << " ";
	}
	cout << endl;
	
	cout << b.size() << endl;
	rep(i, b.size()) {
		cout << b[i];
		if (i + 1 < b.size()) cout << " ";
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
import queue
n,m = map(int,input().split())

g = [[0 for i in range(n)] for j in range(n)]

for _ in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    g[a][b] = g[b][a] = 1

ans = 0
for i in range(n):
    for j in range(i):
        if g[i][j] == 1:
            g[i][j] = g[j][i] = 0

            vis = [False for _ in range(n)]
            vis[0] = True
            q = queue.Queue()
            q.put(0)
            while not q.empty():
                v = q.get()
                for e in range(n):
                    if g[v][e] == 1 and not vis[e]:
                        vis[e] = True
                        q.put(e)

            add = 0
            for k in range(n):
                if not vis[k]:
                    add = 1
            ans += add

            g[i][j] = g[j][i] = 1

print(ans)


Measured memory_bytes: 3952
//
// Created by kashi on 20-06-2020.
//
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define Endl endl
#define int long long
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
bool cmp(pair<int,int> a, pair<int,int>b) {
    return a.second<b.second;
}

int32_t main(){
    char a;
    cin>>a;
    if(isupper(a))
        cout<<"A"<<endl;
    else
        cout<<"a"<<Endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++) 
#define FOR(i,ini,n) for(int i=(ini);i<(n);i++)
#define SZ(x) (int)x.size()

using namespace std;

struct Point{
public:
	int x;
	int y;
	Point(){}
	Point(int _x, int _y){
		x = _x;
		y = _y;
	}
	
	int getDistance(int ix,int iy){
		return abs(ix-x)+abs(iy-y);
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	while(cin >> n >> m){
		vector<Point> students;
		vector<Point> checkPoint;
		REP(i,n){
			int a,b;
			cin >> a >> b;
			students.push_back(Point(a,b));
		}
		
		REP(i,m){
			int c,d;
			cin >> c >> d;
			checkPoint.push_back(Point(c,d));
		}
		
		REP(i,n){
			int currentBestInd = -1;
			int currentBest = INT_MAX;
			REP(j,m){
				int c = checkPoint[j].x;
				int d = checkPoint[j].y;
				int dis = students[i].getDistance(c,d);
				if(dis < currentBest){
					currentBest = dis;
					currentBestInd = j;
				}
			}
			cout << currentBestInd+1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int n, k;
	cin >> n >> k;
	int dp[10] = {};
	for (int i = 0; i < k; i++) {
		int a;
		cin >> a;
		dp[a] = 1;
	}
	int check = 0;
	while (check == 0) {
		string s = to_string(n);
		for (int i = 0; i < s.size(); i++) {
			if (dp[s[i]-'0'] == 1) {
				break;
			}
			if (i == s.size() - 1) {
				check = 1;
			}
		}
		n = n + 1;
	}
	cout << n - 1;
}

Measured memory_bytes: 256
// header {{{
using namespace std;

// C++
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

#pragma GCC optimization_level 3

// util {{{
#define print(x)	        cout << (x)
#define printvec(x)       for(int i = 0;i < (x).size();i++)cout << (x).at(i) << " ";cout << endl
#define println(x)	        cout << (x) << endl
#define printn		        cout << endl
#define read(x)	            cin >> (x)
#define readvec(x)        for(int i = 0; i < (x).size();i++)cin >> (x).at(i)

#define rep(i, n)	        for(int i = 0; i < (int)(n); i++)
#define rep_1(i, n) 	    for(int i = 1; i <=(int)(n); i++)

#define all(x) 		        (x).begin(),(x).end()
#define vint                vector<int>
#define outif(x,y,z)        if(x) cout<<(y)<<endl; else cout<<(z)<<endl
#define loop 		        while(true)

// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

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

//--------------------------------------------------------------------

void solve() {
    vector<int> ans;
    loop{
        int a,b;
        char op;
        read(a);
        read(op);
        read(b);
        if(op == '?')break;
        switch(op){
            case '+':
                ans.push_back(a+b);
                break;
            case '-':
                ans.push_back(a-b);
                break;
            case '*':
                ans.push_back(a*b);
                break;
            case '/':
                ans.push_back(a/b);
                break;
        }
    };
    rep(i,ans.size()){
        println(ans.at(i));
    }

}

signed main() {
    solve();
    return 0;
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long  N; cin >> N;
   long ans = 0;
    for(long n = 1; n <= N; n++){
        ans += n * (N / n) * (N / n + 1) / 2;
    }
  cout<<ans;


}

Measured memory_bytes: 3624
def main():
    cards = {'a': '', 'b': '', 'c': ''}

    cards['a'] = input()
    cards['b'] = input()
    cards['c'] = input()

    current = 'a'
    next = ''

    while True:
        # ToDO 1回目に先頭削るのおかしい
        if not cards[current]:
            print(current.upper())
            return
        next = cards[current][0]
        cards[current] = cards[current][1:]
        current = next

if __name__ == "__main__":

    main()


Measured memory_bytes: 3060
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e5+5 ,mod = 1e9+7 ;

string str ;
int mem[N][2] ;
int solve(int i,int up){
    if(i==str.size()) return up==0 ;
    int&ret = mem[i][up] ;
    if(~ret) return ret;
    if(str[i]=='0') return ret = (solve(i+1,up) + solve(i+1,1)*2%mod)%mod ;
    return ret = (solve(i+1,0) + solve(i+1,up)*2%mod)%mod;
}
int main(){
    cin >> str ;
    reverse(str.begin(),str.end());
    memset(mem,-1,sizeof mem);
    cout << solve(0,0) ;
    return 0;
}


Measured memory_bytes: 5888
D,G = map(int,input().split())
P = [0]
C = [0]

for x in range(0,D):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)

answer = sum(P)

for x in range(1<<D):
    score = 0
    number = 0
    for i in range(1,D+1):
        if x & (1<<(i-1)) > 0:
            score += P[i]*i*100 + C[i]
            number += P[i]
    
    if score >= G:
        answer = min(answer,number)
        continue

    for i in range(D,0,-1):
        if x & (1<<(i-1)) == 0:
            n = (G-score)//(100*i)
            if n <= P[i]:
                score += 100*i*n
                number += n
            else:
                score += 100*i*P[i]
                number += P[i]
        if score >= G:
            answer = min(answer,number)
            break

print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <math.h>
#include<algorithm>
#include <utility>
using namespace std;
int main() {
    int h, r,a;
    cin >> h >> r;
    a = h + r;
    if (a == 0) {
        cout << "0" << endl;
    }
    else if(a>0){
        cout << "1" << endl;
    }
    else {
        cout << "-1" << endl;
    }
    return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll q, h, s, d, n; cin >> q >> h >> s >> d >> n;
  chmin(s, q*4);
  chmin(s, h*2);
  chmin(d, s*2);
  cout << (n/2)*d+(n%2)*s << endk;
  return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()) {
			double underSpeed = stdIn.nextDouble();

			double t = underSpeed / 9.8;
			System.out.println((int)Math.ceil((4.9 * t * t + 5) / 5));
		}
	}
}

Measured memory_bytes: 18628
grid=Array.new(3).map{Array.new(3)}
(0..2).each do |i|
  str=gets.chomp.split(" ").map{|str|str.to_i}
  grid[i]=str
end
p=Array.new()
q=Array.new()
r=Array.new()
(0..2).each do |i|
  p<<grid[i][0]-grid[i][1]
  q<<grid[i][1]-grid[i][2]
  r<<grid[i][2]-grid[i][0]
end

flag1=p[0]==p[1] && p[1]==p[2] && p[0]==p[2]
flag2=q[0]==q[1] && q[1]==q[2] && p[0]==p[2]
flag3=r[0]==r[1] && r[1]==r[2] && p[0]==p[2]

if flag1 && flag2 && flag3 then
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
//2017-12-03
//LZYeah
//
#include<bits/stdc++.h>
#define ll long long
#define For(i,a,b) for(register int i=a;i<=b;i++)
#define Forr(i,a,b) for(register int i=a;i>=b;i--)
using namespace std;
inline void File()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
inline void read(int &x)
{
	int p=1;
	x=0;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c^'0');c=getchar();}
	x*=p;
}
int a;
int main()
{
//	File();
	read(a);
	int b=a,num=0;
	while(b>0)
	{
		num+=b%10;
		b/=10;
	}
	if(a%num==0)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cout<<fixed<<setprecision(12);
  int n;
  int s[1000];
  double sum,ans;
  while(1){
  cin>>n;
  if(n==0) break;
  sum=0;
  ans=0;
  for(int i=0;i<n;i++){
    cin>>s[i];
    sum+=s[i];
  }
  sum/=n;
  for(int i=0;i<n;i++){
    ans+=pow(sum-s[i],2);
  }
  ans=sqrt(ans/n);
  cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3236
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n,m;
	while(cin>>n>>m,n){
		int cd[200]; int t=0,h=0;
		rep(i,n)cin>>cd[i],t+=cd[i];
		rep(i,m)cin>>cd[i+n],h+=cd[i+n];
		sort(cd,cd+n),sort(cd+n,cd+n+m);
		
		rep(i,n)rep(j,m){
			if(t-cd[i]+cd[j+n]==h-cd[j+n]+cd[i]){
				cout<<cd[i]<<" "<<cd[j+n]<<endl;; goto NEXT;
			}
		}
		cout<<-1<<endl;
		NEXT:;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
 
const ll MAX_V=1000006;//頂点の制約
 
struct edge{ll to,cost;};
 
vector<edge> G[MAX_V];//隣接リスト
vector<ll> d(MAX_V,INF);//頂点sからの最短距離
ll N;//頂点数
 
void dijkstra(ll s){
    priority_queue<P,vector<P>,greater<P> > que;
    d[s]=0;
    que.push(P(0LL,s));//P.a:最短距離 P.b:頂点の番号
 
    while(!que.empty()){
        P p=que.top(); que.pop();
        ll v=p.b;//頂点番号
        if(d[v]<p.a) continue;
        rep(i,G[v].size()){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}
 
int main(){
    ll K; cin>>K;
    //辺の情報入力
    rep(i,K){
        if(i%10 != 9){
            G[i].pb((edge){(i+1)%K,1});
        }
        G[i].pb((edge){(i*10)%K,0});
    }
    dijkstra(1);
    cout<<d[0]+1;
}

Measured memory_bytes: 40020
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

n = int(input())
k = int(input())

ans = 1
for i in range(n):
    if (ans > k):
        ans += k
    else:
        ans *= 2

print(ans)



Measured memory_bytes: 9044
use text_io::*;
use std::collections::*;
use std::process::exit;

fn main() {
    let mut n:usize = read!();
    let mut k:usize = read!();
    let mut q:usize = read!();
    let mut v:Vec<isize> = Vec::new();
    for i in 0..n {
        v.push(k as isize - q as isize);
    }
    for i in 0..q {
        let a:usize = read!();
        v[a-1]+=1;
    }
    for i in 0..n {
        if v[i]<=0 {
            println!("No");
        }
        else {
            println!("Yes");
        }
    }
}

Measured memory_bytes: 2964
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int N,i,count=0;
  cin >> N;
  vector<int> p(N);
  for(i=0;i<N;i++)cin >> p[i];
  for(i=0;i<N;i++)if(p[i] != i+1)count++;
  if(count == 0 || count == 2)cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 998244353;

int main() {
    Int s;
    cin >> s;
    Int x[6] = {};
    x[0] = x[1] = 0;
    if (s <= 1e9) {
        x[2] = 0;
        x[3] = 1;
        x[4] = s;
        x[5] = 0;
        for (Int i = 0; i < 6; i++) cout << x[i] << " ";
        cout << endl;
    }
    else {
        Int ok = 1e9;
        Int ng = 0;
        while (abs(ok - ng) > 1) {
            Int mid = (ok + ng) / 2;
            if (s <= mid * mid)  {
                ok = mid;
            }
            else {
                ng = mid;
            }
        }
        x[2] = x[5] = ok;
        Int bc = ok * ok - s;
        if (bc == 0) {
            x[3] = x[4] = 0;
        }
        else {
            x[3] = 1;
            x[4] = bc;
        }
        for (Int i = 0; i < 6; i++) cout << x[i] << " ";
        cout << endl;
        //cout << ok * ok - bc << endl;
    }
    return 0;
}

Measured memory_bytes: 256
K, N = map(int, input().split())
A = list(map(int, input().split()))
length = []

for i in range(N-1):
  length.append(abs(A[i]-A[i+1]))


length.append(K-sum(length))

max_l = length[0]
for j in range(N):
  if max_l <= length[j]:
    max_l = length[j]
  else:
    pass


length.remove(max_l)
result = sum(length)
print(result)

Measured memory_bytes: 32388