akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <map>

using namespace std;


int main(void) {
	int a, b,c=0,d;
	cin >> a >> b;
	if (a >= b) {
		c++;
	}
	for (int i = 1; i < a; i++) {

		cin >> d;
		if (b >= d) {
			c++;
          	b = d;
		}
		else {

		}
	}
	cout << c << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define BUF_SIZE 30

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}
#define PACKS_MAX 100000
#define TRACKS_MAX 100000

int desc(const void *a, const void *b) {
    return *(int*)b - *(int*)a;
}

int asc(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int judge(int *cum, int size, int tracks, int key) {
    int cnt;
    int prev = 0;
    for(cnt = 0; cnt < tracks; cnt++) {
        int low = prev-1;
        int high = size;
        while(low + 1 < high) {
            int mid = (low+high)/2;
            // [prev, mid)
            int rsum = cum[mid] - cum[prev];
            // upper bound
            if(rsum <= key) {
                low = mid;
            } else {
                high = mid;
            }
        }
        prev = low;
        // no packages
        if(prev == size-1) break;
#ifdef DEBUG
        printf("prev: %d\n", prev);
#endif
    }
    return (prev == size-1);
}

#define max(a,b) ((a) > (b) ? (a) : (b))

int main(void) {
    int ps, tracks;
    get_int2(&ps, &tracks);
    int i;
    int low = 0;
    static int cum[PACKS_MAX+1];
    for(i = 1; i <= ps; i++) {
        int p = get_int();
        cum[i] = cum[i-1] + p;
        low = max(low, p);
    }

    int high = cum[ps];
    low--; high++;
    // binary-search
    while(low + 1 < high) {
        int mid = (low + high)/2;
        // lower bound
        if(judge(cum, ps+1, tracks, mid)) {
            high = mid;
        } else {
            low = mid;
        }
    }
    printf("%d\n", high);
    return 0;
}


Measured memory_bytes: 2188
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	private long gcd(long m, long n) {
		long temp;
		while((temp = m%n) != 0) {
			m = n;
			n = temp;
		}
		return n;
	}
	
	private long lcm(long m, long n) {
		return (m*n)/gcd(m,n);
	}
	
	private long f(long a, long b) { // a以下の、bでわりきれるかず
		return a/b;
	}
	
	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		
		sc.close();
		a--;
		long aa = a - (f(a, c) + f(a,d) - f(a, lcm(c,d)));
		long bb = b - (f(b, c) + f(b,d) - f(b, lcm(c,d)));
		long ans =  bb-aa;
		
		out.println(ans);
		

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
	
	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray1origin(Scanner sc, int n) {
		int[] result = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 22612
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,p,e=0,o=0;
  cin>>n>>p;
  in a;
  forn(z,n){
    cin>>a;
    if(a%2)
      ++o;
    else
      ++e;
  }
  in s=(1LL<<e);
  if(o==0){
    if(p==1)
      s=0;
  }
  else{
    s*=(1LL<<(o-1));
  }
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define itn int
#define gI gi

using namespace std;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int n, m, a[200003];
string ss, t;

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi();
	for (int i = 1; i <= n; i+=1) a[i] = gi();
	sort(a + 1, a + 1 + n);
	for (int i = 1; i < n; i+=1) if (a[i] == a[i + 1]) {puts("NO"); return 0;}
	puts("YES");
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  char c;
  cin >> c;
  
  vector<char> v = {'a', 'e', 'i', 'o', 'u'};
  bool flag = false;
  rep(i, 5) {
    if (c == v[i]) flag = true;
  }
  cout << ((flag) ? "vowel" : "consonant") << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
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;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n,-1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int main() {
  	//根の直径が答え
    int N, M; cin >> N >> M;
    vector<int> X(M), Y(M), Z(M);
    for (int i = 0; i < M; ++i) cin >> X[i] >> Y[i] >> Z[i], --X[i], --Y[i];
    UnionFind uf(N);
    for (int i = 0; i < M; ++i) uf.unite(X[i], Y[i]);
    set<int> se;
    for (int i = 0; i < N; ++i) se.insert(uf.root(i));
    p((int)se.size());
}

Measured memory_bytes: 6528
#!/usr/bin/env python3
import sys
from collections import Counter
from scipy.misc import comb

def solve(N: int, s: "List[str]"):
    print(sum([comb(v, 2, exact=True) for v in Counter(s).values()]))

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

if __name__ == '__main__':
    main()


Measured memory_bytes: 31096
h, n = map(int, input().split()) 
magics = sorted([list(map(int, input().split())) for _ in range(n)])
max_a = magics[-1][0]

dp = [float("inf")] * (h + max_a)
dp[0] = 0

for ai, bi in magics:
  for i in range(h + max_a - ai):
    if dp[i] != float("inf"):
      dp[i + ai] = min(dp[i] + bi, dp[i + ai])


print(min(dp[h:h + max_a]))

Measured memory_bytes: 72036
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX_ARRAY 100

int selectSort(int *a, int n) {
	int count = 0;
	for (int i = 0; i < n; i++) {
		int min_idx = i;
		for (int j = i+1; j < n; j++) {
			if (a[j] < a[min_idx]) {
				min_idx = j;
			}
		}
		if (i != min_idx) {
			swap(a[i], a[min_idx]);
			count++;
		}
	}

	return count;
}


int main(void) {
	int n = 0, R[MAX_ARRAY] = { 0 };
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> R[i];
	}

	int sc = selectSort(R, n);
	for (int i = 0; i < n; i++) {
		if (i != 0) {
			cout << ' ';
		}
		cout << R[i];
	}
	cout << endl << sc << endl;
	return 0;
}

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

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

    map<int, int> ma;
    int flag = 0;
    for(int i = 0; i < n; i++){
        if(a[i] != 1){
            auto itr = ma.find(a[i]);
            if(itr == ma.end()){
                ma[a[i]] = 1;
            }else{
                flag = 1;
                break;
            }
        }
        
        for(int j = 2; j * j <= a[i]; j++){
            if(a[i] % j == 0){
                auto itr = ma.find(j);
                if(itr == ma.end()){
                    ma[j] = 1;
                }else{
                    flag = 1;
                    break;
                }
                int t = a[i] / j;
                if(j != t){
                    auto itr_2 = ma.find(t);
                    if(itr_2 == ma.end()){
                        ma[t] = 1;
                    }else{
                        flag = 1;
                        break;
                    }
                }
            }
        }

        if(flag == 1){
            break;
        }
    }

    if(flag == 0){
        cout << "pairwise coprime" << endl;
    }else{
        int k = a[0];
        for(int i = 1; i < n; i++){
            k = gcd(k, a[i]);
            if(k == 1){
                flag = 2;
                break;
            }
        }

        if(flag == 2){
            cout << "setwise coprime" << endl;
        }else{
            cout << "not coprime" << endl;
        }
    }
}

Measured memory_bytes: 7592
n = int(input())
k = int(input())
x = list(map(int, input().split()))
ans = 0
for i in range(n):
    b = abs(k - x[i])
    if x[i] > b:
        ans += 2 * b
    else:
        ans += 2 * x[i]
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>

using namespace std;

long long a[100002];
long long b[100002];
long long h[100002];

int main(){
	int n;
	cin >> n;
	long long ans = 0;
	for (int i = 0; i < n+1; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		cin >> b[i];
	for (int i = 0; i < n; ++i)
	{
		if(i == 0){
			if(a[i] >= b[i]) {
				ans += b[i];
				h[i] = 0;
			}
			else {
				ans +=a[i];
				h[i] = b[i] - a[i];
			}	
		}
		else {
			if(a[i] >= b[i] + h[i-1]){
				ans +=b[i] + h[i-1];
				h[i] = 0;
			}	
			else {
				ans +=a[i];
				if(h[i-1] >= a[i])
					h[i] = b[i];
				else 
					h[i] = h[i-1] + b[i] - a[i];
			}
		}
	}

	if(a[n] < h[n-1]) ans += a[n];
	else ans +=h[n-1];
	
	cout << ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    ll k;cin >> k;
    set<ll> s;
    rep(i,k){
        ll d;cin >> d;
        rep(j,d){
            ll x;cin >> x;
            s.ins(x);
        }
    }
    cout << n-s.size() <<endl;
}

Measured memory_bytes: 3628
loop{
a,op,b = gets.split.map(&:to_s)
a = a.to_i
b = b.to_i
if op == "+"
    puts a + b
elsif op == "-"
    puts a - b
elsif op == "*"
    puts a * b
elsif op == "/"
    puts a / b
elsif op == "?"
    break
end
}


Measured memory_bytes: 6876
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
 
int main() {
  int n, cnt;
  vector<int> nums;
  auto insertionSort = [&nums, &n, &cnt](int d) {
    for(int i = d; i < n; ++i) {
      int top = nums[i];
      int j;
      for(j = i - d; j >= 0 && nums[j] > top; j -= d) {
        nums[j + d] = nums[j];
        ++cnt;
      }
      nums[j + d] = top;
    }
  };
  auto shellSort = [&nums, &n, insertionSort]() {
    int maxid = log(2 * n + 1) / log(3) - 1;
    cout << maxid + 1 << endl;
    for(int id = maxid; id >= 0; --id) {
      unsigned int d = (pow(3, id + 1) - 1) / 2;
      cout << d << (id == 0 ? "\n" : " ");
      insertionSort(d);
    }
  };
  cin >> n;
  nums = vector<int>(n);
  for(int& c: nums) cin >> c;
  cnt = 0;
  shellSort();
  cout << cnt << endl;
  for(auto&& c: nums) cout << c << endl;
  return 0;
}


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

const int INF = 1e9;
const int MOD = 998244353;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> vpii;
    REP(i, k)
    {
        ll a, b;
        cin >> a >> b;
        vpii.push_back({ a, b });
    }
    vector<ll> memo(n+1,0);
    memo[1]=1;
    vector<vector<int>> start(n+1);
    vector<vector<int>> stop(n+1);
    set<int> si;
    ll a=0;
    FOR(i,1,n+1){
        if(!start[i].empty()){
            REP(j,start[i].size()){
                a+=memo[start[i][j]];
                a%=MOD;
            }
        }
            memo[i]+=a;
            memo[i]%=MOD;
        REP(j,k){
            if(i+vpii[j].first<=n)
            start[i+vpii[j].first].push_back(i);
            if(i+vpii[j].second<=n)
            stop[i+vpii[j].second].push_back(i);
        }
        if(!stop[i].empty()){
            REP(j,stop[i].size()){
                a=a-memo[stop[i][j]]+MOD;
                a%=MOD;
            }
        }
    }
    cout<<memo[n]<<endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll D;
    cin >> D;
    vector<ll> C(26);
    rep(i, 26) cin >> C[i];
    vector<vector<ll>> S(D, vector<ll>(26));
    rep(i, D) {
        rep(j, 26) {
            cin >> S[i][j];
        }
    }
    vector<ll> T(D);
    rep(i, D) cin >> T[i];
    vector<ll> last(26, 0);

    vector<ll> ans(D);
    ll sum = 0;
    rep(d, D) {
        ll t = T[d];
        sum += S[d][t - 1];
        last[t - 1] = d + 1;
        rep(i, 26) {
            sum -= C[i] * ((d + 1) - last[i]);
        }
        ans[d] = sum;
    }
    ll M;
    cin >> M;
    vector<P> query(M);
    rep(i, M) cin >> query[i].first >> query[i].second;
    rep(i, M) {
        P p = query[i];
        ll d2 = query[i].first;
        ll q = query[i].second;
        sum = 0;
        last.assign(26, 0);
        rep(d, D) {
            ll t = T[d];
            if (d == d2 - 1) {
                t = q;
                T[d] = t;
            }
            sum += S[d][t - 1];
            last[t - 1] = d + 1;
            rep(j, 26) {
                sum -= C[j] * ((d + 1) - last[j]);
            }
        }
        cout << sum << '\n';
    }
}

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


Measured memory_bytes: 4680
import sys
sys.setrecursionlimit(10**6)

n = int(input())
graph = []
chart = [[int(i)] for i in range(1,n+1)]
for i in range(n):
    z = [c-1 for c in list(map(int,input().split()))][2:]
    graph.append(z)
time = 0

def dfs(nod):
    global graph
    global time
    #break condition
    if len(chart[nod]) != 1:
        return 
    #end condition not necessary
    #if not graph[nod]:
    #    time += 1
    #    chart[nod].append(time)
    #    return
    # command
    time += 1
    chart[nod].append(time)
    
    # move
    for dis in graph[nod]:
            dfs(dis)

    # post-command
    time += 1
    chart[nod].append(time)
for i in range(n):
    dfs(i)
for i in range(n):
    print(*chart[i])



Measured memory_bytes: 5656
# -*- coding: utf-8 -*-

#すぬけくんは N 本の棒を持っています。 i 番目の棒の長さは li です。
#すぬけくんは K 本の棒を選んでつなげて、ヘビのおもちゃを作りたいです。
#ヘビのおもちゃの長さは選んだ棒たちの長さの総和で表されます。 
#ヘビのおもちゃの長さとしてありうる長さのうち、最大値を求めなさい。

A = input().split()
B = input().split()
#A = [5, 3]
#B = [1, 2, 3, 4, 5]
#A = [15, 14]
#B = [50, 26, 27, 21, 41, 7, 42, 35, 7, 5, 5, 36, 39, 1, 45]

N = int(A[0])
K = int(A[1])

C = []

for i in range(N):
    C.append(int(B[i]))

D = sorted(C)

ans = 0

for i in range(K):
    x = N - i -1
    ans = ans + D[x]

print(ans)


Measured memory_bytes: 3060
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    s=2
    k=1
    for i in range(1,1000):
        if k==n:
            print("Yes")
            break
        if k>n:
            print("No")
            sys.exit()
        k+=s
        s+=1
    lis=[[]for _ in range(s)]
    x=1
    for i in range(s-1):
        for j in range(i+1,s):
            lis[i].append(x)
            lis[j].append(x)
            x+=1
    print(len(lis))
    for l in lis:
        print(str(len(l))+' '+' '.join(map(str,l)))

    

if __name__=='__main__':
    main()

Measured memory_bytes: 43740
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>
#include<math.h>

typedef int32_t i32;
typedef int64_t i64;

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) > (0) ? (a) : -(a))
#define ALLOC(size,type) ((type*) calloc ((size), sizeof (type)))

void run (void) {
  i32 n, m;
  scanf ("%" SCNi32 "%" SCNi32, &n, &m);
  i32 *cnt = ALLOC (n + 1, i32);
  char *s = ALLOC (n + 1, char);
  for (i32 i = 0; i < m; ++i) {
    scanf ("%s", s);
    for (i32 j = 0; j < n; ++j) {
      cnt[j] += s[j] == 'E' ? 1 : 0;
    }
  }
  for (i32 i = n - 1; i >= 0; --i) {
    cnt[i] += cnt[i + 1];
  }
  i32 min_index = 0;
  i32 min = n * m - cnt[0];
  for (i32 i = 1; i <= n; ++i) {
    i32 v = (n - i) * m - cnt[i] + (cnt[0] - cnt[i]);
    if (v < min) {
      min = v;
      min_index = i;
    }
  }
  printf ("%" PRIi32 " %" PRIi32 "\n", min_index, min_index + 1);
}

int main (void) {
  run();
  return 0;
}



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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(int (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(int (i) = (ceiling); (i) >= (bottom); --(i))
#define pub push_back
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define clr(a) memset((a),0,sizeof(a))
#define all(v)  begin((v)),end((v))

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const vector<pair<int,int>> DIR = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF = -1 + (1<<30);
const int MOD = (int)1e9 + 7;

template<typename T> T gcd(T a,T b){ if(a % b){ return gcd(b,a % b); }else{ return b; } }

template<typename T> T lcm(T a,T b){ return a / gcd(a,b) * b; }

long long Pow(long long n,long long m,int mod = MOD){
	long long res = 1,pow = n % mod;
	while(m) {
		if(m & 1) res = (res * pow) % mod;
		pow = (pow * pow) % mod;
		m >>= 1;
	}
	return res;
}

vector<long long> Frac(int range,int mod = MOD){
	vector<long long> frac;
	frac.push_back(1);
	for(int i = 1; i <= range; ++i) frac.push_back((long long)frac.back() * i % mod);
	return frac;
}

long long Comb(int n,int m,int mod = MOD){
	if(n < m || m < 0) return 0;
	vector<long long> frac(Frac(n,mod));
	long long rev = Pow((long long)frac[m] * frac[n-m] % mod,mod-2,mod);
	return rev * frac[n] % mod;
}

template<class T,class U> auto LB(T v,U in){ return lower_bound(v.begin(),v.end(),in); }

template<class T,class U> auto UB(T v,U in){ return upper_bound(v.begin(),v.end(),in); }

unsigned long long next_subset(unsigned long long subset){
	unsigned long long tem = subset + (subset & -subset);
	unsigned long long btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}


int N;
ll C,x[100002],v[100002];

void solve(){
	ll cw_now,acw_now,cw_last = 0,acw_last = 0;
	ll max_cw_1[100002], max_cw_2[100002], max_acw_1[100002], max_acw_2[100002];
	max_cw_1[0] = max_cw_2[0] = max_acw_1[0] = max_acw_2[0] = 0;
	rep1(i,N){
		cw_now = cw_last+x[i-1]-x[i]+v[i];
		acw_now = acw_last-x[N+2-i]+x[N+1-i]+v[N+1-i];
		max_cw_1[i] = max(max_cw_1[i-1],cw_now);
		max_cw_2[i] = max(max_cw_2[i-1],cw_now - x[i]);
		max_acw_1[i] = max(max_acw_1[i-1],acw_now);
		max_acw_2[i] = max(max_acw_2[i-1],acw_now - C + x[N+1-i]);
		cw_last = cw_now;
		acw_last = acw_now;
	}
	ll ans=0;
	rep(i,N+1) ans = max(ans, max_cw_1[i] + max_acw_2[N - i]);
	rep(i,N+1) ans = max(ans, max_cw_2[i] + max_acw_1[N - i]);
	cout<<ans<<endl;
	return;
}

void input(){
	cin>>N>>C;
	x[0]=v[0]=v[N+1]=0;
	x[N+1]=C;
	rep1(i,N) cin>>x[i]>>v[i];
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	input();
	solve();
	return 0;
}





Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int ans = 60 * H2 + M2;
  ans -= 60 * H1 + M1 + K;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll n, t;
    cin >> n >> t;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    ll ans = t;
    rrep(i, n - 1) {
        ll m = v[i] - v[i - 1];
        ans += min(m, t);
    }
    cout << ans << endl;
  
    return 0;
}

Measured memory_bytes: 1792
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    ll a, b, n;
    cin >> a >> b >> n;
    ll r = n%b;
    if (n < b) {
        cout << (a*r)/b << endl;
    }
    else {
        cout << (a*(b-1))/b << endl;
    }
    return 0;
}




Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,n,m;
	cin>>n>>m;
    long long a=0,b=0,c;
    for(i=0;i<n;i++)
    a=(a*10)+m;
	for(i=0;i<m;i++)
    b=(b*10)+n;
    c=a>b?a:b;
    cout<<c;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	var cnt int
	for i := 1; i <= n; i++ {
		s := strconv.Itoa(i)
		if len(s)%2 == 1 {
			cnt++
		}
	}
	fmt.Println(cnt)
}


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

using namespace std;

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




int main() {
   long long a,b,c,d;
 
   cin>>a>>b>>c>>d;
   long e=min(a,b);
   long  f=max(a,b);
   long long co=0;
 //  cout<<"ee"<<ee;
     // cout<<"f"<<f;
      // cout<<"e"<<e;
   
   //cout<<"ff"<<ff;
   //cout<<"CO"<<co;
   
   
   
   
 long long g=(e-1)/c;
 long long gg=(f)/c;
co+= gg-g;
 long long h=(e-1)/d;
 long long hh=f/d;
 co+=hh-h;
 long long m1=max(c,d);
  long long m2=min(c,d);
 long long i=(e-1)/((c*d)/gcd(m1,m2));
 long long ii=f/((c*d)/gcd(m1,m2));
 co-=ii-i;

 cout<<f-e+1-co;
 
   
 
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main(){
#ifdef CIN
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif

	int x;

	cin >> x;

	int h, m, s;

	h = x / 3600;

	x %= 3600;

	m = x / 60;

	x %= 60;

	s = x;

	cout << h << ":" << m << ":" << s << endl;


	return 0;
}

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

int main() {
  int N, K, num = 1;

  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int A, B;
    A = num * 2;
    B = num + K;
    if (A < B) num = A;
    else num = B;
  }
  cout << num << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;

int main()
{
	char a[20];
	scanf("%s",a);
	int len = strlen(a);
	for(int i = 0 ; i < len ; i++)
		{
		if(a[i] == ',')cout << " ";
		else cout << a[i];
		}
		cout << endl;
	return 0;
	}

Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353



x, y = list(map(int, sys.stdin.buffer.readline().split()))
print(int(x + y // 2))


Measured memory_bytes: 13340
#!/usr/bin/env python3
import sys
from itertools import accumulate
INF = float("inf")


def solve(N: int, C: int, x: "List[int]", v: "List[int]"):

    # 時計回りターンなし
    nt_cost = x
    nt_benefit = accumulate(v)
    nt_callory = [b-c for c, b in zip(nt_cost, nt_benefit)]
    nt_callory_acc = list(accumulate([0]+nt_callory, max))

    # 反時計回りターンなし
    rnt_cost = [C-v for v in reversed(x)]
    rnt_benefit = accumulate(reversed(v))
    rnt_callory = [b-c for c, b in zip(rnt_cost, rnt_benefit)]
    rnt_callory_acc = list(accumulate([0]+rnt_callory, max))

    # 時計回り
    m = max(nt_callory_acc[-1], rnt_callory_acc[-1])
    for i in range(N-1):
        callory = nt_callory[i]-nt_cost[i]+rnt_callory_acc[N-i-1]
        m = max(m, callory)

    # 反時計回り
    for i in range(N-1):
        callory = rnt_callory[i]-rnt_cost[i]+nt_callory_acc[N-i-1]
        m = max(m, callory)

    print(max(0, m))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, C, x, v)


if __name__ == '__main__':
    main()


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

#define MAXN 500005

typedef long long lint;

using namespace std;

char s[MAXN];
int n;
lint a[MAXN], b[MAXN];

bool check(int k) {
    lint up = 0;
    for (int i = n; i >= 2; --i) {
        lint cur = ((a[i] - up - 9ll * k) % 10 + 10) % 10;
//        cout << (9 * k + cur) << endl;
        up = (9ll * k + cur + up) / 10;
        lint last = ((a[i - 1] - up - 9ll * k) % 10 + 10) % 10;
        if (last > cur)
            --k;
    }
    return k >= 0;
}

int solve() {
//    return check(3);
    int l = 1, r = 500000, res = -1;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (check(mid)) {
            res = mid;
            r = mid - 1;
        }
        else
            l = mid + 1;
    }
    return res;
}

int main() {
//    freopen("in31.txt", "r", stdin);
    scanf("%s", s + 1);
    n = (int)strlen(s + 1);
    for (int i = 1; i <= n; ++i)
        a[i] = s[i] - '0';
    int ans = solve();
    if (((a[n] - 9ll * ans) % 10 + 10) % 10 != 0)
        ++ans;
    printf("%d\n", ans);
}



Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a>b){
    if(b==1){
      cout<<"Bob"<<endl;
    }
    else cout<<"Alice"<<endl;
  }else if(a<b){
    if(a==1){
      cout<<"Alice"<<endl;
    }
     else cout<<"Bob"<<endl;
  }else{
    cout<<"Draw"<<endl;
  }
}


Measured memory_bytes: 256
#include<algorithm>
#include<limits.h>
#include<stdio.h>
#include<string.h>
#include<vector>
#include<queue>


int main(void) {
	int A = 0, B = 0;
	scanf("%d%d", &A, &B);
	if (A == 1)
		A += 20;
	if (B == 1)
		B += 20;
	if (A > B)
		printf("Alice\n");
	else if (A < B)
		printf("Bob\n");
	else
		printf("Draw\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
	int m, f, r;
	while (1) {
		scanf("%d %d %d", &m, &f, &r);
		if (m == -1 && f == -1 && r == -1)break;
		if (m == -1 || f == -1)printf("%c\n", 'F');
		else if (m + f >= 80)printf("%c\n", 'A');
		else if (m + f >= 65)printf("%c\n", 'B');
		else if (m + f >= 50 || r >= 50)printf("%c\n", 'C');
		else if (m + f >= 30)printf("%c\n", 'D');
		else printf("%c\n", 'F');
	}
}


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

int main()
{
    long n,k;
    cin >> n >> k;
    
    vector<int> a(n);
    for(long  i=0;i<n;i++)
        cin >> a[i];
    
    long dp[n];
    for(long i=0;i<n;i++)
        dp[i] = LONG_MAX;
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    
    for(int i=2;i<n;i++)
    {
        if(i-k < 0)
        {
            for(int j=i;j>=0;j--)
            {
                dp[i] = min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
            }
        }
        else
        {
            for(int j=k;j>=0;j--)
            {
                dp[i] = min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
            }
        }
        
        //dp[i] = min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
    }
    cout << dp[n-1] <<"\n";
    
}

Measured memory_bytes: 4544
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	res := make([]int, 0, n)

	min := math.MaxInt64
	max := -1

	for i := 0; i < n; i++ {
		sc.Scan()
		v, _ := strconv.Atoi(sc.Text())

		var ok bool

		if v > min {
			for i, r := range res {
				if r >= v {
					continue
				}
				res[i] = v
				ok = true
				if v > max {
					max = v
				}
				break
			}
		}

		if !ok {
			res = append(res, v)
			if v < min {
				min = v
			}
		}
	}

	fmt.Println(len(res))
}


Measured memory_bytes: 3072
N = int(input())
ans = 0
l = N//2
for i in range(1, l+1): #約数についてのループ
    n = N//i
    ans += i*n*(n+1)//2
    
# 約数がl+1より大きい時は、それを約数に持つ数は1個しかない(それ自身)
ans += (l+1+N)*(N-l)//2

print(ans)

Measured memory_bytes: 9084
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x)     		(x).begin(),(x).end()
#define ub    			upper_bound
#define lb 				lower_bound
#define ins				insert
#define int 			long long
#define endl			'\n'
#define ff              first
#define ss              second
#define ull				unsigned long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define si 				set<int>
#define usi 			unordered_set<int>		
#define mii             map<int,int>
#define umii			unordered_map<int ,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,a,n)		for(int i=a;i<n;++i)
#define repd(i,a,n)		for(int i=a;i>n;--i)
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define deb(x)			cout<<#x <<"="<<x<<endl;
#define deb2(x,y)		cout<<#x<<"="<<x<<"  "<<#y<<"="<<y<<endl;
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int Pow(int a,int b){int res=1;while(b>0){if(b&1)res*=a;a*=a;b/=2;}return res;}
int MPow(int a,int  b){int res=1;while(b>0){if(b&1)res=(res*a)%Mod;a=(a*a)%Mod;b/=2;}return res%Mod;}
int log(int x){return 64-__builtin_clzll(x)-1;}

void c_p_p()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
}
struct Node
{
	int a,b,c,d;
	
};
bool cmp(Node A,Node B)
{
	return A.a<B.a;
}
const int Max=1e5+1;

int32_t main()
{
	c_p_p();
	int n;
	cin>>n;
	int A[n+1],ans=0;
	rep(i,1,n+1)
	{
		cin>>A[i];
		if(i&1 && A[i]&1)
		{
			++ans;
		}

	}
	cout<<ans;
	
	return 0;
}
	

Measured memory_bytes: 3644
n = gets.to_i
if n.digits[0] == 2 || n.digits[0]== 4 || n.digits[0] == 5 || n.digits[0] == 7 || n.digits[0] == 9
  puts 'hon'
elsif n.digits[0] == 0 || n.digits[0] == 1 || n.digits[0] == 6 || n.digits[0] == 8
  puts 'pon'
else
  puts 'bon'
end

Measured memory_bytes: 14312
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
const int mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n,r; cin >> n >> r;
    if(n >= 10) cout << r << endl;
    else cout << r + 100*(10-n) << endl;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
s=[list(map(str,list(input()))) for i in range(h)] 

for i in range(1,h-1):
    for j in range(1,w-1):
        if s[i][j]=='#':
            if s[i-1][j]=='.' and s[i][j-1]=='.' and s[i][j+1]=='.' and s[i+1][j]=='.':
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 39024
/* به نام یزدان */
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	vector<int> d(4), d0 = {1, 1, 2, 2};
	for (int i = 0; i < 6; i++) {
		int a;
		cin >> a;
		d[a - 1]++;
	}
	sort(d.begin(), d.end());
	if (d == d0)
		cout << "YES";
	else 
		cout << "NO";
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    long long a, b;
    while (cin >> a >> b)
    {
        int ans = 1;
        while ((a << 1) <= b)
        {
            ans++;
            a = a << 1;
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<map>
#include<utility>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
    ll t,n,i,m,x,y,k,j;
    string s;
    cin>>k;
    cin>>s;
    ll l=s.length();
    for(i=0;i<l&&i<k;i++)
        cout<<s[i];
    if(l>k)
        cout<<"...";


}




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

using namespace std;

int main(){
    int a,b,c; cin >> a >> b >> c;
    int big = max(a,max(b,c));
    int diff = big*3-(a+b+c);
    if(diff%2 != 0) {
        big++;
    }
    cout << (big*3-a-b-c)/2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> pi;
typedef long long ll;
int main(){
	ll n,y;
	cin>>n>>y;
	ll maxbill = y/1000;
	if(n>maxbill) cout<<-1<<" "<<-1<<" "<<-1;
	else if(n==maxbill) cout<<0<<" "<<0<<" "<<maxbill;
	else{
		ll diff = maxbill-n;
		// 9a + 4b = diff;
		for(int i=0; i<=n; i++){
			for(int j=0; j<=n; j++){
				if(9*i+4*j==diff && n-j-i>=0){
					cout<<i<<" "<<j<<" "<<n-j-i;
					return 0;
				}
			}
		}
		cout<<-1<<" "<<-1<<" "<<-1;
	}
}

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

int main(){
//
   int N,M;
   cin>>N>>M;
   int ans = 0;
   vector<int> L(M,0);//0埋め
   for (int i = 0; i < N; ++i) {
     int K;
     cin>>K;
     for (int j = 0; j < K; ++j) {
     int A;
     cin >> A;
     L[A-1]+=1;
    }
}
//
for(int i=0;i<M;++i){
  if(L[i]==N) ans+=1;
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <math.h>
#include <bits/stdc++.h>
#include <deque>
#define ll long long
#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
#define val 1000000000000000000
using namespace std;
int main()
{
    ll a,b;
    cin>>a>>b;
    ll sum=a+b;
    cout<<6-sum<<endl;
}


Measured memory_bytes: 256
r,g,b,n=map(int,input().split())
ans=0
for i in range(3001):
    for j in range(3001):
        if (r*i+g*j)<=n:
            z=n-(r*i+g*j)
            if z%b==0:
                #print(i,j)
                ans+=1
        
print(ans)



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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    int mx = 0;
    int p;
    int ans = 0;
    REP(i, n) {
        cin >> p;
        ans += p;
        chmax(mx, p);
    }
    cout << ans - (mx / 2) << EOL;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main(){
    int n;
    string s;
    cin >> n >> s;
    char cur = s[0]; int cnt = 1;
    for(int i = 0; i < n; i++){
        if(cur != s[i]){
            cnt++;
            cur = s[i];
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
long long a,b,c,d;
cin >>a >>b >>c >>d;
long long x,y;
x = max(a*c , b*d);
y = max(a*d, b*c);
x = max(x,y);
cout <<x;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int a, b;
	string op;
	while(1){
		cin >> a >> op >> b;
		if(op == "+"){
			cout << a + b << endl;;
		}else if(op == "-"){
			cout << a - b << endl;
		}else if(op == "/"){
			cout << a / b << endl;
		}else if(op == "*"){
			cout << a * b << endl;
		}else{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3140
from sys import maxsize
from itertools import product

n, k = map(int, input().split())
p = list(map(lambda x: int(x)-1, input().split()))
c = list(map(int, input().split()))

used = [0] * n
ss = []
for i in range(n):
    if used[i]:
        continue
    now = i
    s = []
    while not used[now]:
        used[now] = 1
        s.append(c[now])
        now = p[now]
    ss.append(s)

res = -maxsize
for s in ss:
    s_len = len(s)
    cumsum = [0]
    # 2周分の累積和
    for i in range(2*s_len):
        cumsum.append(cumsum[-1] + s[i%s_len])

    max_sum = [-maxsize] * s_len
    for i, j in product(range(s_len), repeat=2):
        max_sum[j] = max(max_sum[j], cumsum[i+j] - cumsum[i])

    for i in range(s_len):
        if i > k:
            continue
        v = (k - i) // s_len
        if i == 0 and v == 0:
            continue
        if cumsum[s_len] > 0:
            res = max(res, max_sum[i] + cumsum[s_len] * v)
        elif i > 0:
            res = max(res, max_sum[i])
print(res)


Measured memory_bytes: 74792
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int A, B, C; cin >> A >> B >> C;
    if (A+B+C>21) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
}


Measured memory_bytes: 256
def main(s, k)
  sorted_subs = s.size.times.map do |i|
    s[i..-1]
  end.sort
  sorted_subs.each_with_object([]) do |str, strs|
    ss = str.size.times.map do |i|
      str[0..i]
    end
    strs.concat(ss)
    strs = strs.uniq

    return strs[k - 1] if strs.size >= k
  end
end

s = gets.chomp
k = gets.to_i
puts main(s, k)

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int R, G, B, N; cin >> R >> G >> B >> N;
    ll ans = 0;
    for(int x = 0; x*R <= N; x++){
        for(int y = 0; x*R + y*G <= N; y++){
            int rem = N-x*R-y*G;
            if(rem == 0 || rem % B == 0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1000000000000000000L;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int extgcd(int a, int b, int& x, int&y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else {
        x = 1;
        y = 0;
    }
    return d;
}

int inv(int a) {
    int x, y;
    extgcd(a, MOD, x, y);
    return (x + MOD) % MOD;
}

const int MAX_N = 1000000;
ll sum[MAX_N + 1];

int main() {
    sum[1] = 2;
    for(int i = 2; i <= MAX_N; i++) {
        int x = i;
        int res = x;
        for(int j = 2; j * j <= x; j++) {
            if(x % j == 0) {
                res -= res / j;
                while(x % j == 0) x /= j;
            }
        }
        if(x > 1) res -= res / x;
        sum[i] = sum[i - 1] + res;
    }

    int t;
    cin >> t;
    rep(i, t) {
        int n;
        cin >> n;
        cout << sum[n] << endl;
    }
}



Measured memory_bytes: 10928
N=int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if 4*h*n-N*n-h*N==0:
            continue
        w=(N*h*n)/(4*h*n-N*n-h*N)
        if w==int(w) and w>=1:
            print(h,n,int(w))
            exit()


Measured memory_bytes: 42848
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

typedef long long int lli;

using namespace std;

int main() {

   int K,A,B;
   cin >> K;
   cin >> A >> B;
   int flag =0;
   for(int i=A;i<B+1;i++){
  	 if(i%K==0){
   		flag=1;
     }
   }
   if(flag){
   		cout << "OK" << endl;
     }else{
   		cout << "NG" << endl;
   	 }
    
}

Measured memory_bytes: 3640
n = int(input())
branch = [[] for _ in range(n)]
a, b, inda, indb = [], [], [], []
for _ in range(n-1):
    i, j = map(int, input().split())
    i -= 1
    j -= 1
    branch[i].append(j)
    branch[j].append(i)
    a.append(i)
    b.append(j)
    inda.append(len(branch[i])-1)
    indb.append(len(branch[j])-1)

kind = max([len(i) for i in branch])
print(kind)

# DFS
color = [0 for _ in range(n)]
todo = [0]
color[0] = 1
while len(todo) > 0:
    num = todo.pop(-1)
    col = color[num]
    if col == kind:
        col = 1
    else:
        col = col + 1
    for i in range(len(branch[num])):
        if color[branch[num][i]] == 0:
            color[branch[num][i]] = col
            todo.append(branch[num][i])
            branch[num][i] = -col
            if col == kind:
                col = 1
            else:
                col = col + 1
            

for i in range(n-1):
    if branch[a[i]][inda[i]] < 0:
        print(-branch[a[i]][inda[i]])
    else:
        print(-branch[b[i]][indb[i]])

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

int main(){
	int N;
	cin>>N;
	long a[3*N];
	for(int i=0;i<3*N;++i) cin>>a[i];
	sort(a,a+3*N,greater<int>());
	long ans=0;
	for(int i=0;i<N;++i){
		ans+=a[2*i+1];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2560