akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <climits>
using namespace std;

const static int COLOR_NAME_LENGTH = 7;
const static int BASE_COLOR_NUM = 8;
const static int MASK = 0x0000ff;

const int base_colors[ BASE_COLOR_NUM ] = {
  0x000000,
  0x0000ff,
  0x00ff00,
  0x00ffff,
  0xff0000,
  0xff00ff,
  0xffff00,
  0xffffff
};

const char *base_color_names[ BASE_COLOR_NUM ] = {
  "black",
  "blue",
  "lime",
  "aqua",
  "red",
  "fuchsia",
  "yellow",
  "white"
};

int diffsq( const int color1, const int color2 ) {
  int c1 = color1;
  int c2 = color2;
  int rdiff = ( ( c1 >> 16 ) & MASK ) - ( ( c2 >> 16 ) & MASK );
  int gdiff = ( ( c1 >>  8 ) & MASK ) - ( ( c2 >>  8 ) & MASK );
  int bdiff = ( ( c1       ) & MASK ) - ( ( c2       ) & MASK );

  return rdiff * rdiff + gdiff * gdiff + bdiff * bdiff;
}

int main() {

  while( 1 ) {
    char color_name[ COLOR_NAME_LENGTH + 1 ];
    scanf( "%s", color_name );
    if( color_name[ 0 ] == '0' ) {
      return EXIT_SUCCESS;
    }
    for( int i = 1; i < COLOR_NAME_LENGTH + 1; i++ )  {
      color_name[ i - 1 ] = color_name[ i ];
    }
    int color;
    int minidx = 0;
    int mindiff = INT_MAX;
    sscanf( color_name, "%x", &color );
    for( int i = 0; i < BASE_COLOR_NUM; i++ ) {
      int diff = diffsq( color, base_colors[ i ] );
      if( diff < mindiff ) {
        minidx = i;
        mindiff =  diff;
      }
    }
    printf( "%s\n", base_color_names[ minidx ] );
  }
}

Measured memory_bytes: 1024
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstring>
#include<sstream>
#include<complex>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < int(Y);++(X))
#define rrep(X,Y) for (int (X) = int(Y-1);(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll dp[312][312],INF=1ll<<50,a[312],n,sum[312];

ll Cost(ll l,ll m){ //cout<<"cost:"<<l<<","<<m<<":";
  if(l<m)swap(l,m);
  ll re=0;
  int f=0;
  while(l){
    re+=(l%10)*(m%10);
    re+=f=((l%10)+(m%10)+f>=10);
    l/=10;
    m/=10;
  }
  return re;
}

int main(){
  int i,j,k;
  fill(dp[0],dp[0]+312*312,INF);
  scanf("%lld",&n);
  rep(i,n)
    scanf("%lld",a+i);
  rep(i,n)
    sum[i+1]=a[i]+sum[i];
  rep(i,n+1)
    rep(j,n-i+1){
      ll &tmp=dp[j][i+j];
      if(i<2)
        tmp=0;
      else
        for(k=j+1;k<i+j;k++)
          tmp=min(tmp,dp[j][k]+dp[k][i+j]+Cost(sum[k]-sum[j],sum[i+j]-sum[k]));
    }
  printf("%lld\n",dp[0][n]);
  return 0;
}

Measured memory_bytes: 1956
#include<bits/stdc++.h>
using namespace std;
int n, l[110];

int check(int a, int b, int c) {
  if (a == b || a == c || b == c) return 0;
  return (a + b > c && a + c > b && b + c > a);
}

int main() {
  int ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &l[i]);
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      for (int k = j + 1; k <= n; ++k)
        if (check(l[i], l[j], l[k]))
          ++ans;
  printf("%d\n", ans);
  return 0;
}

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

using namespace std;

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

#ifndef ONLINE_JUDGE
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define dbg(x)
#endif

#define X first
#define Y second

int main(){
    std::ios_base::sync_with_stdio(false);
    ll arr[3];
    for (int i = 0; i < 3; i++) cin >> arr[i];
    sort(arr, arr + 3);
    for (int i = 0; i < 3; i++){
        if ((arr[i] & 1) == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << arr[0] * arr[1] << endl;


    return 0;
}


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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    int n;
    cin >> n;

    vector<int> ans(n + 1);

    for(int x = 1; x <= 100; x++){
        for(int y = 1; y <= 100; y++){
            for(int z = 1; z <= 100; z++){
                int tmp = x*x + y* y + z * z + x * y + y * z + z * x;

                if(tmp <= n){
                    ans[tmp]++;
                }
            }
        }
    }

    rep(i, n){
        cout << ans[i + 1] << endl;
    }

    return 0;
}


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

#define ll long long

using namespace std;

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n, 0), b(m, 0);
  vector<ll> pa(n+1, 0), pb(m+1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> a[i - 1];
    pa[i] = pa[i - 1] + a[i - 1];
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i - 1];
    pb[i] = pb[i - 1] + b[i - 1];
  }
  int result = 0;
  for (int i = 0; i <= n; i++) {
    ll diff = k - pa[i];
    int res = 0;
    if (diff < 0)
      break;
    int l = 1, r = m;
    while (l <= r) {
      int mid = (l + r) / 2;
      if (pb[mid] <= diff) {
        res = mid;
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
    result = max(result, i + res);
  }
  cout << result;
}


Measured memory_bytes: 8008
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define chmax(x,y) x = max(x, y)

int main() {
    int n ;
    cin >> n;
    vector<ll> a (n) ;
    rep(i, n) cin >> a[i] ;
    ll tot = 0 ;
    for(int i = 1; i < n; i++){
        if(a[i] < a[i - 1]){
            tot += a[i - 1] - a[i] ;
            a[i] = a[i - 1] ;
        }
    }
    cout << tot << endl ;
} 

Measured memory_bytes: 4840
package main

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

func main() {
	N := ReadInt()
	var lt, lx, ly int
	for i := 0; i < N; i++ {
		t, x, y := ReadInt(), ReadInt(), ReadInt()
		d := Abs(lx-x) + Abs(ly-y)
		dt := t - lt
		if d <= dt && d%2 == dt%2 {
			lt, lx, ly = t, x, y
			continue
		} else {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 5956
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in(x) int x; cin>>x;
#define inn(x, y) int x, y; cin>>x>>y;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

//bool primes[1000001];vi prime;
//void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
//if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}

//int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}

int32_t main(void){
	IOS;
	
	in(n);
	int arr[n+1];
	int tmp1[n+1], tmp2[n+1];
	mi m2,m1;
	rep(i, 1, n+1)
	{
		cin>>arr[i];
		tmp1[i] = i-arr[i];
		m1[tmp1[i]] += 1;
		tmp2[i] = i+arr[i];
		m2[tmp2[i]] += 1;
	}
	int ans = 0;
	rep(i, 1, n+1)
	{
		ans += m1[tmp1[i]]*m2[tmp1[i]];
		m1[tmp1[i]] = 0;
		m2[tmp1[i]] = 0;
	}
	cout<<ans;
}

Measured memory_bytes: 31020
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONGINF 1000000000000000000
int n;
bool can_doit(int a) {
	int ok = n;
	for (int i = a;i > 0;--i) {
		if (ok >= i) {
			ok -= i;
		}
	}
	if (ok == 0) {
		return true;
	}
	else return false;
}
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	int top = 100000000;
	int bot = 0;
	while (top - bot > 1) {
		int mid = top + bot;
		mid /= 2;
		if (can_doit(mid) == true) {
			top = mid;
		}
		else {
			bot = mid;
		}
	}
	int setting = 0;
	if (can_doit(bot) == true) {
		setting = bot;
	}
	else setting = top;
	for (int i = setting;i > 0;--i) {
		if (n >= i) {
			cout << i << endl;
			n -= i;
		}
	}
	return 0;
}

Measured memory_bytes: 256
def North(dice):
    w = dice[0]
    dice[0] = dice[1]
    dice[1] = dice[5]
    dice[5] = dice[4]
    dice[4] = w
    return dice
def East(dice):
    w = dice[1]
    dice[1] = dice[2]
    dice[2] = dice[4]
    dice[4] = dice[3]
    dice[3] = w
    return dice

def West(dice):
    w = dice[0]
    dice[0] = dice[2]
    dice[2] = dice[5]
    dice[5] = dice[3]
    dice[3] = w
    return dice

maxloop = 4
Ncnt = 0
Ecnt = 0
Wcnt = 0

Dice1 = input().split()
Dice2 = input().split()

Flag = False
Nloop = True
Eloop = True
Wloop = True

while Eloop:
    while Nloop:
        while Wloop:
            if Dice1 == Dice2:
                Flag = True
                Nloop = False
                Eloop = False
                Wloop = False
                break
            Dice1 = West(Dice1)
            Wcnt += 1
            if Wcnt == maxloop:
                Wloop = False
        Dice1 = North(Dice1)
        Wcnt = 0
        Wloop = True
        Ncnt += 1
        if Ncnt == maxloop:
            Nloop = False
    Dice1 = East(Dice1)
    Ncnt = 0
    Nloop = True
    Ecnt += 1
    if Ecnt == maxloop:
        Eloop = False

if Flag == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7704
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vvi vector<vector<int>>
using namespace std;

bool binalize_ox(char c) {
	if (c == 'o') {
		return 1;
	}
	else {
		return 0;
	}
}

bool binalize_SW(char c) {
	if (c == 'W') {
		return 1;
	}
	else {
		return 0;
	}
}

void visualize(vector<bool> ws) {
	for (int i = 0; i < ws.size(); i++) {

	}
}
int main() {
	int N; cin >> N;
	vector<bool> ox(N);
	for (int i = 0; i < N; i++) {
		char c; cin >> c;
		ox[i] = binalize_ox(c);
	}
	vector<bool> ans;
	for (int f = 0; f < 2; f++) {
		for (int s = 0; s < 2; s++) {
			vector<bool> sw(N);
			sw[0] = f;
			sw[1] = s;
			for (int pos = 2; pos < N; pos++) {
				sw[pos] = sw[pos - 2];
				if (!(ox[pos - 1] ^ sw[pos - 1])) {
					sw[pos] = !sw[pos];
				}
			}
			vector<bool> tmp(N);
			tmp[0] = f; tmp[1] = s;
			for (int i = 0; i < N; i++) {
				int ind_prev = (N + i - 1) % N;
				int ind_next = (N + i + 1) % N;
				if (sw[i] == 0) {
					tmp[i] = !(sw[ind_prev] ^ sw[ind_next]);
				}
				else {
					tmp[i] = sw[ind_prev] ^ sw[ind_next];
				}
			}
			bool fg = true;
			for (int pos = 0; pos < N; pos++) {
				if (tmp[pos] != ox[pos]) {
					fg = false;
					break;
				}
			}
			if (fg == true) {
				ans = sw;
				goto endloop;
			}
		}
	}
endloop:
	if (ans.size() > 0) {
		for (bool b: ans) {
			if (b == true) {
				cout << 'W';
			}
			else {
				cout << 'S';
			}
		}
		cout << endl;
	}
	else {
		cout << -1 << endl;
	}
}

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

int main() {
    int X;
    cin >> X;
    if(X < 600) {
        cout << 8 << endl;
    } else if(X < 800) {
        cout << 7 << endl;
    } else if(X < 1000) {
        cout << 6 << endl;
    } else if(X < 1200) {
        cout << 5 << endl;
    } else if(X < 1400) {
        cout << 4 << endl;
    } else if(X < 1600) {
        cout << 3 << endl;
    } else if(X < 1800) {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
count = gets.chomp.to_i
data = count.times.map { gets.strip.split.map(&:to_i) }
current = [0, 0, 0]

def is_reachable?(current, next_data)
  tc, xc, yc = current
  tn, xn, yn = next_data
  dt = tn - tc
  dist = (xn - xc).abs + (yn - yc).abs

  return false if dist > dt
  (dist - dt).even?
end

data.each do |d|
  unless is_reachable?(current, d)
    puts 'No'
    exit 0
  end
  current = d
end

puts 'Yes'


Measured memory_bytes: 21080
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])


def main():
    """エントリーポイント"""
    N = input(int)
    X = input([int, N])
    f, c = floor(sum(X) / N), ceil(sum(X) / N)
    ans = [0, 0]
    for x in X:
        ans[0] += (f - x) ** 2
        ans[1] += (c - x) ** 2
    print(min(ans))


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 3436
import math
n, k = map(int, input().split())
w = [int(input()) for i in range(n)]


def check(P): # 最駄積載量Pのk台のトラックで何個目の荷物まで積めるか。積める荷物の数をreturn
    i = 0
    for j in range(k):
        s = 0
        while (s + w[i]) <= P:
            s += w[i]
            i += 1
            if (i==n):
                return n
    return i

# 今、条件より1<=w<=10,000であり、1<=n<=100000
# つまり、トラックの最大積載量の取りうる最大値はこれらが一つのトラックに乗る時、つまり100000*10000
# 従ってこの範囲でPを探索すればよい
# 二分探索を使うことができる（これらのmidをPと仮定してcheckで積める個数を調べる
#→これがnよりも大きければPはもっと小さくて良いと言うことなのでrightをmidに、小さければleftをmidに！

        
def solve():
    left = 0
    right = 100000*10000
    while (right - left) > 1:
        mid = (left + right) / 2
        v = check(mid)
        if (v >= n):   # ?
            right = mid
        else:
            left = mid
            
    return right

ans = math.floor(solve())
print(ans)




Measured memory_bytes: 9624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BTheater solver = new BTheater();
        solver.solve(1, in, out);
        out.close();
    }

    static class BTheater {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            out.println(IntStream.range(0, in.ints()).map(i -> 1 - in.ints() + in.ints()).sum());
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



Measured memory_bytes: 28116
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
int32_t main(){
    int n;
    cin>>n;
    int a[n+1];
    int sum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    int dp[n+1][n+1];
    memset(dp,0,sizeof dp);
    for(int i=1;i<=n;i++){
        dp[i][i]=a[i];
    }
    
    for(int d=0;d<=n-1;d++){
        for(int i=1,j=d+1;i<=n-d && j<=n;i++,j++){
            if(i==j){
                continue;
            }
            int op1=a[i]+min(dp[i+2][j],dp[i+1][j-1]);
            int op2=a[j]+min(dp[i][j-2],dp[i+1][j-1]);
            dp[i][j]=max(op1,op2);
        }
    }    
    int x=dp[1][n];
    int y=sum-x;
    int ans=x-y;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,m;
	cin >> n >> m;
	vector<pair<int,int> > e(m);
	for(int i = 0; i < m; i++){
		cin >> e[i].second >> e[i].first;
	}

	sort(all(e));
	int ans = 0, now = 0;
	for(int i = 0; i < m; i++){
		if(now < e[i].second){
			now = e[i].first-1;
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  int n;
  string s[2];
  cin >> n >> s[0] >> s[1];
  ll res = 0;
  bool is;
  if(s[0][0] == s[1][0]){
    is = true;
    res = 3;
    for(int i = 1;i < n;i++){
      if(s[0][i] == s[1][i]){
        if(is){
          res = (res*2)%MOD;
          is = true;
        }else{
          is = true;
        }
      }else{
        if(is){
          res = (res*2)%MOD;
          is = false;
          i++;
        }else{
          res = (res*3)%MOD;
          is = false;
          i++;
        }
      }
    }
  }else{
    is = false;
    res = 6;
    for(int i = 2;i < n;i++){
      if(s[0][i] == s[1][i]){
        if(is){
          res = (res*2)%MOD;
          is = true;
        }else{
          is = true;
        }
      }else{
        if(is){
          res = (res*2)%MOD;
          is = false;
          i++;
        }else{
          res = (res*3)%MOD;
          is = false;
          i++;
        }
      }
    }
  }
  cout << res << endl;



  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define P pair<ll, ll>
using namespace std;

const ll mod = 1e9+7;

int main(){
    ll n;
    cin >> n;
    ll sum0 = 1;
    for(int i=0;i<n;i++){
        sum0 *= 10;
        sum0 %= mod;
    }
    ll sum1 = 1; 
    for(int i=0;i<n;i++){
        sum1 *= 9;
        sum1 %= mod;
    }sum1 *= 2;
    sum1 %= mod;
    ll sum2 = 1;
    for(int i=0;i<n;i++){
        sum2 *= 8;
        sum2 %= mod;
    }

    ll ans = (sum0 - sum1 + sum2)%mod;
    if(ans < 0) ans += mod;

    cout << ans << endl;
}

Measured memory_bytes: 3632
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
double dist(ll x1,ll y1, ll x2,ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll ans = 0;
	ans += min(a, k);
	k -= min(a, k);
	k -= min(b, k);
	ans -= min(c, k);
	k -= min(c, k);
	cout << ans;
	return 0;
}


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

using namespace std;

int main() {

    int N; cin>>N;

    int minimum; cin >> minimum;
    int ans = 1;
    for (int i = 1; i < N; ++i) {
        int Pi; cin>>Pi;
        if(Pi <= minimum) {
            ans++;
            minimum = Pi;
        }
    }
    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int x[12];
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	x[0]=a*c-b;
	cout<<x[0]<<endl;
	for(int i=1;i<=9;i++){
		x[i]=a*x[i-1]-b;
		cout<<x[i]<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,n) for(ll i=0;i<n;i++)
#define pb push_back
#define mod 1000000007;
// ll mod=1e9+7;
vector<vector<ll>> mult(vector<vector<ll>>&a,vector<vector<ll>>&b,int n){
  vector<vector<ll>>dp(n,vector<ll>(n));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      dp[i][j]=0;
      for(int k=0;k<n;k++){
        dp[i][j]+=a[i][k]*b[k][j];
        dp[i][j]%=mod;
      }
    }
  }
  return dp;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  ll n;
  cin>>n;
  ll k;
  cin>>k;
  vector<vector<ll>> a(n,vector<ll>(n));
  for(int i=0 ;i<n;i++){
    // a[i][i]=1;
    f(j,n){
      cin>>a[i][j];
    }
  }
  // cout<<"gag";
  // vector<vector<int>>temp=a;
  vector<vector<ll>>dp(n,vector<ll>(n,0));
  f(i,n)dp[i][i]=1;
//   // int k
  while(k>0){
    if(k%2==1)dp=mult(dp,a,n);
    a=mult( a,a, n);
    k/=2;
// cout<<k<<endl;
  }
  long long ans=0;
  // dp=mult(dp,temp,n);
  f(i,n){
    f(j,n)ans=(ans+dp[i][j])%mod;

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



Measured memory_bytes: 3708
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#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 vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_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 MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int dp[3100][3100][4];

void run(){
    int r,c,k;
    cin>>r>>c>>k;
    vvi v(r+1,vi(c+1));
    rep(i,k){
        int x,y,z;
        cin>>x>>y>>z;
        x--,y--;
        v[x][y]=z;
    }
    rep(i,r+1){
        rep(j,c+1){
            rep(k,3){
                dp[i][j+1][k+1]=max(dp[i][j+1][k+1],dp[i][j][k]+v[i][j]);
                dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]+v[i][j]);
            }
            rep(k,4){
                dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
                dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
            }
        }
    }
    int ans=0;
    rep(i,4)ans=max(ans,dp[r][c][i]);
    cout<<ans<<endl;
}

Measured memory_bytes: 364432
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

ll mod_pow(ll x, ll p, ll MOD) {
    ll a = 1;
    while (p) {
        if (p%2) a = a*x%MOD;
        x = x*x%MOD;
        p/=2;
    }
    return a;
}

// mod_inverse
ll mod_inverse(ll a, ll m) {
    return mod_pow(a, m-2, m);
}

const int MOD = 1e9+7;
const int MAX = 1000000;
ll fact[MAX], rfact[MAX];
ll p3[MAX];

ll nCr(int n, int r) {
    return fact[n]*rfact[r]%MOD*rfact[n-r]%MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    fact[0] = rfact[0] = 1;
    for (int i = 1; i < MAX; i++) {
        fact[i] = i*fact[i-1]%MOD;
        rfact[i] = mod_inverse(fact[i], MOD);
    }
    p3[0] = 1;
    for (int i = 1; i < MAX; i++) {
        p3[i] = p3[i-1]*3%MOD;
    }
    int N, M, K;
    cin >> N >> M >> K;
    ll ans = 0;
    // for (int m = 0; m <= M; m++) {
    //     for (int k = 0; k <= K; k++) {
    //         ll tmp = fact[N-1+m+k];
    //         (tmp *= rfact[N-1])%=MOD;
    //         (tmp *= rfact[m])%=MOD;
    //         (tmp *= rfact[k])%=MOD;
    //         (tmp *= p3[M+K-m-k])%=MOD;
    //         (ans += tmp) %= MOD;
    //     }
    // }
    ll sum = 1;
    int low = 0, high = 0;
    for (int i = 0; i <= M+K; i++) {
        ans += nCr(N-1+i, N-1)*sum%MOD*p3[M+K-i]%MOD;
        int nh = min(i+1, M);
        int nl = max(0, i+1-K);
        sum = 2*sum;
        if (low < nl) sum -= nCr(i, low);
        if (high == nh) sum -= nCr(i, high);
        sum = (sum%MOD+MOD)%MOD;
        high = nh;
        low = nl;
    }
    ans %= MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 23808
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <bitset>
#include <time.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
int sx,sy,tx,ty;
int main()
{
    scanf("%d%d%d%d",&sx,&sy,&tx,&ty);

    for(int i=ty-sy;i;--i)putchar('U');
    for(int i=tx-sx;i;--i)putchar('R');

    for(int i=ty-sy;i;--i)putchar('D');
    for(int i=tx-sx;i;--i)putchar('L');

    putchar('L');
    for(int i=ty-sy;i;--i)putchar('U');
    putchar('U');
    putchar('R');
    for(int i=tx-sx;i;--i)putchar('R');
    putchar('D');

    putchar('R');
    for(int i=ty-sy;i;--i)putchar('D');
    putchar('D');
    putchar('L');
    for(int i=tx-sx;i;--i)putchar('L');
    putchar('U');
    puts("");
    return 0;
}


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

#define ll long long

int main() {
  ll int X;
  cin >> X;
  ll int ans = 0;

  while(X >= 500) {
    X-=500;
    ans+=1000;
  }
  while(X >= 5) {
    X-=5;
    ans+=5;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3640
import sys
from itertools import permutations

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    D, G = map(int, input().split())
    PC = [(0, 0, 0)]
    for i in range(1, D + 1):
        p, c = map(int, input().split())
        PC.append((i, p, c))
    perms = permutations(range(1, D + 1))

    ans = INF
    for p in perms:
        tmp = 0
        cnt = 0
        for idx in p:
            i, p, c = PC[idx]
            if tmp + 100 * i * p >= G:
                cnt += (G - tmp + 100 * i - 1) // (100 * i)
                break
            elif tmp + 100 * i * p + c >= G:
                cnt += p
                break
            else:
                tmp += 100 * i * p + c
                cnt += p

        if cnt < ans:
            ans = cnt

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 40812
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

string reverse(string input, int length);

int main()
{
 ios::sync_with_stdio(false);
 cin.tie(0);
 
 string S;
 cin >> S;
 string revS = reverse(S, S.size());
 if(revS == S)
 {
  int a = (S.size()-1)/2-1;
  int b = (S.size()+3)/2-1;
  string s1 = S.substr(0, a+1);
  string s2 = S.substr(b, S.size()-b);
  if(s1 == reverse(s1, s1.size()) && s2 == reverse(s2, s2.size())) cout << "Yes";
  else cout << "No";
 }
 else
 {
  cout << "No";
 }
}

string reverse(string input, int length)
{
 string rev = input;
 for(int i=0; i<(length/2); i++)
 {
  char temp = rev[i];
  rev[i] = rev[length-i-1];
  rev[length-i-1] = temp;
 }
 return rev;
}

Measured memory_bytes: 256
def main():
    x = int(input())
    res = 0
 
    for i in range(-200, 200):
        for j in range(-200, 200):
            if i**5 - j**5 == x:
                res = [i, j]
                break
        if res:
            break
    
    print(res[0], res[1])
                
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n; cin>>n;
    int a=0, b=0, p=0;
    for(int t, x, y; cin>>t>>x>>y; a=x, b=y, p=t) {
        int w=abs(a-x)+abs(b-y);
        int u=t-p;
        if (w>u or w%2!=u%2) return !printf("No\n");
    }
    puts("Yes");
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	long long a[3],k,i;

	for(i=0;i<3;i++)
	{
		scanf("%lld",&a[i]);
	}
	scanf("%lld",&k);
	
	 if(k%2==0)
	{
		if(abs(a[0]-a[1])>pow(10,18))
		{
			printf("Unfair\n");
		}
		if(abs(a[0]-a[1])<=pow(10,18))
		printf("%lld\n",a[0]-a[1]);
	}
	else if(k%2!=0)
	{
			if(abs(a[0]-a[1])>pow(10,18))
		{
			printf("Unfair\n");
		}
		if(abs(a[0]-a[1])<=pow(10,18))
		printf("%lld\n",a[1]-a[0]);
	}
	
	return 0;
	
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
n,d,a = map(int,input().split())
H = [list(map(int,input().split())) for i in range(n)]
H.sort()

ans = 0
m = 0
M = []
t = 0
for i in range(n):
    while t < len(M) and M[t][1] < H[i][0]:
        m -= M[t][0]
        t += 1
    H[i][1] -= m
    if H[i][1] > 0:
        dn = -(-H[i][1]//a)
        dd = dn * a
        M.append([dd, H[i][0]+d*2])
        ans += dn
        m += dd
    # print(m,M)
print(ans)

Measured memory_bytes: 97884
/*
 * Atcoder Beginner Contest 154
 * 
 * Time: 8ms
 * Memory: 888KB
 * 
 * Author:DragonLee
 */

#include <iostream>
#include <map>
using namespace std;

int main() {
    string s, t, u;
    int a, b;
    map<string, int> m;
    cin >> s >> t >> a >> b;
    m[s] = a;
    m[t] = b;
    cin >> u;
    m[u] -= 1;
    cout << m[s] << " " << m[t] << endl;
    return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
const ll MOD=1000000007;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const vector<pll> dir={{0,1},{1,0},{-1,0},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}};
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm (ll a,ll b) {return a*b/gcd(a,b);}
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}

vector<ll> func,inv;
void init(ll n){
    func.resize(n+1);inv.resize(n+1);
    func[0]=1;
    rep(i,0,n) {func[i+1]=func[i]*(i+1)%MOD;}
    inv[n]=intpow(func[n],MOD-2);
    rrep(i,1,n+1) {inv[i-1]=inv[i]*i%MOD;}
}
ll comb(ll a,ll b) {return func[a]*inv[b]%MOD*inv[a-b]%MOD;}

inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return v[(size / 2) - 1] ;
}
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;}

int main(){
    string s;
    cin>>s;
    vector<string> a(2*10e5);
    a[0]=s[0];
    ll cnt=0;
    bool f=1;
    rep(i,1,s.size()){
        if(f) a[++cnt]=s[i];
        else a[cnt]+=s[i];
        if(a[cnt-1]!=a[cnt]) f=1;
        else f=0;
    }
    if(a[cnt-1]!=a[cnt]) cnt++;
    cout<<cnt;
}

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

namespace ABC098A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,b,c;

            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            c = a + b;
            if (c < a - b) c = a - b;
            if (c < a * b) c = a * b;

            Console.WriteLine(c);

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <string.h>
#define N 1000
 
char x[N], y[N];
 
int lcs(){
    int i, j;
    int m = strlen(x);
    int n = strlen(y);
    int c[m+1][n+1];
     
    for(i = 1; i <= m; i++) c[i][0] = 0;
    for(j = 0; j <= n; j++) c[0][j] = 0;
     
    for(i = 1;i<=m;i++){
        for(j = 1;j<=n;j++){
            if(x[i-1] == y[j-1]){
                c[i][j] = c[i-1][j-1] + 1;
            } else if (c[i-1][j] >= c[i][j-1]){
                c[i][j] = c[i-1][j];
            } else {
                c[i][j] = c[i][j-1];
            }
        }
    }
     
    return c[m][n];
}
 
main(){
    int n, i;
     
    scanf("%d",&n);
    for(i = 0;i<n;i++){
        scanf("%s%s",x,y);
        printf("%d\n",lcs());
    }
     
    return 0;
}



Measured memory_bytes: 5684
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

char s[100005];

int main() {
    scanf("%s",s);
    int len=strlen(s);
    if ((len&1)!=(s[0]==s[len-1])) printf("First\n"); else printf("Second\n");

    return 0;
}



Measured memory_bytes: 384
mod=10**9+7
n,a,b=map(int,input().split())
ans=pow(2,n,mod)-1

def comb(n,mm):
  m=min(mm,n-mm)
  ans=1
  for i in range(m):
    ans*=n-i
    ans%=mod
  for i in range(m):
    ans*=pow(i+1,mod-2,mod)
    ans%=mod
  return ans

ans=((ans+(mod-comb(n,a)))%mod)+(mod-comb(n,b))
print(ans%mod)

Measured memory_bytes: 40876
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>
#include <list>
#include <queue>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int N,K; cin>>N>>K;
  map<int,int> bucket; // kind, count
  for(int i=0; i<N; i++) {
    int a; cin>>a;
    bucket[a]++;
  }

  int now_kinds = bucket.size();
  int sum = 0;
  vector<int> count;
  for(auto b: bucket) {
    count.push_back(b.second);
  }
  sort(count.begin(), count.end());
  for(int i=0; i < (int)count.size(); i++) {
    if(now_kinds <= K) {
      break;
    }
    sum += count[i];
    now_kinds--;
  }
  cout << sum << endl;
}


Measured memory_bytes: 10744
import java.util.Scanner;

class Node {
   private int parent;
   private int left;
   private int right;

   public Node(int parent, int left, int right) {
       this.parent = parent;
       this.left = left;
       this.right = right;
   }
   public void setLeft(int left) {
       this.left = left;
   }
   public void setRight(int right) {
       this.right = right;
   }
   public void setParent(int parent) {
       this.parent = parent;
   }
   public int getParent() {
       return this.parent;
   }
   public int getLeft() {
       return this.left;
   }
   public int getRight() {
       return this.right;
   }
}
public class Main {
    static final int NIL = -1;
    static final int MAX = 100005;
    static Node[] T = new Node[MAX];
    static int n;
    static int D[] = new int[MAX];

    public static void main(String[] args){
        int left = 0;

        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();

        for (int i = 0; i < n; i++) {
            T[i] = new Node(NIL, NIL, NIL); // 初始化节点
        }
        for (int i = 0; i < n; i++) {
            int number = scanner.nextInt();
            int childrenSize = scanner.nextInt();
            for (int j = 0; j < childrenSize; j++) {
                int child = scanner.nextInt();
                // 左子右兄弟
                if (j == 0) {
                    T[number].setLeft(child);
                } else {
                    T[left].setRight(child);
                }
                left = child;
                T[child].setParent(number);
            }
        }
        scanner.close();
        // 求各节点的深度
        for ( int i = 0; i < n; i++) {
            D[i] = getDepth(i);
        }

        for (int i = 0; i < n; i++) {
            print(i);
        }
    }

    static int getDepth(int number) {
        int d = 0;
        while(T[number].getParent() != NIL) {
            number = T[number].getParent();
            d ++;
        }
        return d;
    }

    static void print(int number) {
        System.out.print("node " + number + ": " + "parent = " + T[number].getParent() + ", " + "depth = " + D[number] + ", ");

        if (T[number].getParent() == NIL) {
            System.out.print("root, ");
        } else if (T[number].getLeft() == NIL) {
            System.out.print("leaf, ");
        } else {
            System.out.print("internal node, ");
        }

        System.out.print("[");

        for (int i = 0, c = T[number].getLeft(); c != NIL; i++, c = T[c].getRight()){
            if(i != 0) {
                System.out.print(", ");
            }
            System.out.print(c);
        }
        System.out.println("]");
    }
}



Measured memory_bytes: 110368
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int digit(int x) {
  int d = 0;
  while (x > 0) {
    x /= 10;
    ++d;
  }
  return d; 
}

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    if (digit(i)%2==1) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3168
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    long Squ[100100];
    for (int i = 1; i < 100000; i++) {
        Squ[i] = i * i;
    }
    for (int i = 1; i < 100000; i++) {
        if (N < Squ[i]){
        cout << Squ[i - 1] << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cctype>
using namespace std;

int mcxi[4];
const char c[] = {'m', 'c', 'x', 'i'};

void count(string s)
{
  if(!isdigit(s[0]))
    s = "1" + s;
  for(int i = 1; i < (int)s.size(); i++)
    if(s[i] == c[0]){
      if(isdigit(s[i-1]))
        mcxi[0] += s[i-1] - '0';
      else
        mcxi[0]++;
    }else if(s[i] == c[1]){
      if(isdigit(s[i-1]))
        mcxi[1] += s[i-1] - '0';
      else
        mcxi[1]++;
    }else if(s[i] == c[2]){
      if(isdigit(s[i-1]))
        mcxi[2] += s[i-1] - '0';
      else
        mcxi[2]++;
    }else if(s[i] == c[3]){
      if(isdigit(s[i-1]))
        mcxi[3] += s[i-1] - '0';
      else
        mcxi[3]++;
    }
}

void show(int x, char c)
{
  if(mcxi[x]){
    if(mcxi[x] > 1)
      cout << mcxi[x];
    cout << c;
  }
}


int main()
{
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    fill(mcxi, mcxi + 4, 0);
    string s1, s2;
    cin >> s1 >> s2;
    count(s1);
    count(s2);
    for(int j = 3; j > 0; j--){
      mcxi[j-1] += mcxi[j] / 10;
      mcxi[j] %= 10;
    }
    for(int j = 0; j < 4; j++)
      show(j, c[j]);
    cout << endl;
  }
}

Measured memory_bytes: 1208
import fractions as frac
a, b, c, d, e, f = map(int, input().split())
memo=[[(-1, -1)]*1000 for i in range(10000)]
func = lambda t: frac.Fraction(t[0], t[1]) if t[1]>0 else -10
def dp(s, w):
    if w*e<s or w*100+s>f:
        return (-1, -1)
    m=memo[s][w]
    if m[0]>0:
        return m
    p0=(s,w) 
    p1=dp(s, w+a)
    p2=dp(s, w+b)
    p3=dp(s+c, w)
    p4=dp(s+d, w)
    memo[s][w]=max(p0, p1, p2, p3, p4, key = func) if w>0 else max(p1, p2, key = func)
    return memo[s][w]
    
ans=dp(0,0)
print(ans[0]+ans[1]*100, ans[0])


Measured memory_bytes: 84408
import java.util.*;

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

        int[] time = new int[5];
        int sum = 0;
        int min = 10;
        for (int i = 0; i < 5; i++) {
            time[i] = sc.nextInt();
        }
        for (int i = 0; i < 5; i++) {
            if (time[i] % 10 == 0)
                sum += time[i];
            else
                sum += time[i] + 10 - time[i] % 10;
        }
        for (int i = 0; i < 5; i++) {
            if (time[i] % 10 != 0) {
                if (min > time[i] % 10) {
                    min = time[i] % 10;
                }
            }
        }
        System.out.println(sum - (10 - min));
    }
}

Measured memory_bytes: 22100
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>

using namespace std;
int64_t pow(int64_t a,int64_t b){//a^bを求める
	if(b==0){
		return 1;
	}else{
		int64_t temp = pow(a,b/2);
		temp = temp * temp;
		if(b%2==1){
			temp = temp * a;
		}
		return temp;
	}
}
int main() {
	int n,m;
	cin>>n>>m;
	int64_t ans;
	int64_t once=1900*m+100*(n-m);
	ans=once*pow(2,m);
	cout<<ans<<endl;


}


Measured memory_bytes: 256
from fractions import gcd
from functools import reduce
import sys
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
def solve(N, A):
    mod = 10 ** 9 + 7
    lcm = lcm_list(A)
    ans = [lcm//a for a in A]
    return sum(ans) % mod
    
 
def main():
    read = sys.stdin.buffer.read
    N,*A = map(int,read().split())
    ans = solve(N, A)
    print(ans)
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 264772
import sys

input = sys.stdin.readline

def main():
    n,k,q=map(int,input().split())
    a=[-q]*n
    for i in range(q):
       a[int(input())-1]+=1
    for i in range(n):
        a[i]+=k
    for i in range(n):
        print("Yes" if a[i]>0 else "No")



if __name__ == "__main__":
    main()



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

int main(void)
{
	int i, n;
	cin >> n;

	std::vector<int> a(n);
	std::vector<int> b(n);

	for (i=0; i<n; i++) cin >> a[i];
	for (i=0; i<n; i++) b[a[i]-1] = i+1;
	for (i=0; i<n; i++) cout << b[i] << " ";
	cout << endl;

	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d,x[114][514];
    cin>>n>>d;
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin>>x[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            double sum=0;
            for(int k=0;k<d;k++){
                sum+=pow(x[i][k]-x[j][k],2);
            }
            sum=sqrt(sum);
            if(ceil(sum)!=floor(sum)){
              //hahahahahaha
              //hogehogehoge
              //(\__/)\\
              //written by ckjaskkc
            }
          	else{
				ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string a,b;
    cin >> a >> b;
    if(a.size() > b.size()) cout << "GREATER" << endl;
    else if(a.size() < b.size()) cout << "LESS" << endl;
    else{
        REP(i,a.size()){
            if(a[i] > b[i]){
                cout << "GREATER" << endl;
                return 0;
            }else if(a[i] < b[i]){
                cout << "LESS" << endl;
                return 0;
            }
            i++;
        }
        cout << "EQUAL" << endl;
    }
}

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

using namespace std;

#define BUF_SIZE 1024
#define ARRAY_SIZE 100

int main(){

	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));
	int array[ARRAY_SIZE];
	int change_count = 0;

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

	int tmp = 0;
	for(int i = n-1;i > 0;i--){
		for(int j = 0; j < i;j++){
			if(array[j] > array[j+1]){
				tmp = array[j+1];
				array[j+1] = array[j];
				array[j] = tmp;
				change_count++;
			}
		}
	}

	for(int i = 0; i < n; i++){
		if(i != n-1){
			printf("%d ",array[i]);
		}else{
			printf("%d\n",array[i]);
		}
	}
	printf("%d\n",change_count);
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S;
    for (int i = S.size() - 2; i > 0; i -= 2) {
        if (S.substr(0, i / 2) == S.substr(i / 2, i / 2)) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3588