akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>  
using namespace std;

int main ()
{
	int n;
	scanf("%d",&n);
	long long x,m;
	scanf("%lld",&x);
	for(int i=1;i<n;i++)
	{
		scanf("%lld",&m);
		 long long a = max(x,m);  
        long long b = min(x,m);  
		while(b)  
        {  
            long long c = a%b;  
            a = b;  
            b = c;  
        }
        x = x/a*m;
    }  
	printf("%lld\n",x);
	return 0;
}

Measured memory_bytes: 128
#include <iostream> 
#include <boost/math/common_factor.hpp> 
  
using namespace std; 
  
int main() 
{ 
  long long int a,b;
  cin>>a>>b;
    cout <<(long long)boost::math::lcm(a,b)  ;
         //<< endl; 
    return 0; 
} 

Measured memory_bytes: 256
program main
	implicit none
	integer :: a(1:5), k, TF = 0, i, j
	do i = 1, 5
		read(*, *) a(i)
	end do
	read(*, *) k
	do i = 1, 4
		do j = i+1, 5
			if(a(j) - a(i) > k) then
				TF = 1
				exit
			end if
		end do
	end do
	if(TF == 1) then
		write(*, *) ":("
	else
		write(*, *) "Yay!"
	end if
end program main

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef long long int ll;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}


void init(ll n) {
	REP(i, n) {
		par[i] = i;
		depth[i] = 0;
	}
	return;
}

ll find(ll x) {
	if (par[x] == x) { return x; }
	else { return par[x] = find(par[x]); }
}

void merge(ll x, ll y) {
	x = find(x); y = find(y);
	if (x == y) { return; }
	if (depth[x] > depth[y]) {
		par[y] = x;
	}
	else {
		par[x] = y;
		if (depth[x] == depth[y]) {
			depth[y]++;
		}
	}
}

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

//------------------変数-----------------------//
ll n, a, b, c;
string str;
char grid[4][56];
//-------------------関数----------------------//
int main() {
	fill_all(grid, (char)'#');
	cin >> n;
	for (int i = 1; i < 3; i++)
	{
		for (int j = 1; j < n+1; j++)
		{
			char ch; cin >> ch; grid[i][j] = ch;
		}
	}
	ll cnt = 1;
	ll mae;
	REP(i, n) {
		ll retu = i + 1;
		if (grid[1][retu] != grid[2][retu]) {
			i++;
			if (retu == 1) { cnt *= 6; mae = 1; continue; }
			if (mae == 1) {
				cnt *= 3; cnt %=  mod;
			}
			else {
				cnt *= 2; cnt %= mod;
			}
			mae = 1;
		}
		else {
			if (retu == 1) { cnt *= 3; mae = 0; continue; }
			if (mae == 1) {
				cnt *= 1; cnt %= mod;
			}
			else {
				cnt *= 2; cnt %= mod;
			}
			mae = 0;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
using namespace std;


int main() {
	int x, a;
	cin >> x >> a;
	if (x >= a) cout << 10 << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static List<Tuple<long, long>>[] graph;
        static long[] dst;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            graph = Enumerable.Range(0, (int)N).Select(_ => new List<Tuple<long, long>>()).ToArray();
            for (var i = 0L; i < N - 1; ++i) 
            {
                var abc = Sarray();
                var a = abc[0] - 1;
                var b = abc[1] - 1;
                var c = abc[2];
                graph[a].Add(Tuple.Create(b, c));
                graph[b].Add(Tuple.Create(a, c));
            }
            dst = new long[N];
            var QK = Sarray();
            var Q = QK[0];
            var K = QK[1] - 1;
            dsf(K, -1);
            for (var i = 0; i < Q; ++i)
            {
                var xy = Sarray();
                var x = xy[0] - 1;
                var y = xy[1] - 1;
                WriteLine(dst[x] + dst[y]);
            }
            Out.Flush();
        }
        static void dsf(long r, long p)
        {
            foreach(var g in graph[r])
            {
                var nr = g.Item1;
                if (nr == p) continue;
                dst[nr] = dst[r] + g.Item2;
                dsf(nr, r);
            }
        }
    }
}

Measured memory_bytes: 50896
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
	class Program
	{
		public static void Main()
		{
			var intArray = IO.ReadIntArray();
			var players = new[]
			{
				new[] { intArray[0] , intArray[1] },
				new[] { intArray[2] , intArray[3] }
			};
			var playerIndex = 0;
			while(true)
			{
				var player = players[playerIndex];
				var targetIndex = (playerIndex + 1) % 2;
				var target = players[targetIndex];
				target[0] -= player[1];
				if(target[0] <= 0)
				{
					IO.Write(playerIndex == 0);
					return;
				}
				playerIndex = targetIndex;
			}
		}
	}

	public static class IO
	{
		public static string   Read()								 { return Console.ReadLine(); }
		public static string[] ReadArray(char iSplitter = ' ')		 { return Read().Split(iSplitter); }
		public static int	   ReadInt()							 { return int.Parse(Read()); }
		public static int[]	   ReadIntArray(char iSplitter = ' ')	 { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); }
		public static long	   ReadLong()							 { return int.Parse(Read()); }
		public static long[]   ReadLongArray(char iSplitter = ' ')	 { return ReadArray().Select(iText => long.Parse(iText)).ToArray(); }
		public static double   ReadDouble()							 { return double.Parse(Read()); }
		public static double[] ReadDoubleArray(char iSplitter = ' ') { return ReadArray().Select(iText => double.Parse(iText)).ToArray(); }
		public static char[]   ReadCharArray()						 { return Read().ToCharArray(); }

		public static void Write(string iValue)									   { Console.WriteLine(iValue); }
		public static void Write(int iValue)									   { Console.WriteLine(iValue); }
		public static void Write(IEnumerable<int> iValue , string iJoinWord = " ") { Console.WriteLine(string.Join(iJoinWord , iValue)); }
		public static void Write(long iValue)									   { Console.WriteLine(iValue); }
		public static void Write(double iValue)									   { Console.WriteLine(iValue); }
		public static void Write(decimal iValue)								   { Console.WriteLine(iValue); }
		public static void Write(bool iValue)									   { Console.WriteLine(iValue ? "Yes" : "No"); }
	}

	public static class Util
	{
		public static long Gcd(long i0 , long i1) { return (i0 > i1) ? _Gcd(i0 , i1) : _Gcd(i1 , i0); }
		public static long Lcm(long i0 , long i1) { return (i0 * i1) / Gcd(i0 , i1); }
		public static long ModPow(long iBaseNumber , long iPow , long iModNumber)
		{
			var num = 1L;
			while(iPow != 0)
			{
				if((iPow & 0x1) != 0)
				{
					num = (num * iBaseNumber) % iModNumber;
				}
				iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber;
				iPow >>= 1;
			}
			return num;
		}
		public static long CombinationNum(int iLeftNumber , int iRightNumber)
		{
			if(iRightNumber == 0) { return 1; }
			if(iLeftNumber == 0)  { return 0; }
			return iLeftNumber * CombinationNum(iLeftNumber - 1 , iRightNumber - 1) / iRightNumber;
		}

		private static long _Gcd(long i0 , long i1)	{ return (i1 == 0) ? i0 : _Gcd(i1 , i0 % i1); }
	}
}


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

const int nmax =100010;

int act[3];
int dp[nmax][3];

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

    int n;cin>>n;
    int a=0 , b=0 ,c=0;
    for(int i=1;i<=n;++i)
    {
        cin>>act[0]>>act[1]>>act[2];
        dp[i][0]=max(b + act[0], c + act[0]);
        dp[i][1]=max(a + act[1], c + act[1]);
        dp[i][2]=max(a + act[2], b + act[2]);
        a = dp[i][0];
        b = dp[i][1];
        c = dp[i][2];
    }
    int sol = max({ dp[n][0],dp[n][1],dp[n][2] });
    cout<<sol;

    return 0;
}


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

int main() {
  int n,y;
  cin >> n >> y;
  int a=-1, b=-1, c=-1;
  for(int i=0; i<=n; i++) {
    for(int j=0; i+j<=n; j++) {
      int k=n-i-j;
      int sum=i*10000+j*5000+k*1000;
      if(sum==y) {
        a=i;
        b=j;
        c=k;
        break;
      }
    }
  }
  cout << a << " " << b << " " << c;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
const char COLORS[] = "RYGB";
int main()
{
    int n, m, d;
    scanf("%d%d%d", &n, &m, &d);
    for (int i = 0; i < n; ++ i) {
        for (int j = 0; j < m; ++ j) {
            int x = (i + m - j) / d % 2;
            int y = (i + j) / d % 2;
            putchar(COLORS[x * 2 + y]);
        }
        puts("");
    }
    return 0;
}

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

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

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    int sum = accumulate(a.begin(), a.end(), 0);

    int num = a.size();
    int ave = sum / num;
    int dist = 0;
    REP(i, n) dist += pow(ave - a[i], 2);

    int ave2 = sum / num + 1;
    int dist2 = 0;
    REP(i, n) dist2 += pow(ave2 - a[i], 2);

    int ave3 = sum / num - 1;
    int dist3 = 0;
    REP(i, n) dist3 += pow(ave3 - a[i], 2);

    cout << min({dist, dist2, dist3}) << '\n';
    return 0;
}


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

N = int(readline())
A = list(map(int, readline().split()))
S = sum(A)
bits = 1
for a in A:
    bits |= bits << a
ans = (S + 1) // 2
bits >>= ans
while True:
    if bits & 1:
        print(ans)
        exit()
    bits >>= 1
    ans += 1


Measured memory_bytes: 5396
hyou = [0]*100001

N =  int(input())
a_data = [int(x) for x in input().split()]
Q = int(input())
b_data = [[int(x) for x in input().split()] for _ in range(Q)]

# 数列を分類
for x in a_data:
    hyou[x] += 1
# 現段階の合計を求める。
total = 0
for i,x in enumerate(hyou):
    total += i*x

# 操作と合計
for before_value,after_value in b_data:
    total += (after_value - before_value) * hyou[before_value] 
    # 数値の入れ替え
    hyou[after_value] = hyou[before_value] + hyou[after_value] 
    hyou[before_value] = 0

    # 合計を出力
    print(total)

Measured memory_bytes: 30508
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main(){
    int N,C;
    cin >> N >> C;
    VVI T(C, VI(100000, 0));
    VI sum(100000, 0);
    REP(i,N){
        int s,t,c;
        cin >> s >> t >> c;
        T[c-1][s]++;
        T[c-1][t]--;
    }
    REP(i,C){
        REP(j,100000){
            if(T[i][j]==1){
                sum[j]++;
            }else if(T[i][j]==-1){
                sum[j+1]--;
            }
        }
    }
    int result = -1;
    REP(i,100000){
        sum[i+1]=sum[i]+sum[i+1];
        if(result<sum[i+1]){
            result=sum[i+1];
        }
    }
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 12416
#include "bits/stdc++.h"

using namespace std;

#define endl            "\n"
#define sz(x)          (int) (x.size())
#define all(v)          v.begin(), v.end()
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n; cin >> n;
    ll a[n], sum = 0, tot = 0;
    for(auto &i: a) cin >> i, sum += i;

    for(int i = 0; i < n; i++){
        sum -= a[i];
        tot += ((a[i] % MOD) * (sum % MOD)) % MOD;
        if(tot >= MOD) tot -= MOD;
    }
    cout << tot;
    return 0;
}


Measured memory_bytes: 5116
S=input()
T=input()

ans = len(T)
for s in range(len(S)-len(T)+1):
    # SとTの違いをスライドさせながら計算する
    diff = 0
    # Tを一文字目から順番に照らし合わせていく
    for t in range(len(T)):
        if T[t] != S[s+t]:
            diff += 1
    ans = min(diff,ans)
print(ans)

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

class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var N = input[0];
        var X = input[1];
        var T = input[2];

        Console.WriteLine((N / X + Convert.ToInt32(N % X > 0)) * T);
    }
}


Measured memory_bytes: 28288
//Gaurav Singh (saintpopo)
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long int
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
    boost
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++){
      cin>>a[i];
    }
    ll i,m=INT_MAX;
    sort(a,a+n);
    for(i=0;i<n;i++){
      if(i+k-1 >= n)  break;
      m=min(m,a[i+k-1]-a[i]);
    }
    cout<<m<<endl;
    return 0;
} 



Measured memory_bytes: 1024
#include <iostream>
#include <climits>
#include <memory.h>
#include <random>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <bitset>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
#ifdef LOCAL
    #define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
    #define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*++++++++++++++++++++++++++++++++++++coding area start+++++++++++++++++++++++++++++++++++++++++*/
const int MAXN = 20;
string s1, s2, a, b;
LL dp[MAXN][MAXN], ret;
void solve() {
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int k = 0; k < s2.size(); k++) {
        for (int i = 0; i <= min((int)a.size(), k); i++) {
            int j = k - i;
            if (i < a.size() && s2[k] == a[i]) {
                dp[i+1][j] += dp[i][j];
            }
            if (j < b.size() && s2[k] == b[j]) {
                dp[i][j+1] += dp[i][j];
            }
        }
    }
    ret += dp[a.size()][b.size()];
}
void dfs(int i) {
    if (i == s1.size()) {
        solve();
        return;
    }
    a.push_back(s1[i]);
    dfs(i+1);
    a.pop_back();
    b.push_back(s1[i]);
    dfs(i+1);
    b.pop_back();
}



/*-------------------------------------coding area end------------------------------------------*/
int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.precision(10); cout << fixed;
    #ifdef LOCAL
        freopen("../test.txt", "r", stdin);
//        freopen("../output.txt", "w", stdout);
    #endif
/*++++++++++++++++++++++++++++++++++++coding area start+++++++++++++++++++++++++++++++++++++++++*/
    int n; cin >> n;
    string s; cin >> s;
    s1 = s.substr(0, n);
    s2 = s.substr(n);
    reverse(s2.begin(), s2.end());
    dfs(0);
    cout << ret << endl;


/*-------------------------------------coding area end------------------------------------------*/

    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
    #endif
    return 0;
}
/* author:  txingml */


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
ll m,n,ans=1; 
vector<ll> yy[100005];
inline void dfs(ll deep,ll fa,ll now,ll bro)
{
	ans=ans*bro%mod;
	ll sum,e=yy[now].size(),hh=0;
	if(deep==1) sum=n-1;
	else sum=n-2;
	for(int i=0;i<e;++i)
	{
		if(yy[now][i]==fa) {hh++; continue;}
		dfs(deep+1,now,yy[now][i],sum-i+hh);
	}
}
int main()
{
    std::ios::sync_with_stdio(0); std::cin.tie(0);
    cin>>m>>n;
    ll a,b;
    for(int i=1;i<m;++i)
    {
    	cin>>a>>b;
    	yy[a].push_back(b);
    	yy[b].push_back(a);
	}
	dfs(1,0,1,n);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 14932
#include <iostream>
#include <cstdio>
#include <queue>
#include <string.h>

using namespace std;

#define MAXN 10001
#define INF 999999999


struct Edge
{
	int u, v, next, d, c;
}edge[MAXN * 4];

int head[MAXN], e;
int n, m;
int total;
int dis[MAXN];
int cost[MAXN];
bool vis[MAXN];

void add(int u, int v, int d, int c)
{
	edge[e].u = u;
	edge[e].v = v;
	edge[e].d = d;
	edge[e].c = c;
	edge[e].next = head[u];
	head[u] = e++;
}

void init()
{
	e = 0;
	memset(head, -1, sizeof(head));
	memset(vis, false, sizeof(vis));
}

queue <int> q;

void solve()
{
	while (!q.empty())
	{
		q.pop();
	}
	for (int i = 0; i <= n; i++)
	{
		dis[i] = INF;
		cost[i] = INF;
	}
	
	int cur, next, ans = 0;
	q.push(1);
	vis[1] = true;
	dis[1] = 0;
	cost[1] = 0;
	
	while (!q.empty())
	{
		cur = q.front();
		q.pop();
		vis[cur] = false;
		for (int i = head[cur]; i != -1; i = edge[i].next)
		{
			int v = edge[i].v;
				if (dis[v] > dis[cur] + edge[i].d)
				{
					dis[v] = dis[cur] + edge[i].d;
					cost[v] = edge[i].c;
					if(!vis[v])
				     {
					vis[v] = true;
					q.push(v);
				    }
				}
				else if (dis[v] == dis[cur] + edge[i].d && cost[v] > edge[i].c)
	             {
			
					cost[v] = edge[i].c;
					if(!vis[v])
			     	{
					vis[v] = true;
					q.push(v);
				    }
				}
				
		}
		
		
	}
	
	int ss = 0;
	for(int i = 1; i <= n; i++)
	{
		ss += cost[i];
	}
	
	cout << ss << endl;
}

void input()
{
	int u, v, d, c;
	
	while (cin >> n >> m)
	{
		total = 0;
		if (!n && !m)
		{
			break;
		}
		init();
		
		for (int i = 0; i < m; i++)
		{
			cin >> u >> v >> d >> c;
			add(u, v, d, c);
			add(v, u, d, c);
			total += 2 * c;
		}
		
		solve();
	}
}

int main()
{
	std::ios::sync_with_stdio(false);
	input();
	return 0;
}

Measured memory_bytes: 2164
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int N,R,L;
int p[100010];
int T[100010];

int main(){
	//cin.tie(0);
	//ios_base::sync_with_stdio(0);
	
	scanf("%d %d %d",&N,&R,&L);
	set<pair<int,int> > S;
	rep(i,R){
		S.insert(mp(0,i));
	}
	int preT = 0;
	int preID = 0;
	rep(i,R){
		int d,t,x;
		scanf(" %d %d %d",&d,&t,&x);
		d--;
		T[preID] += t - preT;
		S.erase(mp(p[d],d));
		S.insert(mp(p[d]-=x,d));
		preID = (*(S.begin())).sec;
		preT = t;
	}
	T[preID] += L - preT;
	int ans=0;
	//rep(i,N)printf("%d ",T[i]);
	rep2(i,1,N){
		if(T[i] > T[ans])ans=i;
	}
	printf("%d\n",ans+1);
}

Measured memory_bytes: 31668
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    VEC(int) A(N + 1, 1 << 20);
    FOR(i, 1, N) {
        int b;
        cin >> b;
        A[i] = min(A[i], b);
        A[i + 1] = min(A[i + 1], b);
    }
    
    lint ret = 0;
    FOR(i, 1, N + 1)
        ret += A[i];
    
    cout << ret << endl;
    return 0;
};


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm> // sort
#include <map>       // pair
#include <vector>
using namespace std;

#define REP(a,b) for(int i =(a);i < (b);i++)
#define FOR(n) for(int i = 0; i<(n); i++)
#define COUT(c)  cout<<(c)<<endl


const int INF = 100100100;
const int MOD = (int)1e9 +7;
const double EPS = 1e-9; 

typedef long long int ll;

//char in[120];
//ex. pair
//pair<pair<string,int>,int> p[110];

int main(){
    string s,t;
    cin >> s >> t;
    vector<int> s2t(26,-1);
    vector<int> t2s(26,-1);
    for(int i=0; i<s.size();i++){
        //ascii 'a' = 97
        int num_s = s[i] - 'a';
        int num_t = t[i] - 'a';
        if(s2t[num_s]!=-1 || t2s[num_t]!=-1){
            if(s2t[num_s]!=num_t || t2s[num_t]!=num_s){
                cout <<"No"<<endl;
                return 0;
            }
        }
        else{
            s2t[num_s]=num_t;
            t2s[num_t]=num_s;
        }
    }
    cout << "Yes" << endl;

    return 0;    
}

Measured memory_bytes: 776
#include<stdio.h>

typedef struct{
    int num;
    char design;
    int rank;
}Card;

int Partition(Card[],int,int);
void Quicksort(Card[],int,int);
 
int main(){
 
    int n,i,stable=1;
    Card C1[100000];
 
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf(" %c%d", &C1[i].design, &C1[i].num);
        C1[i].rank = i;
    }

    Quicksort(C1,0,n - 1);

    for(i = 0; i < n -1; i++){
        if(C1[i].num == C1[i - 1].num && C1[i-1].rank > C1[i].rank && stable == 1){
            printf("Not stable\n");
            stable = 0;
        }
    }

    if(stable) printf("Stable\n");

    for(i = 0; i < n; i++){
        printf("%c %d\n",C1[i].design,C1[i].num);
    }
    return 0;
}
 
int Partition(Card A[],int p,int r){
    int x,i,j;
    Card tmp;
    x = A[r].num;
    i = p - 1;
    for(j = p; j < r; j++){
        if(A[j].num <= x){
          i++;
          tmp = A[i];
         A[i] = A[j];
         A[j] = tmp;
        }
    }
    tmp = A[i + 1];
    A[i + 1] = A[r];
    A[r] = tmp;

    return i + 1;
}
 
void Quicksort(Card A[],int p,int r){
    int q;
    if(p < r){
        q = Partition(A,p,r);
        Quicksort(A,p,q-1);
        Quicksort(A,q+1,r);
    }
}


Measured memory_bytes: 2980
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}


pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: i64 = 1_000_000_007;
const INF: i64 = std::i64::MAX/3;

fn solve() {
	let (a,b) = read!(u64,f64);
	println!("{}", a*((b*100.0)+0.5)as u64 / 100);
}

fn run() {
    solve();
}


Measured memory_bytes: 2260
N = int(input())
*A, = map(int, input().split())
d = {}

for i in range(0, 10**5+1, 1):
    d[i] = 0

for a in A:
    d[a] += 1


table = sorted(d.items())

ans = 0
for i in range(1, len(table)-1, 1):
    ans = max(ans, table[i-1][1]+table[i][1]+table[i+1][1])
print(ans)


Measured memory_bytes: 24284
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    if(a-2*b <= 0) {
      System.out.println(0);
    } else {
      System.out.println(a-2*b);
    }
  }
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LONG_LONG_MAX    9223372036854775807LL
#define LONG_LONG_MIN    (-LONG_LONG_MAX-1)
vector<vector<long long>> dpsum,dpcost; // dp(i,j) ways when i children and ith children get j candies
vector<int>v;



void solve(){
    int n;cin>>n;
    v.resize(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    dpsum.resize(n,vector<long long>(n,-1));
    dpcost.resize(n,vector<long long>(n,-1));
    for(int i=0;i<n;i++){
        dpsum[i][i]=v[i];
        dpcost[i][i]=0;
    }
    for(int d=1;d<n;d++){
        for(int i=0;i<n-d;i++){
            int j = i+d;
            dpcost[i][j]=LONG_LONG_MAX;
            dpsum[i][j] = dpsum[i][j-1]+v[j];
            for(int k=i;k<j;k++){
                dpcost[i][j] = min(dpcost[i][j],dpcost[i][k]+dpcost[k+1][j]+dpsum[i][j]);
            }
        }
    }
    cout<<dpcost[0][n-1]<<"\n";
}

int main(){
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
    cout.sync_with_stdio(0);

    cout.precision(10);
    int t=1;//cin>>t;
    while(t--){

        solve();
    }
    return 0;
}


Measured memory_bytes: 2816
S=input()
T=input()

a=1
if len(T)==len(S)+1:
    for i in range(len(S)):
        if S[i]==T[i]:
            a=1
            if a==0:
                break
        
        else:
            a=0
            print('No')
            break
else:
    print('No')
if a==1:
    print('Yes')

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

int n, m;
int a[110][110] = {};
int b[110] = {};
int c[110] = {};

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


	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
		}
	}

	for (int i = 0; i < m;i++)
	{
		cin >> b[i];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++)
		{
			c[i] += a[i][j] * b[j];
		}
	}


	for (int i = 0; i < n; i++)
	{
		cout << c[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3112
n = gets.chomp.to_i
ans = 0

ary357 = ['3','5','7']

def retarys(int, ary)
  retary = []
  for i in 1..int 
    retary << ary
  end
  retary
end

2.step(8){|i|
  ans += ary357.product(*retarys(i,ary357)).count {|aa| (aa.uniq.size == 3) && (aa.inject(:+).to_i <= n)}
}
puts ans

Measured memory_bytes: 5116
#include <iostream>
#include <vector>
using namespace std;
int N;
void space(vector<int> &a){
  for(int i = 0; i < N; i++){
    if(i > 0){
      cout << " ";
    }
    cout << a[i];
  }
  cout << endl;
}
void selectionsort(vector<int> &a){
  int minj, count = 0;
  for(int i = 0; i < N; i++){
    minj = i;
    for(int j = minj; j < N; j++){
      if(a[j] < a[minj]){
        minj = j;
      }
    }
    int sw = a[i]; a[i] = a[minj], a[minj] = sw;
    if(i != minj) {
      count++;
    }
  }
  space(a);
  cout << count << endl;
}
int main(){
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }

  selectionsort(a);

  return 0;
}


Measured memory_bytes: 3112
S = input()
T = input()

# dp = [[[] for _ in range(len(S)+1)] for _ in range(len(T)+1)]
cdp = [[None for _ in range(len(S)+1)] for _ in range(len(T)+1)]
ddp = [[None for _ in range(len(S)+1)] for _ in range(len(T)+1)]
# dp[0] = [[''] for _ in range(len(S)+1)]
cdp[0] = [0 for _ in range(len(S)+1)]
ddp[0] = [0 for _ in range(len(S)+1)]

for i in range(1,len(T)+1):
    for j in range(len(S)+1):
        if j == 0:
            # dp[i][j] = ['']
            cdp[i][j] = 0
            ddp[i][j] = 0
            continue
        if S[j-1] == T[i-1]:
            # dp[i][j] = [p + S[j-1] for p in dp[i-1][j-1]]
            cdp[i][j] = cdp[i-1][j-1] + 1
            ddp[i][j] = 2
        else:
            if cdp[i][j-1] > cdp[i-1][j]:
                # dp[i][j] = dp[i][j-1]
                cdp[i][j] = cdp[i][j-1]
                ddp[i][j] = 1
            else:
                # dp[i][j] = dp[i-1][j]
                cdp[i][j] = cdp[i-1][j]
                ddp[i][j] = 0

# print(dp[-1][-1][0])

i, j = len(T), len(S)
L = ''
while i > 0 and j > 0:
    if ddp[i][j] == 2:
        i -= 1
        j -= 1
        L += T[i]
    elif ddp[i][j] == 1:
        j -= 1
    elif ddp[i][j] == 0:
        i -= 1

print(L[::-1])


Measured memory_bytes: 322312
#include <stdio.h>

int main(void) {
  int i, j, k, r, c;
  scanf("%d%d", &r, &c);
  int sum[c + 1];
  for(i = 0; i <= c; ++i) sum[i] = 0;
  for(i = 0; i < r; ++i) {
    int ans = 0, t;
    for(j = 0; j < c; ++j) {
      scanf("%d", &t);
      ans += t;
      sum[j] += t;
      printf("%d ", t);
    }
    printf("%d\n", ans);
    sum[c] += ans;
  }
  for(i = 0; i <= c; ++i) {
    if(i != c) printf("%d ", sum[i]);
    else printf("%d\n", sum[i]);
  }
  return 0;
}


Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;
int a, b, c;

signed main(void) {
    cin >> a >> b >> c;

    int p[3];
    p[0] = abs(a-b);
    p[1] = abs(b-c);
    p[2] = abs(c-a);


    sort(p, p+3);

    cout << p[0] + p[1] << endl;


    return 0;
}



Measured memory_bytes: 256
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0

if a[0] > x:
    ans += a[0] - x
    a[0] = x

# print(a, ans)

for i in range(1, n):
    total = a[i-1] + a[i]
    if total > x:
        # print('yay,', total-x)
        a[i] -= total - x
        ans += total - x

    # while a[i-1] + a[i] > x:
    #     a[i] -= 1
    #     ans += 1

print(ans)




Measured memory_bytes: 63856
#include<iostream>
using namespace std;
int main() {
	int xx,x,yy, y, r,kazu;
	cin >> xx >> yy;
	x = xx;
	y = yy;
	if (x < y) {
		r = x;
		x = y;
		y = r;
	}
	r = x % y;
	while (r!=0) {
		x = y;
		y = r;
		r = x % y;
	}
	kazu = xx + yy - y + 1;
	cout << kazu << endl;
}


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

int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;
 
  int ans = 0;

  if(A >= K){
    ans =K;
  }else if(A < K && K <= A+B){
    ans = A;
  }else if(A+B < K){
    ans = A*2 - K + B;
  }
  
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    int a,b;
    while(scanf("%d %d",&a,&b)==2)
    {
        int i,j,m;
    i=a+b;j=a-b;m=a*b;
    if(i>m)
        m=i;
    if(j>m)
        m=j;
    printf("%d\n",m);
    }

    return 0;
}


Measured memory_bytes: 256
chiper = input()
key = input()
save = []
cl = len(chiper)
kl = len(key)

def writeWord(ci):
    word=''
    for i in range(ci):
        if(chiper[i]=='?'):
            word += 'a'
        else:
            word += chiper[i]

    word += key
    for i in range(ci+kl,cl):
        if(chiper[i]=='?'):
            word += 'a'
        else:
            word += chiper[i]

    return word

def search():
    if(cl<kl):
        return
    last= cl-kl
    for i in range(last+1):
        for j in range(kl):
            if(chiper[i+j]=='?' or chiper[i+j]==key[j]):
                if(j==kl-1):
                    word = writeWord(i)
                    save.append(word)
            else:
                break
        
search()
if(len(save)==0):
    print('UNRESTORABLE')
else:
    save.sort()
    print(save[0])            


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	char a[55][55];
	int i,j,c,n,m;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
	{
	  for(j=1;j<=m;j++)
	  {
		cin>>a[i][j];
	  }
	}
	for(i=1;i<=n;i++)
	{
	  for(j=1;j<=m;j++)
	  {
		  c=0;
		 if(a[i][j]=='.')
		 {
			 if(a[i][j-1]=='#')
				 c++;
			 if(a[i-1][j]=='#')
				 c++;
			 if(a[i-1][j-1]=='#')
				 c++;
			     
			 if(a[i+1][j]=='#')
				 c++;
			     
			 if(a[i][j+1]=='#')
				 c++;
			 if(a[i+1][j+1]=='#')
				 c++;
		
			 if(a[i-1][j+1]=='#')
				 c++;
			 if(a[i+1][j-1]=='#')
				 c++;
			     
			 a[i][j]=c+'0';
			 c=0;
		 }
		 else
			 continue;
	  }
	}
	for(i=1;i<=n;i++)
	{
	  for(j=1;j<=m;j++)
	  {
		 printf("%c",a[i][j]);
	  }
	  printf("\n");
	}
	return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>

#define MAX_OP_NUM 2000000
#define MAX_KEY_VALUE 1000000000
#define MAX_LIST_LENGTH 1000000

using namespace std;

struct Cell {
  int value;
  Cell* next;
  Cell* prev;
};

class LinkedList {
public:
  LinkedList() {
    nil = new Cell();
    nil->next = nil;
    nil->prev = nil;

    head = nil;
    last = nil;
  }

  void insert(int value) {
    Cell* cell = new Cell();
    cell->value = value;

    cell->prev = head;
    cell->next = head->next;
    head->next->prev = cell;
    head->next = cell;
  }

  void remove(int value) {
    Cell* cell = findCell(value);
    if(cell == NULL) return;
    deleteCell(cell);
  }

  void deleteFirst() {
    Cell* cell = head->next;
    if(cell == nil) return;

    deleteCell(cell);
  }

  void deleteLast() {
    Cell* cell = last->prev;
    if(cell == nil) return;

    deleteCell(cell);
  }

  void print() {
    Cell* cell = head->next;
    while(cell != nil) {
      printf("%d", cell->value);
      cell = cell->next;

      if(cell != nil) {
        printf(" ");
      }
    }
  }
private:
  void deleteCell(Cell* cell) {
    cell->prev->next = cell->next;
    cell->next->prev = cell->prev;
    delete cell;
  }

  Cell* findCell(int value) {
    Cell* cell = head->next;

    while(cell != nil) {
      if(cell->value == value) {
        return cell;
      }
      cell = cell->next;
    }
    return NULL;
  }

  Cell* nil;
  Cell* head;
  Cell* last;
};

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

  LinkedList list;

  char operation[255];
  int arg;
  for(int i=0; i<n; i++) {
    scanf("%s%d\n", operation, &arg);
    //printf("%s %d\n", operation, arg);

    if(strcmp("insert", operation) == 0) {
      list.insert(arg);
    } else if(strcmp("delete", operation) == 0) {
      list.remove(arg);
    } else if(strcmp("deleteFirst", operation) == 0) {
      list.deleteFirst();
    } else if(strcmp("deleteLast", operation) == 0) {
      list.deleteLast();
    } else {
      printf("unknown op %s\n", operation);
      return 1;
    }

    //list.print();
    //printf("\n");
  }


  list.print();
  printf("\n");
  return 0;
}

Measured memory_bytes: 34396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,p,cnt=0;cin>>n;
  rep(i,n) {cin>>p;if(p!=i+1) cnt++;}
  print((cnt<=2)?"YES":"NO");
  return 0;
}


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

cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]

for i in range(n):
    ch, rank = input().split()
    rank = int(rank)
    
    cards[pattern.index(ch)][rank-1] = True

for ch in pattern:
    for rank in range(13):
        if cards[pattern.index(ch)][rank]:
            pass
        else:
            print(f"{ch} {rank+1}")


Measured memory_bytes: 5612
#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 << "Left" << endl;
  if((A + B) == (C + D)) cout << "Balanced" << endl;
  if((A + B) < (C + D)) cout << "Right" << endl;
}

Measured memory_bytes: 256
from collections import Counter
def solve():
    N = int(input())
    A = list(map(int, input().split()))

    counter = Counter(A)
    
    res = 0
    for i in range(N+1):
        res += counter[i] * (counter[i] - 1) / 2
    
    for i in range(N):
        val = counter[A[i]]
        before = val * (val-1)/2
        after = (val - 1) * (val - 2) / 2
        print(int(res + after - before))

if __name__ == '__main__':
    solve()

Measured memory_bytes: 88140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int64_t N,a10=1,a9=1,a8=1; cin>>N;
  rep(i,N){
    a10=(a10*10)%MOD;
    a9=(a9*9)%MOD;
    a8=(a8*8)%MOD;
  }
  cout<<(a10+a8-2*a9+2*MOD)%MOD;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}


int main(){
    ll x;
    cin >> x;
    for (ll i=-121;i<121;i++){
        for (ll j=-121;j<121;j++){
            if (i*i*i*i*i-j*j*j*j*j==x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
void solve()
{
	string s,t;
	cin>>s>>t;
	int n=s.size(),m=t.size();
	int arr[n+1][m+1];
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			if((i==0)||(j==0))
				arr[i][j]=0;
			else
			{
				if(s[i-1]==t[j-1])
				{
					arr[i][j]=arr[i-1][j-1]+1;
				}
				else
				{
					arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
				}
			}
		}
	}
	// cout<<arr[n][m];
	char backtrack[arr[n][m]];    int z=arr[n][m]-1,count1=0;
	int a=n,b=m;
	while(count1<arr[n][m])
	{
		if(arr[a][b]!=max(arr[a-1][b],arr[a][b-1]))
		{
			backtrack[z]=s[a-1];
			z--;   a--;    b--;   count1++;
		}
		else
		{
			if(arr[a][b]==arr[a-1][b])
			{
				a--;
			}
			else
			{
				b--;
			}
		}
	}
	for(int i=0;i<arr[n][m];i++)
	{
		cout<<backtrack[i];
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	solve();     
}

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

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    @SuppressWarnings("unchecked")
    private static void solve(Scanner in) {
        int N = in.nextInt(), M = in.nextInt();
        int[] l = new int[N + 1], r = new int[N + 1];
        List<Integer>[] nByLen = new List[M + 1];

        for (int n = 1; n < N + 1; n++) {
            l[n] = in.nextInt();// 1 <= l <= r <= M
            r[n] = in.nextInt();
            int len = r[n] - l[n] + 1;
            if (nByLen[len] == null) {
                nByLen[len] = new ArrayList<>();
            }
            nByLen[len].add(n);
        }

        int accum = N;
        Fenwick F = new Fenwick(M);

        StringBuilder ans = new StringBuilder();
        for (int d = 1; d < M + 1; d++) {
            int sum = accum;
            for (int e = d; e < M + 1; e += d) {
                sum += F.accum(e);
            }
            if (nByLen[d] != null) {
                accum -= nByLen[d].size();
                for (int n : nByLen[d]) {
                    F.add(l[n], 1);
                    F.add(r[n] + 1, -1);
                }
            }
            ans.append(sum).append('\n');
        }
        System.out.println(ans);
    }
}

class Fenwick {
    private final int[] fenwick;

    public Fenwick(int n) {
        fenwick = new int[n + 1];
    }

    public int accum(int i) {
        int sum = 0;
        for (; i > 0; i -= i & -i) {
            sum += fenwick[i];
        }
        return sum;
    }

    public int sum(int begin, int end) {
        return accum(end) - accum(begin - 1);
    }

    public void add(int i, int a) {
        for (; i < fenwick.length; i += i & -i) {
            fenwick[i] += a;
        }
    }
}

Measured memory_bytes: 154788
h, w = map(int, input().split())

if h != 1 and w != 1:
    if h % 2 == 0:
        print(int(h / 2 * w))
    elif w % 2 == 0:
        print(int(w / 2 * h))
    else:
        print(int((h // 2 + 1) * w - w // 2))
else:
    print(1)


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

#define FOR(i,a,b) for(int i = (a); i< (b); i++)
#define REP(i,n) FOR(i,0,n)
#define endl '\n'
#define ll long long

using namespace std;

const int MAXN = 1e5+1000;

map <int,int> najmanji;
map<int,int> brojac;
set<int> brojevi;
ll tren = 0;
ll sol[MAXN];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    FOR(i,1,n+1){
        int x;
        cin>>x;
        if(najmanji[x]==0)
            najmanji[x]=MAXN;
        najmanji[x] = min(najmanji[x],i);
        brojevi.insert(x);
        brojac[x]++;
    }
    int lastnum = 1e9+100;
    int lastin = MAXN-1;
    tren = 0;
    for(auto it = brojevi.rbegin();it!=brojevi.rend();it++){
        //cout<<*it<<" "<<brojac[*it]<<" "<<najmanji[*it]<<endl;
        sol[lastin]+=(lastnum-*it)*tren;
        tren+=brojac[*it];
        lastin=min(lastin,najmanji[*it]);
        lastnum = *it;
    }
    sol[lastin]+=lastnum*tren;
//    int lastnum = brojevi[0].first;
//    int lastin = najmanji[brojevi[0].first];
//    tren = brojevi[0].second;
//    brojevi.push_back({0,0});
//    FOR(i,1,brojevi.size()){
//        sol[lastin]+=(lastnum-brojevi[i].first)*tren;
//        lastnum = brojevi[i].first;
//        lastin = min(lastin,najmanji[brojevi[i].first]);
//        tren+=brojevi[i].second;
//    }

    FOR(i,1,n+1){
        cout<<sol[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<62;
const double pi=acos(-1);
const long double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;

int main(){
	cin>>n;
	cout<<48-n<<endl;
}

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

int main(void)
{
  char a,b,dammy;
  scanf("%c%c%c",&a,&dammy,&b);
  if(a=='H')
    printf("%c\n",b);
  else if(b=='H')
    printf("D\n");
  else
    printf("H\n");
  return 0;
}


Measured memory_bytes: 128