akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

static const int MAX = 100001;

/******* c++14 don't include *******/

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

/*******                      *******/

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    
    
    double res = (double)((double)h*(double)w/(double)2);
    
    int res_2 = (x*2==w && y*2==h)? 1:0;
    
    printf("%9f %d\n", res, res_2);
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    vector<ll> t(N), a(N);
    for(int i=0; i<N; i++) cin >> t[i] >> a[i];

    ll tkhs = t[0], aok = a[0];
    for(int i=1; i<N; i++){
        ll n = max( (tkhs-1)/t[i]+1, (aok-1)/a[i]+1 );
        tkhs = n*t[i];
        aok = n*a[i];
    }

    cout << tkhs + aok << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long r, a = 1, b;
    double sum = 0;
    cin >> r;
    cout << r * r << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int[] D = new int[N + 1];  // D[N] = 0
		for(int i = 0; i < N; i++)
			D[i] = GetInt();

		int[] cnt = new int[13];
		for(int i = 0; i <= N; i++)
			cnt[D[i]]++;

		var free = new List<int>();
		bool[] exist = new bool[24];
		exist[0] = true;
		for(int i = 0; i < N; i++)
		{
			if(cnt[D[i]] >= 3)
			{
				Console.WriteLine(0);
				return;
			}
			else if(cnt[D[i]] == 2)
			{
				if(D[i] == 0 || D[i] == 12)
				{
					Console.WriteLine(0);
					return;
				}
				else
				{
					exist[D[i]] = true;
					exist[24 - D[i]] = true;
				}
			}
			else if(cnt[D[i]] == 1)
				free.Add(i);
		}

		int ans = 0;
		int L = free.Count;
		for(int s = 0; s < (1 << L); s++)
		{
			bool[] tmpExist = new bool[24];
			Array.Copy(exist, tmpExist, 24);

			for(int i = 0; i < L; i++)
			{				
				if(contain(s, i))
					tmpExist[D[free[i]]] = true;
				else
					tmpExist[24 - D[free[i]]] = true;				
			}

			int min = int.MaxValue;
			for(int i = 0; i < 24; i++)
			{
				for(int j = i + 1; j < 24; j++)
				{
					if(tmpExist[i] && tmpExist[j])
						min = Math.Min(min, Math.Min(j - i, 24 - (j - i)));
				}
			}
			ans = Math.Max(ans, min);
		}

		Console.WriteLine(ans);
	}

	private bool contain(int s, int x) => ((s >> x) & 1) == 1;
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 13140
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func f(s string) {
	pos := -1
	m := make([]int, 26)
	v := byte(0)
L0:
	for i := len(s) - 1; i >= 0; i-- {
		c := int(s[i] - 'a')
		// out(c, m)
		for j := c; j < 26; j++ {
			if m[j] == 1 {
				v = byte(j + 'a')
				pos = i
				break L0
			}
		}
		m[c]++
	}

	if pos == -1 {
		out(-1)
		return
	}

	out(s[:pos] + string(v))

	return
}

func main() {
	sc.Split(bufio.ScanWords)
	s := getString()
	m := make([]int, 26)
	for _, v := range s {
		m[int(v-'a')]++
	}
	c := -1
	for i := 0; i < 26; i++ {
		if m[i] == 0 {
			c = i
			break
		}
	}
	if c == -1 {
		f(s)
		return
	}
	out(s + string(byte(c+'a')))
}


Measured memory_bytes: 640
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    V<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
    cout << a[k - 1] << '\n';
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 600010
using namespace std;

main(){
    int h,w;
    cin>>h>>w;
    int a[600][600];
    rep(i,h)rep(j,w)cin>>a[i][j];
    int b[600][600];
    rep(i,h)rep(j,w)b[i][j]=a[i][j];
    int count=0;
    rep(i,h)rep(j,w){
        if(j!=w-1){
            if(b[i][j]%2){
                count++;
                b[i][j+1]++;
            }
        }
        else if(b[i][j]%2&&i!=h-1){
            count++;
            b[i+1][j]++;
        }
    }
    cout<<count<<endl;
    rep(i,h)rep(j,w){
        if(j!=w-1){
            if(a[i][j]%2){
                printf("%d %d %d %d\n",i+1,j+1,i+1,j+2);
                a[i][j+1]++;
            }
        }
        else if(a[i][j]%2&&i!=h-1){
            printf("%d %d %d %d\n",i+1,j+1,i+2,j+1);
            a[i+1][j]++;
        }
    }
    return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=100010;

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

    ll n;
    cin>>n;
    ll ans=n*n*n;
    cout<<ans<<endl;

	return(0);
}


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

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <list>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
#include <ctime>
#include <assert.h>
using namespace std;

//const unsigned long long MOD = (unsigned long long)(1e9 + 7);
const long long BASE = (long long)(998244353);

#define FROM_0(i, n) for(int i = 0; i < (n); i++)
#define FROM_S(i, s, e) for(int i = (s); i < (e); i++)
#define ITER_BEGIN_END(iter, vec) for(auto iter = vec.begin(); iter != vec.end(); iter++)

long long dp[200001];
long long cumsum[200001];

int main()
{
    int n, k;
    int left[11], right[11];
    cin >> n >> k;
    FROM_0(i, k)
    {
        cin >> left[i] >> right[i];
    }
    dp[1] = 1;
    cumsum[1] = 1;
    FROM_S(i, 2, n + 1)
    {
        long long ret = 0;
        FROM_0(j, k)
        {
            int l = max(1, i - right[j]);
            int r = i - left[j];
            if (l > r)
                continue;
            long long tmp = (cumsum[r] - cumsum[l - 1]) % BASE;
            ret = (ret + tmp) % BASE;
            if (ret < 0)
                ret += BASE;
        }
        dp[i] = ret;
        cumsum[i] = (cumsum[i - 1] + dp[i]) % BASE;
    }
    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 6744
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;

int main()	{
  ll n;
  cin >> n;
  ll a[n] = {0};
  ll sum = 0;
  for (ll i = 0; i < n; i++)	{
    cin >> a[i];
    sum += a[i];
  }
  ll asum = 0;
  ll mindif = 1000000000000000;
  for (ll i = n - 1; i >= 1; i--)	{
    sum -= a[i];
    asum += a[i];
    mindif = min(mindif, abs(sum - asum));
  }
  cout << mindif << endl;
  return 0;
}

Measured memory_bytes: 5112
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

#include <unordered_set>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i,N) cin >> A[i];

	unordered_set<int> o;
	rep(i,N) {
		if(i%2)
			o.insert(A[i]);
	}
	sort(A.begin(), A.end());
	int res = 0;
	rep(i,N) {
		if(i%2 && o.find(A[i]) == o.end())
			res++;
	}
	cout << res << endl;
	return 0;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

string s, t, u;
int a, b;
void solve() {
    cin >> s >> t; cin >> a >> b; cin >> u;
    if (s == u) --a; else --b;
    cout << a << " " << b << endn;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
 


int main()
{
	//ifstream cin("input.txt");
	ll a,b, k;
	cin>>a>>b>>k;
	vi divs;
	int m = min(a,b);
	rep(i, 1, m)
		if(a%i == 0 && b%i == 0)
			divs.push_back(i);
	cout<<divs[divs.size() - k];
	
}


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

void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
}

int main(){
    fast();
    ll n,m,a=0,flag=0;
    cin>>n>>m;
    for(ll i=1;i<=10000;i++){
    	if(((8*i)/100)==n and (i/10)==m){
    		a=i;
    		flag=1;
    		break;
		}
	}
	if(flag){
		cout<<a;
	}
	else
	cout<<"-1";
}

Measured memory_bytes: 256
n = int(input())
s = input()
l = []
count = s[1:].count('E')
r = count
for i in range(n-1):
  if s[i] == 'W':
    count += 1
  if s[i + 1] == 'E':
    count -= 1
    if count < r:
      r = count
print(r)


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+5;
vector<int>E[maxn];
int d[maxn][3]; // mod 3=j
int vis[maxn][3];
void bfs(int x)
{
    for(int i=0;i<maxn;i++)
    {
        for(int j=0;j<3;j++)
        {
            d[i][j]=1e9;
        }
    }
    queue<pair<int,int>>q;
    d[x][0]=0;
    vis[x][0]=1;
    q.push({x,0});
    while(!q.empty())
    {
        int now=q.front().first;
        int t=q.front().second;//这一步mod3的值
        int y=(t+1)%3;//下一步mod3的值
        q.pop();
        for(auto&v:E[now])
        {
            if(vis[v][y]) continue;
            vis[v][y]=1;
            d[v][y]=d[now][t]+1;
            q.push({v,y});
        }
    }

}
void dijkstra(int x)
{

}
int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n,m;
   cin>>n>>m;
   for(int i=1;i<=m;i++)
   {
       int u,v;
       cin>>u>>v;
       E[u].push_back(v);
   }
   int s,t;
   cin>>s>>t;
   bfs(s);
   if(d[t][0]==1e9)
   {
       cout<<-1<<'\n';
   }
   else
    cout<<d[t][0]/3<<'\n';



}











Measured memory_bytes: 11904
#include <stdio.h>
#define min(a, b) ((a) < (b) ? (a) : (b))
const long long INF = (int)1e15;

int main(void)
{
    int n, m;
    int d[1024];
    int c[1024];
    long long dp[1024];
    int i, j;

    scanf("%d %d", &n, &m);
    for (i = 0; i < n; i++) scanf("%d", d + i);
    for (i = 0; i < m; i++) scanf("%d", c + i);

    dp[0] = 0;
    for (i = 1; i <= n; i++) dp[i] = INF;
    for (i = 0; i < m; i++){
        for (j = n; j > 0; j--){
            dp[j] = min(dp[j], dp[j - 1] + d[j - 1] * c[i]);
        }
    }

    printf("%lld\n", dp[n]);

    return 0;
}

Measured memory_bytes: 612
package main

import (
	"fmt"
)

func main() {
	var h, n int
	fmt.Scan(&h, &n)
	as := make([]int, n)
	bs := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i], &bs[i])
	}

	const inf = int(1e12 + 1)

	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, h+1)
		for j := range dp[i] {
			dp[i][j] = inf
		}
	}

	dp[0][0] = 0

	for i := 1; i <= n; i++ {
		for j := range dp[i] {
			a, b := as[i-1], bs[i-1]

			if dp[i-1][j] != inf {
				dp[i][j] = min(dp[i][j], dp[i-1][j])
			}
			if j >= a && dp[i][j-a] != inf {
				dp[i][j] = min(dp[i][j], dp[i][j-a]+b)
			}
			if dp[i][j] != inf && j+a >= h {
				dp[i][h] = min(dp[i][h], dp[i][j]+b)
			}
		}
	}

	ans := inf
	for i := 1; i <= n; i++ {
		ans = min(ans, dp[i][h])
	}

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 83456
import java.io.*;
import java.util.*;
class Main{
	static final int MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int H = saori.saori_hayami();
		int W = saori.saori_hayami();
		char[][] a = new char[H][W];
		for (int i = 0; i < H; i++) {
			String s = saori.nextHayami();
			for (int j = 0; j < W; j++) {
				a[i][j] = s.charAt(j);
			}
		}
		int[][] dp = new int[H+1][W+1];
		dp[0][0] = 1;
		for(int i = 0;i < H;i++){
			for(int j = 0;j < W;j++){
				if(i != 0 && a[i][j] != '#'){
					dp[i][j] += dp[i-1][j];   
				}
				if(j != 0 && a[i][j] != '#'){
					dp[i][j] += dp[i][j-1];
				}
				dp[i][j] = dp[i][j]%MOD;
			}
		}
		
		System.out.println(dp[H-1][W-1]%MOD);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 36332
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
ll modpow(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2, M);
        return t*t % M;
    }
    return N * modpow(N, P-1, M) % M;
}
int main(){
  int n;
  cin >> n;
  vector<ll>v(n);
  rep(i,n)cin >> v[i];
  map<ll,ll>cnt;
  if(n % 2 == 0){
    rep(i,n){
      if(v[i] % 2 == 0){
        cout << 0 << endl;
        return 0;
      }
      cnt[v[i]]++;
      if(cnt[v[i]] > 2){
        cout << 0 << endl;
        return 0;
      }
      if(v[i] >= n){
        cout << 0 << endl;
        return 0;
      }
    }
    cout << modpow(2,n / 2,INF) << endl;
  }
  else{
    rep(i,n){
      if(v[i] % 2){
        cout << 0 << endl;
        return 0;
      }
      cnt[v[i]]++;
      if(v[i] >= n){
        cout << 0 << endl;
        return 0;
      }
      if(v[i] == 0){
        if(cnt[v[i]] > 1){
          cout << 0 << endl;
          return 0;
        }
      }
      else{
        if(cnt[v[i]] > 2){
          cout << 0 << endl;
          return 0;
        }
      }
    }
    cout << modpow(2,n / 2,INF) << endl;
  }
  return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; i++)
  {
    cin >> h.at(i);
  }

  vector<int> dp(N, INF);
  dp.at(0) = 0;
  for (int i = 0; i < N; i++)
  {
    for (int j = 1; j <= K; j++)
    {
      if (i + j >= N) break;
      chmin(dp.at(i + j), dp.at(i) + abs(h.at(i + j) - h.at(i)));
    }
  }
  
  int ans = dp.at(N - 1);
  cout << ans << endl;
}

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

int main(){

    string str;
    int company[1001] = {0};
    int number=0,n;
    bool rowFlag[1001];

    for(int i=0; i<1001; i++){
        rowFlag[i] = false;
    }

    while(getline(cin,str) , str != ""){
        for(int i=0; i<str.length(); i++){
            if(str[i] == ','){
                company[number]++;
                number = 0;
                break;
            }
            number *= 10;
            number += (int)str[i] - '0';
        }
    }

    while(scanf("%d,%d",&number,&n) != EOF){
        if(company[number] > 0){
            rowFlag[number] = true;
            company[number]++;
        }
    }

    for(int i=1; i<1001; i++){
        if(rowFlag[i]){
            cout<<i<<' '<<company[i]<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
	float t,Max = 0,Min = 1000000;
	while(scanf("%f",&t) != EOF){
		Max = max(Max,t);
		Min = min(Min,t);
	}
	printf("%f\n",Max - Min);
	return 0;
}

Measured memory_bytes: 1072
#include <iostream>

using namespace std;

int main () {
	char s[9];
	cin >> s;
	if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I'){
		cout << "Yes";
	}else{
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

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

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

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////
ll p(ll i) {
	if (i == 0) { return 1; }
	return p(i - 1) * 3;
}


int main() {
	ll Q;
	cin >> Q;

	rep(i, Q) {
		ll a, b, c, d;
		cin >> a >> b >> c >> d;

		if (abs(a - c) < abs(b - d)) { swap(a, b); swap(c, d); }
		if (c < a) { swap(a, c); swap(b, d); }
		
		ll ob = 0;
		repn(j, 30) {
			ll w = p(j - 1);
			ll I = b / (3 * w);
			
			if (I * 3 * w + w < b&&b <= I * 3 * w + 2 * w&&I * 3 * w + w < d&&d <= I * 3 * w + 2 * w) {
				ll J = (a-w)/(3*w);
				if (3 * w*J < a - w) { J++; }
				//cout << j<<I<<J;
				if (3 * w*J + 2 * w < c) { ob = j; }
			}
		}

		//cout << ob;

		if (ob == 0) { cout << abs(a - c) + abs(b - d); }

		else {
			ll w = p(ob - 1);

			ll t = b % w;
			if (t == 0) { t = w; }
			ll u = d % w;
			if (u == 0) { u = w; }

			ll dist1 = t+u;
			ll dist2 = 2 * (w + 1) - dist1;
			cout << abs(c - a) + min(dist1, dist2);
		}

		cout << endl;

	}

	

	system("PAUSE");

}





Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

signed main(){
    int N;
    int d[314514];
    cin >> N;
    REP(i,N){
        cin >> d[i];
    }
    int R=d[0];
    OREP(i,N-1){
        if(10*i>R){cout << "no" << endl;return 0;}
        R=max(R,i*10+d[i]);
    }
    int L=d[N-1];
    OREP(i,N-1){
        if(10*i>L){cout << "no" << endl;return 0;}
        L=max(L,i*10+d[N-1-i]);
    }
    cout << "yes" << endl;
    return 0;
}   


Measured memory_bytes: 5484
// CODE by Kazhybay Askar
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define iter   set<int>::iterator
#define f      first
#define s      second
#define pb     push_back
#define pf     push_front
#define mp     make_pair
#define cont   continue
#define ll     long long
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define endl   '\n'

const int MAXN = 1e5  + 7;
const int MOD  = 1e9  + 7;
const int INF  = 1e9  + 7;
const ll  MINF = 1e18 + 7;
const int EPS  = 1e-6;
const int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[] = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);


typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

vector<int>g[MAXN],v;
bool used[MAXN];
ll n,m,k,cnt,sum,ans,mx,mn=INF;
bool y;

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

ll a,b,c;
void solve(){
	cin>>a>>b>>c;
    mn=min(b,c);
    cnt+=mn*2;
    b-=mn;
    c-=mn;
    mn=min(a,c);
    cnt+=mn;
    a-=mn;
    c-=mn;
    cnt+=b;
    if(c>0){
        cnt++;
    }
    cout<<cnt;
}

int main(){
	Speed;
	ll T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	r0;
}




Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD				1000000007
#define MOD1			998244353
#define EPS				1e-9
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)

using namespace std;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const int tam = 10000010;
bitset<1000> bi;
vector<int> pri;
int can[200];
void criba()
{
	bi.set();
	fore(i, 2, 1000)
	{
		if(bi[i])
		{
			forg(j, i + i, 1000, i)
				bi[j] = 0;
			pri.pb(i);
		}
	}
}
int n;
void facto()
{
	for(int i = 0; i <= n; i++)
	{
		int con = 0;
		int ax = i;
		while(pri[con] * pri[con] <= ax)
		{
			while(ax % pri[con] == 0)
			{
				ax /= pri[con];
				can[pri[con]]++;
			}
			con++;
		}
		if(ax > 1)
			can[ax]++;
	}
}
int dp[200][10];
int canu[] = {2, 4, 4};
int f(int pos, int mask)
{
	//cout<<pos<<' '<<mask<<' '<<n<<' '<<pri[pos]<<' '<<dp[pos][mask]<<'\n';
	if(mask == 7) return 1;
	if(pri[pos] > n) return 0;
	if(dp[pos][mask] != -1) return dp[pos][mask];
	int res = 0;
	fore(i, 0, 3)
	{
		if((mask & (1<<i)) == 0 && can[pri[pos]] >= canu[i])
		{
			res += f(pos+1, (mask | (1<<i)));
			if(i == 1) break;
		}
	}
	if((mask & 6) == 0 && can[pri[pos]] >= 24)
	{
		res += f(pos + 1, (mask | 6));
	}

	if((mask & 3) == 0 && can[pri[pos]] >= 14)
	{
		res += f(pos + 1, (mask | 3));
	}
	else
	{

		if((mask & 5) == 0 && can[pri[pos]] >= 14)
		{
			res += f(pos + 1, (mask | 5));
		}
	}

	if((mask & 7) == 0 && can[pri[pos]] >= 74)
	{
		res += f(pos + 1, (mask | 7));
	}
	res += f(pos + 1, mask);
	return dp[pos][mask] = res;
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("asd.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	criba();
	cin>>n;
	facto();
	mem(dp, -1);
	cout<<f(0,0)<<'\n';

	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
        int a,b;
        cin >> a >> b;
        if(a>=13)
                cout << b << "\n";
        if(a<13 && a>5)
                cout << b/2 << "\n";
        if(a<=5)
                cout << 0 << "\n";
        return 0;
}


Measured memory_bytes: 256
def changeStr(num, charactor):
  sum = num + ord(charactor)
  if sum > 64 + 26 :
    return chr(sum - 26)
  else:
    return chr(sum)

inputStr = [input() for i in range(2)]
num = int(inputStr[0])
targetStr = inputStr[1]

for target in list(targetStr):
  print(changeStr(num, target), end="")

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())

int main() {
	cin.sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;

	cout << min(a, b) + min(max(a,b), c) << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(k)]

MOD = 998244353

dp = [0] * n
dp[0] = 1

ruidp = [0] * (n + 1)
ruidp[1] = 1


for i in range(n):
  for l, r in LR:
    dp[i] += (ruidp[max(i - l + 1, 0)] - ruidp[max(i - r, 0)])
    dp[i] %= MOD
  ruidp[i + 1] = ruidp[i] + dp[i] 
  ruidp[i + 1] %= MOD

print(dp[-1])


Measured memory_bytes: 24708
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let h1: u64 = sc.read();
    let m1: u64 = sc.read();
    let h2: u64 = sc.read();
    let m2: u64 = sc.read();
    let k: u64 = sc.read();

    let t1 = h1 * 60 + m1;
    let t2 = h2 * 60 + m2;
    println!("{}", t2 - t1 - k);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2184
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N, long long K, std::vector<long long> H){
  sort(H.begin(), H.end());
  long long t = 0;

  for (int i = 0; i < N-K; ++i) {
    t += H[i];
  }
  std::cout << t << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> H(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&H[i]);
  }
  solve(N, K, std::move(H));
  return 0;
}


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


def solve(N: int):
    print(N * 2 * math.pi)
    return


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

if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
import sys
from collections import defaultdict
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
import numpy as np

def solve(N: int, M: int, L: int, A: "List[int]", B: "List[int]", C: "List[int]", Q: int, s: "List[int]", t: "List[int]"):
    distance = [[0 for i in range(N)] for _ in range(N)] ## nかけるn
    for abc in zip(A,B,C):
        distance[abc[0]-1][abc[1]-1] = abc[2]
        distance[abc[1]-1][abc[0]-1] = abc[2]
    graph = csr_matrix(distance)
    dist_matrix = floyd_warshall(graph,directed=False) ## 最短経路の行列
    
    fuel_matrix = [[0 for i in range(N)] for _ in range(N)] ## nかけるn
    for i in range(N):
      for j in range(N):
        if 0 < dist_matrix[i][j] <= L:
          fuel_matrix[i][j] = 1
    graph2 = csr_matrix(fuel_matrix)
    dist_matrix2 = floyd_warshall(graph2,directed=False) ## 最短経路の行列

    for i in range(Q):
      if dist_matrix2[s[i]-1][t[i]-1] == float("inf"):
        print(-1)
      else:
        print(int(dist_matrix2[s[i]-1][t[i]-1])-1)
                
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    L = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    Q = int(next(tokens))  # type: int
    s = [int()] * (Q)  # type: "List[int]"
    t = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        s[i] = int(next(tokens))
        t[i] = int(next(tokens))
    solve(N, M, L, A, B, C, Q, s, t)

if __name__ == '__main__':
    main()


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

int main(){
	int n,m;
	cin >> n>>m;
	vector<pair<int,string>>p(m);
	rep(i,m){
		cin>>p[i].first>>p[i].second;
	}
	vector<bool> ac(n+1,0);
	vector<int>wa_cnt(n+1,0),ac_cnt(n+1,0);
	rep(i,m){
		if(ac[p[i].first]==false){
    		if(p[i].second=="WA"){	
				wa_cnt[p[i].first]++;
			}else{
              ac[p[i].first]=true;
				ac_cnt[p[i].first]=1;
			}
		}
	}
   int sum_ac=0,sum_wa=0;
    for(int i=1;i<=n;i++){
      if(ac[i]==true)sum_wa+=wa_cnt[i];
      sum_ac+=ac_cnt[i];
    }
	cout<<sum_ac<<" "<<sum_wa<<'\n';
	return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int n, m, Q;
vector<vector<int>> sum;

int buildSumTable(vector<int> L, vector<int> R) {
    sum = vector<vector<int>>(n+1, vector<int>(n+1, 0));
    rep(i, m) {
        sum[L[i]][R[i]]++;
    }

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            sum[i][j] += sum[i-1][j];
            sum[i][j] += sum[i][j-1];
            sum[i][j] -= sum[i-1][j-1];
        }
    }
}

int getSumRange(int L, int R) {
    int ans = sum[R][R] - sum[R][L-1] - sum[L-1][R] + sum[L-1][L-1];
    return ans;
}

int main() {
    cin >> n >> m >> Q;
    vector<int> L(m);
    vector<int> R(m);
    rep(i, m) {
        cin >> L[i] >> R[i];
    }
    vector<int> p(Q);
    vector<int> q(Q);
    rep(i, Q) {
        cin >> p[i] >> q[i];
    }

    buildSumTable(L, R);

    rep(i, Q) {
        int ans = getSumRange(p[i], q[i]);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 5120
var
	N,K,ans,now,i:Longint;
	x:Array[1..100000]of Longint;
begin
	read(N,K);
	for i:=1 to N do read(x[i]);
	ans:=2000000000;
	for i:=1 to N-K+1 do begin
		now:=x[i+K-1]-x[i];
		if abs(x[i+K-1])>abs(x[i])then inc(now,abs(x[i]))else inc(now,abs(x[i+K-1]));
		if ans>now then ans:=now;
	end;
	writeln(ans);
end.


Measured memory_bytes: 512
k, n = map(int, input().split())
a_list = [int(i) for i in input().split()]

max_diff = -1
for i in range(n-1):
    max_diff = max(max_diff, a_list[i+1] - a_list[i])
max_diff = max(max_diff, abs(k-a_list[-1] + a_list[0]))
print(k-max_diff)


Measured memory_bytes: 26436
n = [int(e) for e in input().split(" ")]
a = [int(e) for e in input().split(" ")]
a.append(n[0] + a[0])
m = 0
for i in range(len(a) - 1):
    d = a[i + 1] - a[i]
    if(m < d):
        m = d
else:
    print(n[0] - m)

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

using namespace std;

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

vector<P> e[100100];
int N, Q, K;
ll cost[100100];
ll hist[100100];


void calc_dis(int v, ll dis){
    cost[v] = dis;
    hist[v] = 1;
    for(int i = 0; i < e[v].size(); i++){
        int des = e[v][i].first;
        ll c = e[v][i].second;
        if(hist[des] == 1)  continue;
        calc_dis(des, dis+c);
    }
}


int main(){
    cin >> N;
    for(int i = 0; i < N-1; i++){
        int a, b; ll c;
        cin >> a >> b >> c;
        a--; b--;
        e[a].emplace_back(P(b, c));
        e[b].emplace_back(P(a, c));
    }
    fill(hist, hist+N, 0);
    fill(cost, cost+N, 0);
    cin >> Q >> K;
    calc_dis(K-1, 0);
    for(int i = 0; i < Q; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << cost[x] + cost[y] << endl;
    }

    return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x,y;
	for(int i=1;i<=10001;i++){
		cin>>x>>y;
		if(x==0&&y==0)break;
		if(x<y)
		cout<<x<<" "<<y<<endl;
		else if(x>y)
		cout<<y<<" "<<x<<endl;
		else
		cout<<x<<" "<<y<<endl;
		
	}
}




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

using namespace std;

int main()
{
  int h, w, a[500][500];
  cin >> h >> w;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      cin >> a[i][j];
  vector<string> ans;
  for (int i = 0; i < h - 1; i++)
    for (int j = 0; j < w; j++)
      if (a[i][j] % 2 == 1)
      {
        ans.push_back(to_string(i + 1) + " " + to_string(j + 1) + " " + to_string(i + 2) + " " + to_string(j + 1));
        a[i + 1][j]++;
      }
  for (int i = 0; i < w - 1; i++)
    if (a[h - 1][i] % 2 == 1)
    {
      ans.push_back(to_string(h) + " " + to_string(i + 1) + " " + to_string(h) + " " + to_string(i + 2));
      a[h - 1][i + 1]++;
    }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 11892
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int length_of_year(int y){ // 1-indexed
  if(y%400 == 0 || ((y%100 != 0) && (y%4 == 0)))return 366;
  return 365;
}

int length_of_month(int y, int m){ // 1-indexed
  int monthes[12] = {31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    if(m != 2)return monthes[m-1];
    if(length_of_year(y) == 366)return 29;
    return 28;
}

/*int date_to_int(string date){ //ex) 2018/08/05
    int y = stoi(date.substr(0, 4)), m = stoi(date.substr(5, 2)), d = stoi(date.substr(8, 2));
    int ans = 0;
    repi(i,1,y)ans += length_of_year(i);
    repi(i,1,m)ans += length_of_month(y, i);
    return ans + d;
}*/

/*string int_to_date(int date){
    int y = 1, m = 1;
    for(int i = 1;length_of_year(i) < date;i++){date -= length_of_year(i);y++;}
    for(int i = 1;length_of_month(y, i) < date;i++){date -= length_of_month(y, i);m++;}
    string ans;
    ans += string(4-to_string(y).size(), '0') + to_string(y) + "/";
    ans += string(2-to_string(m).size(), '0') + to_string(m) + "/";
    ans += string(2-to_string(date).size(), '0') + to_string(date);
    return ans;
}*/

int struct_to_int(int y, int m, int d){
	int ans = 0;
	repi(i,1,y)ans += length_of_year(i);
	repi(i,1,m)ans += length_of_month(y, i);
	return ans+d;
}

/*string struct_to_date(int y, int m, int d){
	return int_to_date(struct_to_int(y, m, d));
}*/

struct st{int y, m, d;};
signed main(){
	st a, b;
	scanf("%lld%lld%lld", &a.y, &a.m, &a.d);
	scanf("%lld%lld%lld", &b.y, &b.m, &b.d);
	int aa = struct_to_int(a.y, a.m, a.d), bb = struct_to_int(b.y, b.m, b.d);
	if(aa > bb)swap(a, b);
	
	int ans = b.y-a.y;
	if(a.m == b.m and a.d == b.d){
		if(a.m == 2 and a.d == 29)printf("%lld\n", ans+1);
		else printf("%lld\n", ans);
		return 0;
	}
	if(b.m < a.m || (b.m <= a.m and b.d < a.d)){
		printf("%lld\n", ans);
	}else printf("%lld\n", ans+1);
	//printf("%lld %lld %lld", a.y, a.m, a.d);
	return 0;
}








Measured memory_bytes: 3236
package main

import "fmt"

func Rectangle(a, b int) (int, int) {
    area := a * b
    length := ( a + b ) * 2

    return area, length
}

func main() {
    var a,b int
    fmt.Scan(&a)
    fmt.Scan(&b)

    fmt.Println(Rectangle(a, b))
}


Measured memory_bytes: 1160
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX 100000
int ti[100000],a=0,e=0,deqti;
string name[MAX], deqname;
void enq(int n,string na){ti[e]=n;name[e]=na;e=(e+1)%MAX;}
void deq(){ deqti=ti[a]; deqname=name[a]; a=(a+1)%MAX;}

int main(){
  int timecnt = 0, n, quantum, itime;
  string str;
  cin>>n>>quantum;
  for(int i = 0; i < n; i++){
    cin>>str>>itime;
    enq(itime, str);
  }
  while(true){
    deq();
    if(deqti - quantum <= 0){
      int t = deqti;
      timecnt+=t;
      cout<<deqname<<" "<<timecnt<<endl;
    }
    else {
      timecnt+=quantum;
      enq(deqti-quantum,deqname);
    }
    if(a==e)break;
  }
  return 0;
}



Measured memory_bytes: 6524
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

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

  vector<vector<int>> G(n);
  for(int i = 0; i < n; i++){
    if(i > 0) G[a[i]].push_back(i);
  }

  int ans = 0;
  vector<int> dp(n,0);
  function< void(int,int) > dfs =
  [&](int u,int pre){
    for(int v : G[u]){
      if(v == pre) continue;
      dfs(v,u);
      dp[u] = max(dp[u],dp[v] + 1);
    }
    if(dp[u]+1 == k){
      dp[u] = -1;
      if(u != 0 && pre != 0) ans++;
    }
  };
  dfs(0,-1);
  cout << ans + (a[0] != 0) << endl;

  return 0;
}


Measured memory_bytes: 16640
s = int(input())
ans = 0
tmp = [s]
for i in range(1, 10 ** 6 + 1):
    if tmp[i - 1] % 2 == 0:
        t = tmp[i - 1] // 2
    else:
        t = 3 * tmp[i - 1] + 1
    if tmp.count(t) != 0:
        print(i+1)
        exit(0)
    else:
        tmp.append(t)

Measured memory_bytes: 9172