akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int INT;

int main()
{
    int n;
    cin>>n;
    vector<int> A(n);
    vector<vector <int>> x(n);
    vector<vector <int>> y(n);
    for (int i=0; i<n;i++){
        cin>>A.at(i);
        for (int j=0;j<A[i];++j){
            int tempx,tempy;
            cin>>tempx>>tempy;
            tempx-=1;
            x.at(i).push_back(tempx);
            y.at(i).push_back(tempy);
        }
    }
    int ans=0;

    for (int i=0;i<(1<<n);++i){
        int cnt=0;
        bool ok=true;
        for (int j=0;j<n;j++){    
            if((i>>j)%2==0){
                continue;
            }
            else{
                cnt++;
                for (int k=0;k<A.at(j);k++){
                    if(y[j][k]==1){
                        if((i>>x[j][k])%2==0) {
                            ok=false;
                        }  
                    }
                    else if(y[j][k]==0){
                        if((i>>x[j][k])%2==1){
                            ok=false;
                        }
                    }
                }
            }
        }
        if(ok){
            ans=max(ans,cnt);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3596
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, D: int, X: int, A: "List[int]"):
    print(X + sum(
        -(-D // Ai)
        for Ai in A
    ))


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
    D = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, D, X, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define f first
#define s second
using namespace std;
int n, m;
vector<vector<int> > adjlist;
ll memo[100005];
ll solve(int v){
    if(adjlist[v].size()==0)
        return 0;
    ll &res = memo[v];
    if(res != -1)
        return res;
    for(int i = 0; i < adjlist[v].size(); ++i)
        res = max(res, 1 + solve(adjlist[v][i]));
    return res;
}
int main() {
    IO;
    memset(memo, -1, sizeof memo);
    cin >> n >> m;
    adjlist.resize(n+1);
    int x, y;
    for(int i = 0; i < m; ++i){
        cin >> x >> y;
        adjlist[x].push_back(y);
    }
    ll ans = 0;
    for(int i = 1; i <= n; ++i)
        ans = max(ans, solve(i));
    cout << ans;
    return 0;
}


Measured memory_bytes: 7936
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}

		sales := make([]int, 4000)
		members := make([]int, 0)
		memberCheck := make(map[int]bool)

		for i := 0; i < n; i++ {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			e, _ := strconv.Atoi(input[0])
			p, _ := strconv.Atoi(input[1])
			q, _ := strconv.Atoi(input[2])

			if e >= 1 && e <= 4000 && memberCheck[e] == false {
				members = append(members, e)
				memberCheck[e] = true
			}
			sales[e-1] += p * q
		}

		emptyFlag := true
		for _, v := range members {
			if sales[v-1] >= 1000000 {
				fmt.Println(v)
				emptyFlag = false
			}
		}

		if emptyFlag == true {
			fmt.Println("NA")
		}
	}
}



Measured memory_bytes: 1312
n = int(input())
a = [[int(i) for i in input().split()] for _ in range(n)]
a.sort(key=lambda x: x[1], reverse=True)
b=a[0][1]
for i in a:
    b = min(b, i[1]) - i[0]
if b >= 0:
    print('Yes')
else:
    print("No")


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll l = 0, r = n;
    auto f = [a, b](ll x) { return (a * x / b) - a * (x / b); };
    while (abs(r - l) > 1e7) {
        ll m1 = (2*l+r)/3, m2 = (l+2*r)/3;
        if (f(m1) < f(m2)) l = m1;
        else r = m2;
    }
    ll res = -LINF;
    for (ll i=l; i<=r; ++i) chmax(res, f(i));
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

long long N, K;


int main(){
	cin >> N >> K;
	vector<long long> p;
	for(long long i = 0; i < N; i++) {
		long long tmp;
		cin >> tmp;
		p.push_back(tmp);
	}

	sort(p.begin(), p.end());
	long long ans = 0;
	for(long long i = 0; i < K; i++) {
		ans += p[i];
	}
	cout << ans << endl;

}



Measured memory_bytes: 3596
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i=0; i<s.size(); i++)
        {
            if(s[i]=='?')
                {
                    s[i]='D';
                }
        }
    cout<<s<<endl;
}


Measured memory_bytes: 3372
#include <cstdio>
using namespace std;
const int MAXN = 1e4 + 7;
int p[MAXN], rank[MAXN];
int find(int x) {
	return p[x] == x ? x : (p[x] = find(p[x]));
}
int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    for (int i = 0; i < n; i++) {
    	p[i] = i;
	}
	while (q--) {
		int op, x, y;
		scanf("%d%d%d", &op, &x, &y);
		if (op) {
			if (find(x) == find(y)) printf("1\n");
			else printf("0\n");
		}
		else {
			int px = find(x), py = find(y);
			if (rank[px] > rank[py]) p[py] = px;
			else if (rank[px] < rank[py]) p[px] = py;
			else {
				p[py] = px;
				rank[px]++;
			}
		}
	}
	return 0;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

int n,k;
int main(){
  cin >> n >> k;
  vector<int>v(n);
  int ans = 0;
  for(int i = 0 ; i < n; i++) cin >> v[i];
  int cnt = min(n,k);
  for(int a = 0; a<=cnt; a++){
    for(int b = 0; b<=cnt-a;b++){
      vector<int>get;
      // cout <<"a:" << a <<" b:"<<b << endl;
      for(int i = 0; i<a; i++)get.push_back(v[i]);
      for(int i = 0; i<b; i++)get.push_back(v[n-1-i]);
      sort(all(get));
      // for(int i = 0; i < get.size(); i++)cout << get[i] << " ";
      // cout << endl;
      int tmp = accumulate(all(get), 0);
      // cout << (int)get.size() << endl;
      for(int i = 0; i < min(k-a-b, (int)get.size()); i++){
        if(get[i] < 0)tmp -= get[i];
      }
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
s = input()
t = input()
cmin = len(t)

for i in range(len(s)-len(t)+1):
  c = 0
  for j in range(len(t)):
    if not s[i+j] == t[j]:
      c += 1
  if c < cmin:
    cmin = c
    
print(cmin)

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

int n;
int u[500], v[500];
int res[500][500];

bool solve(int a, const vector<ull> &S, const vector<ull> &T, const vector<ull> &U, const vector<ull> &V) {
    rep(i, n) rep(j, n) res[i][j] = -1;
    rep(i, n) {
        u[i] = (U[i] >> a) & 1;
        v[i] = (V[i] >> a) & 1;
    }
    rep(i, n) rep(j, n) {
        if (!S[i] && u[i]) {
            if (T[j] && !v[j]) return false;
            res[i][j] = 1;
        } else if (S[i] && !u[i]) {
            if (!T[j] && v[j]) return false;
            res[i][j] = 0;
        } else if (T[j] && !v[j]) {
            res[i][j] = 0;
        } else if (!T[j] && v[j]) {
            res[i][j] = 1;
        }
    }

    rep(_, 2) {
        rep(i, n) {
            if (S[i] == !u[i]) continue;
            bool flg = false;
            vector<int> unk;
            rep(j, n) {
                if (res[i][j] == S[i]) flg = true;
                if (res[i][j] == -1) unk.push_back(j);
            }
            if (flg) continue;
            if (!unk.size()) return false;
            if (unk.size() == 1) res[i][unk[0]] = S[i];
        }
        rep(i, n) {
            if (T[i] == !v[i]) continue;
            bool flg = false;
            vector<int> unk;
            rep(j, n) {
                if (res[j][i] == T[i]) flg = true;
                if (res[j][i] == -1) unk.push_back(j);
            }
            if (flg) continue;
            if (!unk.size()) return false;
            if (unk.size() == 1) res[unk[0]][i] = T[i];
        }
    }
    vector<int> is, js;
    rep(i, n) {
        bool flg = true;
        rep(j, n) if (res[i][j]==-1) flg = false;
        if (!flg) is.push_back(i);
    }
    rep(i, n) {
        bool flg = true;
        rep(j, n) if (res[j][i]==-1) flg = false;
        if (!flg) js.push_back(i);
    }
    rep(i, is.size()) rep(j, js.size()) {
        res[is[i]][js[j]] = (i+j) % 2;
    }
    return true;
}

int main() {
    cin >> n;
    vector<ull> S(n), T(n), U(n), V(n);
    rep(i, n) cin >> S[i];
    rep(i, n) cin >> T[i];
    rep(i, n) cin >> U[i];
    rep(i, n) cin >> V[i];
    vector<vector<ull>> A(n, vector<ull>(n));
    rep(a, 64) {
        if (!solve(a, S, T, U, V)) {
            cout << -1 << endl;
            return 0;
        }
        rep(i, n) rep(j, n) A[i][j] |= ull(res[i][j]) << a;
    }
    rep(i, n) rep(j, n) {
        cout << A[i][j];
        if (j == n-1) cout << endl;
        else cout << " ";
    }
    return 0;
}

Measured memory_bytes: 9332
#include <iostream>
#include <cstdio>
#include <cstring>
 
using namespace std;

typedef long long ll;

const int MAX_N = 100000;
const int MOD = 1e9+7; // 10億7
int count[MAX_N];

int solve(int N)
{
    ll answer = 1;
    
    // 奇数
    if (N % 2 == 1)
    {
        // 奇数のときは 0 が一つだけ存在する (真ん中の人がいるので)
        if (count[0] != 1)
        {
            return 0;
        }
        // 真ん中の人以外は絶対値は偶数になる
        for (int i = 2; i < N; i += 2)
        {
            // 真ん中から前のパターン、後ろのパターンのみ存在する、それ以外は NG
            if (count[i] != 2)
            {
                return 0;
            }
            // 掛け算するたびに MOD して良い (これによってオーバーフローを防ぐ)
            answer *= 2;
            answer %= MOD;
        }
    }
    // 偶数
    else
    {
        // 絶対値はすべて奇数になる
        for (int i = 1; i < N; i += 2)
        {
            // 真ん中から前のパターン、後ろのパターンのみ存在する、それ以外は NG
            if (count[i] != 2)
            {
                return 0;
            }
            // 掛け算するたびに MOD して良い (これによってオーバーフローを防ぐ)
            answer *= 2;
            answer %= MOD;
        }
    }
    
    return answer;
}

int main()
{
    int answer;
    
    int N;
    cin >> N;
    
    for (int i = 0; i < N; i++)
    {
        int temp;
        cin >> temp;
        count[temp]++;
    }
    
    answer = solve(N);
    
    printf("%d\n", answer);

    return 0;
}


Measured memory_bytes: 640
from fractions import gcd
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

import copy
class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = N
        self.func = func
        self.I = copy.deepcopy(I)
        self.seg = [copy.deepcopy(I) for i in range(N * 2)]

    def assign(self, k, x):
        self.seg[k + self.sz] = copy.deepcopy(x)

    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = copy.deepcopy(x)
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = copy.deepcopy(self.I)
        R = copy.deepcopy(self.I)
        a += self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)

def main():
    N = int(readline())
    m = map(int, read().split())
    seg = SegmentTree(N, gcd, 0)
    for i in range(N):
        seg.assign(i, next(m))
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans, gcd(seg.query(0, i), seg.query(i+1, N)))
    print(ans)

main()

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

int main(){
  int n1,n2;
  cin>>n1>>n2;
  while(n1!=0){
  if(n1<n2){
    int temp=n2;
    n2=n1;
    n1=temp;
  }
    n1=n1%n2;
  }
  cout<<n2<<endl;
  
  return 0;
}

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

int main() {
    int h, m, s;
    for (int _i = 0; _i < 3; _i++) {
        cin >> h >> m >> s;
        const int s_in = h * 3600 + m * 60 + s;
        
        cin >> h >> m >> s;
        const int s_out = h * 3600 + m * 60 + s;
        const int time = s_out - s_in;

        // b: Between
        const int h_b = time / 3600, m_b = (time - h_b * 3600) / 60;

        cout << time / 3600 << " " << m_b << " "
             << time - h_b * 3600 - m_b * 60 << endl;
    }
}


Measured memory_bytes: 3100
# ABC065D

import sys
input=sys.stdin.readline
import heapq

class UnionFind:
    def __init__(self, n):
        self.p=[-1]*n
        self.size=[1]*n
    def root(self, x):
        st=set()
        while(self.p[x]>=0):
            st.add(x)
            x=self.p[x]
        for y in st:
            self.p[y]=x
        return x
    def find(self, x, y):
        return self.root(x)==self.root(y)
    def union(self, x, y):
        r1=self.root(x)
        r2=self.root(y)
        if r1==r2:
            return
        p1=self.p[r1]
        p2=self.p[r2]
        if p1<=p2:
            self.p[r2]=r1
            self.size[r1]+=self.size[r2]
            if p1==p2:
                self.p[r1]-=1
        else:
            self.p[r1]=r2
            self.size[r2]+=self.size[r1]

def main():
    N=int(input())
    r=[tuple([i]+list(map(int,input().split()))) for i in range(N)]
    rx=sorted(r,key=lambda x:x[1])
    ry=sorted(r,key=lambda x:x[2])
    pq=[]
    for i in range(1,N):
        dx=abs(rx[i][1]-rx[i-1][1])
        heapq.heappush(pq,(dx,rx[i][0],rx[i-1][0]))
        dy=abs(ry[i][2]-ry[i-1][2])
        heapq.heappush(pq,(dy,ry[i][0],ry[i-1][0]))
    uft=UnionFind(N)
    ans=0
    while(uft.size[uft.root(0)]<N):
        e=heapq.heappop(pq)
        if not(uft.find(e[1],e[2])):
            ans+=e[0]
            uft.union(e[1],e[2])
    print(ans)
    
if __name__=="__main__":
    main()


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

long long insertionSort(vector<int>& A, int N, int g) {
	long long cnt = 0;
	for (int i = g; i < N; i++) {
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j+g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j+g] = v;
	}
	return cnt;
}

long long shellSort(vector<int>& A, int N) {
	long long cnt = 0;

	vector<int> G;
	int g = 1;
	while (g <= N) {
		G.push_back(g);
		g = 3*g + 1;
	}
	int m = G.size();
	reverse(G.begin(), G.end());

	for (int i = 0; i < m; i++) {
		cnt += insertionSort(A, N, G[i]);
	}

	cout << G.size() << endl;
	for (int i = 0; i < m; i++) {
		cout << G[i];
		if (i < m-1) cout << ' ';
		else cout << endl;
	}
	return cnt;
}

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

	long long cnt = shellSort(A, N);
	cout << cnt << endl;
	for (int i = 0; i < N; i++) cout << A[i] << endl;
}



Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N,T;
    cin >> N >> T;
    vector<long long> t(N);
    for(long long i = 0; i < N; i++) cin >> t[i];
    long long D = T;
    for(long long i = 1; i < N; i++){
        long long d = t[i] - t[i-1];
        if(d <= T) D += d;
        else D += T;
    }
    cout << D << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,k;
    cin >> n >> k;
    cout << n - k + 1 << endl;

}

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/

int main() {
	int n;
	std::cin >> n;
	V<V<int> > g(n);
	rep(i,n-1) {
		int a,b;
		std::cin >> a >> b;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	lnt rt=-1;
	rep(i,n) if(g[i].size()>=3) rt=i;
	if(rt==-1) {
		print(1);
		return 0;
	}
	int cost=0;
	auto dfs = [&](auto f, int i, int par) -> int {
		if(g[i].size()==1) return 0;
		int cnt=0;
		int zc=0;
		for(auto to:g[i]) {
			if(to==par) continue;
			cnt++;
			int x=f(f,to,i);
			if(x==0) zc++;
		}
		if(g[i].size()==2) return (int)(cnt!=zc);
		cost+=std::max(0,zc-1);
		return 1;
	};
	dfs(dfs,rt,-1);
	print(cost);
}


Measured memory_bytes: 14624
module WeightedDirectedGraph
  (Weight : sig
    type t
    val inf : t (* オーバーフローの恐れはないので，max_intとか突っ込んでも良い *)
    val zero : t
    val neg_inf : t (* オーバーフローの恐れはないので，min_intとか突っ込んでも良い *)
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  val bellman_ford :
    (* 頂点数n *)
    int ->
    (* 辺のリスト
       頂点は0からn-1までの整数でなくてはならない *)
    (int * int * Weight.t) church_list ->
    (* 始点 *)
    int ->
    (* 頂点を受け取り，そこまでの距離を返す関数
       頂点に到達するパスが無ければinfを返し，
       そこに到達するまでに負閉路があればneg_infを返す *)
    (int -> Weight.t)
end =
struct
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  let bellman_ford n es s =
    (* 距離を覚えるやつ *)
    let d = Array.make n Weight.inf in
    (* 自己辺の最小のコスト *)
    let self = Array.make n Weight.zero in
    (* 始点より終点のインデックスが大きくなる辺を集めた隣接リスト *)
    let inc = Array.make n [] in
    (* 始点より終点のインデックスが小さくなる辺を集めた隣接リスト *)
    let dec = Array.make n [] in
    es.fold (fun ((u, v, c) as e) () ->
      match compare v u with
      | 0 -> if 0 < Weight.compare self.(u) c then self.(u) <- c
      | cmp when 0 < cmp -> inc.(u) <- e :: inc.(u)
      | _ -> dec.(u) <- e :: dec.(u)) ();
    (* 自己辺は最初に緩和する必要がある *)
    Array.iteri (fun v c ->
      if 0 < Weight.compare Weight.zero c then
        inc.(v) <- (v, v, c) :: inc.(v)) self;
    d.(s) <- Weight.zero;
    (* 残りの反復回数 *)
    let i = ref n in
    (* 更新が行われたか *)
    let is_modified = ref true in
    (* 各辺の処理 *)
    let f (u, v, c) =
      let open Weight in
      (* 原点から到達できない頂点は更新しない *)
      if 0 < Weight.compare inf d.(u) then
        let dv = if 0 <= Weight.compare neg_inf d.(u) then neg_inf else d.(u) + c in
        if 0 < Weight.compare d.(v) dv then
          (is_modified := true; d.(v) <- if !i <= succ n lsr 1 then neg_inf else dv) in
    while 0 < !i && !is_modified do
      is_modified := false;
      (* インデックスが増加する辺の処理 *)
      Array.iter (List.iter f) inc;
      (* インデックスが減少する辺の処理 *)
      for u = n - 1 downto 0 do
        List.iter f dec.(u)
      done;
      decr i
    done;
    Array.get d
end

module G = WeightedDirectedGraph (struct
  type t = int
  let zero = 0
  let inf = min_int
  let neg_inf = max_int
  let ( + ) = ( + )
  let compare x y = compare y x
end)

let () = Scanf.scanf "%d %d %d\n" @@ fun n m p ->
  let abc = Array.init m @@ fun _ ->
    Scanf.scanf "%d %d %d\n" @@ fun a b c -> a - 1, b - 1, c - p in
  let d = G.bellman_ford n { G.fold = fun f -> Array.fold_right f abc } 0 (n - 1) in
  if max_int <= d
  then print_endline "-1"
  else Printf.printf "%d\n" @@ max 0 d


Measured memory_bytes: 6172
s = str(input())
if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair


int main() {
  int n, k;
  cin >> n >> k;
  vl x(n);
  rep (i, n) {
    cin >> x[i];
  }
  ll ans = INF;
  for (int i = 0; i + k - 1 < n; i++) {
    ll r = x[i + k - 1], l = x[i];
    if (r * l >= 0) {
      chmin(ans, max(abs(r), abs(l)));
    }
    else {
      chmin(ans, r - l + min(abs(r), abs(l)));
    }
  }
  cout << ans << endl;
}
                                


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

#define N 100010

ll inv[N],fac[N],ifac[N];

int main(){
  int n;
  cin>>n;
  ll a[n+1]={};
  ll s[n+1]={};
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }

  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<=n+1;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;
    //cout<<inv[i]<<" "<<fac[i]<<" "<<ifac[i]<<endl;
  }

  ll ans=0;
  for(int i=1;i<=n;i++){
    s[i]=(s[i-1]+inv[i])%MOD;
  }

  for(int i=1;i<=n;i++){
    ans=ans+a[i]*(s[i]+s[n-i+1]-s[1])%MOD;
    ans=(ans+MOD)%MOD;
  }
  ans=ans*fac[n]%MOD;

  cout<<(ans+MOD)%MOD<<endl;
  return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N, T;
    cin >> N >> T;
    int ans = 1 << 30;
    REP(i,N) {
        int c, t;
        cin >> c >> t;
        if (ans > c && t <= T) ans = c;
    }

    if (ans < 1e6) OUT(ans)
    else OUT("TLE")

    return 0;
}

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); ++i)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

signed main() {
    int a, b, x;
    cin >> a >> b >> x;

    double theta;

    if (2 * x >= a * a * b) {
        theta = atan2(2 * (a * a * b - x), a * a * a);
    } else {
        theta = atan2(a * b * b, 2 * x);
    }
    cout << setprecision(15) << theta * 180 / M_PI << endl;

    return 0;
}


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

int primeNumber(int n){
    if(n == 2) return 1;
    else if(n < 2) return 0;
    else{
        for(int i = 2; i * i <= n; i++){
            if(n % i == 0) return 0;
        }
        return 1;
    }
}
int main(){
    int sum = 0;
    for(int n; cin >> n;){
        sum+=primeNumber(n);
    }
    cout << sum << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
set<int> primes;
bool isPrime(int i){
  if(i<=1)return false;
  for(int p:primes){
    if(p>=i)break;
    if(i%p==0)return false;
  }
  return true;
}
int n,p;
void solve(){
  vector<int> m;
  auto a=primes.upper_bound(n);
  REP(i,p){
    auto b=a;
    REP(j,p){
      m.push_back((*a)+(*b));
      b++;
    }
    a++;
  }
  sort(m.begin(),m.end());
  cout<<m[p-1]<<endl;
}

int main(){ _;
  primes.insert(2);
  for(int i=3;i<120000;i+=2)
    if(isPrime(i))
      primes.insert(i);
  while(cin>>n>>p,(n&p)!=-1){
    solve();
  }
}

Measured memory_bytes: 1860
/**
 * @author karayuu
 */

fun main(args: Array<String>) {
    val (a, b, k) = readLine()!!.split(" ").map { it.toInt() }

    val one = (0 until k).map {
        a + it
    }

    val two = (0 until k).map {
        b - it
    }

    val r = (one + two).toSortedSet()

    for (i in r) {
        if (i in a..b) println(i)
    }
}

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

int main() {
  int a, b, c, k;

  cin >> a >> b >> c >> k;

  if(a >= k) {
    cout << k << endl;
  }
  else if(a+b >= k) {
    cout << a << endl;
  }
  else {
    cout << a - (k-a-b) << endl;
  }

  
}

Measured memory_bytes: 3632
X = int(input())
ans = 0
coin = [500, 5]
while X >= 500:
    a, b = divmod(X, 500)
    ans += 1000 * a
    X = b
while X >= 5:
    a, b = divmod(X, 5)
    ans += 5 * a
    X = b
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    string S,T,Q;
    int N;
    cin >> N;
    cin >> S;
    REP(i,N/2){
        char tmp;
        tmp = S[i];
        T = T + tmp;
    }
    for(int i = N/2 ;i < N;i++){
        char tmp;
        tmp = S[i];
        Q = Q + tmp;
    }
    if(T == Q){
        cout <<"Yes"<< "\n";
    }else{
        cout <<"No"<< "\n";

    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		if(a>=10 || b >=10) {
			System.out.println(-1);
		}else {
			System.out.println(a*b);
		}
		
		
		
		
	}

}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int n;
    cin>>n;
    int ans=(n/11)*2;
    if(1<=n%11 && n%11<=6) ans++;
    else if(7<=n%11) ans+=2;
    cout<<ans<<endl;
    return 0;
}

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


int main() {
  int N; cin >> N;
  vector<int> a(N);
  int ans = 0;
  for(int i=0; i<N; i++){
    cin >> a[i];
    ans += a[i]-1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int m[101][101];

int main(){
	int i,n,j,k,u,v;
	scanf("%d",&n);
	v = n;
	while(n--){
		scanf("%d",&u);
		scanf("%d",&j);
		while(j--){
			scanf("%d",&i);
			m[u][i] = 1;
		}
	}
	for( i = 1; i <= v; i++ ){
		for( j = 1; j <= v; j++ ){
			if(j!=1) printf(" ");
			printf("%d",m[i][j]);
		}
		printf("\n");
	}
} 


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int memo[1000001];
bool is_prime(int n){
  if(memo[n] != -1) return memo[n];
  for(int i = 2; i * i <= n ; i++){
    if(n % i == 0) return memo[n] = false;
  }
  return memo[n] = true;
}

int main(){
  int m, a, b;
  memset(memo, -1, sizeof(memo));
  while(cin>>m>>a>>b && b){
    int product = 0;
    int ansp, ansq;
    for(int p = 2; p * p <= m; p++)if(is_prime(p)){
      for(int q = p; ; q++){
        if(!((ll)a * q <= (ll)p * b)) break;
        if(!(q <= m / p)) break;
        if(!is_prime(q)) continue;
        if(product < p * q){
          product = p * q;
          ansp = p;
          ansq = q;
        }
      }
    }
    printf("%d %d\n", ansp, ansq);
  }
  return 0;
}

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

using namespace std;

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

void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> edges[n+1];
	for(int i = 0; i < m; i++){
		int a,b;
		cin >> a >> b;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}

	
	int prev[n+1] {0};
	queue<int> q;
	q.push(1);
	prev[1] = 1;
	
	while(!q.empty()){
		int c = q.front();
		q.pop();
		for(int i: edges[c]){
			if(prev[i] == 0){
				prev[i] = c;
				q.push(i);
			}
		}
	}
	
	bool works = true;
	for(int i = 2; i <= n; i++){
		if(prev[i] == 0){
			works = false;
			break;
		}
	}
	
	if(works){
		cout << "Yes" << endl;
		for(int i = 2; i <= n; i++){
			cout << prev[i] << endl;
		}
	}else{
		cout << "No" << endl;
	}
}

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

Measured memory_bytes: 10492
N,A,B = map(int,input().split())

C = B-A

if C % 2 == 0:
    dec = (B-A)//2
    print(int(dec))
else:
    if N-B > A-1:
        dec = (B+A)//2
        print(int(dec))
    else:
        dec = N - (A+B-1)//2
        print(int(dec))
        

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

void solve()
{
	int n;
	string s;
	cin >> n >> s;

	int ans = 0;
	for (int k = 0; k < 1000; k++)
	{
		string g = to_string(k);
		while (g.length() < 3)
			g = "0" + g;
		
		int j = 0;
		for (int i = 0; i < n; i++)
			if (j == 3)
				break;
			else
				if (s[i] == g[j])
					j++;
		if (j == 3)
			ans++;
	}

	cout << ans;
}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();
}

Measured memory_bytes: 384
#include <stdio.h>

void bubbleSort(int A[],int n){
  int i=0,j,temp=0;
  int flag=1;
  while(flag){
    flag=0;
    for(j=n-1;j>=1;j--){
      if(A[j]<A[j-1]){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
	flag=1;
	i++;
      }  
    }
   
  }   
  for(j=0;j<n;j++){
    
    printf("%d",A[j]);
    if(j!=n-1){      
      printf(" ");
    }
  }
  printf("\n");
  printf("%d\n",i);
}



int main(){
  int n,A[100];
  int i;
  scanf("%d",&n);
  if(n>=1 && n<=100){
    for(i=0;i<n;i++){
      scanf("%d",&A[i]);
    }
  
  bubbleSort(A,n);
  }
  return 0;
}



Measured memory_bytes: 2084
#include <cstdio>
#include <iostream>
#define MOD (1000000007LL)
using namespace std;

int S;
long long memo[2005];

long long f(int n) {
  if (n <= 2) { return 0; }
  if (memo[n] >= 0) { return memo[n]; }

  long long res = 1;
  for (int i = 0; i <= n-3; i++) {
    res = (res + f(i)) % MOD;
  }

  return (memo[n] = res);
}

int main() {
  cin >> S;
  for (int i = 0; i <= 2000; i++) { memo[i] = -1; }
  printf("%lld\n", f(S));
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int N;
    cin >> N;
    vector<string> city;
    map<string, int> dic;
    for(int i = 0; i < N; i++) {
        string tempstr;
        int temppoint;
        cin >> tempstr;
        cin >> temppoint;
        city.push_back(tempstr + "_" + to_string(999 - temppoint));
        dic[tempstr + "_" + to_string(999 - temppoint)] = i + 1;
    }
    sort(city.begin(), city.end()); //昇順ソート
    for(int i = 0; i < N; i++) {
        cout << dic[city[i]] << endl;
    }
    cout << "";
    return 0;
}


Measured memory_bytes: 256
// AOJ DSL_1 A Set - Disjoint Set: Union Find Tree
// 2017.10.31 bal4u@uu

#include <stdio.h>

#define MAX 10002
/* UNION-FIND library */
int p[MAX], rank[MAX];
void make_set(int x) { p[x] = x, rank[x] = 0; }
void link(int x, int y) {
	if (rank[x] > rank[y]) p[y] = x;
	else { p[x] = y; if (rank[x] == rank[y]) rank[y] = rank[y] + 1;	}
}
int find_set(int x) { if (x != p[x]) p[x] = find_set(p[x]);	return p[x]; }
void union_set(int x, int y) { link(find_set(x), find_set(y)); }

char buf[32], *bp;
int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int main()
{
	int n, q, i;
	int cmd, x, y;

//	scanf("%d%d", &n, &q);
	fgets(bp=buf, sizeof(buf), stdin);
	n = getint(), bp++, q = getint();
	for (i = 1; i <= n; i++) make_set(i);
	while (q--) {
//		scanf("%d%d%d", &cmd, &x, &y);
		fgets(bp=buf, sizeof(buf), stdin);
		cmd = *bp++, bp++, x = getint(), bp++, y = getint();
		if (cmd == '0') union_set(x, y);
		else putchar('0'+(find_set(x)==find_set(y))), putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 1816
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;
int p[1001];

int main(void) {
  int N, M;
  unsigned long long sum;
  while(cin >> N >> M, N != 0 && M != 0) {
    sum = 0;
    for(int i = 0 ; i < N ; i++) cin >> p[i];
    sort(p, p+N, greater<int>());
    for(int i = M-1 ; i < N ; i+=M) p[i] = 0;
    for(int i = 0 ; i < N ; i++) sum += p[i];
  
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void){
  int a ,b,c,d,x = 0,y;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  y = a + b + c +d;
  while(y >= 60){
    y -= 60;
    x ++;
  }
  printf("%d\n%d\n",x,y);
  return 0;
}



Measured memory_bytes: 2044
import java.util.*;
import java.lang.*;


public class Main {
    static int n;
    static int[] a;
    static int[] b;
    static int[] c;
    static int[][] dp;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = new int[n + 1];
        b = new int[n + 1];
        c = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        dp = new int[3][n + 1];
        dp[0][1] = a[1];
        dp[1][1] = b[1];
        dp[2][1] = c[1];
        natsu(1);
        System.out.println(Math.max(dp[0][n], Math.max(dp[1][n], dp[2][n])));
    }
    static void natsu(int l) {
        if (l == n) {
            return;
        }
        dp[0][l + 1] = Math.max(dp[1][l], dp[2][l]) + a[l + 1];
        dp[1][l + 1] = Math.max(dp[0][l], dp[2][l]) + b[l + 1];
        dp[2][l + 1] = Math.max(dp[0][l], dp[1][l]) + c[l + 1];
        natsu(l + 1);
    }
}

Measured memory_bytes: 105156
#include <bits/stdc++.h>
using namespace std;
int main(){
 int  A,B,C,D;
 cin >> A>>B>>C>>D;
 if(A*B>=C*D){
    cout<<A*B<<endl;
 }else if(A*B<C*D){
    cout<<C*D<<endl;
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;



int32_t main()
{



    IOS



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

    vector<int> v(n);

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

    for(int i = k; i < n; i++)
    {
      if(v[i] > v[i-k])
      {
        cout << "Yes" << endl;
      }
      else
      {
        cout << "No" << endl;
      }
    }






    return 0;
}


Measured memory_bytes: 4780
<?php
$n = intval(fgets(STDIN));
$str = trim(fgets(STDIN));
$Q = intval(fgets(STDIN));

$seg = new SegTree($n);
function op($a, $b){return $a | $b;}

for($i = 0; $i < $n; $i++){
  $seg->set($i, 1<<(ord($str[$i])-97));
}
while($Q--){
  list($q, $a, $b) = explode(" ", trim(fgets(STDIN)));
  if($q == "1"){
    $seg->set($a-1, 1<<(ord($b)-97));
  }else{
    $ret[] = popcount($seg->get($a-1, $b));
  }
}
echo implode("\n", $ret);


class SegTree{
  public $tree;
  public $bits;
  function __construct($n){
    $this->bits = max(1, ceil(log($n)/log(2)));
    for($i = 0; $i < $this->bits; ++$i){
      $this->tree[$i] = array_fill(0, 2**($this->bits-$i), 0);
    }
  }
  function set($i, $amount){
    $this->tree[0][$i] = $amount;
    for($j = 1, $J = $this->bits; $j < $J; ++$j){
      $this->tree[$j][$i>>$j] = $this->tree[$j-1][$i>>$j<<1] | $this->tree[$j-1][($i>>$j<<1) + 1];
    }
  }
  function get($f, $t){
    $sum = 0;
    $tree = $this->tree;
    $bits = $this->bits;
    $i = 0;
    while($f!=$t){
      $treei = $tree[$i];
      if(($f >> $i) & 1){
        $sum |= $treei[$f>>$i];
        $f+=1<<$i;
      }
      if(($t >> $i) & 1){
        $sum |= $treei[($t>>$i)-1];
        $t-=1<<$i;
      }
      ++$i;
    }
    return $sum;
  }
}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


Measured memory_bytes: 39544
//include <bits/stdc++.h>
// Headder {{{
#pragma GCC optimize("O3")
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
// }}}
using namespace std;
#define int long long
#define read cin >>
#define echo cout <<
#define fin << '\n'
#define _ << ' ' <<

signed main ( ) {

    char a;
    cin >> a;
    echo (char)(a+1) fin;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define swap(a,b) {int t=a;a=b;b=t;}

int select_sort(int A[], int N) {
    int cnt=0;
    for(int i=0;i<N;i++) {
        int minj = i;
        for (int j=i+1;j<N;j++) {
            if(A[j]<A[minj]) {
                minj = j;
            }
        }
        if (minj != i) {
            swap(A[minj], A[i]);
            cnt++;
        }
    }
    return cnt;
}


int main() {
    int N, A[100+1];
    scanf("%d", &N);
    for(int i=0;i<N;i++) {
        scanf("%d", &A[i]);
    }
    int cnt = select_sort(A, N);
    for(int i=0;i<N;i++) {
        printf("%d%c", A[i], i==N-1?'\n':' ');
    }
    printf("%d\n", cnt);
    return 0;
}



Measured memory_bytes: 2736
#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;
typedef long long ll;

void insert(unordered_map<int, int> &mp, int a){
  if (mp.find(a) == mp.end())
    mp[a] = 1;
  else
    mp[a]++;
}

int main(int argc, const char * argv[]) {

  int n; cin >> n;
  unordered_map<int, int> map_even, map_odd;
  int e, o;
  for (int i=0; i<n/2; i++) {
    cin >> e >> o;
    insert(map_even, e);
    insert(map_odd, o);
  }
  
  vector<pair<int, int>> v_even, v_odd;
  v_even.push_back(make_pair(0, 0));
  v_odd.push_back(make_pair(0, 0));
  for(auto e: map_even) v_even.push_back(make_pair(e.second, e.first));
  for(auto o: map_odd) v_odd.push_back(make_pair(o.second, o.first));
  sort(v_even.begin(), v_even.end());
  sort(v_odd.begin(), v_odd.end());
  
  int ans = n - v_even.back().first - v_odd.back().first;
  if(v_even.back().second != v_odd.back().second){
    cout << ans << endl;
  }else{
    ans += min(v_even.back().first - v_even[v_even.size()-2].first, v_odd.back().first - v_odd[v_odd.size()-2].first);
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 5524
from functools import reduce

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)
    
def lcm_base(x, y):
    return x*y//gcd(x, y)

def lcm_list(list):
    return reduce(lcm_base, list)

N, M = map(int, input().split())
a = list(map(int, input().split()))
b = [x//2 for x in a]
T = lcm_list(b)
for n in b:
    if T//n%2 == 0:
        print (0)
        break
else:
    print ((M//T+1)//2)

Measured memory_bytes: 14748