akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>
using namespace std;
#define N 4
#define N2 16
#define LIMIT 100

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle {int f[N2], space, MD;};

Puzzle state;
int limit;
int path[LIMIT];

int getAllMD(Puzzle pz){
	int sum = 0;
	for(int i=0;i<N2;i++){
		if(pz.f[i] == N2) continue;
		sum += MDT[i][pz.f[i]-1];
	}
	return sum;
}

bool isSolved(){
	for(int i=0;i<N2;i++) if(state.f[i] != i+1) return false;
	return true;
}

bool dfs(int depth, int prev){
	if(state.MD == 0) return true;
	if(depth + state.MD > limit) return false;

	int sx = state.space / N;
	int sy = state.space % N;
	Puzzle tmp;

	for(int r=0;r<4;r++){
		int tx = sx + dx[r];
		int ty = sy + dy[r];
		if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
		if(max(prev,r) - min(prev,r) == 2) continue;
		tmp = state;
		state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
		state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
		swap(state.f[tx * N + ty], state.f[sx * N + sy]);
		state.space = tx * N + ty;
		if(dfs(depth + 1, r)) {path[depth] = r; return true;}
		state = tmp;
	}

	return false;
}

string iterative_deepening(Puzzle in){
	 in.MD = getAllMD(in);

	 for( limit = in.MD; limit <= LIMIT; limit++){
		 state = in;
		 if(dfs(0,-100)){
			 string ans = "";
			 for(int i=0;i<limit;i++) ans += dir[path[i]];
			 return ans;
		 }
	 }

	 return "unsolved";
}

int main(){
	for(int i=0;i<N2;i++)
		for(int j=0;j<N2;j++)
			MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
	Puzzle in;

	for(int i=0;i<N2;i++){
		cin >> in.f[i];
		if(in.f[i] == 0){
			in.f[i] = N2;
			in.space = i;
		}
	}
	string ans = iterative_deepening(in);
	cout << ans.size() << endl;

	return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int A,P;cin >> A >> P;
    P+=A*3;
    int cnt=0;;
    while(P-2>=0){
        P-=2;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

#define FOR(i, a, b)  for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << "\n"
#define _ << " _ " <<
#define ll long long

using namespace std;

int price[5];

int main() {
  ios_base::sync_with_stdio(false);

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  price[0] = a;
  price[1] = min(price[0] * 2, b);
  price[2] = min(price[1] * 2, c);
  price[3] = min(price[2] * 2, d);
/*
  cout << price[0] << " ";
  cout << price[1] << " ";
  cout << price[2] << " ";
  cout << price[3] << "\n";
*/
  int n;
  cin >> n;

  ll out = 0;

  out += (ll) price[3] * (ll) (n / 2);
  n = (n % 2);
  out += (ll) price[2] * (ll) n;
  cout << out << "\n";

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int ds(int n){
	int res=0;
	while(n){
		res+=n%10;
		n/=10;
	}
	return res;
}
int main(){
	int n,mn=1000000;
	cin>>n;
	for(int i=1;i<=n/2;i++){
		mn=min(ds(i)+ds(n-i),mn);
	}
	cout<<mn;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        //int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        string input= Console.ReadLine();
        
        Console.WriteLine((int.Parse(input.Substring(5,2))==4&&int.Parse(input.Substring(8,2))<=30)|| int.Parse(input.Substring(5, 2)) < 4 ? "Heisei" : "TBD");


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

Measured memory_bytes: 11092
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()
count = 0
for i in range(N):
    for j in range(i+1, N):
        max_len = L[i] + L[j]
        count += bisect_left(L, max_len) - j - 1
print(count)


Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <iomanip>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#define ll long long
         
using namespace std;
     
long long gcd(int x, int y){
     if ( x == 0 ) return y;
     
     return gcd(y%x, x);
}
     
long long lcm(int x, int y){
     if ( y == 0 ){
          return x;
     }
     
     return x*y/gcd(x, y);
}
     
int min(int a, int b){
     return a > b ? b : a;
}
     
int max(int a, int b){
     return a > b ? a : b;
}

int main()
{
     cin.sync_with_stdio( false );
     
     int n,m;
     cin>>n>>m;
     
     int l[m],r[m];
     for (int i=0;i<m;i++){
         cin>>l[i]>>r[i];
     }
     
     sort(l, l+m);
     sort(r, r+m);
     
     int res = r[0] - l[m-1] + 1;
     if ( res < 0 ){
         cout<<0<<endl;
     }else{
         cout<<res<<endl;
     }
}

Measured memory_bytes: 4400
#include <iostream>
#include <string>
#include <vector>
#include <map>


int main() {
    int N;
    std::string S;
    std::cin >> N >> S;
    std::map<char, std::vector<int>> idx_lists;
    idx_lists['R'] = std::vector<int>();
    idx_lists['G'] = std::vector<int>();
    idx_lists['B'] = std::vector<int>();

    for (int i = 0; i < N; i++) {
        idx_lists[S[i]].emplace_back(i);
    }

    long long int sum = idx_lists['R'].size() * idx_lists['G'].size() * idx_lists['B'].size();
    long long int not_cond = 0;

    auto count = [&S, &N] (int i1, int i2) {
        long long int cnt = 0;
        int diff = i2 - i1;
        int i_b0 = i1 - diff;
        int i_b1 = i2 + diff;
        if (i_b0 >= 0 && S[i_b0] == 'B') {
            cnt++;
        }
        if (i_b1 < N && S[i_b1] == 'B') {
            cnt++;
        }
        if (diff % 2 == 0) {
            int i_b2 = i1 + diff / 2;
            if (S[i_b2] == 'B') {
                cnt++;
            }
        }
        return cnt;
    };
    
    for (auto &i_r : idx_lists['R']) {
        for (auto &i_g : idx_lists['G']) {
            if (i_r < i_g) {
                not_cond += count(i_r, i_g);
            } else {
                not_cond += count(i_g, i_r);
            }
        }
    }
    std::cout << sum - not_cond << std::endl;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    double a;
    cin >> a;
    a /= 3;
    printf("%.10lf", a * a * a + EPS);
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

dp = [0]*N

for i, x in enumerate(H):
  if i == 0:
    continue
  elif i == 1:
    dp[i] = abs(H[i]-H[i-1])
  else:
    dp[i] = min( dp[i-2] + abs(H[i] - H[i-2]) , dp[i-1] + abs( H[i] - H[i-1] ))

print(dp[-1])

Measured memory_bytes: 20460
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

ll mod = 1e9+7;

void solve() {
  ll a, b, n; cin >> a >> b >> n;
  ll ans = 0;
  if (n >= a) {
    ll t = (n - a) / (a - b);
    ans = (t % mod) * (a % mod) % mod;
    n -= t * (a - b);
    assert(n >= 0);
    while (n >= a) {
      ans = (ans + a) % mod;
      n -= a - b;
    }
  }
  ans = (ans + n) % mod;
  cout << ans << endl;
}



Measured memory_bytes: 3208
#include <stdio.h>

int main(void) {

  int h,w;
  scanf("%d %d", &h, &w);
  char s[h][w+1];
  for (int i = 0; i < h; i++) {
    scanf("%s", s[i]);
  }
  int flag;
  int achieve = 1;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        flag = 0;
        if (i > 0 && s[i-1][j] == '#') {
          flag = 1;
        }
        if (i < h-1 && s[i+1][j] == '#') {
          flag = 1;
        }
        if (j > 0 && s[i][j-1] == '#') {
          flag = 1;
        }
        if (j < w-1 && s[i][j+1] == '#') {
          flag = 1;
        }
        if (flag == 0) {
          achieve = 0;
          break;
        }
      }
    }
    if (achieve == 0) {
      break;
    }
  }
  if (achieve == 1) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        var l = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var s = l.OrderByDescending(x => x).ToArray();
        int sum = 0;
        for (int i = 1; i < s.Length; i += 2) sum += s[i];
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 11348
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

double sq(double x){ return x*x;}

void mainmain(){
	double a,b,c,d;
	double r = 6378.1;
	double PI = M_PI;
	while(cin>>a>>b>>c>>d){
		if(a==-1&&b==-1&&c==-1&&d==-1) return;
		double aa = a / 180 * PI;
		double bb = b / 180 * PI;
		double cc = c / 180 * PI;
		double dd = d / 180 * PI;
		double x1 = r * cos(bb) * cos(aa);
		double x2 = r * cos(dd) * cos(cc);
		double y1 = r * sin(bb) * cos(aa);
		double y2 = r * sin(dd) * cos(cc);
		double z1 = r * sin(aa);
		double z2 = r * sin(cc);
		double dist = sq(x1-x2) + sq(y1-y2) + sq(z1-z2);
		double th = acos(1 - dist/2/sq(r));
		int ans = floor(th * r + 0.5);
		cout << ans << endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 3400
n=int(input())

query = [1, 2, 3, 4, 5, 6, 7, 8, 9]

if n <= 9:
    print(n)
else:
    count = 9
    while count<=n:
        i = query.pop(0)

        if i%10-1>=0:
            query.append(i*10+(i%10-1))
            count += 1
            if count == n:
                print(i*10+(i%10-1))
                break

        query.append(i*10+(i%10))
        count += 1
        if count == n:
            print(i*10+(i%10))
            break

        if i%10+1<=9:
            query.append(i*10+(i%10+1))
            count += 1
            if count == n:
                print(i*10+(i%10+1))
                break

Measured memory_bytes: 42864
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
N = INT()
ab = [LIST() for _ in range(N-1)]
graph = [[] for _ in range(N)]

for a, b in ab:
	graph[a-1].append(b-1)
	graph[b-1].append(a-1)

length = [len(x) for x in graph]
ans = max(length)

color = defaultdict(int)

q = deque([])
cnt = 1
for x in graph[0]:
	q.append((x, 0, cnt))
	cnt += 1

while q:
	n, previous, col = q.popleft()
	cnt = 1
	for x in graph[n]:
		if x == previous:
			color[(n, x)] = col
			color[(x, n)] = col
		else:
			if cnt == col:
				cnt += 1
			color[(n, x)] = cnt
			color[(x, n)] = cnt
			q.append((x, n, cnt))
			cnt += 1

print(ans)
for a, b in ab:
	print(color[(a-1, b-1)])

Measured memory_bytes: 72908
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
color = [0]*3
ans = 1
for i in range(N):
  if A[i] not in color:
    ans = 0
    break
  ind = color.index(A[i])
  ans *= len([c for c in color if c == A[i]])
  ans %= mod
  color[ind] += 1

#ans = rec(color,0)
print(ans)

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  double T, X; cin >> T >> X;
  cout << setprecision(16) << T / X << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N, M;
  scanf("%d %d", &N, &M);
  int ans = 1900 * M + (N - M) * 100;
  for (int i = 0; i < M; ++i) {
    ans *= 2;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 200005;

int n, mnr = 1 << 30, mnb = 1 << 30, cur = 1 << 30, mxr = 0, mxb = 0;
pii a[MAXN];

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 1; i <= n; i ++)
	{
		a[i].xx = Read(), a[i].yy = Read();
		if (a[i].xx > a[i].yy)
			swap(a[i].xx, a[i].yy);
		mnr = min(mnr, a[i].xx), mxr = max(mxr, a[i].xx);
		mnb = min(mnb, a[i].yy), mxb = max(mxb, a[i].yy);
	}
	sort(a + 1, a + n + 1);
	LL ret = 1LL * (mxr - mnr) * (mxb - mnb);
	for (int i = 1; i <= n; i ++)
		ret = min(ret, 1LL * (mxb - mnr) * (mxr - min(cur, a[i].xx))), cur = min(cur, a[i].yy), mxr = max(mxr, a[i].yy);
	return printf("%lld\n", ret), 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define rep(i, j) for (long long i = j; i > 0; i--)
using namespace std;

int gcd(int _a, int _b) {
	vector<int> num(3);
	if (_a < _b) {
		num[0] = _b;
		num[1] = _a;
	}
	else {
		num[0] = _a;
		num[1] = _b;
	}
	num[2] = num[0] % num[1];
	while (num[2]) {
		num[0] = num[1];
		num[1] = num[2];
		num[2] = num[0] % num[1];
	}
	return num[1];
}


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

	long long ans = 0;
	long long lcm_num = lcm - (lcm / c) - (lcm / d) + 1;

    long long num_a;
	long long num = (a - 1) / lcm;
	long long amari = (a - 1) % lcm;
	num_a = num * lcm_num;
	num_a += amari - (amari / c) - (amari / d);


	long long num_b;
	num = b / lcm;
    amari = b % lcm;
	num_b = num * lcm_num;
	num_b += amari - (amari / c) - (amari / d);
	
	ans = num_b - num_a;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	n := nextInt()
	a := nextInt()
	b := nextInt()

	fare := a * n
	if fare > b {
		fare = b
	}

	fmt.Println(fare)

}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();
		
		if(k > a) {
			b = b - (k - a);
			a = 0;
			if(b < 0) b = 0;
		}
		else {
			a -= k;
		}
		System.out.println(a+" "+b);
	}
}

Measured memory_bytes: 23124
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			// count[0]は1の倍数の数、count[1]は2の倍数の数、count[2]は4の倍数の数
			int[] count = new int[3];
			IntStream.range(0, n).forEach(i -> count[getMultiple(scanner.nextInt())]++);
			System.out.println((count[2] >= (count[0] - ((count[1] > 0) ? 0 : 1))) ? "Yes" : "No");
		}
	}

	/**
	 * @param n 入力数字
	 * @return 0：nは1の倍数、1：nが2の倍数、2：nが4の倍数
	 */
	private static int getMultiple(int n) {
		int result = 0;
		while (0 == (n & 1)) {
			result++;
			n >>= 1;
			if (result >= 2) {
				break;
			}
		}
		return result;
	}
}


Measured memory_bytes: 49428
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

signed main()
{
  ll n, m;
  vector< ll > a;

  cin >> n >> m;
  REP(i, m)
  {
    ll ai;
    cin >> ai;
    a.push_back(ai);
  }

  ll sum = 0;
  for (ll i = 0; i < a.size(); i++)
  {
    sum += a[i];
  }
  ll ans;
  if (n >= sum)
  {
    ans = n - sum;
  }
  else
  {
    ans = -1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3724
import fractions
from functools import reduce
n=int(input())
l=list(map(int,input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

k=lcm_list(l)

m=0
for i in range(n):
    m+=k//l[i]
print(m%(10**9+7))


Measured memory_bytes: 6116
#include <iostream>
#include <string>

using namespace std;

int main() {
	string a, b, c;
	string abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	cin >> a >> b >> c;
	cout << abc[a[0] - 'a']<< abc[b[0] - 'a']<<abc[c[0] - 'a'] << endl;
	return 0;
}

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

int n, p = 0;
int t[50][6];
set<int> ts;

int main()
{	
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 6; j++) {
			int h, m;
			cin >> h >> m;
			t[i][j] = h * 100 + m;
			ts.insert(t[i][j]);
		}
	}

	for (set<int>::iterator itr1 = ts.begin(); itr1 != ts.end(); itr1++) {
		for (set<int>::iterator itr2 = itr1; itr2 != ts.end(); itr2++) {
			for (set<int>::iterator itr3 = itr2; itr3 != ts.end(); itr3++) {
				int pt = 0;
				for (int i = 0; i < n; i++) {
					if (*itr1 >= t[i][0] && *itr1 <= t[i][1] && *itr2 >= t[i][2] && *itr2 <= t[i][3] &&
						*itr3 >= t[i][4] && *itr3 <= t[i][5])
						pt++;
				}
				if (pt > p)
					p = pt;
			}
		}
	}

	cout << p << endl;

	return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define ll long long
#define md 1000000007
using namespace std;
ll ps[200001];
int main()
{
	ll n,k;
	cin>>n>>k;
	ll has=0;
	
	/*for(ll i=0; i<k; i++)
		{
			//a=(a%md+i%md)%md;
			a+=i;
		}
	for(ll i=n; i>n-k; i--)
		{
			//cout<<i<<endl;
			//b=(b%md+i%md)%md;
			b+=i;

	}*/
	ps[0]=0;
	for(int i=1; i<=n; i++)
	{
		ps[i]=ps[i-1]+i;
	}

	while(k<=n+1)
	{
		//cout<<k<<endl;
		ll a=0;
		ll b=0;
		if(k<=n)
		{
			a=ps[k-1];
			b=ps[n]-ps[n-k];
			//cout<<b<<" "<<a<<endl;
			b-=a;
		}else
		{
			b=1;
			has=(has%md+b%md)%md;
			break;
		}
		has++;
		has=(has%md+b%md)%md;

		//cout<<has<<endl;
		k++;
	}
	cout<<(has)%md<<endl;

}

Measured memory_bytes: 5088
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	int n;
	cin>>n;
	set<pair<int, int> > c;
	REP(i, n) {
		char foo;
		pair<int, int> gomi;
		cin>>foo;
		if(foo == 'S') gomi.first = 0;
		if(foo == 'H') gomi.first = 1;
		if(foo == 'C') gomi.first = 2;
		if(foo == 'D') gomi.first = 3;
		cin>>gomi.second;
		--gomi.second;
		c.insert(gomi);
	}
	REP(i, 4) {
		REP(j, 13) {
			if(c.count(pair<int, int>(i, j)) == 0) {
				switch(i) {
					case 0: cout<<'S'<<' '<<j + 1<<endl; break;
					case 1: cout<<'H'<<' '<<j + 1<<endl; break;
					case 2: cout<<'C'<<' '<<j + 1<<endl; break;
					case 3: cout<<'D'<<' '<<j + 1<<endl; break;
				}
			}
		}
	}
}

Measured memory_bytes: 3068
import math
import re
import time

N,L=map(int,input().split())

total=(L-1)*N+((1+N)/2)*N
mn=1e9
ans=1e9
for a in range(N):
    l=L+(a+1)-1
    if abs(l)<mn:
        mn=min([mn,abs(l)])
        ans=l
print(int(total-ans))

Measured memory_bytes: 3316
package main

import "fmt"

func main() {
	var n, a int
	fmt.Scan(&n)
	m := map[int]int{}
	for i := 1; i <= n; i++ {
		fmt.Scan(&a)
		m[a] = i
	}
	for i := 1; i <= n; i++ {
		fmt.Print(m[i], " ")
	}
}


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

using namespace std;
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
#define debug(_x)		cerr << #_x << '=' << (_x) << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << (_x) << ' ' << #_y << '=' << (_y) << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << (_x) << ' '; cerr << endl;

#define HERE debug(__LINE__);

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;

int32_t main() {
	FAST_IO;
	
//	freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);

	int a, b, n;
	cin >> a >> b >> n;
	
	int ans = min(n, b-1);
	cout << ((a*ans/b)-(a*(ans/b))) << endl;
	
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B < C + D){
      cout << "Right" << endl;
  }
  else if (A + B > C + D){
      cout << "Left" << endl;
  }
  else {
      cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;

int main(){
    string s;
    int count = 1;
    cin >> s;
    REP(i,s.length()-1){
        if(s[i] != s[i+1]) count++;
    }
    cout << count-1 << endl;
    return 0;
}


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

int main(){
	string s;
	int i, salah1=0, salah2=0;
	cin>>s;
	for(i=0;i<s.length();i++){
		if(i%2>0){
			if(s[i]=='0'){
				salah1++;
			}
		}else{
			if(s[i]=='1'){
				salah1++;
			}
		}
	}
	for(i=0;i<s.length();i++){
		if(i%2==0){
			if(s[i]=='0'){
				salah2++;
			}
		}else{
			if(s[i]=='1'){
				salah2++;
			}
		}
	}
	cout<<min(salah1, salah2)<<endl;
	return 0;
}

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


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

struct edge {int to, cost; };

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

ll GCD(ll a, ll b){
  if(b==0) return a;
  else return GCD(b, a%b);
}

ll LCM(ll a, ll b){
  if(a<b) swap(a,b);
  return a/GCD(a,b)*b;
}

int main(){
  int n;
  cin >> n;
  ll a[n];
  ll mod = 1e9+7;
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  ll s[n];
  s[0] = a[0];
  for(int i=1; i<n; i++){
    s[i] = s[i-1]+a[i];
    s[i] %= mod;
  }
  ll ans = 0;
  for(int i=0; i<n-1; i++){
    ll tmp = s[n-1]-s[i];
    if(tmp<0) tmp += mod;
    ans += (a[i]*tmp)%mod;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6736
N, Y = (int(x) for x in input().split())
x, y, z, t = -1, -1, -1, Y // 1000

for i in range(N+1):
    for j in range(N+1):
        if 9*i + 4*j + N == t and i + j <= N:
            x, y, z = i, j, N - i - j
            break
        elif 9*i + 4*j + N > t:
            break
    else:
        continue
    if x != -1:
        break

print('{} {} {}'.format(x, y, z))


Measured memory_bytes: 3064
#include <stdio.h>
#include <ctype.h>

#define ALNUM ('Z' - 'A' + 1)

int
main(void)
{
	char s[ALNUM] = {};
	char buf[1200];

	for (;;) {
		if (scanf("%s", buf) == EOF)
			break;

		for (char *c = buf; *c != '\0'; c++) {
			int a = toupper(*c);
			if ('A' <= a && a <= 'Z')
				s[a - 'A']++;
		}
	}

	for (int i = 0; i < ALNUM; i++)
		printf("%c : %d\n", 'a' + i, s[i]);

	return 0;
}



Measured memory_bytes: 2064
n = int(input())
XYH = [tuple(map(int, input().split())) for _ in range(n)]
for cx in range(101):
    for cy in range(101):
        H = set()
        for x, y, h in XYH:
            if h == 0:
                continue
            H.add(h + abs(x - cx) + abs(y - cy))
        if len(H) != 1:
            continue
        H = list(H)[0]
        flag = True
        for x, y, h in XYH:
            if h != max(H - abs(x - cx) - abs(y - cy), 0):
                flag = False
                break
        if flag:
            print(cx, cy, H)


Measured memory_bytes: 3064
N, m = map(int, input().split())
v = [0]*N
for i in range(m):
    c, d = map(int, input().split())
    v[c-1] += 1
    v[d-1] -= 1
s = 0; fst = 0
ans = N+1
for i in range(N):
    if s == 0 and v[i] > 0:
        fst = i
    s += v[i]
    if s == 0 and v[i] < 0:
        ans += (i - fst)*2
print(ans)

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

int main(){
  int idx=0;
  string s=(16,"CODEFESTIVAL2016");
  string ss;
  cin>>ss;
  for(int i=15;i>=0;i--){
  	  if(s[i]!=ss[i])idx+=1;
  }
  
  cout<<idx<<endl;
  
 return 0; 
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var NM=Arr.shift().split(" ").map(Number);
var N=NM[0];
var M=NM[1];
var ab=[];
for(var i=0;i<M;i++){
   var v=Arr.shift().split(" ").map(Number);
   ab.push(v);
}
ab.sort(function(a,b){return b[1]-a[1];});
var i=0;
var cnt=0;
var memo;
while(true){
   if(i>=N)break;
   if(memo==i){cnt="Impossible";break;}
   memo=i;
   cnt++;
   for(var j=0;j<ab.length;j++){
      if(ab[j][0]<=i+1){i=ab[j][1];break;}
   }
}
console.log(cnt);

Measured memory_bytes: 8540
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[])
{
	ll i, j;
	ll l, r;
	ll answer;
	cin >> l >> r;

	if (r - l > 2019)
		answer = 0;
	else {
		answer = (l * (l + 1)) % 2019;
		for (i = l; i < r; i++) {
			for (j = i + 1; j <= r; j++) {
				if (answer > (i * j) % 2019)
					answer = (i * j) % 2019;
			}
		}
	}
	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 256
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	inll a, b, c, x;

	ll res = 0;

	REP(i, a + 1)
	{
		REP(j, b + 1)
		{
			REP(k, c + 1)
			{
				if (500 * i + 100 * j + 50 * k == x)
					res++;
			}
		}
	}

	return OUT(res);
}


Measured memory_bytes: 256
import math
n,d = map(int, input().split())


#nums = [[0 for _ in range(d)] for _ in range(n)]
nums = []

for i in range(n):
    tmp = list(map(int, input().split()))
    nums.append(tmp)

ans = 0
tmp = 0
for i in range(n-1):

    for j in range(i+1, n):
        tmp = 0
        for k in range(d):
            tmp += (nums[i][k] - nums[j][k])**2


        #print((tmp))
        if math.sqrt(tmp).is_integer():
            
            ans += 1

                

print(ans)

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

int main() {
    int64_t a,b,c;
    cin >> a >> b >> c;
    if(((a+b-c)*(a+b-c) > 4*a*b) && (a + b - c) < 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const ll MOD  = (ll)1e9 + 7;
const ll INF  = (ll)1e9 + 1;
const ll LINF = (ll)1e18 + 1;

class BIT {
public:
    vector<ll> bit;
    ll M;

    BIT(ll M):
        bit(vector<ll>(M+1, 0)), M(M) {}

    ll sum(ll i) {
        if(!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(ll i, ll x) {
        if(i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

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

    ll N, K;
    std::cin >> N >> K;

    BIT bit(2001);
    vector<ll> A(N);
    ll ans = 0;
    REP(i, N) {
        std::cin >> A[i];
        bit.add(A[i], 1);
        ans += (i + 1 - bit.sum(A[i])) * K;
        ans %= MOD;
    }

    REP(i, N) {
        ans += (N - bit.sum(A[i])) * (((K - 1) * K / 2) % MOD);
        ans %= MOD;
    }

    std::cout << ans << std::endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>

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

    bool flg = true;
    for(int i = 0; i < n; ++i){
        int t, x, y;
        std::cin >> t >> x >> y;
        if(t < x + y || 0 != (t - x - y) % 2){
            flg = false;
            break;
        }
    }

    std::string ans = "Yes";
    if(!flg){
        ans = "No";
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)

def dfs(s):
    if visited[s]:
        return
    visited[s] = 1
    for to in t[s]:
        if visited[to]:
            continue
        dfs(to)
    
N, M = map(int,input().split())
t = [[] for _ in range(N)]
visited = [0] * N
for _ in range(M):
    X, Y, Z = map(int,input().split())
    X -= 1
    Y -= 1
    t[X].append(Y)
    t[Y].append(X)
ans = 0
for i in range(0, N):
    if visited[i]:
        continue
    ans += 1
    dfs(i)
print(ans)

Measured memory_bytes: 104692
//By: Luogu@rui_er(122461)
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5+5;

int a[N], b[N], book[N], ans[N], n, q;

struct Node {
    int l, r, id;
    bool operator < (const Node &a) const {
		return r < a.r;
	}
}p[N];
void add(int n, int u) {
	for(;n<=N;n+=n&(-n)) {
		b[n] += u;
	}
}
int sum(int n) {
	int res = 0;
	for(;n;n-=n&(-n)) {
		res += b[n];
	}
	return res;
}

int main()
{
	scanf("%d%d", &n, &q);
	for(int i=1;i<=n;i++) {
		scanf("%d", &a[i]);
	}
	for(int i=1;i<=q;i++) {
		scanf("%d%d", &p[i].l, &p[i].r);
		p[i].id = i;
	}
	sort(p+1, p+1+q);
//	puts("Sorted. ");
	int nxt = 1;
    for(int i=1;i<=q;i++) {
//   	printf("For: i=%d\n", i);
		for(int j=nxt;j<=p[i].r;j++) {
//			printf("\tj=%d\n", j);
			if(book[a[j]]) {
				add(book[a[j]], -1);
			}
			add(j, 1);
			book[a[j]] = j;
		}
		nxt = p[i].r + 1;
		ans[p[i].id] = sum(p[i].r) - sum(p[i].l-1);
	}
	for(int i=1;i<=q;i++) {
		printf("%d\n", ans[i]);
	}
	return 0;
}

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

int main(){
  int n,ans;
  cin >> n;
  ans = 0;
  int cnt = 0;
  for(int i = 1;ans < n;i++){
    ans = i*i;
    cnt = i;
  }
  if(ans != n){
  cnt--;
  ans = cnt*cnt;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main(){
	vector<int> vec;
	int a;
	cin>>a;
	while(a != 0){
		vec.push_back(a);
		cin>>a;
	}
	for(int i = 0; i < vec.size(); i++)
		cout<<"Case "<<i+1<<": "<<vec[i]<<endl;
}


Measured memory_bytes: 3152
#include <iostream>
#include <string>

using namespace std;

int main() {
	int stage = 0;
	int n;
	string a;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int counter = 0;
		int before = 0;
		stage = 0;
		for (int i = 0; i < n; i++) {
			cin >> a;
			if (stage == 0) {
				if (a == "lu") {
					stage = 1;
				} else {
					stage = 2;
				}
				before = 0;
			} else if (stage == 1) {
				if (a == "ru") {
					stage = 3;
					if (before == 0) {
						counter++;
					}
				} else {
					stage = 0;
					if (before == 3) {
						counter++;
					}
				}
			} else if (stage == 2) {
				if (a == "lu") {
					stage = 3;
					if (before == 0) {
						counter++;
					}
				} else {
					stage = 0;
					if (before == 3) {
						counter++;
					}
				}
			} else {
				if (a == "ld") {
					stage = 2;
				} else {
					stage = 1;
				}
				before = 3;
			}
		}
		cout << counter << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
import numpy as np

N = int(input())
p = np.array(input().split(), dtype=np.int64)

q1 = np.sort(p)

q2 = q1 - p

if np.sum(q2 != 0) == 0 or np.sum(q2 != 0) == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 21892
#include<stdio.h>

typedef long long int llu;

llu max(llu a, llu b) {
    return (a < b) ? b : a;
}

int main() {
    // INPUT
    int N, W;
    scanf("%d%d", &N, &W);

    int w[N], v[N];
    for (int i = 0; i < N; ++i) {
        scanf("%d%d", &w[i], &v[i]);
    }

    // INITIALIZE
    llu dp[W+1];
    for (int j = 0; j <= W; ++j) {
        dp[j] = 0;
    }

    // DP
    for (int i = 1; i <= N; ++i) {
        for (int j = W; j >= 1; --j) {
            if (j < w[i-1]) {
                dp[j] = dp[j];
            } else {
                dp[j] = max( dp[j-w[i-1]] + v[i-1] ,
                                dp[j] );
            }
        }
    }

    // OUTPUT
    printf("%llu\n", dp[W]);
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll N;
	ll ans = 0;
	cin >> N;
	vector<ll> B(N);
	rep(i, N-1) cin >> B[i];

	ans += B[0];
	for(long long i = 0; i < N-2; i++) {
		ans += min(B[i], B[i+1]);
	}
	ans += B[N-2];

	cout << ans << endl;

}



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

int main()
{
  string s;
  cin >> s;
  string ans = "No";
  for (int i = 2; i <= 10; i += 2) {
    if (s == string("hihihihihi", i)) {
      ans = "Yes";
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define i(a) insert(a)
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e9 + 7 ;
ll modexp( ll base ,ll power)
{
    if( power == 0  ) return 1 ;
    if( power & 1) return base*modexp( base , power-1 )%inf ;
    return modexp(base*base%inf,power/2) ;
}
const ll N = 100001 ;
vector<ll> a[N] , visited(N,0) ;
ll dfs( ll x ){
      if( visited[x] ) return 0 ;
      visited[x] = 1 ;
      for( auto it : a[x] ){
        if( visited[it] ) continue;
        ll temp = dfs(it) ;
      }
      return 0 ;
}
int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin ) ;
  ll t = 1;
  //cin>>t;
  while(t--)
   {
       ll n,m ; cin>>n>>m ;
       for( ll i =0 ; i<m ; i++ ){
        ll x,y ; cin>>x>>y ;
        a[x].push_back(y) ;
        a[y].push_back(x) ;
       }
       ll ans = 0 ;
       for( ll i = 1 ; i<=n ; i++ ){
        if( visited[i] ) continue;
        else {
                ll temp = dfs(i) ;
                ++ans ;
             }
       }
       cout<<ans-1;

   }
 return 0;
}




Measured memory_bytes: 10584
#include <iostream>
#include <fstream>
#define nmax 3001

using namespace std;
ifstream fin("p.in");
ofstream fout("p.out");

long long v[nmax],dp[nmax][nmax];
int n;

int main()
{
    cin>>n;
    long long sum=0;
    for(int i=1; i<=n; i++)
        {
            cin>>v[i];
            sum+=v[i];
        }
    for(int i=1; i<=n; i++)
        for(int j=1; j<=n; j++)
            if(i==j) dp[i][j]=v[i];
            else if(j==i+1) dp[i][j]=max(v[i],v[j]);

    int i=1;
    int val=3;
    while(i<=n-2)
        {
            int j=val;
            int it=1;
            while(j<=n)
                {
                    dp[it][j]=max(v[it]+min(dp[it+2][j],dp[it+1][j-1]),v[j]+min(dp[it+1][j-1],dp[it][j-2]));
                    j++;
                    it++;
                }
            val++;
            i++;
        }

    /*for(int i=1; i<=n;  i++)
        {
            for(int j=1; j<=n; j++)
                fout<<dp[i][j]<<" ";
            fout<<endl;
        }*/

    cout<<dp[1][n]-(sum-dp[1][n]);
    return 0;
}


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

int main()
{
	int n, d; cin >> n >> d;
	vector <int> v;
	v.push_back(d+1);
	int ans = 1;
	for (;v.back() + d < n;)
	{
		v.push_back(v.back() + d*2+1);
		ans++;
	}
	//for (auto it : v) cout << it << ' ';
	cout << ans;
}

Measured memory_bytes: 256
//
//  main.cpp
//  Sample
//
//  Created by h3037183 on 2017/07/31.
//  Copyright ?? 2017??´ ?°????. All rights reserved.
//

#include <iostream>
using namespace std;
int main(){
    int i, j;
    while(cin >> i >> j){
        
        i += j;
        j = 0;
        
        while( i > 0, j++, i /=  10);
        cout << j << endl;
    }
    return 0;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

long count(vector<int> a, bool plus) {
  plus = !plus;
  long sum = 0;
  long count = 0;
  int n = a.size();
  for (int i = 0; i < n; i++) {
    plus = !plus;
    sum += a.at(i);
    if (plus) {
      if (sum > 0) {
        continue;
      } else {
        count += 1 - sum;
        sum = 1;
      }
    } else {
      if (sum < 0) {
        continue;
      } else {
        count += 1 + sum;
        sum = -1;
      }
    }
  }
  return count;
}

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

  vector<int> a(n);
  for (int &x : a) {
    cin >> x;
  }

  cout << min(count(a, true), count(a, false)) << endl;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

template <typename T>
using vec =vector<T>;

template <typename T>
using vvec =vector<vector<T>>;

int main(){
  int n,x,t;
  cin>>n>>x>>t;
  cout<<((n/x)+(n%x!=0))*t;
}


/* きょむ〜 */


Measured memory_bytes: 3652