akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<cstring>
using namespace std;
long long temp,tt;
char c;
int k,q;
int main()
{
	while (scanf("%d",&q)!=EOF)
	{
		temp = 0;
		for (int i = 1;i<=q;i++)
		{
			scanf("%d",&k);
			getchar();
			c = getchar();
			scanf("%lld",&tt);
			if (c == ')') tt = -tt;
			temp+=tt;
			if (!temp) printf("Yes\n");
			else printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <numeric>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<vector<lli> > mat;
const lli MOD = 1000000007;
lli n,k;
vll d;
vll dp;
lli ans = 0;
lli pow(lli a,lli n,lli mod = MOD){
	lli ret = 1;
	for(;n!=0;n=n>>1){
		if(n&1) ret = (ret * a) % mod;
		a = (a * a) % mod;
	}
	return ret;
}
int main(){
    cin >> n >> k;
    lli i;
    for(i = 1;i*i < n;i++) if(n%i == 0) d.push_back(i),d.push_back(n/i);
    if(i*i == n) d.push_back(i);
    sort(d.begin(),d.end());
    dp = vector<lli> (d.size());
    for(lli i = 0;i < d.size();i++){
        dp[i] += pow(k,(d[i]+1)/2);//k*(d[i]+1)/2;
        dp[i] %= MOD;
        for(lli j = i+1;j < d.size();j++){
            if(d[j]%d[i] == 0) dp[j] -= dp[i],dp[j] = (dp[j] + MOD) % MOD;
        }
    }
    for(lli i = 0;i < d.size();i++){
        ans += (dp[i]*(d[i]%2 ? d[i] : d[i]/2)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;

}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF INT_MAX/3

typedef vector<int> vi;
typedef vector<vi> vvi;

int main()
{
	while (1)
	{
		int n; cin >> n;
		if (n == 0) return 0;

		vvi t(n + 1, vi(n + 1));
		rep(y, 1, n+1) rep(x, 0, n + 1) cin >> t[y][x];

		vi dp(1 << n, INF);
		dp[0] = 0;
		rep(i, 0, (1 << n) - 1)
		{
			set<int> items;
			rep(j, 0, n) if ((i & (1 << j)) != 0) items.insert(j+1);
			rep(j, 0, n)
			{
				if ((i & (1 << j)) == 0)
				{
					int next_i = i | (1 << j);
					dp[next_i] = min(dp[next_i], dp[i] + t[j + 1][0]);
					for (int item : items)
					{
						dp[next_i] = min(dp[next_i], dp[i] + t[j + 1][item]);
					}
				}
			}
		}

		cout << dp[(1 << n) - 1] << endl;
	}
}

Measured memory_bytes: 3340
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int n;
vector<int> a;
vector<vector<int>> graph;
vector<int> dp;
vector<int> ans;

void dfs(int from = 0, int p = -1){
    int PrePos = lower_bound(dp.begin(), dp.end(), a[from]) - dp.begin();
    int PreVal = dp[PrePos];
    dp[PrePos] = a[from];
    ans[from] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();

    for(int to : graph[from]){
        if(to == p) continue;
        dfs(to, from);
    }

    dp[PrePos] = PreVal;
    return;
}

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

    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    graph.resize(n);
    for(int i = 0; i < n - 1; ++i){
        int u, v;
        cin >> u >> v;
        --u, --v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    dp.assign(n, INF);
    ans.resize(n);
    dfs();

    for(int x : ans)    cout << x << '\n';
}

Measured memory_bytes: 27880
x = int(input())

if x <= 6:
    print(1)
    import sys
    sys.exit()

dice = 6
ans = 0

ans = x // 11 * 2
m = x % 11
if m != 0:
    if m <= 6:
        ans += 1
    else:
        ans += 2

print(ans)

Measured memory_bytes: 3060
import math as m

a, b, x = map(int, input().split())
if x < a * a * b / 2:
    print(m.degrees(m.atan(a * b * b / 2 / x)))
else:
    print(m.degrees(m.atan(2 * (a * a * b - x) / a / a / a)))


Measured memory_bytes: 3060
#include<bits/stdc++.h> 
using namespace std;
string s,t;
bool a[26]={true};
int main()
{
for(int i=0;i<26;i++)
a[i]=true;
cin>>s;
t=s;
if(s.size()<26)
{
for(int i=0;i<s.size();i++)
{
a[s[i]-'a']=false;
}
cout<<s;
for(int i=0;i<26;i++)
{
if(a[i]) {
cout<<char('a'+i)<<endl;
return 0;
}
}
}
else 
{
if(next_permutation(s.begin(),s.end())) 
{
for(int i=0;i<26;i++)
{
cout<<s[i];
if(s[i]!=t[i]) break;
}
}
else cout<<"-1"<<endl;
}
system ("pause"); 
return 0;
} 

Measured memory_bytes: 504
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
ll n,k;
set<string> s;

int main()
{while(1){
	cin>>n>>k;
	if(!n) return 0;
	s.clear();
	vector<string> data(n);
	for(ll i=0;i<n;++i) cin>>data[i];
	sort(data.begin(),data.end());
	do{
		string tmp;
		for(ll i=0;i<k;i++){
			tmp+=data[i];
		}
		s.insert(tmp);
	}while(next_permutation(data.begin(),data.end()));
	cout<<s.size()<<endl;
}}

Measured memory_bytes: 3424
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.E
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var A = ReadLongs();

            var oneCount = 0L; // A.Count(x => x == 1);

            var primeCount = new long[1000001];
            foreach (var item in A)
            {
                if (item==1)
                {
                    oneCount++;
                    continue;
                }
                foreach (var factor in GetPrimeFactors(item))
                {
                    primeCount[factor]++;
                }
            }

            // すべて1の場合
            if (oneCount == N) return "pairwise coprime";

            var max = primeCount.Max();

            if (oneCount != 0)
            {
                // 1 以外が素の場合
                if (max == 1) return "pairwise coprime";
                return "setwise coprime";
            }

            if (max == 1) return "pairwise coprime";
            if (max == N) return "not coprime";
            return "setwise coprime";
        }
        public static IEnumerable<long> GetPrimeFactors(long n)
        {
            for (long a = 2; a * a <= n; ++a)
            {
                if (n % a != 0) continue;

                // 割れる限り割り続ける
                while (n % a == 0)
                {
                    //yield return a;
                    n /= a;
                }

                // TODO：重複を許さない場合はここで返す
                yield return a;

            }

            // 最後に残った数について
            if (n != 1) yield return n;
        }
        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 124988
#include <iostream>
#include<stdio.h>
#define MAX 5000001
#define INFTY (1<<30)

using namespace std;
int n = 0, arr[MAX];

void swapNode(int index1, int index2) {
    int temp = arr[index1];
    arr[index1] = arr[index2];
    arr[index2] = temp;
}

void maxHeapify(int i) {
    //if(i > n) return;
    int left = 2*i;
    int right = 2*i+1;
    int largest = i;
    if(left <= n && right <= n) {
       int larger = arr[left] > arr[right] ? left : right;
       largest = arr[largest] > arr[larger] ? largest : larger;
    }else if(left <= n) {
        largest = arr[largest] > arr[left] ? largest : left;
    }else if(right <= n) {
        largest = arr[largest] > arr[right] ? largest : right;
    }
    if(largest != i) {
        swapNode(i, largest);
        maxHeapify(largest);
    }
}

void insertNode(int key) {
    arr[++n] = key;
    int i = n;
    while(i > 1 && arr[i/2] < arr[i]) {
        swapNode(i, i/2);
        i = i/2;
    }
}

int extract() {
    if(n < 1) return -INFTY;
    int res = arr[1];
    arr[1] = arr[n--];
    maxHeapify(1);
    return res;
}

int main()
{
    char com[10];
    int key;
    while(1) {
        scanf("%s", com);
        if(com[0] == 'e' && com[1] == 'n') break;
        else if(com[0] == 'i') {
            scanf("%d", &key);
            insertNode(key);

        }else {
            printf("%d\n", extract());
        }
    }
    return 0;
}

Measured memory_bytes: 7080
A[999][1000],I[1000],u[999];i,j;d;F=2;main(N){for(scanf("%d",&N);i<N;++i)for(j=0;j<N-1;)scanf("%d",A[j++]+i);for(;F&2;)for(F=1,i=!++d;i<N;++i)u[i]<d&I[i]<N-1&&u[F&=2,j=A[I[i]][i]-1]<d&A[I[j]][j]==i+1&&++I[u[i]=u[j]=d,++I[i],F=2,j];printf("%d",F*d-1);}


Measured memory_bytes: 4096
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different 
Yours Faithfully
Shobhit Yadav */

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

ll M,N;
/*ll freq[200005];*/
void solve(){
	 /*memset(freq,0,sizeof(freq));*/
  cin>>N;
  ll temp;
  ll turn = 0 , even = 0;

  for(ll i = 0 ; i<N ; i++){
    cin>>temp;
    if(temp%2 == 0){
       even++;
       if(temp%3 == 0 || temp%5 == 0)
      turn++;
    }
  }

  if(turn == even)
    cout<<"APPROVED"<<'\n';

  else
    cout<<"DENIED"<<'\n';



}



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

	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
 
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
 
#define infi INT_MAX
#define infl LONG_LONG_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple
#define pll pair<ll,ll> 
#define endl "\n"
#define ALL(v) v.begin(),v.end()
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;


void func()
{
  ll n,m;
  cin>>n>>m;
  ll ans=0;
  if(n>1)
  {
  	ans+=((n*(n-1))/2);
  }
  if(m>1)
  {
  	ans+=((m*(m-1))/2);
  }
  cout<<ans<<endl;
}

int main() 
{
    fast
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    
    ll ntc=1;
    //cin>>ntc;

    f(i,1,ntc+1)
    {
      //cout<<"Case #"<<i<<":";
      func();
    }
 
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	foreach (line; stdin.byLine) {
		auto x = line.split.map!(to!int).array;

		int sum;
		foreach (i; 0..x[2]) {
			x[0] %= x[1];
			x[0] *= 10;
			sum += x[0] / x[1];
		}
		sum.writeln;
	}
}

Measured memory_bytes: 1060
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

void main() {
    int n, m;
    scanf("%d %d\n", &n, &m);
    int[][] g = new int[][](n, n);
    foreach (i; 0 .. m) {
        int a, b, c;
        scanf("%d %d %d\n", &a, &b, &c);
        g[a][b] = c;
    }
    int[] cache = new int[n];
    cache[] = -1;
    int dfs(int v) {
        if (v == n - 1) return 0;
        if (cache[v] >= 0) return cache[v];
        int ret = 0;
        foreach (i; 0 .. n) {
            if (v == i) continue;
            if (g[v][i] == 0) continue;
            ret = max(ret, g[v][i] + dfs(i));
        }
        return cache[v] = ret;
    }
    dfs(0).writeln;
}

Measured memory_bytes: 1868
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

int main(){

	string S;
	cin >> S;
	if (S == "Sunny")cout << "Cloudy" << endl;
	else if(S == "Cloudy") cout << "Rainy" << endl;
	else cout << "Sunny" << endl;

	return 0;
}

Measured memory_bytes: 256
N, K = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
def get_expectation(n):
  return n*(2+n-1)/2/n
A = [get_expectation(i) for i in A]
maximum = sum([A[i] for i in range(K)])
tmp = maximum
for i in range(N-K):
  diff = A[i+K]-A[i]
  if tmp+diff >= maximum:
    maximum = tmp+diff
  tmp = tmp+diff
print(maximum)

Measured memory_bytes: 24676
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  ll n;
  cin >> n;
  ll tmp = 0;
  int cnt = 0;
  for(int i = 1; tmp < n; i++) {
    tmp += i;
    cnt = i;
  }
  //cout << cnt << endl;
  ll sum = cnt;
  vector<ll> ans;
  ans.push_back(cnt);
  for(int i = cnt - 1; i >= 0; i--) {
    if(sum + i == n){
      if(i != 0){
        ans.push_back(i);
      }
      break;
    }
    if(sum + i > n){
      continue;
    }else{
      sum += i;
      ans.push_back(i);
    }
  }
  for(auto p : ans){
    cout << p << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

bool hasSub(int n, int m, string s) {
  bool exists = false;
  REP(i, n - m + 1) {
    string subs = s.substr(i, m);
    if (s.find(subs, i + m) != string::npos) {
      exists = true;
      break;
    }
  }
  return exists;
}

int main()
{
  int n;
  string s;
  cin >> n >> s;
  if (!hasSub(n, 2, s)) {
    cout << 0 << endl;
    return 0;
  }
  int minl = 2, maxl = n / 2 + 1;
  while(minl < maxl) {
    int m = (minl + maxl + 1) / 2;
    if (hasSub(n, m, s)) {
      minl = m;
    } else {
      maxl = m - 1;
    }
  }
  cout << minl << endl;
  return 0;
}


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

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

//------------------------------------------------
int main(){
  string s;
  cin>>s;
  if(s.at(0)==s.at(1)||s.at(1)==s.at(2)||s.at(2)==s.at(3)){
    cout<<"Bad"<<endl;
  }
  else{
    cout<<"Good"<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

struct Info{

	bool operator<(const struct Info &arg) const{

		return loc < arg.loc;
	}

	ll loc,dir;
};

int N;
ll L;
ll left_dp[SIZE],right_dp[SIZE];
Info info[SIZE];


int main(){

	scanf("%d %lld",&N,&L);
	L--;

	for(int i = 0; i < N; i++){

		scanf("%lld %lld",&info[i].loc,&info[i].dir);
		info[i].loc--;
	}

	sort(info,info+N);

	left_dp[0] = 0;

	//i番目まで左詰めした時の、左端方向の得点
	for(int i = 0; i < N; i++){

		if(info[i].dir == 0){ //左向き

			left_dp[i+1] = left_dp[i]+(info[i].loc-i);

		}else{ //右向き

			left_dp[i+1] = left_dp[i]-(info[i].loc-i);
		}
	}

	right_dp[N] = 0;

	//i番目まで右詰めした時の、右端方向の得点
	for(int i = N-1; i >= 0; i--){

		if(info[i].dir == 0){ //左向き

			right_dp[i] = right_dp[i+1]-((L-(N-1-i))-info[i].loc);

		}else{ //右向き

			right_dp[i] = right_dp[i+1]+((L-(N-1-i))-info[i].loc);
		}
	}

	ll ans = 0;

	for(int i = 0; i <= N; i++){

		ans = max(ans,left_dp[i]+right_dp[i]);
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 6308
// AOJ 1160: How Many Islands? http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1160

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
	"strconv"
)

var SEA = 0
var LAND = 1

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func discoverIslands(M, V [][]int, H, W int) int {
	// 島を探す
	queue := list.New()
	islands := 0
	for i := 1; i <= H; i++ {
		for j := 1; j <= W; j++ {
			// 訪問済みの土地ならスキップ
			if V[i][j] == 1 {
				continue
			}

			// 訪問中の土地が海なら訪問済みにしてスキップ
			if M[i][j] == SEA {
				V[i][j] = 1
				continue
			}

			// 未訪問の陸地が見つかったので
			// 島の数を1つ増やし、この陸地から辿れる陸地を訪問していく
			islands++
			queue.PushBack([]int{i, j})

			for queue.Len() > 0 {
				cur := queue.Remove(queue.Front()).([]int)
				h, w := cur[0], cur[1]
				if V[h][w] == 1 {
					continue
				}
				V[h][w] = 1

				// 全方向に未訪問の陸地がないか探索
				for v := -1; v <= 1; v++ {
					for l := -1; l <= 1; l++ {
						dh := h + v
						dw := w + l
						if M[dh][dw] == LAND && V[dh][dw] == 0 {
							queue.PushBack([]int{dh, dw})
						}
					}
				}
				/*
					if M[h-1][w] == LAND {
						queue.PushBack([]int{h - 1, w})
					}
					if M[h-1][w+1] == LAND {
						queue.PushBack([]int{h - 1, w + 1})
					}
					if M[h][w+1] == LAND {
						queue.PushBack([]int{h, w + 1})
					}
					if M[h+1][w+1] == LAND {
						queue.PushBack([]int{h + 1, w + 1})
					}
					if M[h+1][w] == LAND {
						queue.PushBack([]int{h + 1, w})
					}
					if M[h+1][w-1] == LAND {
						queue.PushBack([]int{h + 1, w - 1})
					}
					if M[h][w-1] == LAND {
						queue.PushBack([]int{h, w - 1})
					}
					if M[h-1][w-1] == LAND {
						queue.PushBack([]int{h - 1, w - 1})
					}
				*/
			}
		}
	}
	return islands
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		W, H := nextInt(sc), nextInt(sc)

		if W == 0 && H == 0 {
			break
		}
		// Initialize map and visted list
		M := make([][]int, H+2)
		V := make([][]int, H+2)
		for i := 0; i < H+2; i++ {
			M[i] = make([]int, W+2)
			V[i] = make([]int, W+2)
		}
		for i := 1; i <= H; i++ {
			for j := 1; j <= W; j++ {
				M[i][j] = nextInt(sc)
			}
		}

		islands := discoverIslands(M, V, H, W)

		fmt.Println(islands)
	}
}



Measured memory_bytes: 3116
#include<iostream>
#include<cstdio> 
#include<algorithm>
using namespace std;
#define MAX 1010
int nums[MAX];
int main(){
	int n,m;
	int sum=0;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d",&nums[i]);
		sum+=nums[i];
	}
	double temp=1.0/(m*4)*sum;
	int cnt=0;
	for(auto i:nums){
		if(i>=temp) cnt++;
	}
	cnt>=m?printf("Yes"):printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define LIM 1000007
#define ll long long
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int x = 0;
  int m = 0;
  for (char c : s) {
    if (c == 'I') {
      x++;
    } else {
      x--;
    }
    m = max(m, x);
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    vector<vector<int>> l(n,vector<int>(2));
    for (int i=0; i<n; i++){
        for(int j=0;j<2;j++){
            cin>>l[i][j];
        }
    }

    double sum=0;
    vector<int> a(n);
    for (int i=0; i<n; i++){
        a[i]=i;
    }
    do
    {
        for (int i=0; i<n-1; i++){
           sum+=(double)sqrt((l[a[i]][0]-l[a[i+1]][0])*(l[a[i]][0]-l[a[i+1]][0])+(l[a[i]][1]-l[a[i+1]][1])*(l[a[i]][1]-l[a[i+1]][1]));
        }
    } while (next_permutation(a.begin(),a.end()));
    
    int num=1;
    for (int i=1; i<=n; i++){
        num*=i;
    }
    cout<<fixed<<setprecision(8)<<sum/num;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;

  int n,k;
  cin>>n>>k;
  cin>>s;
  int cnt=0;
  for(int i=0;i<(s.size()-1);i++)
  {
      if((s[i]=='L'&&s[i+1]=='L')||(s[i]=='R'&&s[i+1]=='R'))
      {
          cnt+=1;
          //++i;
      }
  }

  cout<<min(n-1,cnt+2*k);
  return 0;
}


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

int64_t fib(int n){
  int64_t a=0,b=1;
  for(int i=0;i<n;i++){
    a=(a+b)%1000000007;
    b=(a-b+1000000007)%1000000007;
  }
  return a;
}

int main(){
  int64_t n,m,ans=1;
  cin >> n >> m;
  vector<int>br(m);
  for(int i=0;i<m;i++)
    cin >> br.at(i);
  int x=0;
  for(int i=0;i<m;i++){
    ans=(ans*fib(br.at(i)-x))%1000000007;
    x=br.at(i)+1;
  }
  ans=(ans*fib(n-x+1))%1000000007;
  cout << ans << endl;
  return 0;
}
      

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

int main(){
  long int n,a,b=0,c=1000000000; cin>>n;
  
  for(int i=0;i<n;i++){
    cin>>a;
    b = max(b,a);
    c = min(c,a);
  }
  
  cout<<b-c<<endl;
  return 0;
}

Measured memory_bytes: 256
import Foundation

private func readString() -> String {
    readLine()!
}

private func readStringArray() -> [String] {
    readString().components(separatedBy: " ")
}

private func readInt() -> Int {
    Int(readString())!
}

private func readIntArray() -> [Int] {
    readStringArray().map { Int($0)! }
}

private func readStringTupple() -> (String, String) {
    let array = readStringArray()
    return (array[0], array[1])
}

private func readStringTupple() -> (String, String, String) {
    let array = readStringArray()
    return (array[0], array[1], array[2])
}

private func readIntTupple() -> (Int, Int) {
    let array = readIntArray()
    return (array[0], array[1])
}

private func readIntTupple() -> (Int, Int, Int) {
    let array = readIntArray()
    return (array[0], array[1], array[2])
}

/*＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿
 〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓
 ￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣*/

let (n, m) = readIntTupple()
let h = [0] + readIntArray()
var mh = [Int](repeating: 0, count: n + 1)
for _ in 0..<m {
    let (a, b) = readIntTupple()
    mh[a] = max(h[b], mh[a])
    mh[b] = max(h[a], mh[b])
}
var ans = 0
for i in 1..<n+1 {
    ans += mh[i] < h[i] ? 1 : 0
}
print(ans)

/*＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿
〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣*/


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


#define DEBUG(x)                cout << '>' << #x << ':' << x << endl;
#define D(x)                    cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define DD(x,y)                 cerr << __LINE__ << ": " << #x << " = " << x << "   " << #y << " = " << y << '\n'
#define DDD(x,y,z)              cerr << __LINE__ << ": " << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << '\n'
#define DBG                     cerr << __LINE__ << ": Hi" << '\n'
#define fresh                   {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define read                    freopen("in.txt","rt",stdin)
#define write                   freopen("out.txt","wt",stdout)
#define PI                      3.1415926535897932384626433832795
#define mems(ds_name,val)       memset(ds_name,val,sizeof(ds_name))
#define ll                      long long


void run(istream& in,ostream& out){
    int a,b,c;
    in>>a>>b;
    c=a*b;
    if( (c*1)%2 !=0 || (c*2)%2 !=0 || (c*3)%2 !=0 )out<<"Yes\n";
    else out<<"No\n";
}


int main()
{
    fresh;
//    read;
//	write;
    run(cin,cout);
    return 0;
}



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

import itertools


UNDEF = 0


def color_edges(n, edges):
    adj_list = [set() for _ in range(n)]
    for i, (a, b) in enumerate(edges):
        adj_list[a].add(i)
        adj_list[b].add(i)
    colors = [UNDEF] * (n - 1)
    for v in range(n):
        adj_es = adj_list[v]
        num_adj = len(adj_es)
        cur_cols = set(colors[i] for i in adj_es if colors[i] != UNDEF)
        new_cols = set()
        for i in itertools.count(1):
            if len(cur_cols) + len(new_cols) >= num_adj:
                break
            elif i not in cur_cols:
                new_cols.add(i)
        for u in adj_es:
            if colors[u] == UNDEF:
                colors[u] = new_cols.pop()
    return max(colors), colors


def main():
    n = int(input())
    edges = []
    for _ in range(n - 1):
        a, b = (int(z) - 1 for z in input().split())
        edges.append((a, b))
    k, cs = color_edges(n, edges)
    print(k)
    print(*cs, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 91608
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

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

	ll a, b, x;
	cin >> a >> b >> x;

	cout << b/x+1-(a>0?(a-1)/x+1:0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	int n,m;
	cin >> n >> m;
	int sum=0,a[n+5];
	rep(i,n)cin>>a[i],sum+=a[i];

	int cnt=0;
	double target = ((1.0*sum)/(4*m));
	rep(i,n)
	{
		if(a[i]>=target)
		{
			cnt++;
		}
	}
	if(cnt>=m)
	{
		cout << "Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
loop do
  a,b,c = gets.split
  a=a.to_i
  c=c.to_i
  break if b == "?"
  if b == "+"
    puts a+c
  elsif b == "-"
    puts a-c
  elsif b == "/"
    puts a/c
  elsif b == "*"
    puts a*c
  end
end


Measured memory_bytes: 6864
#include<stdio.h>
#include<iostream>
#include<string.h>
#include <iomanip>
#include<math.h>
#include<queue>
#include<vector>
#define Max (int)1e5+10
#define MAX_INT (int)1e9+2
#define MOD ((int)1e9+7)
using namespace std;

int dp[Max];

void init(){
	int i;
	for(i=0;i<Max;i++)
		dp[i] = -1;
}

int canWin(int k,int min,int n,int a[]){
	if(k == 0)
		return 0;
	if(dp[k] != -1)
		return dp[k];
	int status = 0,i;
	for(i=0;i<n;i++){
		if(k-a[i] >= 0){
			if(canWin(k-a[i],min,n,a) == 0)
				status = 1;
		}
	}
	dp[k] = status;
	return dp[k];
}

int main(){
	int n,k,a[Max],min=MAX_INT,i;

	init();
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(min > a[i])
			min = a[i];
	}

	if(canWin(k,min,n,a))
		printf("First\n");
	else
		printf("Second\n");

}










/*
Atcoder Dp G-Longest Path iterative solution

vector<int>vec[Max];
queue<int>q;

int dp[Max];
int vis[Max];

void init(){
	int i;
	for(i=0;i<Max;i++){
		dp[i] = 0;
		vis[i] = 0;
	}
}

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

void solve(int x){
	int i,u;
	q.push(x);

	while(!q.empty()){
		u = q.front();
		q.pop();

		if(vis[u])
			continue;
		vis[u] = 1;
		
		for(i=0;i<vec[u].size();i++){
			dp[vec[u][i]] = getMax(dp[vec[u][i]],dp[u]+1);
			q.push(vec[u][i]);
		}
	}

}

int main(){
	int n,m,incoming[Max],x,y,i;
	for(i=0;i<Max;i++)
		incoming[i] = 0;
	
	init();

	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d%d",&x,&y);
		vec[y].push_back(x);
		incoming[x]++;
	}
	
	for(i=1;i<=n;i++)
		solve(i);
	
	int max = 0;
	for(i=0;i<Max;i++)
		max = getMax(max,dp[i]);
	
	printf("%d\n",max);
	return 0;
}
*/

Measured memory_bytes: 8448
import heapq
N,C = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(N)]
X.insert(0,[0,0])
A = [0 for _ in range(N+1)]
for i in range(1,N+1):
    A[i] = A[i-1]+X[i][1]
A = [A[i]-X[i][0] for i in range(N+1)]
B = [0 for _ in range(N+1)]
B[N] = X[N][1]
for i in range(N-1,0,-1):
    B[i] = B[i+1]+X[i][1]
B = [B[i]-(C-X[i][0]) for i in range(N+1)]
heap = []
for i in range(1,N+1):
    heapq.heappush(heap,(-B[i],i))
vmax = 0
for i in range(1,N):
    cnt = A[i]
    vmax = max(vmax,cnt)
    cnt -= X[i][0]
    b,j = heap[0]
    while heap and j<=i:
        heapq.heappop(heap)
        if heap:
            b,j = heap[0]
    b = -b
    cnt += b
    vmax = max(vmax,cnt)
vmax = max(vmax,A[N])
heap = []
for i in range(1,N+1):
    heapq.heappush(heap,(-A[i],i))
for i in range(N,1,-1):
    cnt = B[i]
    vmax = max(vmax,cnt)
    cnt -= (C-X[i][0])
    b,j = heap[0]
    while heap and j>=i:
        heapq.heappop(heap)
        if heap:
            b,j = heap[0]
    b = -b
    cnt += b
    vmax = max(vmax,cnt)
vmax = max(vmax,B[1])
print(vmax)

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    int N;
    int A[30],B[30],C[30];
    int sum=0;
    
    cin >> N ;
    rep(i,N) cin >> A[i];

    rep(i,N) cin >> B[i];

    rep(i,N-1) cin >> C[i];
    int pre=-100;
    rep(i,N){
        sum+=B[i];

            if(pre+1 ==A[i]-1){
                sum+=C[pre];
            }
        pre  = A[i]-1;
    }
    cout << sum << endl;
    
    return 0;
    

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    X=I()
    if X>=30:
        print("Yes")
    else:
        print("No")

main()


Measured memory_bytes: 61936
#include <iostream>
#include <unordered_map>

using namespace std;

int main() {
	int n, a;
  	cin >> n;
  	unordered_map<int, bool> mp;
  	for (int i = 0; i < n; i++) {
    	cin >> a;
      	if (mp.find(a) != mp.end()) {
        	mp.erase(a);
        } else {
        	mp[a] = true;
        }
    }
  	cout << mp.size();
  	return 0;
}

Measured memory_bytes: 6644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int pos = 0;
    int cnt = 1;
    for(int i = 0; i < n+5; i++){
        if(a[pos]==2){
            cout << cnt << endl;
            return 0;
        }
        cnt++;
        pos = a[pos]-1;
    }
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
int n, m;
vector<int> nail[5000];
scanf("%d%d", &n, &m);
for(int i = 0; i < n; ++i)
nail[i].resize(i + 1);
for(int i = 0; i < m; ++i) {
int a, b, x;
scanf("%d%d%d", &a, &b, &x);
a -= 1, b -= 1;
nail[a][b] = x + 1;
}
int ans = 0;
for(int a = 0; a < n; ++a) {
for(int b = 0; b <= a; ++b) {
int l = a > 0 && b > 0 && (b - 1) <= (a - 1) ? nail[a - 1][b - 1] : 1;
int r = a > 0 && (b) <= (a - 1) ? nail[a - 1][b] : 1;
nail[a][b] = max(nail[a][b], max(l - 1, r - 1));
if(nail[a][b] > 0)
ans += 1;
}
}
printf("%d\n", ans);
return 0;
}

Measured memory_bytes: 50040
inp = [i for i in input().split()]
n = int(input())
array = [[i for i in input().split()] for i in range(n)]
for i2 in range(n):
    fuck =""
    for i in range(1,33):
        if (i<=20 and i%5==0) or i==22 or i==27 or i==28:
            s = "N"
        else:
            s = "E"
        if s == "E":
            a = []
            a.append(inp[3])
            a.append(inp[1])
            a.append(inp[0])
            a.append(inp[5])
            a.append(inp[4])
            a.append(inp[2])
            inp = a
            if inp[0] == array[i2][0] and inp[1] == array[i2][1] and inp[2] != fuck:
                print(inp[2])
                fuck = inp[2]
        elif s == "N":
            a = []
            a.append(inp[1])
            a.append(inp[5])
            a.append(inp[2])
            a.append(inp[3])
            a.append(inp[0])
            a.append(inp[4])
            inp = a
            if inp[0] == array[i2][0] and inp[1] == array[i2][1] and inp[2] != fuck:
                print(inp[2])
                fuck = inp[2]

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

template<typename T>
class MaxHeap{
private:
	vector<T> d;
public:
	void push(T t){
		d.push_back(t);
	}
	void maxHeapify(int k){
		int l = 2 * k + 1;
		int r = 2 * k + 2;
		T largest;
		if(l < d.size() && d[l] > d[k]) largest = l;
		else largest = k;

		if(r < d.size() && d[r] > d[largest]) largest = r;

		if(largest != k){
			swap(d[k], d[largest]);
			maxHeapify(largest);
		}
	}
	void buildMaxHeap(){
		for(int i = d.size() / 2; i >= 0; i--){
			maxHeapify(i);
		}
	}
	void printHeap(){
		for(int i = 0; i < d.size(); i++){
			cout << " " << d[i];
		}
		cout << endl;
	}
};

int main(){
	int h;
	cin >> h;
	MaxHeap<int> mh;
	for(int i = 0; i < h; i++){
		int a;
		cin >> a;
		mh.push(a);
	}
	mh.buildMaxHeap();
	mh.printHeap();
}

Measured memory_bytes: 4860
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <climits>

//find out the use of the below
#include <list>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
const int mod = 1e9+7;
int R, C;
char gr[1000][1000];
vector<vector<int> > dp(1000, vector<int>(1000, 0));
int fr[1000*1000];
int dr[] = {1, 0};
int dc[] = {0, 1};
inline bool vd(int r, int c){
    return !(r < 0 || r >= R || c < 0 || c >= C || gr[r][c] == '#');
}
void bfs(int r, int c){
    queue<pair<int, int> > q;
    q.push(mp(r, c));
    fr[R*r+c] = 1;
    while (!q.empty()){
        r = q.front().x;
        c = q.front().y;
        //cout << r << ' ' << c << endl;
        fr[R*r+c]--;
        q.pop();
        if (fr[R*r+c] != 0)
            continue;
        for (int i = 0; i < 2; ++i){
            int nr = r+dr[i], nc = c + dc[i];
            if (vd(nr, nc)){
                q.push(mp(nr, nc));
                fr[R*nr+nc]++;
                dp[nr][nc] = (dp[nr][nc] + dp[r][c])%mod;
            }
        }
    }
}
int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    scanf("%d %d", &R, &C);
    for (int i = 0; i < R; ++i){
        scanf("\n");
        for (int j = 0; j < C; ++j){
            scanf("%c", &gr[i][j]);
        }
    }
//    for (int i = 0; i < R; ++i)
//        for (int j = 0; j < C; ++j)
//            printf("%s\n", gr[i]);
    dp[0][0] = 1;
    bfs(0,0);
    printf("%d", dp[R-1][C-1]);
    return 0;
}
/* BEFORE submitting, check for:
 *  1. Integer overflow
 *  2. Float/Double precision errors
 *  3. Array index out of bounds
 *  4. Edge cases.(n=1, n=max, etc.)
 *  5. Time complexity. No TLEs
 */


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

int main(){
    ll A, B, K;
    cin >> A >> B >> K;
    for (int i = 0; i < K; i++) {
        if (i%2 == 0) {
            if (A%2 == 1) A--;
            B += A/2;
            A /= 2;
        } else {
            if (B%2 == 1) B--;
            A += B/2;
            B /= 2;
        }
    }
    cout << A << ' ' << B << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> dat(n);
    rep(i,n){
        int a,b;
        cin>>a>>b;
        dat[i]=make_pair(a,b);
    }
    sort(dat.begin(),dat.end());
    ll ans=0,now=0;
    rep(i,n){
        while(now!=m&&dat[i].second!=0){
            dat[i].second--;
            ans+=dat[i].first;
            now++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3928
def main():
    K, Q = list(map(int, input().split()))
    D = list(map(int, input().split()))
    query_list = [list(map(int, input().split())) for _ in range(Q)]
    ans = [0 for _ in range(Q)]
    for q, query in enumerate(query_list):
        N, X, M = query
        # 増分の数列をmod_dにした数列を考える
        mod_d = [d % M for d in D]
        # a_{j} mod M = a_{j+1} mod M なる j (in {0, ..., N - 2})の個数
        cnt_no_change = 0
        for i, d in enumerate(mod_d):
            # mod_d_{j mod K} = 0 なる j の個数をカウント
            if d != 0:
                continue
            cnt = (N - 2) // K
            if i <= (N - 2) % K:
                cnt += 1
            cnt_no_change += cnt
        # a_{j} mod M > a_{j+1} mod M なるjの個数
        initial_a = X
        final_a = initial_a  # a_{N - 1}
        for i, d in enumerate(mod_d):
            cnt = (N - 2) // K
            if i <= (N - 2) % K:
                cnt += 1
            final_a += cnt * d
        cnt_decrease = final_a // M - initial_a // M
        ans[q] = N - 1 - cnt_no_change - cnt_decrease
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 85616
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <math.h>
#define REP0(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REP1(i,n) for((i)=1;(i)<=(long long)(n);(i)++)
#define ll long long
using namespace std;

ll i,j,k;
const ll MOD = 1000000000 + 7;

int main(){
    int n;
    ll ans=0;
    cin>>n;
    REP1(i,n){
        ans+=i*(1+(n/i))*(n/i)/2;
    }


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

Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n){
    cin >> a[i];
    a[i] -= (i + 1);
  }
  vector<int> d = a;
  sort(ALL(d));
  int b = d[n/2];

  ll ans = 0;
  rep(i, n){
    ans += abs(a[i] - b);
  }
  cout << ans << endl;
}



Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 21) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 100010;
const int MOD = 1000000007;
const int INF = 1000000000;

int n, k;
int a[MAXN];

int main()
{
	
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++ i)
		scanf("%d", &a[i]);
	//int p = lower_bound(a+1, a+n+1, 0)-a;
	int ans = INF;
	for (int i = 1; i <= n; ++ i)
	{
		int j = i+k-1;
		if (!(1 <= j && j <= n)) continue;
		int tmp = min(abs(a[i]), abs(a[j]))+abs(a[i]-a[j]);
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	char lc1Buf[1024];

	// 値 - 取得
	long long llA, llB, llN;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%lld%lld%lld", &llA, &llB, &llN);

	// 最大値
	long long llMax;
	if (llN < llB) {
		llMax = llA * llN / llB;
	}
	else {
		llMax = llA * (llB - 1) / llB;
	}

	// 出力
	sprintf(lc1Buf, "%lld\n", llMax);
	fOutLine(lc1Buf);

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 1772
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
long long gcd(long long a,long long b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int main() {
	long long n,m,ans=1,ki=0,fo=0;
	cin>>n;
	vector<long long>t(n);
	rep(i,n)cin>>t[i];
	rep(i,n){
	    ans=ans/gcd(ans,t[i])*t[i];
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto ve = readln.split.to!(int[]);
    auto V = ve[0];
    auto E = ve[1];
    auto G = new long[][](V, V);
    foreach (i, ref g; G) {
        g[] = long.max/3;
        g[i] = 0;
    }
    foreach (_; 0..E) {
        auto std = readln.split.to!(int[]);
        G[std[0]][std[1]] = std[2];
    }

    foreach (k; 0..V) {
        foreach (i; 0..V) {
            foreach (j; 0..V) {
                if (G[i][j] > G[i][k] + G[k][j]) {
                    G[i][j] = G[i][k] + G[k][j];
                }
            }
        }
    }
    auto G2 = new long[][](V, V);
    foreach (i; 0..V) foreach (j; 0..V) G2[i][j] = G[i][j];
    foreach (k; 0..V) {
        foreach (i; 0..V) {
            foreach (j; 0..V) {
                if (G[i][j] > G[i][k] + G[k][j]) {
                    G[i][j] = G[i][k] + G[k][j];
                }
            }
        }
    }
    foreach (i; 0..V) foreach (j; 0..V) if (G2[i][j] != G[i][j]) {
        writeln("NEGATIVE CYCLE");
        return;
    }
    auto R = new string[][](V, V);
    foreach (i; 0..V) foreach (j; 0..V) {
        if (G[i][j] >= long.max/4) {
            R[i][j] = "INF";
        } else {
            R[i][j] = G[i][j].to!string;
        }
    }

    foreach (r; R) writeln(r.join(" "));
}


Measured memory_bytes: 3140
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;


int main() {
	long long A, B, N;

	cin >> A >> B >> N;

	/*N<Bならx=Nが最大。そうでないときはx=B-1が最大*/

	if (N < B) {
		cout << ((A*N) / B) - A * (N / B);
	}
	else {
		cout << ((A*(B - 1)) / B) - A * ((B - 1) / B);
	}

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
using namespace std;
ll lim=1e18;

int main() {
   fast
    ll a;cin>>a;
    string b;cin>>b;
    int n=b.length();
    int val=(b[n-2]-'0')*10+(b[n-1]-'0');
    int x=stoi(b);
    x=x*100+val;
    ll ans=a*x/100;
    cout<<ans;
   return 0;
   
}

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

ll dp[1010][10010];
const ll INF=1e18;

int main(){
    int h,n;
    cin>>h>>n;
    vector<int>a(n),b(n);
    rep(i,n)cin>>a[i]>>b[i];
    rep(i,1010)rep(j,10010)dp[i][j]=INF;
    rep(i,1010)dp[i][0]=0;
    for(int i=0; i<n; ++i){
        for(int j=0; j<=h; ++j){
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            dp[i+1][min(j+a[i],h)]=min(dp[i+1][min(j+a[i],h)],dp[i+1][j]+b[i]);
        }
    }
    cout<<dp[n][h]<<endl;
}

Measured memory_bytes: 82632