akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace AtCoderBeginnercontest161
{
	class Program
	{
		static void Main(string[] args)
		{
			var inputs = ReadLongArray();
			var n = inputs[0];
			var k = inputs[1];

			if (n < k)
			{
				Console.WriteLine(Math.Min(n, k - n));
				return;
			}

			n = n % k;
			Console.WriteLine(Math.Min(n, k - n));
			return;
		}

		public static int ReadInt()
			=> int.Parse(Console.ReadLine());

		public static int[] ReadIntArray()
			=> Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

		public static long ReadLong()
			=> long.Parse(Console.ReadLine());

		public static long[] ReadLongArray()
			=> Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

		public static string ReadString()
			=> Console.ReadLine();

		public static string[] ReadStringArray()
			=> Console.ReadLine().Split();
	}
}


Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
 
int main()
{
    ll a, b, k;
    cin >> a >> b;
    if(a % 2 != b % 2){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    else{
        cout << (a+b)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	ll N, K;
	cin >> N >> K;
	ll sum = 0;
	if(K != 0) {
		FOR(i, K + 1, N + 1) {
			sum += int(N / i)*(i - K);
			//cout << i << " " << sum << " ";
			if (N % i >= K) sum += (N % i - K + 1);
			//cout << sum << endl;
		}
	}
	else sum = N*N;
	cout << sum << endl;
	//cin >> N >> K;


	
	return 0;
}


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

using namespace std;

struct Data
{
  string s;
  int t;
};

class Queue
{
private:
  int head, tail;
  enum { MAX = 100000 };
  Data deq[MAX+1];

public:
  
  Queue() : head(0), tail(0) {}
  
  void push(Data p)
  {
    deq[tail++] = p;
    if(tail == MAX+1) tail = 0;
  }
  
  Data pop()
  {
    Data ret = deq[head++];
    if(head == MAX+1) head = 0;
    return ret;
  }
  
  bool empty()
  {
    return head == tail;
  }
  
};

int main(){
  
  int N, Q;
  cin >> N >> Q;
  
  Queue que;
  
  for(int i=0; i<N; i++) {
    string s; int t;
    cin >> s >> t;
    que.push((Data){s, t});
  }
  
  int elasped = 0;
  
  while(!que.empty()) {
    Data dat = que.pop();
    if(dat.t > Q) {
      dat.t -= Q;
      elasped += Q;
      que.push(dat);
    }
    else {
      elasped += dat.t;
      cout << dat.s << ' ' << elasped << endl;
    }
  }
  
  return 0;
}

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

int gcd(int x, int y){
	if(y == 0){return x;
	}else return gcd(y, x%y);
}

int main(){
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans=0;
	ll lcm = c*d/gcd(c,d);

	ans = b/c + b/d - (a-1)/c - (a-1)/d - b/lcm + (a-1)/lcm;
	ans = b-a + 1 -ans;
	cout << ans << endl;

	return 0;
}


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

int main(){
    string in;
    cin >> in;
    vector<string> s;
    int year = stoi(in.substr(0,4));
    int month = stoi(in.substr(5,2));
    int day = stoi(in.substr(8,2));
    bool hei = true;
    if(year > 2020){
        hei = false;
    }
    else if(year == 2019 && month > 4){
        hei = false;
    }
    if(hei){
        cout<< "Heisei"<<endl;
    }
    else{
        cout << "TBD" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#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... }); }

ll a, b, k;
void solve() {
    cin >> a >> b >> k;

    auto mi = min(a, k);
    a -= mi;
    k -= mi;
    b = max(0LL, b - k);

    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<stdio.h>
int a[4096];
int dp[3005][3005];
int dp2[3005][3005];
int main()
{
	int n,q;
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(a[i]>a[j])
			{
				dp[i][j]=1;
			}
		}
	}
	for(int __=0;__<q;__++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(x>y)
		{
			int t=x;
			x=y;
			y=t;
		}
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(i!=x&&i!=y)
				{
					if(j<=x)
					{
						j=x;
					}
					else if(j<=y)
					{
						j=y;
					}
					else
					{
						break;
					}
				}
				int ii=i,jj=j;
				if(ii==x)
				{
					ii=y;
				}
				else if(ii==y)
				{
					ii=x;
				}
				if(jj==x)
				{
					jj=y;
				}
				else if(jj==y)
				{
					jj=x;
				}
				dp2[i][j]=dp[ii][jj];
			}
		}
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(i!=x&&i!=y)
				{
					if(j<=x)
					{
						j=x;
					}
					else if(j<=y)
					{
						j=y;
					}
					else
					{
						break;
					}
				}
				dp[i][j]+=dp2[i][j];
				if(dp[i][j]>=1000000007)
				{
					dp[i][j]-=1000000007;
				}
				dp[i][j]=(long long)dp[i][j]*500000004%1000000007;
			}
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			ans+=dp[i][j];
			if(ans>=1000000007)
			{
				ans-=1000000007;
			}
		}
	}
	for(int i=0;i<q;i++)
	{
		ans<<=1;
		if(ans>=1000000007)
		{
			ans-=1000000007;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 70656
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

struct UnionFind {
    V<ll> rank;
    V<ll> parent;

    UnionFind(ll N) : rank(N, 0), parent(N) {
        iota(parent.begin(), parent.end(), 0ll);
    }

    ll find(ll child) {
        return (child == parent[child] ? child : parent[child] = find(parent[child]));
    }

    void unit(ll x, ll y) {
        ll px = find(x);
        ll py = find(y);
        if(px == py) {
            return;
        }
        if(rank[px] < rank[py]) {
            swap(px, py);
        }
        parent[py] = px;
        rank[px] += (rank[px] == rank[py]);
    }

    bool same(ll x, ll y) {
        return (find(x) == find(y));
    }
};

int main() {
    ll N, M;
    cin >> N >> M;
    UnionFind uf(N);
    for(ll i = 0; i < M; i++) {
        ll a, b, z;
        cin >> a >> b >> z;
        uf.unit(a - 1, b - 1);
    }

    set<ll> se;
    for(ll i = 0; i < N; i++) se.insert(uf.find(i));
    cout << se.size() << endl;
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    
    int b1,b2,b3;
    cin>>b1>>b2>>b3;
    if(b1>0&&b2>0||b3>0){
      cout<<"Open"<<"\n";
    }
    else{
      cout<<"Close"<<"\n";
    }


    return 0;
}




Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll INF=1LL<<60;
const ll mod=1E9+7;



int main(){
  int n;cin >> n;
  vector<ll>a(n);
  rep(i,n)cin >> a[i];
  sort(a.begin(),a.end());
  ll sum=0;
  sum+=a[n-1];
  int j=n-2;
  for(int i=n-2;i>0;i--){
    sum+=a[j];
    if(((n-2)-i)%2==1)j--;
  }
  cout << sum;
}





Measured memory_bytes: 4832
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

string ans = {};

void solve(){
  // main algorithm
  int rnk = 0, rnk_min = 0;
  for(auto&& ch : S) {
    if(ch == '(') {
      rnk++;
    }
    else {
      rnk--;
      rnk_min = min(rnk_min, rnk);
    }
  }
  for (int i = 0; i < -rnk_min; ++i)
  {
    ans += '(';
  }
  ans += S;
  for (int i = 0; i < rnk - rnk_min; ++i)
  {
    ans += ')';
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N >> S;
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int pre[100005];
int main()
{
   	string s;
  	cin >> s;
  	int year = 0 , x = 1000;
  	for(int i = 0 ; i < 4 ; i++)
    {	
      year += (s[i] - '0')*x;
      x/=10;
    }	
  	int month = (s[5]-'0') * 10 + (s[6] - '0');
  	if(year > 2019)
      cout << "TBD" << endl;
  	else if(year == 2019 && month > 4)
      cout << "TBD" << endl;
  	else
      cout << "Heisei" << endl;
	return 0;
}

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

#define _CRT_SECURE_NO_WARNINGS

int main(int argc, char const *argv[]){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a == b && b == c)	puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
n = int(input())
l = list(map(int,input().split()))
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
                if l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[i] + l[k] > l[j]:
                    ans += 1
print(ans)

Measured memory_bytes: 9212
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var dp = new int[n, n];
            var L = new List<int>[n];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                    if (i != j) dp[i, j] = 999999999;
                L[i] = new List<int>();
            }
            var tsum = 0;
            for (int i = 0; i < n - 1; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                var a = int.Parse(line[0]) - 1;
                var b = int.Parse(line[1]) - 1;
                var t = int.Parse(line[2]);
                dp[a, b] = t; dp[b, a] = t;
                tsum += t;
                L[a].Add(b); L[b].Add(a);
            }
            var p = Enumerable.Range(1, n - 1).ToList();
            for (int i = 1; i < n; i++)
                if (L[i].Count() == 1)
                {
                    p.Remove(i);
                    tsum -= dp[i, L[i][0]];
                }
            tsum *= 2;
            goWarshall(dp);
            Console.WriteLine(tsum - getpmax(dp, p));
        }
    }
    public static int getpmax(int[,] dp, List<int> p)
    {
        var pmax = 0;
        foreach (var x in p)
            pmax = Max(pmax, dp[0, x]);
        return pmax;
    }
    public static void goWarshall(int[,] dp)
    {
        var n = dp.GetLength(0);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++)
                    dp[j, k] = Min(dp[j, k], dp[j, i] + dp[i, k]);
    }
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
   ll A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;

   ll water = 0, sugar = 0;
   double cons = -1.0;

   for(ll i = 0; 100 * A * i <= F; i++){
      for(ll j = 0; 100 * A * i + 100 * B * j <= F; j++){
         if (i == 0 && j == 0) continue;
         for(ll k = 0; (C * k <= (A * i + B * j) * E) && (100 * A * i + 100 * B * j + C * k <= F) ; k++){
            for(ll l = 0; (C * k + D * l <= (A * i + B * j) * E) && (100 * A * i + 100 * B * j + C * k + D * l <= F); l++){
               if(chmax(cons, (double) (C * k + D * l) / (double) (A * i + B * j))){
                  water = 100 * A * i + 100 * B * j ;
                  sugar = C * k + D * l;
               }
            }
         }
      }
   }
   cout << water + sugar << ' ' << sugar << endl;

}


Measured memory_bytes: 256
def gcd(a, b):
    if a > b:
        tmp = a
        a = b
        b = tmp

    if a == 0:
        return b

    else:
        return gcd(a, b%a)

n, x = map(int,input().split())

ans = 3 * (n - gcd(n, x))

print(ans)


Measured memory_bytes: 43120
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";

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

ll A, B, C, X, Y;

int main(){
    vl in(3, 0); cin >> in[0] >> in[1] >> in[2];
    sort(in.begin(), in.end(), greater<ll>());
    ll d1 = in[0] - in[1];
    ll d2 = in[1] - in[2];
    
    ll res = 0;
    if(d1 % 2 == 0 && d2 % 2 == 0){
        res = (d1 + d1 + d2) / 2;
    }
    else if(d1 % 2 == 0){
        res = (d1 + d1 + d2 + 1) / 2 + 1;
    }
    else if (d2 % 2 == 0){
        res = (d1 - 1 + d1 - 1 + d2) / 2 + 1;
    }
    else{
        res = (d1 + 1 + d1 + 1 + d2 - 1) / 2 + 1;
    }
    cout << res << endstr;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

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

  rep(i, n+1) rep(j, (n-i+1)){
    int k = n-i-j;
    if(10000*i+5000*j+1000*k == y){
      cout << i << " " << j << " " << k << endl;
      return 0;
    }
  }

  cout << -1 << " " << -1 << " " << -1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int N;
	int l[100000],r[100000],a=0;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>l[i]>>r[i];
		a=a+(r[i]-l[i]+1);
	}
	cout<<a<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;
int main()
{
    std::map<std::string, int> hoge;
    int N, M;
    std::cin >> N;
    std::string s;
    for (int i = 0; i < N; i++) {
        std::cin >> s;
        hoge[s]++;
    }
    std::cin >> M;
    for (int i = 0; i < M; i++) {
        std::cin >> s;
        hoge[s]--;
    }
    int ans = hoge.begin()->second;
    for (auto it = hoge.begin(); it != hoge.end(); it++) {
        ans = std::max(ans, it->second);
    }
    if (ans < 0) {
        ans = 0;
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3560
using System;
namespace _1{
    class program{
        static void Main(){
            int W, H, x, y, r;
            string [] c = Console.ReadLine().Split();
            W = int.Parse(c[0]);
            H = int.Parse(c[1]);
            x = int.Parse(c[2]);
            y = int.Parse(c[3]);
            r = int.Parse(c[4]);
            if((x - r >= 0 && x + r <= W) && (y - r >= 0 && y + r <= H) )
            {
                Console.Write("Yes\n");
            }
            else
            {
                Console.Write("No\n");
            }
        }
        
    }
}


Measured memory_bytes: 18004
S = input().split(" ")
n = int(S[0])
k = int(S[1])
arr = []
for i in range(n):
    arr.append(int(input()))

def calculate(n, k, arr):
    arr.sort()
    drr = []
    for i in range(1, n):
        drr.append(arr[i] - arr[i - 1])

    j = 0
    s = 0
    sums = []
    for i in range(len(drr) - (k - 1) + 1):
        while j < i + (k-1):
            s = s + drr[j]
            j = j + 1
        sums.append(s)
        s = s - drr[i]
    print(min(sums))



calculate(n, k, arr)


Measured memory_bytes: 15564
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int L = sc.nextInt();
        System.out.println(solve(L));
    }

    private static double solve(int L) {
        double a = L/3.0;

        return Math.pow(a, 3);
    }
}

Measured memory_bytes: 21844
i,F[100],B[100],M[100][100];int D(f,l){
if(~M[f][l])return M[f][l];
if(f==l)return 0;
int x=0x7fffffff,y,i=f;
for(;i<l;i++)if(x>(y=D(f,i)+D(i+1,l)+F[f]*B[i]*F[i+1]*B[l]))x=y;
return M[f][l]=x;}
main(n){memset(M,0xff,sizeof(M));for(scanf("%d",&n);i<n;i++)scanf("%d%d",F+i,B+i);printf("%d\n",D(0,n-1));exit(0);}

Measured memory_bytes: 644
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <map>
#include <tuple>
#include <vector>
using namespace std;

typedef tuple<int, int, int> point;
#define x(p) get<0>(p)
#define y(p) get<1>(p)
#define z(p) get<2>(p)

inline int r(int &a, int &b) {
	static constexpr int C = ~(1 << 31);
	static constexpr int M = (1 << 16) - 1;

	a = 36969 * (a & M) + (a >> 16);
	b = 18000 * (b & M) + (b >> 16);
	return (C & ((a << 16) + b)) % 1000000;
}

inline bool check(int y, int z, const map<int, int> &contour) {
	const auto it = contour.upper_bound(y);
	return it != contour.end() && it->second < z;
}

int solve(vector<point> &points) {
	sort(points.begin(), points.end());

	int max_count = 0;
	int prev_x = x(points.front());
	vector<tuple<int, int, int>> buf;
	vector<map<int, int>> maps{{{1, -1}}};
	buf.reserve(points.size());
	maps.reserve(points.size());

	for(const auto &p : points) {
		const int x = x(p);
		const int y = -y(p);
		const int z = z(p);

		if(prev_x != x) {
			maps.resize(max_count + 1);
			prev_x = x;

			for(const auto &e : buf) {
				int k, ty, tz;
				tie(k, ty, tz) = e;

				auto &target = maps[k];
				auto it = target.lower_bound(ty);

				if(it == target.end() || it->second > tz) {
					target[ty] = tz;
					it = target.find(ty);

					while(it != target.begin()) {
						--it;
						if(tz > it->second) break;
						it = target.erase(it);
					}
				}
			}
			buf.clear();
		}

		int low = 0;
		int high = maps.size();

		while(low + 1 < high) {
			const int mid = (low + high) / 2;
			if(check(y, z, maps[mid])) {
				low = mid;
			}
			else {
				high = mid;
			}
		}

		if(low == max_count) ++max_count;
		buf.emplace_back(high, y, z);
	}

	return max_count;
}

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

	for(int m, n, a, b; cin >> m >> n >> a >> b && a;) {
		vector<point> points;
		points.reserve(n + m);

		for(int i = 0; i < m; ++i) {
			int x, y, z;
			cin >> x >> y >> z;
			points.emplace_back(x, y, z);
		}

		for(int i = 0; i < n; ++i) {
			const int x = r(a, b);
			const int y = r(a, b);
			const int z = r(a, b);
			points.emplace_back(x, y, z);
		}

		cout << solve(points) << "\n";
	}

	return EXIT_SUCCESS;
}

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

int main(){
    int k,a,b;
    string ans = "NG";
    cin >> k >> a >> b;
    for(int i = a ; i <= b ; ++i){
        for(int j = 1; j <= 1000 ; ++j){
            if(k*j == i)
                ans = "OK";
        }
    }
    cout << ans;

    return 0;
}

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

int main() {
    int n,x=0,mx=0;
    char c;
    cin>>n;
    for (int i = 0; i < n; ++i) {
        cin>>c;
        if (c=='I') x++; else x--;
        mx=max(x,mx);
    }
    cout<<mx<<endl;
}


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

N,M = map(int,input().rstrip().split())
S = [0]*M
C = [0]*M
for i in range(M):
    S[i],C[i] = map(int,input().rstrip().split())

for i in range(1000):
    ans = str(i)
    if len(ans) != N:
        continue
    ok = True
    for j in range(M):
        if int(ans[S[j]-1]) != C[j]:
            ok = False
    if ok:
        print(i)
        exit()

print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>

using namespace std;

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

const ll mod = 1e9 + 7;
const ll mmod = 998244353;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<string> g;
vector<vector<bool>> used;
vector<ll> d;

int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll h, w, k, sx, sy, ex, ey;
    cin >> h >> w >> k >> sx >> sy >> ex >> ey;
    
    g = vector<string>(h);
    used = vector<vector<bool>>(h, vector<bool>(w));
    for (int i = 0; i < h; ++i)
    {
        cin >> g[i];
    }
    sx--;
    sy--;
    ex--;
    ey--;
    P s = P(sx, sy);
    vector<vector<ll>> dist(h, vector<ll>(w, mod));
    dist[sx][sy] = 0;
    queue<P> q;
    q.push(s);
    
    while (q.size() > 0)
    {
        P cur = q.front();
        q.pop();
        if (used[cur.first][cur.second])
        {
            continue;
        }
        used[cur.first][cur.second] = 1;
        for (int i = 0; i < 4; ++i)
        {
            for (int j = 1; j <= k; ++j)
            {
                ll nx = cur.first + dx[i] * j;
                ll ny = cur.second + dy[i] * j;
                if (nx >= 0 && ny >= 0 && nx < h && ny < w)
                {
                    if (used[nx][ny])
                    {
                        break;
                    }
                    if (g[nx][ny] == '@')
                    {
                        break;
                    }
                    if (dist[nx][ny] <= dist[cur.first][cur.second])
                    {
                        break;
                    }
                    dist[nx][ny] = dist[cur.first][cur.second] + 1;
                    q.push(P(nx, ny));
                }
            }
        }
        if (dist[ex][ey] != mod)
        {
            cout << dist[ex][ey] << endl;
            return 0;
        }
    }
    
    cout << -1 << endl;
    
    return 0;
}

Measured memory_bytes: 20052
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Osenbei
 * JOI 7th, Pre 5
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);

			int R, C;
			R = parseInt(st.nextToken());
			C = parseInt(st.nextToken());
			if ((R | C) == 0) break;

			int[] CR = new int[C];

			for (int i = 0; i < R; i++) {
				st = new StringTokenizer(br.readLine());
				for (int j = 0; j < C; j++) {
					if (st.nextToken().equals("1")) CR[j] |= 1 << i;
				}
			}

			//solve
			int max = 0;

			for (int i = 0; i < 1 << R; i++) {
				int[] _CR = new int[C];
				for (int j = 0; j < C; j++) {
					_CR[j] = CR[j];
				}
				int flip = 0;
				for (int j = 0; j < R; j++) {
					if ((i >> j & 1) == 1) flip |= 1 << j;
				}
				//
				int count = 0;
				for (int j = 0; j < C; j++) {
					int bits = bits(_CR[j] ^ flip, R);
					count += (bits > R - bits ? bits : R - bits);
				}
				max = Math.max(max, count);
			}

			System.out.println(max);
		}
	}

	static int bits(int b, int size) {
		int ret = 0;
		for (int i = 0; i < size; i++) {
			if ((b >> i & 1) == 1) ret++;
		}
		return ret;
	}
}

Measured memory_bytes: 63904
//nmCk × ある2マスに駒が置かれる確率 × 全2マス間のマンハッタン距離の総和(むずい)
#include <iostream>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int powmod(int a, int n, int mod) {
	if (n == 0) return 1;
	if (n % 2) return (a * powmod(a, n - 1, mod)) % mod;
	return powmod((a * a) % mod, n / 2, mod);
}

int mod = 1000000007;
int fact[200001];
int factInv[200001];

void init() {
	int i;
	fact[0] = 1; factInv[0] = 1;
	for (int i = 1; i < 200001; i++) {
		fact[i] = (i * fact[i - 1]) % mod;
		factInv[i] = powmod(fact[i], mod - 2, mod);
	}
}

int comb(int n, int k) {
	if (n < k) return 0;
	return fact[n] * factInv[n - k] % mod * factInv[k] % mod;
}

int beet(int n) {
	return n * (n + 1) / 2;
}

int h, w, k;

signed main() {
	int y, x;
	
	init();
	cin >> h >> w >> k;
	int hoge = comb(h * w - 2, k - 2);
	
	int wa = 0;
	rep(y, h) {
		rep(x, w) {
			int wax = beet(x) + beet(w - 1 - x);
			int way = beet(y) + beet(h - 1 - y);
			wax %= mod;
			way %= mod;
			wa += wax * h + way * w;
			wa %= mod;
		}
	}
	wa *= powmod(2, mod - 2, mod);
	wa %= mod;
	
	cout << wa * hoge % mod << endl;
	return 0;
}

Measured memory_bytes: 3328
N = int(input())
mod = 10**9+7

def check(s):
    for i in range(4):
        l=list(s)
        if i>0:
            l[i-1],l[i]=l[i],l[i-1]
        if "".join(l).count("AGC"):
            return False
    else:
        return True

memo=[dict() for _ in range(N)]
def dfp(i,seq):
    if i==N:
        return 1
    if seq in memo[i]:
        return memo[i][seq]
    ret=0
    for s in ["A","G","C","T"]:
        if check(seq+s):
            ret=(ret+dfp(i+1,seq[1:]+s))%mod
    memo[i][seq] = ret
    return ret

print(dfp(0,"TTT"))

Measured memory_bytes: 3892
N, M = map(int, input().split())
list=[]
for i in range(M):
    p, y =map(int, input().split())
    list.append([p, y, i])
list.sort(key=lambda list:(list[0], list[1]))
list[0][1]=1
for i in range(M-1):
    if list[i][0] != list[i+1][0]:
        list[i+1][1] = 1
    else:
        list[i+1][1] = list[i][1] + 1 
list.sort(key=lambda list:(list[2]))
for i in range(M):
    print(str(list[i][0]).zfill(6)+str(list[i][1]).zfill(6))

Measured memory_bytes: 30788
import sys

N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(N):
  if(A[i]%2==0):
    B.append(A[i])
for i in range(len(B)):
  if(B[i]%3!=0 and B[i]%5!=0):
    print("DENIED")
    sys.exit()
print("APPROVED")

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

int main(){
  long long w,h,x,y;
  cin>>w>>h>>x>>y;
  double s=double(w)*double(h)/2;
  if(x+x==w && y+y==h){
    cout<<s<<' '<<'1'<<endl;
  }else{
    cout<<s<<' '<<'0'<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll nature(ll a){
  return max(a,-1*a);
}
int main(){
  ll N,sumprice;
  cin>>N;
  vector<ll> A(N);
  for(ll i=0;i<N;i++){
    cin>>A.at(i);
    if(i==0){sumprice=nature(A.at(0));}
    if(i>0){sumprice+=nature(A.at(i)-A.at(i-1));}
    if(i==N-1){sumprice+=nature(A.at(N-1));}
  }
  ll memo=sumprice;
  for(ll i=0;i<N;i++){
    if(i==0){sumprice+=nature(A.at(1))-nature(A.at(0))-nature(A.at(1)-A.at(0));}
    else if(i==N-1){sumprice+=nature(A.at(N-2))-nature(A.at(N-1))-nature(A.at(N-2)-A.at(N-1));}
    else{sumprice+=nature(A.at(i+1)-A.at(i-1))-nature(A.at(i)-A.at(i-1))-nature(A.at(i)-A.at(i+1));}
    cout<<sumprice<<endl;
    sumprice=memo;
  }
}

Measured memory_bytes: 2048
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
vector<tuple<LL,LL,LL>> st;

vector<LL> ans;
 
void solve(){
    for(int i=0;i<N-1;i++){//i->i+1->.....->Nについて調べる
        LL sum = 0;
        for(int j=i;j<N-1;j++){//j->j+1に行く時について調べる
            LL C = get<0>(st[j]);
            LL S = get<1>(st[j]);
            LL F = get<2>(st[j]);
            if(sum<=S) sum += (S-sum);
            else sum += (F-sum%F)*(sum%F!=0);
            sum += C;
        }
        ans.push_back(sum);
    }
    ans.push_back(0);
}
 
int main(){
    cin >> N;
    for(int i=0;i<N-1;i++){
        LL c,s,f;cin >> c >> s >> f;
        st.push_back(tuple<LL,LL,LL>(c,s,f));
    }
 
    solve();
 
    for(int i=0;i<ans.size();i++) cout << ans[i] << endl;
    return 0;
}

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

int main()
{
	int N; cin >> N;
	vector<vector<int>>E(N);
	for (int i = 0; i < N-1; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}

	queue<int> que;
	que.push(0);
	vector<int>dist1(N, N + 1), dist2(N, N + 1);
	dist1[0] = 0;
	dist2[N - 1] = 0;
	while (!que.empty()) {
		int p = que.front(); que.pop();

		for (int i = 0; i < E[p].size(); i++) {
			int q = E[p][i];
			if (dist1[q] > dist1[p]) {
				dist1[q] = dist1[p] + 1;
				que.push(q);
			}
		}
	}

	que.push(N - 1);
	while (!que.empty()) {
		int p = que.front(); que.pop();

		for (int i = 0; i < E[p].size(); i++) {
			int q = E[p][i];
			if (dist2[q] > dist2[p]) {
				dist2[q] = dist2[p] + 1;
				que.push(q);
			}
		}
	}

	int cnt1=0, cnt2 = 0,cnt3=0;
	for (int i = 0; i < N; i++) {
		if (dist1[i] < dist2[i])cnt1++;
		else if (dist2[i] < dist1[i])cnt2++;
		else {
			cnt3++;
		}
	}

	if (cnt1+cnt3 > cnt2)cout << "Fennec" << endl;
	else if (cnt2 > cnt1+cnt3)cout << "Snuke" << endl;
	else cout << "Snuke" << endl;

	return 0;
}



Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <algorithm>  
#include <unordered_set>
#define _USE_MATH_DEFINES
#include <cmath>
#define ll long long

using namespace std;

const double pi = 3.14159265358979323846;

vector<int> g[100005];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s, c;

	cin >> s;

	if (s == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}



	return 0;
}

Measured memory_bytes: 5968
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

L A[1000000],c1,n;
int main()
{
    c1=0;
    cin>>n;
    for(L i=0;i<n;i++){
        // scanf("%lld",&A[i]);
        cin>>A[i];
        if(A[i]==0){
            c1++;
        }
    }
    if(c1!=0){
        // printf("-1\n");
        cout<<0<<endl;
        return 0;
    }
    c1=1;
    for(L i=0;i<n;i++){
        if(A[i] <= 1000000000000000000/c1){
            c1*=A[i]; 
        }else{
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<c1<<endl;
    return 0;
}

/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


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

int main(){
  int n, m;
  cin >> n >> m;
  
  vector<string> s(n);
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }
  
  sort(s.begin(), s.end());
  
  for(int i = 0; i < n; i++){
    cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll n;
    cin >> n;
    vector<ll> a;
    vector<ll> b;
    map<ll,ll> A;
    map<ll,ll> B;
    rep(i,n){
        ll v;
        cin >> v;
        if(i%2==0){
            if(A.count(v)) A[v]++;
            else{
                A.emplace(v,1);
                a.push_back(v);
            }
        }else{
            if(B.count(v)) B[v]++;
            else{
                B.emplace(v,1);
                b.push_back(v);
            }
        }
    }
    ll out = 0;
    ll c = a.size();
    ll d = b.size();
    ll ma = 0;
    ll ma2 = 0;
    ll maa = 0;
    ll mb = 0;
    ll mb2 = 0;
    ll mbb = 0;
    rep(i,c){
        if(A[a[i]]>=ma){
            if(ma>ma2) ma2 = ma;
            ma = A[a[i]];
            maa = a[i];
        }else if(A[a[i]]>ma2) ma2 = A[a[i]];
    }
    rep(i,d){
        if(B[b[i]]>=mb){
            if(mb>mb2) mb2 = mb;
            mb = B[b[i]];
            mbb = b[i];
        }else if(B[b[i]]>mb2) mb2 = B[b[i]];
    }
    if(maa!=mbb) out = n-(ma+mb);
    else{
        out = min(n-(ma2+mb),n-(ma+mb2));
    }
    cout << out << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> l(N), r(N);
  for (int i = 0; i < N; i++) {
    cin >> l.at(i) >> r.at(i);
  }
  int ninzu = 0;
  for (int i = 0; i < N; i++) {
    ninzu += r.at(i) - l.at(i) + 1;
  }
  cout << ninzu << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

ll moP(ll x, ll n) {
  ll res=1;
  while(n>0) {
    if(n&1) moC(res, *, x);
    moC(x, *, x);
    n>>=1;
  }
  return res;
}

ll fa[MAX*4], rf[MAX*4];

ll C(ll n, ll k) {
  if(k==0) return 1;
  if(n==k) return 1;
  return fa[n]*rf[k]%MOD*rf[n-k]%MOD;
}

int main(void) {
  ll N, K;
  cin >> N >> K;
  ll i;
  
  fa[0]=rf[0]=1;
  for(ll i=1; i<=400040; i++) {
    fa[i]=fa[i-1]*i%MOD;
    rf[i]=moP(fa[i], MOD-2);
  }
  
  if(N-1<=K) {
    pt(C(N+N-1, N));
    return 0;
  }
  
  ll ans=1;
  //i:0人の部屋の数
  for(i=1; i<=K; i++) {
    moC(ans, +, C(N, i)*C(N-1, N-i-1)%MOD);
    //pt(C(N, i)*C(N, N-i-1));
  }
  
  pt(ans);
}








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

ll dp[100010];

int main(int argc, char **argv)
{
	ll N, K; cin >> N >> K;
	vector<ll> H(N);
	for (ll i = 0; i < N; ++i) cin >> H[i];
	for (ll i = 0; i < N; ++i) dp[i] = 1ll<<60;
	dp[0] = 0;

	for (ll i = 0; i < N; ++i)
	{
		for (ll k = 1; k <= K; ++k)
			if (i-k>=0)dp[i] = min(dp[i], dp[i-k]+abs(H[i] - H[i-k]));
	}
	std::cout << dp[N-1] << std::endl;
}


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

int main() {
  int n;
  bool flag = false;
  cin >> n;
  
  for (int i=0; i<n; i++) {
    string s;
    cin >> s;
    if (s == "Y") flag = true;
  }
  
  if (flag) cout << "Four" << endl;
  else cout << "Three" << endl;
  
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("## ",*x,file=sys.stderr) if LOCAL else 0
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    tot=0
    cur=0
    for a in A:
        if cur>a:
            tot+=cur-a
        else:
            cur=a
    print(tot)



if __name__ == "__main__":
    main()

Measured memory_bytes: 110792
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd>> Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-3;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%MOD
#define CHECK cout<<"arrived"<<endl

ll d[100010][61];
ll N;
const ll BIG=100005;
ll MAX=0;

ll ruijou(ll n, ll k){
    if(!k) return 1;
    ll a=ruijou(n,k/2);
    a=(a*a);
    return k%2 ? (a*n) : a;
}

void Write(ll A,ll x){
    ll K=A;
    rep(i,61){
        if(!K) break;
        if(K%2) d[x][i]=1;
        K/=2;
        MAX=max(MAX,(ll)i+1);
    }
    return;
}

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

    rep(i,N) cin>>D[i];
    rep(i,N) Write(D[i],i);
    ll SX=0;
    rep(i,N) SX^=D[i];
    Write(SX,BIG);
    vec k;
    ll ans=0;
    rep(i,MAX) {
        if(!d[BIG][i]) k.pb(i);
        else ans+=ruijou(2,i);
    }
    ll M=k.size();
    mat A(N+1,vec(M,1));
    vector<bool> used(N,false);
    rep(i,N) rep(j,M) A[i][j]=d[i][k[j]];

    /*rep(i,N){
        rep(j,M) cout<<A[i][j];
        cout<<endl;
    }*/

    for(int j=M-1; j>=0; j--){
        ll memo=-1;
        rep(i,N) if(!used[i]) if(A[i][j]){
            memo=i;
            used[i]=true;
            break;
        }
        //cout<<memo<<' '<<j<<endl;
        if(memo>=0 && memo<N){
            REP(i,memo+1,N+1) if(A[i][j]){
                rep(k,j+1) A[i][k]^=A[memo][k];
            }
        }
    }
    /*rep(j,M) cout<<A[N][j];
    cout<<endl;*/
    rep(j,M) if(!A[N][j]) ans+=ruijou(2,k[j]+1);
    cout<<ans<<endl;



}

Measured memory_bytes: 102328
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N = 200010;
pair <int, int> a[N];
int ans, i, n, t, x, j;

int main()
{
    scanf("%d%d", &n, &t);
    for (i = 1; i <= n; i++)
    {
        scanf("%d", &x);
        a[i].first = x;
        a[i].second = x + t;
    }
    sort(a + 1, a + n + 1);
    a[n + 1].first = 2147483647;
    a[n + 1].second = 2147483647;
    i = 1;
    ans = 0;
    while (i <= n)
    {
        j = i;
        while (a[j + 1].first <= a[j].second) j++;
        ans += a[j].second - a[i].first;
        i = j + 1;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1664