akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int N, X, T;
    cin >> N >> X >> T;
    cout << (N+X-1)/X * T << endl; 
}

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

char f(char c) {
	if (c=='r') return 'p';
	if (c=='s') return 'r';
	if (c=='p') return 's';
	return -1;
}

int main() {
	ll N,K,R,S,P;
	string T;
	cin >> N >> K;
	cin >> R >> S >> P;
	cin >> T;
	map<char, ll> point;
	point['r'] = R;
	point['s'] = S;
	point['p'] = P;

	vector<vector<char>> choice(K);
	rep(i,T.length()) {
		choice[i%K].push_back(f(T[i]));
	}
	ll ans = 0;
	rep(i,K) {
		ll len = choice[i].size();
		char prev_c = choice[i][0];
		ans += point[prev_c];
		rep(j,len-1) {
			if (prev_c!=choice[i][j+1]) {
				ans += point[choice[i][j+1]];
				prev_c = choice[i][j+1];
			}
			else prev_c = -1;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5120
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>

//macros
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define vecuni(a) (a).erase(unique((a).begin(),(a).end()),(a).end())

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;

//frequent functions
int gcd(int a, int b){
  if (a == 0) 
    return b; 
  return gcd(b % a, a); 
}
int findGCD(vector<int> &arr, int n){
  int result = arr[0]; 
  for (int i = 1; i < n; i++) 
    result = gcd(arr[i], result); 
  return result; 
}
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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}
//end

int A,B,C,K;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> A >> B >> C;
  cin >> K;
  pqsi que;
  que.push(A);
  que.push(B);
  que.push(C);
  rep(i,K){
    int update = que.top();
    que.pop();
    que.push(2 * update);
  }
  int ret = 0;
  rep(i,3){
    ret += que.top();
    que.pop();
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
int main(){
 int i,min,a,b;
 static int n,val;
 min=0;
 scanf("%d",&n);
 for(i=0;i<n;i++){
 scanf("%d %d",&a,&b);
 if (min<a) {min =a;val=a+b;}
}
printf("%d",val);
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>

using namespace std;
using LL = long long;

const int N = 200005;
int a[N];

int main()
{
	int n;
	scanf("%d", &n);

	map<int, int> v;
	LL res = 0;

	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
		res += v[i - a[i]];
		++v[a[i] + i];
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 21496
n,m,x= map(int,input().split())
a = list(map(int,input().split()))

count_left=0
count_right=0

for i in range(m):
  if a[i]<x:
    count_left +=1
  if a[i]>x:
    count_right+=1

print(min(count_left,count_right))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll x,k,d,ans;
int main()
{
	cin>>x>>k>>d;
	x=abs(x);
	ll t=x/d;
	if (k<=t)
	{
		ans=x-k*d;
	}
	else
	{
		ll a1=x%d;
		ll a2=a1-d;
		if (t%2!=k%2)
			a1=a2;
		ans=abs(a1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3644
mod = pow(10,9)+7
n,m = map(int,input().split())
ans = 0
inv = [0,1]
fact = [1,1]
ifact = [1,1]
for i in range(2,m+1):
    inv.append(inv[mod%i]*(mod-int(mod/i))%mod)
    fact.append(i*fact[-1]%mod)
    ifact.append(ifact[-1]*inv[i]%mod)

def combi(a,b):
    return fact[a]*ifact[b]*ifact[a-b]%mod
def permi(a,b):
    return fact[a]*ifact[a-b]%mod

for i in range(n+1):
    now = combi(n,i)
    now *= permi(m-i,n-i)
    now %= mod
    ans += now*(-1)**(i&1)
    ans %= mod
ans *= permi(m,n)
ans %= mod
print(ans)

Measured memory_bytes: 68736
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        int N = scanner.nextInt();
        List<Integer> A = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            A.add(scanner.nextInt());
        }
        A.sort((o1, o2) -> o2 - o1);
        int[] max = new int[2];
        max[0] = 0;
        max[1] = 0;
        int twin = 0, prev = -1;
        for (int Ai : A) {
            if (Ai == prev) {
                max[twin] = Ai;
                twin++;
                prev = -1;
                if (twin == 2) {
                    break;
                }
            } else {
                prev = Ai;
            }
        }
        System.out.println((long)max[0] * max[1]);
    }
}


Measured memory_bytes: 54828
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	vi l(n), r(n);
	rep(i, n) cin >> l[i] >> r[i];
	sort(all(l), greater<int>()); sort(all(r));
	
	ll ans = 0;
	for(int d = -1; d <= 1; d++){
		ll tmp = 0;
		int i = 0, j = 0;
		if(d > 0) tmp += l[i++];
		if(d < 0) tmp -= r[j++];
		ans = max(ans, tmp);
		for(; i < n && j < n; ){
			tmp += l[i++] - r[j++];
			ans = max(ans, tmp);
		}
	}
	cout << 2 * ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
/*

                              Jai Shree Krishna !!
                                 Radhe Radhe !!
                                 
             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
             
*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vvi vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
#define ins insert
#define rep(i,s,e)   for(int i=s;i<=e;i++)
#define repd(i,s,e)  for(int i=e;i>=s;i--)
#define vb vector<bool>
#define read2(n,m) int n,m; cin >> n >> m;
#define range(v) v.begin(),v.end()
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define sorti(v) sort(v.begin(),v.end())

const ll inf = 1e18;
const ll mod = 1e9 + 7;
 

signed main()
{
 
    fast;
    int n ;
    cin >> n ;
    int l[n];
    for(int i=0;i<n;i++) cin >> l[i];
    if(n==1 || n==2){
    	cout<<0<<endl;
    	return 0;
    }
    int c=0;
    for(int i=0;i<n-2;i++){
    	for(int j=i+1;j<n-1;j++){
    		for(int k=j+1;k<n;k++){
    		    if(l[i]!=l[k] && l[k]!=l[j] && l[i]!=l[j]){
    		    	if(l[i]+l[j]>l[k] && l[i]+l[k]>l[j] && l[k]+l[j]>l[i]){
    		    		c++;
    		    	}
    		    }
    		}
    	}
    }
    
    cout<<c<<endl;
    return 0;
}

/* Pooja Yadav */

Measured memory_bytes: 3612
#include <cstdio>
#include <algorithm>

using namespace std;

#define rep1(i,x) for(int i=1;i<=(x);++i)
#define chmax(a,b) a=max(a,b)

int a[100001];
int memo[100001];
int start[100001];

int main()
{
	int n, k;
	while (scanf("%d %d", &n, &k), n || k) {
		fill_n(a, n, 0);
		fill_n(memo, n, 0);
		fill_n(start, n, 0);

		bool f = false;

		rep1(i, k) {
			int tmp; scanf("%d", &tmp);
			if (tmp == 0) f = true;
			else a[tmp] = true;
		}

		rep1(i, n) {
			if (a[i]) {
				if (a[i - 1]) {
					start[i] = start[i - 1];
					memo[start[i]]++;
				} else {
					start[i] = i;
					memo[start[i]]++;
				}
			}
		}

		int ma = 0;

		rep1(i, n) {
			if (a[i]) {
				chmax(ma, memo[start[i]]);
			} else if (f) {
				if (i + 1 <= n) {
					chmax(ma, memo[start[i - 1]] + memo[start[i + 1]] + 1);
				} else {
					chmax(ma, memo[start[i - 1]] + 1);
				}
			}
		}

		printf("%d\n", ma);
	}
}

Measured memory_bytes: 2200
#%%
S = list(input())

ans = 0
count = 0
i = 0

while i < len(S):
    if i == 0:
        tmp = S[i]
        ans += 1
        i += 1
        #print(tmp)
    else:
        x = S[i]    
        for j in range(1, len(S)):
            if x != tmp:
                ans += 1
                tmp = x
                i += j
                #print(tmp)
                break
            else:
                if i+j < len(S):
                    x += S[i+j]
                else:
                    i = 10000000000000
                    break

print(ans)



Measured memory_bytes: 4840
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;

#define MAX 1024
typedef pair<int, int> C;

int main(void) {
	while(1) {
		set<C> comp[MAX];
		int n, m, a;
		int h, p, q;
		int now, highest = -1;

		scanf("%d %d %d", &n, &m, &a);
		if(!n && !m && !a) break;
		now = a;

		for(int i = 0; i < m; i++) {
			scanf("%d %d %d", &h, &p, &q);
			comp[h - 1].insert(C(p, q));
			if(h - 1 > highest) highest = h - 1;
		}

		for(int i = highest; i >= 0; i--) {
			for(int j = -1; j <= 1; j += 2) {
				if(comp[i].find(C(now+j, now)) != comp[i].end() || comp[i].find(C(now, now+j)) != comp[i].end()) {
					now += j;
					break;
				}
			}
		}
		printf("%d\n", now);
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

ll n, k;
vi		path;
vi		visited;
unordered_map<int, int> cnt, idx;

void	dfs()
{
	int p = path[0];
	int i = 0;
	while (true) {
		k--;
		cnt[p]++;
		if (cnt[p] >= 2) {
			int d = visited.size() - idx[p];
			int id = k % d;
			cout << visited[idx[p] + id] << endl;
			break;
		} else if (k == 0){
			cout << p << endl;
			break;
		}
		visited.push_back(p);
		idx[p] = i;
		i++;
		p = path[p - 1];
	}
}

void	solve()
{
	cin >> n >> k;
	rep(i, n) {
		int a;
		cin >> a;
		path.push_back(a);
	};
	dfs();
}

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

	solve();
}

Measured memory_bytes: 18660
def main():
    while True:
        word = input()
        if word == '-':
            break
        count = int(input())
        for _ in range(count):
            h = int(input())
            word = word[-(len(word) - h):] + word[0:h]
        print(word)


if __name__ == '__main__':
    main()



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

int n;
int X1[2000], Y1[2000], X2[2000], Y2[2000];
int fld[4000][4000];
int compress(int*X1, int*X2,vector<int>&X) {
	rep(i, n) {
		X.push_back(X1[i]);
		X.push_back(X2[i]);
	}
	sort(X.begin(), X.end());
	X.erase(unique(X.begin(), X.end()), X.end());
	rep(i, n) {
		X1[i] = lower_bound(X.begin(), X.end(), X1[i]) - X.begin();
		X2[i] = lower_bound(X.begin(), X.end(), X2[i]) - X.begin();
	}
	return X.size();
}
int main() {
	scanf("%d", &n);
	rep(i, n)scanf("%d%d%d%d", &X1[i], &Y1[i], &X2[i], &Y2[i]);
	vector<int>a, b;
	int w = compress(X1, X2, a), h = compress(Y1, Y2, b);
	rep(i, n) {
		for (int j = X1[i]; j < X2[i]; j++)
			for (int k = Y1[i]; k < Y2[i]; k++)fld[j][k] = true;
	}
	ll ans = 0;
	rep(i, w - 1)rep(j, h - 1) {
		if (fld[i][j])ans += ((ll)a[i + 1] - a[i])*(b[j + 1] - b[j]);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 65820
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n];
    int cnt=1;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int b[n];
    for(int i=0;i<n;i++){
        b[i]=a[i]-i;
    }
    ll ans=0;
    sort(b,b+n);
    int c=b[(n+1)/2-1];
    for(int i=0;i<n;i++){
        ans+=abs(b[i]-c);
    }
    cout<<ans<<endl;
 return 0;   
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
const double PI = 3.14159265359;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define INF 1000000000000
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
ll n,k;
cin>>n>>k;
if(k>=n)
{
	cout<<min(n,abs(n-k));
}
else
{
	cout<<min(n%k,k-n%k)<<endl;
}
return  0;
}






Measured memory_bytes: 3628
S = str(input())

tmp_list = [0]
bigger = True
for i in range(len(S)):
    if (bigger and S[i] == '<') or (not bigger and S[i] == '>'):
        tmp_list[-1] += 1
    else:
        tmp_list.append(1)
        bigger = not bigger

if len(tmp_list) % 2 == 1:
    tmp_list.append(0)

def func(x):
    return x * (x + 1) // 2

ans = 0
for i in range(len(tmp_list) // 2):
    a = tmp_list[i * 2]
    b = tmp_list[i * 2 + 1]
    if a > b:
        a, b = b, a
    ans += func(a - 1)
    ans += func(b)

print(ans)

Measured memory_bytes: 6300
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=105;
//i_am_noob
int n,a[maxn],ans=4e18,k;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	rep(n) cin >> a[i];
	rep(133){
		k=0;
		rep1(j,n) k+=(a[j]-i)*(a[j]-i);
		ans=min(ans,k);
	}
	print1(ans);
	return 0;
}

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

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


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


n = I()
A = list(MI())

ans = 0
prev = 0
for a in A:
    if a < prev:
        d = prev - a
        ans += d
    else:
        prev = a

print(ans)


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

int main(){
  string s;
  cin>>s;
  if(s[5]=='0'&&(s[6]=='1'||s[6]=='2'||s[6]=='3'||s[6]=='4'))cout<<"Heisei"<<endl;
  else cout<<"TBD"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long n = N;
        sc.close();

        int maxCount = (int) Math.sqrt(N);
        int[] z = new int[maxCount + 3];

        int count = 2;
        while (n != 1) {
            if (count > maxCount) {
                z[maxCount + 1]++;
                break;
            }
            while (n % count == 0) {
                n /= count;
                z[count]++;
            }
            count++;
        }

        int ans = 0;
        for (int i = 0; i <= maxCount + 1; i++) {
            int cnt = 1;
            while (z[i] - cnt >= 0) {
                z[i] -= cnt;
                cnt++;
                ans++;
            }
        }

        System.out.println(ans);
    }
}


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

#define llint long long int

using namespace std;

int main(){
    int H, W, K;

    cin >> H >> W >> K;

    vector<vector<int>> c(H, vector<int>(W));

    for(int i = 0; i < H; i ++){
        string temp;

        cin >> temp;

        for(int j = 0; j < W; j ++){
            if(temp[j] == '.'){
                c[i][j] = 0;
            }else{
                c[i][j] = 1;
            }
        }
    }
    int ans = 0;

    for(int i = 0; i < (1 << H); i ++){
        for(int j = 0; j < (1 << W); j ++){
            vector<vector<int>> d = c;

            for(int k = 0; k < H; k ++){
                if(((i >> k) & 1) == 1){
                    for(int l = 0; l < W; l ++){
                        d[k][l] = 0;
                    }
                }
            }
            for(int k = 0; k < W; k ++){
                if(((j >> k) & 1) == 1){
                    for(int l = 0; l < H; l ++){
                        d[l][k] = 0;
                    }
                }
            }
            int count = 0;

            for(int k = 0; k < H; k ++){
                for(int l = 0; l < W; l ++){
                    if(d[k][l] == 1){
                        count ++;
                    }
                }
            }
            if(count == K){
                ans ++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N;
    cin >> N;
    vector<double> x(N), y(N);
    rep(i, 0, N) cin >> x[i] >> y[i];
    int a[N];
    double div = 1;
    rep(i, 0, N){
        a[i] = i;
        div *= (double)(i+1);
    }
    double ans = 0;
    do{
        double d = 0;
        for(int i = 0; i < N-1; i++){
            double dx = x[a[i]] - x[a[i+1]];
            double dy = y[a[i]] - y[a[i+1]];
            d += sqrt(dx * dx + dy * dy);
        }
        ans += d;
    }while(next_permutation(a, a+N));
    printf("%.12lf\n", ans/div);
    return 0;
}

Measured memory_bytes: 256
import sys
x = []
for line in sys.stdin:
    h,w = line.split()
    h,w = int(h), int(w)
    if h == 0 and w== 0: break
    x.append([h,w])

for i in range(len(x)):
    h, w = x[i]
    s1 = '.#' * ((w+1)/2)
    s2 = '#.' * ((w+1)/2)
    for j in range(h):
        if (j & 1)==0: print s2[:w]
        else: print s1[:w]
    print

Measured memory_bytes: 4240
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

const ll DIVIDE = (1E+9)+7;

vll dp(50, 1);
vll dp2(50);
vector<vvll> a_mul(61, vvll(50, vll(50, 0)));

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  cin >> N >> K;
  vvll a(N, vll(N));
  rep(i, 0, N){
    rep(j, 0, N){
      cin >> a[i][j];
    }
  }

  a_mul[0] = a;
  int count = 1;
  for(ll i=2; i<=K; i*=2){
    rep(x, 0, N){
      rep(y, 0, N){
        rep(z, 0, N){
          a_mul[count][x][y] += (a_mul[count-1][x][z]*a_mul[count-1][z][y])%DIVIDE;
        }
        a_mul[count][x][y] %= DIVIDE;
      }
    }
    count++;
  }

  int tmp = -1;
  while(K>0){
    int flag = K%2;
    K/=2;
    tmp++;
    if(flag==0) continue;
    rep(i, 0, N){
      dp2[i] = 0;
      rep(j, 0, N){
        dp2[i] += dp[j]*a_mul[tmp][j][i];
        dp2[i] %= DIVIDE;
      }
    }
    dp = dp2;
  }

  ll ans = 0;
  rep(i, 0, N){
    ans += dp[i];
    ans %= DIVIDE;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1664
//PDF解説
#include<iostream>
using namespace std;

int main(){
  int x, y;
  cin >> x >> y;
  int A[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  if(A[x] == A[y]) cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 256
l,r = (int(i) for i in input().split())

if l <= 2019 <= r or r <= 2019 <= l or r - l >= 2019 or l - r >= 2019:
  print(0)
  exit(0)

while l // 2019 > 0 or r // 2019 > 0:
  l = l % 2019
  r = r % 2019

mini = 2*(1e+9)
if l < r:
  for i in range(l,r+1):
    for j in range(i+1,r+1):
      mini = min(mini, (i*j) % 2019)
elif l > r:
  for i in range(r,l+1):
    for j in range(i+1,l+1):

      mini = min(mini, (i*j) % 2019)
elif l == r:
  print(l*r% 2019)
  exit(0)
print(mini)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
 
typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};
 
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

int H,W;
int field_A[100][100],field_B[100][100];

int M=-1;
int c[100][100];
bool dp[100][100][30005];

int getId(int x){
    return x+M;
}

void init(){
    for(int i=0;i<100;++i)for(int j=0;j<100;++j)for(int k=0;k<30005;++k)dp[i][j][k]=false;
}

signed main(){
    init();
    cin>>H>>W;
    for(int y=0;y<H;++y){
        for(int x=0;x<W;++x){
            cin>>field_A[y][x];
        }
    }
    for(int y=0;y<H;++y){
        for(int x=0;x<W;++x){
            cin>>field_B[y][x];
        }
    }
    for(int y=0;y<H;++y){
        for(int x=0;x<W;++x){
            c[y][x]=abs(field_A[y][x]-field_B[y][x]);
            chmax(M,(H+W)*c[y][x]);
        }
    }
    dp[0][0][getId(c[0][0])]=true;
    dp[0][0][getId(-c[0][0])]=true;
    for(int y=0;y<H;++y){
        for(int x=0;x<W;++x){
            for(int k=-M;k<=M;++k){
                if(!dp[y][x][getId(k)])continue;
                dp[y+1][x][getId(k+c[y+1][x])]=true;
                dp[y+1][x][getId(k-c[y+1][x])]=true;
                dp[y][x+1][getId(k+c[y][x+1])]=true;
                dp[y][x+1][getId(k-c[y][x+1])]=true;
            }
        }
    }
    int ans=INF;
    for(int k=-M;k<=M;++k){
        if(!dp[H-1][W-1][getId(k)])continue;
        chmin(ans,(int)abs(k));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 296820
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

long long dp[333][333][333];

int main(){
    REP(i, 333) REP(j, 333) REP(k, 333) dp[i][j][k] = 1LL<<60;
    dp[0][0][0] = 0;

    int N, K;
    cin >> N >> K;
    vector<int> H(N+1);
    REP(i, N) cin >> H[i+1];
    for(int i=0; i<N; i++){
        for(int j=0; j<=N; j++){
            for(int k=0; k<=N; k++){
                dp[i+1][j+1][k] = min(dp[i+1][j+1][k], dp[i][j][k]);
                dp[i+1][j][i+1] = min(dp[i+1][j][i+1], dp[i][j][k] + H[i+1] - min(H[k], H[i+1]));
            }
        }
    }
    long long ans = 1LL<<60;
    for(int j=0; j<=K; j++)
        for(int k=0; k<=N; k++)
            ans = min(ans, dp[N][j][k]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 288768
using System;

namespace b122B {
    class Program {
        private static string atgc = "ATGC";
        static void Main(string[] args) {
            var input = Console.ReadLine();
            var result = 0;
            for (int i = 0; i < input.Length; i++) {
                var c = input[i].ToString();
                var j = i;
                var count = 0;
                while (atgc.Contains(c)) {
                    count++;
                    j++;
                    if (j >= input.Length) break;
                    c = input[j].ToString();
                }

                result = Math.Max(result, count);
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 13140
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');
// const input = fs.readFileSync('./input.txt', 'utf8');

_b(input);

function _b(input: string) {
  const [a, b, c, d] = input.split(' ').map((s) => BigInt(s));
  const products = [a * c, a * d, b * c, b * d];
  products.sort((a, b) => Number(a - b));

  const max = products[products.length - 1];
  if (max >= 0) {
    console.log(max.toString());
  } else if ((a <= 0 && 0 < b) || (c <= 0 && 0 <= d)) {
    console.log(0); // 負数しかなく 0 なら作れる場合
  } else {
    console.log(max.toString());
  }
}


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

typedef long long ll;

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

    ll *A = new ll [N];
    ll *h = new ll [N];
    ll *s = new ll [N];
    for(ll i=1; i<=N; i++)
    {
        h[i] = 0;
    }

    for(ll i=0; i<N; i++)
    {
        cin >> A[i];
        h[A[i]]++;
    }

    ll all = 0;
    for(ll i=1; i<=N; i++)
    {
        if(h[i] > 0)
        {
            s[i] = h[i]*(h[i]-1)/2;
            all += s[i];
        }
    }

    for(ll k=0; k<N; k++)
    {
        ll num = all - s[A[k]] + (h[A[k]] -1) * (h[A[k]] -2) / 2;
        cout << num << endl;
    }

    delete [] A, h, s;

    return 0;
}


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

int main() {
    int n;
    int64_t k;
    cin >> n >> k;
    vector<pair<int,int>> ab(n);
    rep(i,n){
        int ai, bi;
        cin >> ai >> bi;
        ab[i] = make_pair(ai,bi);
    }
    sort(ab.begin(),ab.end());
    int64_t cnt = 0;
    int ans;
    rep(i,n){
        int bi = ab[i].second;
        cnt += bi;
        if(cnt >= k){
            int ai = ab[i].first;
            ans = ai;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)

const int INF = 100000000;

using namespace std;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a * 100 + b * 10 + c) % 4 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll n;
    cin >> n;

    MSG(n * 800 - (n / 15) * 200)

    return 0;
}



Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("unroll-loops")

#ifdef __APPLE__
    # include <iostream>
    # include <cmath>
    # include <algorithm>
    # include <stdio.h>
    # include <cstdint>
    # include <cstring>
    # include <string>
    # include <cstdlib>
    # include <vector>
    # include <bitset>
    # include <map>
    # include <queue>
    # include <ctime>
    # include <stack>
    # include <set>
    # include <list>
    # include <random>
    # include <deque>
    # include <functional>
    # include <iomanip>
    # include <sstream>
    # include <fstream>
    # include <complex>
    # include <numeric>
    # include <immintrin.h>
    # include <cassert>
    # include <array>
    # include <tuple>
    # include <unordered_map>
    # include <unordered_set>
    # include <thread>
#else
    #include <bits/stdc++.h>
#endif
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
 
using namespace std;
#define int long long
 
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;
 
const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;
const ll inf=1e18+10;
 
///---program start---///

signed main()
{
    #ifdef __APPLE__
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    int a,b,m;
    cin>>a>>b>>m;
    vi A(a);
    vi B(b);
    for (auto &i:A){
        cin>>i;
    }
    for (auto &i:B){
        cin>>i;
    }
    int ans=*min_element(all(A))+*min_element(all(B));
    while (m--){
        int x,y,c;
        cin>>x>>y>>c;
        ans=min(ans,A[x-1]+B[y-1]-c);
    }
    if (ans<0){
        ans=0;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
	int n,T;
	cin >> n >> T;
	int t[200001];
	t[0]=-T;
	int ans=0;
	for(int i=1;i<=n;i++){
		cin >> t[i];
		if(t[i]<t[i-1]+T) ans+=t[i]-t[i-1];
		else ans+=T;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class116
    {
        static void Main()
        {
            var NP = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NP[0], P = NP[1];
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int even = A.Count(x => x % 2 == 0);
            int odd = A.Count() - even;
            long ans = 1;
            if (P == 0)
            {
                ans *= (long)Math.Pow(2, even);
                if (odd > 0) ans *= (long)Math.Pow(2, odd - 1);
            }
            else
            {
                ans *= (long)Math.Pow(2, even);
                if (odd > 0) ans *= (long)Math.Pow(2, odd - 1);
                else ans *= 0;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
typedef long long int ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<vint> vvint;
const ll LINF = 9000000000000000000ll;
const int INF = 2000000000;
const ll MOD = 1e9+7;

int main() {
    int n;
    string s;
    cin >> n >> s;
    if (n >= 3200) {
        cout << s << endl;
    } else { 
        cout << "red" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int N,M,A[101],B[101],p[101],i,i2,ruio;
	scanf("%d%d",&N,&M);
	for(i=1;i<=M;i++){
		scanf("%d",&A[i]);
	}
	for(i=1;i<=N;i++){
		p[i]=0;
	}
	for(i=1;i<=M;i++){
		for(i2=1;i2<=N;i2++){
			scanf("%d",&B[i2]);
		}
		for(i2=1;i2<=N;i2++){
			if(A[i]!=B[i2]){
				ruio=A[i];
				p[ruio]++;
			}
			if(A[i]==B[i2]){
				p[i2]++;
			}
		}
	}
	for(i=1;i<=N;i++){
		printf("%d\n",p[i]);
	}
	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		String output = (r*100+g*10+b)%4==0 ? "YES" : "NO";
		System.out.println(output);
	}
}


Measured memory_bytes: 20948
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
  
int main() {
	int n;
	cin >> n;
	cout << (1000 - n % 1000) % 1000;
}


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

int main() {
    long long n;
    cin >> n;
    vector<long long> a(n,0);
    long long ans = 1;
    long long m = pow(10,18);
    rep(i,n) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i,n) {
        if (a[i] > m / ans) {
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4036
from collections import deque

n, q = map(int, raw_input().split())
task = [raw_input().split() for _ in range(n)]

for t in task:
    t[1] = int(t[1])

Q = deque(task)
elaps = 0

while len(Q) > 0:
    u = Q.popleft()
    c = min(u[1], q)
    u[1] -= c
    elaps += c

    if u[1] > 0:
        Q.append(u)
    else:
        print u[0], elaps

Measured memory_bytes: 19800
s = int(input())

def func(a):
    if a%2 == 0:
        return a//2
    else:
        return 3*a + 1

a = [s]

i = 2
while True:
    a_i = func(s)
    if a_i in a:
        print(i)
        break
    else:
        i += 1
        a.append(a_i)
        s = a_i 

Measured memory_bytes: 3060
#include<iostream>
int main(){
 int N;
 std::cin>>N;
 long long answer=0;
 int u,v;
 for(int i=0;i<N-1;i++){
  answer+=((long long)(i+1))*(N-i);
  std::cin>>u>>v;
  if(u>v){
	  answer-=((long long)v)*(N-u+1);
  }else{
	  answer-=((long long)u)*(N-v+1);
  }
 }
 answer+=N;
 std::cout<<answer;
 return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << "(" << v.first << ", " << v.second << ")";
    return ostr;
}

vector<string> split(const string &s, char delim) {
    vector<string> result;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
        if (!item.empty()) {
            result.push_back(item);
        }
    }
    return result;
}

int main() {
    int n; cin >> n;
    vector<pair<int, int>> L(n);
    rep(i, n) {    
        L[i].second = i;
        cin >> L[i].first;
    }

    sort(all(L));
    rep(i, n) {
        cout << L[i].second + 1;
        if (i < n) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }

const int MOD = 1000000007;

int main() {
    int N, M;
    cin >> N >> M;
    set<int> a;
    rep(i, M) {
        int x;
        cin >> x;
        a.insert(x);
    }

    int dp[100050];
    rep(i, 100010) dp[i] = 0;
    dp[0] = 1;

    for (int i = 0; i <= N; i++) {
        if (a.find(i) == a.end()) {
            if (a.find(i+1) == a.end()) {
                dp[i+1] += dp[i];
                dp[i+1] %= MOD;
            }
            if (a.find(i+2) == a.end()) {
                dp[i+2] += dp[i];
                dp[i+2] %= MOD;
            }
        }
    }

    dp[N] %= MOD;

    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 5376
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int A, B, C, X, Y;

        try (Scanner sc = new Scanner(System.in)) {
            A = sc.nextInt();
            B = sc.nextInt();
            C = sc.nextInt();
            X = sc.nextInt();
            Y = sc.nextInt();
        }
        int result = 0;
        int C2 = 2 * C;
        int sagaku = C2 - (A + B);
        int min = X < Y ? X : Y;
        if (sagaku < 0) {
            result += C2 * min;
        } else {
            result += A * min;
            result += B * min;
        }

        if (X > Y) {
            if (A > C2) {
                result += C2 * (X - Y);
            } else {
                result += A * (X - Y);
            }
        } else if (X < Y) {
            if (B > C2) {
                result += C2 * (Y - X);
            } else {
                result += B * (Y - X);
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 21972
#include <stdio.h>
int main(void){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
    printf("%d %d %f\n",d,r,f);
    return 0;
}

Measured memory_bytes: 1820
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {
        var N = Console.ReadLine().ToInt32();
        var S1 = Console.ReadLine();
        var S2 = Console.ReadLine();
        var grid = new char[2,N];

        for (int i = 0; i < N; i++)
        {
            grid[0, i] = S1[i];
        }
        for (int i = 0; i < N; i++)
        {
            grid[1, i] = S2[i];
        }
        var timesLs = new List<long>();
        var isX = false;
        for (int i = 0; i < N; i++)
        {
            if (grid[0,i] == grid[1, i])
            {
                if (i == 0)
                {
                    timesLs.Add(3);
                    isX = true;
                }
                else
                {
                    if (isX)
                    {
                        timesLs.Add(2);
                    }
                    else
                    {
                        timesLs.Add(1);
                    }
                    isX = true;
                }
            }
            else
            {
                if (i == 0)
                {
                    timesLs.Add(6);
                    isX = false;
                }
                else
                {
                    if (isX)
                    {
                        timesLs.Add(2);
                    }
                    else
                    {
                        timesLs.Add(3);
                    }
                    isX = false;
                }
                i++;
            }
        }
        Console.WriteLine(timesLs.Aggregate((x,y) => (x * y % 1000000007)));
        Console.ReadLine();
    }



    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();

    public const int INF = int.MaxValue / 2;
    #endregion
}


Measured memory_bytes: 13268