akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define LCM(a,b)                (a / __gcd(a,b) ) *b
#define GCD(a,b)                __gcd(a,b)
#define dist(x1,y1,x2,y2)       sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define distl(x1,y1,x2,y2)      sqrtl((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define fRead(x)                freopen(x,"r",stdin)
#define fWrite(x)               freopen (x,"w",stdout)
#define LL                      long long
#define ULL                     unsigned long long
#define pb                      push_back
#define tcase                   cout<<"Case "<<C++<<": ";
#define all(a)                  a.begin(),a.end()
#define Unique(a)               sort(all(a)),a.erase(unique(all(a)),a.end
#define ABS(x)                  ((x)<0?-(x):(x))
#define min3(a,b,c)             min(a,min(b,c))
#define min4(a,b,c,d)           min(a,min(b,min(c,d)))
#define max3(a,b,c)             max(a,max(b,c))
#define max4(a,b,c,d)           max(a,max(b,max(c,d)))
#define PI                      acos(-1.0)
#define ff                      first
#define ss                      second
#define SP(x,y)                 fixed<<setprecision((y))<<(x)
#define FastRead                ios_base::sync_with_stdio(0);cin.tie(NULL);
#define FOR(x, l, r)            for (int x = l; x<=r; ++x)
#define REP(x,r)               for (int x = 0; x <r; ++x)
#define NN                      cout<<"\n";
#define NNN                     cout<<"\n------------------------------\n";

//***********************************************************************//
//                      SHAHED AHMED, CSE'15, IUT                        //
//***********************************************************************//


int cnt[300];

int main()
{
        FastRead
        int n;
        cin>>n;
        string s;
        cin>>s;
        LL ans=0;
        LL md = 1e9 + 7;
        for(int i=0;i<s.size();i++)
        {
                LL tot=1;
                for(char ch = 'a';ch<='z';ch++)
                {
                        if(ch==s[i]) continue;
                        tot*=(cnt[ch]+1);
                        tot%=md;
                }
                ans+=tot;
                ans%=md;

                cnt[s[i]]++;
        }

        cout<<ans;

}


Measured memory_bytes: 512
def call(n)
  count = ''
  1.upto(n) do |i|
    x = i
    if x % 3 == 0
      count << " " + i.to_s
      next
    elsif
        while x.to_i != 0 do
          if x % 10 == 3
            count << " " + i.to_s
            break
          end
           x = x / 10
        end
    end
  end
  count
end

number = gets.to_i
puts call(number)


Measured memory_bytes: 6884
#include <iostream>

using namespace std;

int main() {
        int N;

        cin >> N;

        int A[N];
        int B[N];

        for (int i = 0; i < N; i++) {
                cin >> A[i];
                B[A[i]-1] = i+1;
        }

        for (int i = 0; i < N; i++) {
                cout << B[i] << " ";
        }
        return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll n,a,b;cin>>n>>a>>b;
  vector<ll>p(n);
  for(i=0;i<n;i++)cin>>p[i];
  ll s=0,t=0,u=0;
  for(i=0;i<n;i++){
    if(p[i]<=a)s++;
    else if(p[i]>b)t++;
    else u++;
  }
  cout<<min({s,t,u})<<endl;

  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[]
b=[]
for i in range(n):
  x,y=map(int,input().split())
  a.append(x)
  b.append(y)
a=sorted(a)
b=sorted(b)
if n%2==1:
  ans=b[n//2]-a[n//2]+1
else:
  ma=b[n//2-1]+b[n//2]
  mi=a[n//2-1]+a[n//2]
  ans=ma-mi+1
print(ans)

Measured memory_bytes: 27060
package main

import (
	"fmt"
	"math"
)

func isMovable(current []int, next []int, t int) bool {
	diffX := next[0] - current[0]
	diffY := next[1] - current[1]

	distance := int(math.Abs(float64(diffX)) + math.Abs(float64(diffY)))

	if t >= distance && ((t%2 != 0 && distance%2 != 0) || (t%2 == 0 && distance%2 == 0)) {
		return true
	}

	return false
}

func main() {
	var (
		n           int
		x           int = 0
		y           int = 0
		currentTime int = 0
	)

	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var t, xi, yi int
		fmt.Scan(&t, &xi, &yi)

		if isMovable([]int{x, y}, []int{xi, yi}, t-currentTime) {
			x = xi
			y = yi
			currentTime = t
			continue
		}
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a, b;
  int suma, sumb;
  int mi = 99999999;
  for(int i=0; i<N/2+1; i++){
    a = i+1;
    b = N-a;
    suma = 0;
    sumb = 0;
    while(a>0){
      suma += a%10;
      a /= 10;
    }
    while(b>0){
      sumb += b%10;
      b /= 10;
    }
   mi = min(mi,suma+sumb);
  }
  cout << mi << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	//freopen("test.in","r",stdin),freopen("test.out","w",stdout);
	long long n,x;
	scanf("%lld%lld",&n,&x);
	printf("%lld\n",3LL*(n-__gcd(n,x)));
	return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::cmp::max;

type Pair = (usize, usize);

fn input_char_vec() -> Vec<char> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().chars().collect()
}

fn main() {
    let s = input_char_vec();
    let t = input_char_vec();
    let mut dp = vec![vec![0; t.len() + 1]; s.len() + 1];
    let mut prev: Vec<Vec<Pair>> = vec![vec![(0, 0); t.len() + 1]; s.len() + 1];
    for i in 0..s.len() {
        for j in 0..t.len() {
            if s[i] == t[j] {
                dp[i+1][j+1] = dp[i][j] + 1;
                prev[i+1][j+1] = (i, j);
            } else {
                if dp[i][j+1] > dp[i+1][j] {
                    dp[i+1][j+1] = dp[i][j+1];
                    prev[i+1][j+1] = (i, j+1);
                } else {
                    dp[i+1][j+1] = dp[i+1][j];
                    prev[i+1][j+1] = (i+1, j);
                }
            }
        }
    }
    let mut i = s.len();
    let mut j = t.len();
    let mut ans: Vec<char> = Vec::new();
    while (i, j) != (0, 0) {
        // println!("{}, {}, {:?}", i, j, prev[i][j]);
        let pre_i = prev[i][j].0;
        let pre_j = prev[i][j].1;
        if pre_i < i && pre_j < j {
            ans.push(s[pre_i]);
        }
        i = pre_i;
        j = pre_j;
    }
    // println!("{:?}", dp);
    ans.reverse();
    for c in ans {
        print!("{}", c);
    }
    println!();
}


Measured memory_bytes: 178116
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

def index_sort(A):
    x = []
    for i,a in enumerate(A):
        x.append((a,i))
    return sorted(x, key=lambda x: x[0])

N = I()
X = III()

y = index_sort(X)
order = [0]*N
for i in range(N):
    order[y[i][1]] = i

for i in range(N):
    if order[i]<=(N-1)//2:
        print(y[(N+1)//2][0])
    else:
        print(y[(N-1)//2][0])

Measured memory_bytes: 102484
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using ld = long double;

const ld INF = 1e100;

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}

template <class T>
inline T sq(T a) { return a * a; }

inline ld dist(std::pair<ld, ld> a, std::pair<ld, ld> b) {
    return sqrtl(sq(a.first - b.first) + sq(a.second - b.second));
}

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

    std::vector<std::pair<ld, ld>> vp(N);
    for (auto& p : vp) std::cin >> p.first >> p.second;
    std::sort(vp.begin(), vp.end());

    auto dp = Vec<ld>(N, N, INF);
    dp[0][0] = 0;
    for (int i = 0; i < N - 1; ++i) {
        for (int j = 0; j < N - 1; ++j) {
            int n = std::max(i, j) + 1;
            dp[n][j] = std::min(dp[n][j], dp[i][j] + dist(vp[i], vp[n]));
            dp[i][n] = std::min(dp[i][n], dp[i][j] + dist(vp[j], vp[n]));
        }
    }

    ld ans = INF;
    for (int i = 0; i < N - 1; ++i) {
        ans = std::min(ans, std::min(dp[N - 1][i], dp[i][N - 1]) + dist(vp[i], vp[N - 1]));
    }

    std::cout << std::fixed << std::setprecision(10) << ans << std::endl;
    return 0;
}



Measured memory_bytes: 18748
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <complex>
#include <bitset>
 
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define sz(a) (int)(a).size()
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

const int MAXN = 111;
const int P = 1e9 + 7;

int dp[MAXN][MAXN * MAXN];
int a[MAXN];

void add(int &a, int b) {
    a += b;
    if (a >= P) {
        a -= P;
    }
}

void sub(int &a, int b) {
    a -= b;
    if (a < 0) {
        a += P;
    }
}

void mul(int &a, int b) {
    ll ans = (ll)a * b;
    ans %= P;
    a = ans;
}

int main() {
    // ifstream cin("input.txt");
    // ofstream cout("output.txt");
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);    
    
    int n, k;
    cin >> n >> k;

    dp[n + 1][0] = 1;
    for (int i = n; i >= 1; --i) {
        for (int j = 0; j <= n * (n + 1) / 2; ++j) {
            for (int l = 0; l <= k; ++l) {
                if (dp[i + 1][j] == 0) {
                    continue;
                }
                if (l > i) {
                    add(dp[i][j], dp[i + 1][j]);
                } else {
                    int cnt = (l + j) / i;
                    add(dp[i][j + cnt], dp[i + 1][j]);
                }
            }
        }
    }

    int ans = k * (k + 1) / 2;
    for (int i = 0; i < n - 1; ++i) {
        mul(ans, k + 1);
    }
    mul(ans, n);

    for (int i = 0; i <= n * (n + 1) / 2; ++i) {
        int tmp = dp[1][i];
        mul(tmp, i);
        sub(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long sum = 0;

		for (int i = 1; i <= n; i++) {
			if (i % 3 != 0 && i % 5 != 0) {

				sum += i;
			}
		}

		System.out.println(sum);

		sc.close();

	}
}

Measured memory_bytes: 35828
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		String s = input.nextLine();
		int N = s.length();
		int START = N/2;
		if (Palindrome(s)&&Palindrome(s.substring(0,START))&&Palindrome(s.substring(START+1))) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
	public static boolean Palindrome(String s) {
		for (int i = 0; i < s.length()/2; i++) {
			if (s.charAt(i)!=s.charAt(s.length()-i-1)) return false;
		}
		return true;
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <stack>
int main()
{
    auto k = int(0);
  	std::cin >> k;
  
    auto ll = std::vector<int>(10);
    auto stk = std::stack<std::pair<int, int>>();

    auto count = int(0);

    auto n = int(0);

    while (count != k)
    {
        for (int i = 9; i > 0; --i) stk.emplace(i, n);

        while (!stk.empty() && count != k)
        {
            auto [num, digit] = stk.top();
            ll[static_cast<std::size_t>(digit)] = num;
            stk.pop();

            if (digit != 0)
            {
                for (int j = 1; j >= -1; --j)
                {
                    if (num + j <= 9 && 0 <= num + j)
                    {
                        stk.emplace(num + j, digit - 1);
                        ll[static_cast<std::size_t>(digit - 1)] = num + j;
                    }
                }
            }
            else if (digit == 0)
            {
                ++count;
                ll[0] = num;
            }
        }
        ++n;
    }

    for (int i = n - 1; i >= 0; --i) std::cout << ll[static_cast<std::size_t>(i)];
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int X, Y;
  cin >> X >> Y;
  int money[] = {300000,
                 200000,
                 100000};
  int ans = 0;
  if (X < 4)
    ans += money[X - 1];

  if (Y < 4)
    ans += money[Y - 1];

  if (X == 1 && Y == 1)
    ans += 400000;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
size = int(input())
element = list(map(int,input().split()))
print(" ".join(map(str,element)))


for i in range(1,len(element)):
    v = element[i]
    j = i-1
    while j >=0 and element[j] > v:
        element[j+1] = element[j]
        j -=1
        element[j+1] = v
    print(" ".join(map(str,element)))

Measured memory_bytes: 7568
main = solve

solve = do
    x <- readLn
    let str = createLine x
    putStrLn str

createLine :: Int -> String
createLine w = concat . (map step) $ [1..w]

step :: Int -> String
step x
    | x `mod` 3 == 0 || three = " " ++ show x
    | otherwise = ""
    where three = include3 x

include3 x
    | one3 = True
    | otherwise = if 0 < ten then include3 ten else False
    where
        one3 = x `mod` 10 == 3
        ten = x `div` 10

Measured memory_bytes: 4116
n = int(input())
if n == 1:
  print(0)
  quit()
mod = 10**9+7
s = 1
n0 = 1
n09 = 1
for i in range(n):
  s*=10
  n0*=9
  n09*=8
  s%=mod
  n0%=mod
  n09%=mod

n0*=2
n0%=mod

ans=s-n0
ans%=mod

ans+=n09
ans%=mod

print(ans)

Measured memory_bytes: 63368
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);


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


    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    while(k--){
        vector<int> sum(n);
        for(int i=0;i<n;i++){
            sum[max(0,i-a[i])]++;
            if(i+a[i]+1 < n)sum[i+1+a[i]]--;
        }
        bool ok = 1;
        if(sum[0]!=n)ok=false;
        for(int i=1;i<n;i++){
            sum[i] += sum[i-1];
            if(sum[i] != n)ok=false;
        }
        swap(a,sum);
        if(ok)break;
    }
    for(int i=0;i<n;i++)cout << a[i] << " ";
    cout << endl;
}


Measured memory_bytes: 4784
#define N_MAX 100000
#define M_MAX 100000
 
 
int main(void){
  int N, M;
  scanf("%d %d", &N, &M);
  
  int L[M_MAX], R[M_MAX];
  int i;
  for(i=0; i<M; i++){
  	scanf("%d %d", &L[i], &R[i]);
  }
  
 
  int min=1, max=N;
  for(i=0; i<M; i++){
      if(min < L[i]){
          min = L[i];
      }
      if(R[i] < max){
          max = R[i];
      }
  }
  
  int temp = max - min + 1;
  if(temp >= 0) printf("%d", temp);
  else printf("%d", 0);
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
using ll=long long;
using namespace std;

int findroot(int a,vector<int>& v){
    if(v[a]>=0){
        int res=findroot(v[a],v);
        v[a]=res;
        return res;
    }else{
        return a;
    }

}

void uni(int a,int b,vector<int>& v){
    int roota=findroot(a,v);
    int rootb=findroot(b,v);
    if(roota==rootb){
        return;
    }else if(v[roota]<v[rootb]){
        v[roota]+=v[rootb];
        v[rootb]=roota;
    }else{
        v[rootb]+=v[roota];
        v[roota]=rootb;
    }
    return;
}

int dec(int a,int b,vector<int>& v){
    int roota=findroot(a,v);
    int rootb=findroot(b,v);
    if(roota==rootb){
        return 1;
    }else{
        return 0;
    }
}

int main(){
    int N,M;
    cin>>N>>M;

    vector<int> v(N+1,-1);
    int a,b;
    for(int i=0;i<M;i++){
        cin>>a>>b;
        uni(a,b,v);
    }

    int ans=0;
    for(int i=0;i<N;i++){
        if(v[i]<ans){
            ans=v[i];
        }
    }
    cout<<-1*ans<<endl;


    return 0;
}

Measured memory_bytes: 4040
while True:
    try:
        a = list(map(int, input().split()))
        b = list(map(int, input().split()))
        hit  = 0
        blow = 0
        for i in range(4):
            if a[i] == b[i]:
                hit += 1
            elif a[i] in b:
                blow += 1
        print(hit, blow)
    except:
        break



Measured memory_bytes: 5592
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
 
int main() {
    ios::sync_with_stdio(false);
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) > abs(x - b)) cout << 'B';
	else cout << 'A'; 
}

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

#include <iostream>
using namespace std;
int main() {
  uint64_t n;
  cin >> n;
  uint64_t total = 0;
  for (size_t i = 1; i < n + 1; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      total += i;
    }
  }
  cout << total << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> s(1 << n);
    for (int i = 0; i < (1 << n); i++) {
        cin >> s[i];
    }
    multiset<int> tree;
    for (int x : s) {
        tree.insert(x);
    }
    auto it = tree.end();
    it--;
    vector<int> state;
    state.push_back(*it);
    tree.erase(it);

    for(int t = 0; t < n; t++) {
        for (int i = 0; i < (1 << t); i++) {
            int from = state[i];
            auto it = tree.lower_bound(from);
            if (it == tree.begin()) {
                cout << "No" << endl;
                return 0;
            }
            --it;
            state.push_back(*it);
            tree.erase(it);
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 14716
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, a[105], cnt[105];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	FOR(i, n) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	sort(a, a+n);
	reverse(a, a+n);
	int ma = a[0], mi = (a[0]+1)/2;
	bool ok = true;
	if ((a[n-1] != mi) || (ma % 2 == 1 && cnt[mi] != 2) || (ma % 2 == 0 && cnt[mi] != 1)) ok = false;
	for (int i = mi+1; i <= ma; i++) {
		if (cnt[i] < 2) ok = false;
	}
	cout << (ok ? "Possible" : "Impossible") << endl;

	return 0;
}

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

int main() {
    double N, T, A, ans, S = 9999999;
    cin >> N >> T >> A;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        S = min(S, abs(T - a * 0.006 - A));
        if (S == abs(T - a * 0.006 - A)) {
            ans = i + 1;
        }
    }
    cout << ans << endl;
}

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

int n, c;
int D[30][30] = {0};
int C[500][500] = {0};
int idx[500][500] = {0};
int to_color[3] = {0};
int sum_d = 0;
int cols[3][30] = {0};

#if 0
inline void change_color (size_t i, size_t j, size_t color) {
  if (C[i][j] == color) {
    return;
  }
  //C[i][j] = color;
  sum_d   += D[C[i][j]][color];
  //std::cout << "["<< i << "," << j << "] : " << C[i][j] << " --> " << color << " D: " << D[C[i][j]][color] << std::endl;
}

inline void change_color2 (size_t i, size_t j) {
  size_t cidx = (i + j) % 3;
  change_color(i, j, to_color[cidx]);
}
#endif

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

  for (size_t i = 0; i < c; ++i) {
    for (size_t j = 0; j < c; ++j) {
      std::cin >> D[i][j];
    }
  }

  for (size_t i = 0; i < n; ++i) {
    for (size_t j = 0; j < n; ++j) {
      int c;
      std::cin >> c;
      c = c - 1;
      C[i][j] = c;

      int idx = (i+j)%3;
      cols[idx][c]++;
    }
  }

  // test for 30p3
  //   --> 30 * 29 * 28

  int min_sum_d = 1000 * 500 * 500;
  for (size_t i = 0; i < c; ++i) {
    for (size_t j = 0; j < c; ++j) {
      if (i == j) continue;
      for (size_t k = 0; k < c; ++k) {
        if (i == k || j == k) continue;

        sum_d = 0;
        for (size_t l = 0; l < c; ++l) {
          sum_d += D[l][i] * cols[0][l];
        }
        for (size_t l = 0; l < c; ++l) {
          sum_d += D[l][j] * cols[1][l];
        }
        for (size_t l = 0; l < c; ++l) {
          sum_d += D[l][k] * cols[2][l];
        }

        if (sum_d < min_sum_d) {
          min_sum_d = sum_d;
        }
      }
    }
  }

  std::cout << min_sum_d << std::endl;

  return 0;
}

Measured memory_bytes: 1280
# どこを選んでもかまわん
n, m, k = map(int, input().split())
for i in range(n + 1):
    for j in range(m + 1):
        black = i * m - (j * i) + (n - i) * j
        if black == k:
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 9120
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
#ts=time.time()
#sys.setrecursionlimit(10**6)
#input=sys.stdin.readline
show_flg=False
show_flg=True

n=I()
ans=0
d=0

while n!=0:
    k=2**(d+1)
    if n%k!=0:
        ans+=1*10**d
        n-=(-2)**d
    d+=1
    
print(ans)


Measured memory_bytes: 38512
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    LLONG X; cin >> X;
    LLONG ans = X / 500 * 1000;
    X %= 500;
    ans += X / 5 * 5;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<stdio.h>
#include<numeric>

using namespace std;

int main(){
    int N, count;
    cin >> N;
    int hmax = 0;
    for (int i = 0; i < N; i++){
        int H;
        cin >> H;
        if (H >= hmax)
            count++;
        hmax = max(hmax, H);
    }
    cout << count << endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

// int gcd(int a, int b){
//   if (a%b==0){
//     return(b);
//   }
//   else{
//     return(gcd(b,a%b));
//   }
// }

ll a[1000000];
ll x[1000000];


int main(){
  int N;
  cin >> N;
  int s = 0;
  int esum = 0;
  for(int i = 1; i<=N; i++){
    cin >> a[i];
    s += a[i];
    if(i%2 == 0) esum += (a[i]+a[i+1]);
  }
  x[1] = s - 2*(esum);
 
  for(int i = 1; i < N; i++){
    x[i+1] = 2*a[i] - x[i];
  }
  // cout << x[2] << endl;
  rep(i,N) cout << x[i+1] << " ";
  cout << endl;
}



Measured memory_bytes: 6144
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
const int N=200005;
struct qq
{
	int son[26];
	int par;
}tr[N];
int last[26];
int num=0;
char ss[N];
void add (int x)
{
	num++;
	for (int u=0;u<26;u++)
		for (int i=last[u];i!=0&&tr[i].son[x]==0;i=tr[i].par)
			tr[i].son[x]=num;
	tr[num].par=last[x];
	last[x]=num;
}
int son[N],len[N];
void dfs (int x)
{
	if (son[x]!=-1) return ;
	if (x==0) 	{len[x]=son[x]=0;return ;}
	for (int u=0;u<26;u++)
	{
		int y=tr[x].son[u];
		dfs(y);
		if (son[x]==-1||len[y]<len[tr[x].son[son[x]]]) son[x]=u;
	}
	len[x]=len[tr[x].son[son[x]]]+1;
}
void print (int x)
{
	if (x==0) return ;
	//printf("YES:%d %d %d\n",x,son[x],tr[x].son[son[x]]);
	printf("%c",son[x]+'a');
	print(tr[x].son[son[x]]);
}
int main()
{
	for (int u=0;u<26;u++) last[u]=1;num=1;
	scanf("%s",ss+1);int len=strlen(ss+1);
	for (int u=1;u<=len;u++)	add(ss[u]-'a');
	memset(son,-1,sizeof(son));
	dfs(1);
	//printf("%d %d\n",son[1],tr[1].son[0]);
	print(1);
	return 0;
}

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

using namespace std;
#define print(x) cout << x << endl;
//#define endl "\n"
#define rep(i, r) for(int i = 0; i < r; i++)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long

ll max(ll a, ll b) {
    if (a > b)
        return a;
    return b;
}

ll min(ll a, ll b) {
    if (a < b)
        return a;
    return b;
}


int main()
{
    int n, m;
    cin >> n >> m;
    ll ans = 0;
    n--;
    m--;

    ans += ((n * (n + 1)) / 2);
    ans += ((m * (m + 1)) / 2);


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int h, n; cin >> h >> n;
	map<int, int> mp;
	rep(i,n) {
		int a, b; cin >> a >> b;
		if(mp.count(a)) {
			mp[a] = min(mp[a], b);
		} else {
			mp[a] = b;
		}
	}
	n = mp.size();
	pair<int, int> p[n];
	int _ = n - 1;
	for(auto e : mp) {
		p[_] = e;
		_--;
	}
	int dp[n + 1][h + 1];
	rep(i,n+1)rep(j,h+1) dp[i][j] = INF;
	dp[0][h] = 0;
	for(int i = 0; i < n; ++i) {
		int a, b;
		tie(a, b) = p[i];
		for(int j = h; j >= 0; --j) {
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			for(int k = 1; ; ++k) {
				if(dp[i + 1][max(0, j - k * a)] < dp[i][j] + k * b) break;
				dp[i + 1][max(0, j - k * a)] = min(dp[i + 1][max(0, j - k * a)], dp[i][j] + k * b);
				if(max(0, j - k * a) == 0) break;
			}
		}
	}
	cout << dp[n][0] << '\n';
	return 0;
}

Measured memory_bytes: 39424
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve()
{
    ll k;cin>>k;
    string s;cin>>s;
    ll n=s.length();
    if(n<=k)
        cout<<s<<endl;
    else
    {
        string ans=s.substr(0,k)+"...";
        cout<<ans<<endl;
    }
    return;
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
        solve();
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    std::string s;
    std::cin>>s;

    std::string ans = "Yes";
    for(char c = 'a';c <= 'c';c++){
        if(s.find(c) == std::string::npos){
            ans = "No";
            break;
        }
    }
    std::cout<<ans<<std::endl;
    return 0;
}

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

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

    std::vector<int> v(N);
    for (int i = 0; i < N; i++) {
        int a;
        std::cin >> a;
        v[a - 1] = i + 1;
    }

    for (int i = 0; i < N; i++) {
        std::cout << v[i];
        if (i != N - 1)
            std::cout << ' ';
        else
            std::cout << std::endl;
    }
}

Measured memory_bytes: 3728
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(){
    char str[20];
    int i, j, ch;
    for(i = 0;i < 20;i++){
        scanf("%c",&str[i]);
        if( str[i] == '\n')break;
    }
    for(j = 0;j < i/2;j++){
        ch = str[j];
        str[j] = str[i - 1 - j];
        str[i - 1 - j] = ch;
    }
    for(j = 0;j < i;j++){
        printf("%c",str[j]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <set>
#include <numeric>
using namespace std;
using ll = long long;

#define no "no"
#define No "No"
#define NO "NO"
#define yes "yes"
#define Yes "Yes"
#define YES "YES"
#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for(auto& (elem) : (_list))
#define view(_list) foreach(e, _list){ cout << e << sp; } cout << next
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define INF 1e+9
#define PI acos(-1)
#define TAU PI * 2
#define EPS 0.00000001
const ll MOD = 998244353;

int main(){
    string s, t;
    cin >> s >> t;
    bool flag = false;
    rep(i, size(s)){
        if(s == t){
            flag = true;
            break;
        }
        s = s.back() + s.substr(0, size(s) - 1);
    }

    if(flag){
        println(Yes);
    }else{
        println(No);
    }
}


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

int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' )
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vt<int>>;

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

  vt<int> a(n), b(m);
  ll time = 0, ac = -1;
  int cnt = 0, cm;
  bool f = true;
  rep(i,n){
    cin >> a[i];
    if(time + a[i] <= k && f){
      time += a[i];
      ++cnt;
      ac = i;
    }
    else
      f = false;
  }
  rep(i,m)  cin >> b[i];

  cm = cnt;
  rep(i,m){
    time += b[i];
    ++cnt;
    if(time <= k) cm = max(cm, cnt);
    else{
      if(ac == -1)  break;
      else{
        while(time > k){
          if(ac == -1)  break;
          time -= a[ac];
          --ac;
          --cnt;
        }
      }
    }
  }

  cout << cm << endl;
  return 0;
}


Measured memory_bytes: 4840
#include<bits/stdc++.h>
#define ll long long
#define maxn 100005
#define inf 2e18
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll n,q,b[maxn],cnt,c[maxn],X[maxn],ans;

inline void wk(ll x,ll y,ll z)
{
	//cout<<x<<" "<<y<<" "<<z<<endl;
	if(y<=1)
	{
		c[1]+=z; c[x+1]-=z;
		return;
	}
	ll p1=x%b[y-1],p2=x/b[y-1]; X[y-1]+=(p2*z);
	ll tmp=upper_bound(b+1,b+cnt+1,p1)-b;
	wk(p1,tmp,z);
}

int main()
{
	n=read(); q=read(); b[++cnt]=n; b[0]=-inf;
	rep(i,1,q)
	{
		ll x=read();
		while(x<=b[cnt]&&cnt!=0) cnt--; b[++cnt]=x;
	}
	X[cnt]=1;
	per(i,cnt,1) wk(b[i],i,X[i]);
	rep(i,1,n) ans+=c[i],printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6064
//writer：Sakura
//problem：
//id：
//from：

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
//#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int n;
 
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&n);
	int ans=1;
	ll k;
	vector<int> flag(n+1,0);
	for(int i=0;i<n;i++){
		int x;
		scanf("%d",&x);
		if(x==1){
			flag[1]=1;
			continue;
		}
		flag[x]=flag[x-1]+1;
		ans=max(ans,flag[x]);
	}
	ans=n-ans;
	printf("%d\n",ans);
	return 0;
}

 

Measured memory_bytes: 1024
class MyArray < Array
  def [](other)
    if other >= self.length or other < 0
      super other % self.length
    else
      super
    end
  end
end
flag = true
while flag
  arr = [MyArray.new(gets.split(//).map(&:to_i))]
  7.times do 
    arr << MyArray.new(gets.split(//).map(&:to_i))
  end
  i = 0
  while arr[i].select{|i|i == 1}.size == 0
    i += 1
  end
  if arr[i].select{|i|i == 1}.size == 4
    puts "C"
  elsif arr[i].select{|i|i == 1}.size == 2
    if arr[i + 1][arr[i].index(1)] == 1
      if arr[i + 1][arr[i].index(1) + 1] == 1
        puts "A"
      else
        puts "G"
      end
    else
      puts "E"
    end
  else
    if arr[i + 2][arr[i].index(1)] == 1
      puts "B"
    elsif arr[i + 2][arr[i].index(1) + 1] == 1
      puts "F"
    else
      puts "D"
    end
  end
  flag = gets
end

Measured memory_bytes: 6116
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on July 30, 2018, 9:02 PM
 */

#include <stdio.h>
#include <stdlib.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 100000000
#define NIL -1

/*
 * 
 */

int M[MAX][MAX], d[MAX], pi[MAX], color[MAX];
int n, u, mincost;
int sum = 0;

void initializeSingleSource();
void dijkstra();

int main(int argc, char** argv) {
    int temp, loop, x, y;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j) M[i][j] = INF;
    
    for (int ix = 0; ix < n; ++ix)
    {
        scanf("%d %d", &temp, &loop);
        for (int jx = 0; jx < loop; ++jx)
        {
            scanf("%d %d", &x, &y);
            M[temp][x] = y;
        }
    }
    dijkstra();

    return (EXIT_SUCCESS);
}

void initializeSingleSource()
{
    for (int v = 0; v < n; ++v)
    {
        d[v] = INF;
        pi[v] = NIL;
        color[v] = WHITE;
    }
    
    d[0] = 0;
    color[0] = GRAY;
}

void dijkstra()
{
    initializeSingleSource();
    
    while (1)
    {
        mincost = INF;
        for (int i = 0; i < n; ++i)
        {
            if (color[i] != BLACK && d[i] < mincost)
            {
                mincost = d[i];
                u = i;
            }
        }
        
        if (mincost == INF) break;
        color[u] = BLACK;
        
        for (int v = 0; v < n; ++v)
        {
            if (color[v] != BLACK && M[u][v] != INF)
            {
                if (d[u] + M[u][v] < d[v])
                {
                    pi[v] = u;
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    
    for (int i = 0; i < n; ++i)
    {
        if (d[i] == INF) printf("%d %d\n", i, NIL);
        else printf("%d %d\n", i, d[i]);
    }
}







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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    gearup;
    string s;cin>>s;
    ll b = 0,res = 0;
    rep(i,s.size()){
        if(s[i]=='B')b++;
        else res += b;
    }
    out(res);
}

Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
using namespace std;
int main()
{
    int n, k;
    string s;
    cin >> n >> k >> s;
    if (s[k-1] == 'A')
    {
        s[k-1] = 'a';
    }
    else if (s[k-1] == 'B')
    {
        s[k-1] = 'b';
    }
    else if (s[k-1] == 'C')
    {
        s[k-1] = 'c';
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn euclid(mut a: usize, mut b: usize) -> usize {
    let mut tmp;
    let mut r;
    if a < b {
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while(r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

fn main(){

    input!{
        a: usize,
        b: usize,
    }

    let e = euclid(a,b);
    let ans =  a * b / e;

    println!("{}", ans);
}

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

#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++)

int main(){
  int n,a,s,ans;
  cin>>n;
  cin>>a;
  s=n*n;
  ans=s-a;
  cout<<ans<<endl;
  }

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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int r,g;
    cin >> r >> g;
    cout << 2*g - r << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define cases int t; cin >> t; while (t--)
#define pb push_back
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c; cin >> a >> b >> c;
    if (c-(a-b)<=0) cout << 0 << "\n";
    else cout << c-(a-b) << "\n";
    return 0;
}

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

int main()
{
	int n,x;
  	cin >> n >> x;
  	int l[n];
  	for(int i=0;i<n;i++)	cin >> l[i];
  	int d[n+1];
  	d[0]=0;
  	int c=0;
  	for(int i=0;i<=(n);i++)
    {
      	if(i>=1)	d[i]=d[i-1]+l[i-1];	
    	if(d[i]<=x)	c++;
      	else	break;
    }
  	cout << c;
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';

int pw[20];
ii dp[10], dp2[10];

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20); 
    #endif

    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }   
    
    pw[0] = 1;
    for (int i = 1; i < 20; ++i)
        pw[i] = pw[i - 1] * 10;

    const int INF = 1e18;

    int ans = 0;
    for (int p = 0; p < 17; ++p) {
        for (int i = 0; i < 10; ++i) {
            dp[i] = mp(INF, -1);
        }   
        dp[0] = mp(0, 0);
        
        for (auto e : a) {
            int x = e % pw[p + 1];
            for (int c = 0; c < 10; ++c)
                dp2[c] = dp[c];
            for (int c = 0; c < 10; ++c) {
                if (dp[c].f == INF)
                    continue;

                {
                int v = c * pw[p] + dp[c].f + x;
                int c1 = (v / pw[p]) % 10;
                int r1 = v % pw[p];
                dp2[c1].f = min(dp2[c1].f, r1);
                dp2[c1].s = max(dp2[c1].s, r1);
                }

                {
                int v = c * pw[p] + dp[c].s + x;
                int c1 = (v / pw[p]) % 10;
                int r1 = v % pw[p];
                dp2[c1].f = min(dp2[c1].f, r1);
                dp2[c1].s = max(dp2[c1].s, r1);
                }
            }   
            for (int c = 0; c < 10; ++c)
                dp[c] = dp2[c];                        
        }   

        for (int c = 9; c >= 0; --c) {
            if (dp[c].f != INF) {
                ans += c;
                break;
            }   
        }
    }   
    cout << ans << endl;
}

Measured memory_bytes: 3688
#include<iostream>
#include<algorithm>
#include<queue>
#include<limits>

using namespace std;

int H, W;
char s[50][50];
int distances[50][50];

int main()
{
	cin >> H >> W;
	int whiteNum = 0;
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> s[i][j];
			if (s[i][j] == '.')
				whiteNum++;
			distances[i][j] = numeric_limits<int>::max();
		}
	}

	pair<int, int> directions[4] = { {0, -1}, {1, 0}, {0, 1}, {-1, 0} };

	queue<pair<int, int>> nq;
	nq.emplace(make_pair(0, 0));
	distances[0][0] = 0;
	while (!nq.empty())
	{
		auto node = nq.front();
		nq.pop();
		if (node.first == H - 1 && node.second == W - 1)
			break;

		for (auto dir : directions)
		{
			int i = node.first + dir.first;
			int j = node.second + dir.second;
			if (i < 0 || i >= H || j < 0 || j >= W || s[i][j] == '#' || distances[i][j] != numeric_limits<int>::max())
			{
				continue;
			}

			distances[i][j] = distances[node.first][node.second] + 1;
			nq.emplace(make_pair(i, j));
		}
	}

	if (distances[H - 1][W - 1] == numeric_limits<int>::max())
	{
		cout << -1 << endl;
		return 0;
	}

	int ans = whiteNum - distances[H - 1][W - 1] - 1;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B;
  cin >> A >> B;
  cout << (A-1) * (B-1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;int k;
set<string>tt;
int main(){
	std::ios::sync_with_stdio(false);
	cin>>s>>k;
	int len=s.size();
	for(int i=1;i<=min(len,k);i++){
		for(int j=0;j<len;j++){
			tt.insert(s.substr(j,i));
			auto it=tt.end();it--;
			if(tt.size()>k) tt.erase(it);
		}
	}
	auto it=tt.begin();int num=1;
	while(num<k) it++,num++;
	cout<<*it<<endl;
	return 0;
} 

Measured memory_bytes: 256
N = int(input())
s = [9,900,90000]
l = len(str(N))
if l ==6:
    print(sum(s))
elif l == 5:
    print(sum(s[:2])+N-9999)
elif l == 4:
    print(sum(s[:2]))
elif l == 3:
    print(sum(s[:1])+N-99)
elif l == 2:
    print(s[0])
else:
    print(N)

Measured memory_bytes: 3064