akhauriyash/Code-Regression huggingface dataset:
module mod_que
    type queue
        integer,pointer:: v(:)
        integer(4):: i=0, ii=0
    end type
contains
    subroutine que_init(q)
        type(queue):: q
        allocate(q%v(1))
    end subroutine

    subroutine que(q,num)
        type(queue):: q
        integer(4):: num

        q%i=q%i+1
        if (q%i > size(q%v)) call add(q)
        q%v(q%i) = num
    end subroutine

    subroutine add(q)
        type(queue):: q
        integer(4),pointer:: tmp(:)
        integer(4):: l

        l = size(q%v)
        allocate(tmp(l))
        tmp(1:l) = q%v(1:l)
        deallocate(q%v)
        allocate(q%v(2*l))
        q%v(1:l) = tmp(1:l)
        deallocate(tmp)
    end subroutine

    function deque(q) result(ret)
        type(queue):: q
        integer(4):: ret

        q%ii=q%ii+1
        ret = q%v(q%ii)
    end function
end module mod_que

program name
    use mod_que
    implicit none
    integer(4):: h,w,i,j,nx,ny,cnt
    character(1),allocatable:: a(:,:)
    character(:),allocatable:: aa
    integer(4),allocatable:: cn(:,:)
    logical,allocatable:: see(:,:)
    logical:: all_see
    type(queue):: x,y

    call que_init(x)
    call que_init(y)
    read*, h,w
    allocate(a(0:w+1,0:h+1), cn(0:w+1,0:h+1), see(0:w+1,0:h+1))
    allocate(character(w):: aa)

    cn(:,:) = -2
    see(:,:) = .false.

    do i=1,h
        read*, aa(:)
        do j=1,w
            a(j,i) = aa(j:j)
            if (a(j,i) == '#') then
                cn(j,i) = 0
                see(j,i) = .true.
                call que(x,j)
                call que(y,i)
            else
                cn(j,i) = -1
            end if
        end do
    end do

    cnt=0
    do while(x%i-x%ii > 0)
        cnt=cnt+1
        nx = deque(x)
        ny = deque(y)
        ! print*, '-'
        ! print*, x%v(x%ii:x%i)
        ! print*, y%v(x%ii:x%i)
        call next(nx+1,ny, nx,ny)
        call next(nx-1,ny, nx,ny)
        call next(nx,ny-1, nx,ny)
        call next(nx,ny+1, nx,ny)
        all_see = .true.

        ! do i=1,h
        !     do j=1,w
        !         if (.not. see(j,i)) all_see =.false.
        !     end do
        ! end do

        ! if(all_see) exit
    end do

    ! print*, 'cnt',cnt
    print*, maxval(cn)
contains
    subroutine next(ix,iy, ox,oy)
        integer(4):: ix,iy,ox,oy
        if (cn(ix,iy) /= -1) return
        call que(x,ix)
        call que(y,iy)
        cn(ix,iy) = cn(ox,oy)+1
        see(ix,iy) = .true.
    end subroutine
end program name

Measured memory_bytes: 18892
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var list = new List<String>();
            var ans = 1;
            for (int i = 0; i < N; i++)
            {
                var S = Read();
                list.Add(S);
            }
            list.Sort();

            for (int i = 0; i < N - 1; i++)
            {
                if (list[i] != list[i + 1])
                {
                    ans++;
                }
            }
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 40764
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (A, B, C): (i64, i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let ans = std::cmp::max(0, C - (A - B));

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


Measured memory_bytes: 4352
mod = 10**9+7
rng = 2000100
fctr = [1]+[0]*(rng-1)
finv = [1]+[0]*(rng-1)
for i in range(1,rng):
  fctr[i] = fctr[i-1]*i%mod
for i in range(1,rng):
  finv[i] = pow(fctr[i],mod-2,mod)
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod

x1,y1,x2,y2 = map(int,input().split())
print((cmb(x2+y2+2,x2+1)-cmb(x2+y1+1,y1)-cmb(x1+y2+1,x1)+cmb(x1+y1,x1))%mod)

Measured memory_bytes: 105200
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
N = ri()
print(floor(sqrt(N)) ** 2)

Measured memory_bytes: 63340
function main(stdin) {
  var splitByN = stdin.split('\n');
  var N = Number(splitByN[0]) //生徒数
  var order = splitByN[1]; //登校順の記録
  var orderArray = order.split(' ');
  var array = new Array(N); //入れ子をまず準備
  for (var i = 0; i < orderArray.length; i++) {
    array[orderArray[i] - 1] = i + 1;
  }
  console.log(array.join(' '));
}

//console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));
main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 34176
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();

		TreeMap<Integer, Long> map = new TreeMap<>();
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			long b = sc.nextInt();
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + b);
			} else {
				map.put(a, b);
			}
		}
		sc.close();

		while (true) {
			Entry<Integer, Long> e = map.pollFirstEntry();
			k -= e.getValue();
			if (k <= 0) {
				System.out.println(e.getKey());
				return;
			}
		}
	}
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll n, m, d;
    cin >> n >> m >> d;

    double ans;
    if(d == 0)
        ans = 1.0 * (n-d) / n  * (m-1) / n;
    else
        ans = 2.0 * (n-d) / n  * (m-1) / n;
    printf("%.15f\n", ans);
    return 0;
}


Measured memory_bytes: 256
import numpy as np
C=[list(map(int,input().split())) for _ in range(3)]
C_t=[list(x) for x in zip(*C)]
C=np.array(C)
C_t=np.array(C_t)
flag=False
if len(set(C[0]-C[1]))==len(set(C[1]-C[2]))==len(set(C[2]-C[0]))==\
    len(set(C_t[0]-C_t[1]))==len(set(C_t[1]-C_t[2]))==len(set(C_t[2]-C_t[0]))==1:
    flag=True
if flag:
    print('Yes')
else:
    print('No')

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

template<typename T> T in() { abort(); return T(); }
template<> std::string in() { std::string str; std::cin >> str; return str; }
template<> int in() { int x; scanf("%d", &x); return x; }

template<typename T> void out(T x) { abort(); }
template<> void out(const char* x) { printf("%s\n", x); }
template<> void out(std::string x) { std::cout << x << std::endl; }
template<> void out(int x) { printf("%d\n", x); }
template<> void out(long x) { printf("%ld\n", x); }

int n;
int xs[128];

int main() {
  n = in<int>();
  for(int i = 0; i < n; ++i) xs[i] = in<int>();

  int res = (1 << 30);
  for(int y = -100; y <= 100; ++y) {
    int temp = 0;
    for(int i = 0; i < n; ++i) {
      temp += (xs[i] - y) * (xs[i] - y);
    }
    res = std::min(res, temp);
  }

  out(res);    
        
  return 0;
}


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

#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fst first
#define snd second

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int n = SZ(s);
    vector<int> a(SZ(s) + 1);
    for (int i = 0; i < SZ(s); i++)
    {
        if (s[i] == '?')
            a[SZ(s) - 1 - i] = -1;
        else
            a[SZ(s) - 1 - i] = s[i] - '0';
    }
    vector<int> seq = {1, 10, 9, 12, 3, 4};
    vector<vector<int>> dp(13, vector<int>(n + 1));
    dp[0][0] = 1;
    const int mod = 1e9 + 7;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 13; j++)
        {
            if (a[i] != -1)
            {
                dp[(j + a[i] * seq[i % SZ(seq)]) % 13][i + 1] += dp[j][i];
                dp[(j + a[i] * seq[i % SZ(seq)]) % 13][i + 1] %= mod;
            }
            else
            {
                for (int d = 0; d < 10; d++)
                {
                    dp[(j + d * seq[i % SZ(seq)]) % 13][i + 1] += dp[j][i];
                    dp[(j + d * seq[i % SZ(seq)]) % 13][i + 1] %= mod;
                }
            }
        }
    }
    cout << dp[5][n];
    return 0;
}

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

namespace A_Beggining
{
    class Program
    {
        static void Main(string[] args)
        {
            string []N = Console.ReadLine().Split(' ');

            string str = N[0] + N[1] + N[2] + N[3];
            if(str.Contains("1")
                &&str.Contains("4")
                &&str.Contains("7")
                && str.Contains("9"))
            {
                Console.Write("YES");
            }
            else
            {
                Console.Write("NO");
            }
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h,w;
  cin >> h >> w;
  char array[60][60] = {{0}};
  for(int i=0; i<h; i++) {
    cin >> array[i];
  }
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      if(array[i][j] == '.') {
	    int sum=0;
	    for(int l=-1;l<=1;l++) {
	        for(int m=-1;m<=1;m++) {
                if(array[i+l][j+m] == '#')
                    sum++;
	        }
	    }
	    array[i][j] = sum + '0';
      }
    }
    cout << array[i] << endl;
  }
}


Measured memory_bytes: 256
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	n := 0
	fmt.Fscanln(r, &n)
	arr := make([]int, 0)

	for i := 0; i < n; i++ {
		tmp := 0
		fmt.Fscanf(r, "%d", &tmp)
		arr = append(arr, tmp)
	}
	count := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			for k := j + 1; k < n; k++ {
				if len(arr) < 3 {
					return
				}
				// fmt.Println(len(arr))
				// fmt.Println(arr[i], arr[j], arr[k])
				// fmt.Println(n)
				// fmt.Println(i, j, k)

				if arr[i]+arr[j] > arr[k] && arr[i]+arr[k] > arr[j] && arr[j]+arr[k] > arr[i] && arr[i] != arr[j] && arr[i] != arr[k] && arr[j] != arr[k] {
					count++
				}
			}
		}
	}

	fmt.Fprintln(w, count)
}


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








int main(){


  int n,q;
  cin>>n>>q;
  
  string s;
  cin>>s;
  
  vector<int> data(n);
  
  data.at(0)=0;
  
  int count=0;
  
  for (int i=0;i<n-1;i++){
    if (s.at(i)=='A' and s.at(i+1)=='C'){
      count++;
    }
    data.at(i+1)=count;
  }
 
  
  for (int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    
    if (l==1){
      cout<<data.at(r-1)<<endl;
    }
    
    else {
      cout<<data.at(r-1)-data.at(l-1)<<endl;
    }
  }
  
 

    
    
    
  
  

  
  

  

        
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 205;
int a[N];
int n, L;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> L;
    int sum = 0;
    for(int i = 1; i <= n; i++) a[i] = L + i - 1, sum += a[i];
    if(a[1] <= 0 && a[n] >= 0) cout << sum ;
    else if(a[1] > 0) cout << sum - a[1];
    else cout << sum - a[n];
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def prime_factorize(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr

n, p = map(int, readline().split())

ans = 1
arr = prime_factorize(p)
for e, p in arr:
    ans *= e ** (p // n)
print(ans)

Measured memory_bytes: 3188
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def f(x, y):
    return (x - y, x + y)


def main():
    N, *XY = map(int, read().split())

    P = [(x, y) for x, y in zip(*[iter(XY)] * 2)]
    Q = [f(x, y) for x, y in P]
    R = [[q[i] for q in Q] for i in (0, 1)]

    ans = 0
    for i in (0, 1):
        ma = max(R[i])
        mi = min(R[i])
        if ans < ma - mi:
            ans = ma - mi

    print(ans)
    return


if __name__ == '__main__':
    main()


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

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

const int MAXN = 5e5 + 5;
const int MOD = 1e9+7;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define FAIL0 {cout << "0\n"; return 0;}
#define FAIL1 {cout << "-1\n"; return 0;}
#define FAILNO {cout << "No\n"; return 0;}

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a,b) << endl;

    return 0;
}


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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

bool pairCompare(const std::pair<string, int>& firstElem, const std::pair<string, int>& secondElem) {
    return firstElem.second > secondElem.second;
}

int main(){
    int n, m;
    while(cin >> n >> m, n+m){
        vector<pair<string, int> > kuji;
        rep(i, n){
            string s; int num;
            cin >> s >> num;
            while(s.find("*") != string::npos) s = s.substr(1);
            kuji.pb(mp(s, num));
        }
        sort(all(kuji), pairCompare);

        long long ans = 0;
        rep(i, m){
            string s;
            cin >> s;

            rep(j, kuji.size()){
                if(s.substr(s.size()-(int)kuji[j].first.size()) == kuji[j].first){
                    ans += kuji[j].second;
                    break;
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1228
# coding: utf-8
# Here your code !
W, H , x ,y ,r = list(map(int, input().split()))

t1_x = x + r
t1_y = y + r

t2_x = x - r
t2_y = y - r

if 0 <= t1_x <= W and 0 <= t1_y <= H and 0 <= t2_x <= W and 0 <= t2_y <= H:
    print("Yes")
else:
    print("No")

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

int main(){
	int n,k;
  cin >> n >>k;
  vector<int> v;
  int a;
  rep(i,n){
  cin >>a;
    v.push_back(a);
  }
  int ans=0;
  rep(i,n){
  if(v[i]>=k){
  	ans++;
  }
  }
cout << ans <<endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;


int main()
{

//整数値の入力
int a,b,q;
cin >> a>>b>>q;
//行列の入力
ll jin[a+2];
ll tera[b+2];
ll start[q]={};

jin[0]=-1000000000000;
for (int i = 1; i < a+1; ++i) {
    cin >> jin[i];
}
jin[a+1]=1000000000000;
tera[0]=-1000000000000;
for (int i = 1; i < b+1; ++i) {
    cin >> tera[i];
}
tera[b+1]=1000000000000;

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

for (int i = 0; i < q; ++i) {
  ll ans=0;
  int nextjin=lower_bound(jin, jin+a+2,start[i])-jin;
  int nexttera=lower_bound(tera, tera+b+2,start[i])-tera;
  //int  = it1 - jin.begin()+1;
  //int  = it2 - tera.begin()+1;

  ans=min({
    
    abs(start[i]-jin[nextjin])+abs(tera[nexttera]-jin[nextjin]),
    abs(start[i]-tera[nexttera])+abs(tera[nexttera]-jin[nextjin]),
    abs(start[i]-jin[nextjin-1])+abs(tera[nexttera]-jin[nextjin-1]),
    abs(start[i]-tera[nexttera-1])+abs(tera[nexttera-1]-jin[nextjin]),
    abs(start[i]-jin[nextjin])+abs(tera[nexttera-1]-jin[nextjin]),
    abs(start[i]-tera[nexttera])+abs(tera[nexttera]-jin[nextjin-1]),
    abs(start[i]-jin[nextjin-1])+abs(tera[nexttera-1]-jin[nextjin-1]),
    abs(start[i]-tera[nexttera-1])+abs(tera[nexttera-1]-jin[nextjin-1]),
    });
  //cout << nextjin<<" "<<nexttera << endl;
  cout << ans << endl; 
}




return 0;
}



Measured memory_bytes: 3712
import Data.List
import Control.Monad
import Data.Char (digitToInt)

main :: IO ()
main = print =<< solve <$> readLn

solve :: Int -> Int
solve n = countN + countLessN
  where
    d = length . show $ n
    countN = length . filter (<=n) . map digitsToInt . generateDigits $ d
    countLessN = sum . map (length.generateDigits) $ [0..(d-1)]

generateDigits :: Int -> [[Int]]
generateDigits = filter isValid . go
  where
    go :: Int -> [[Int]]
    go 0 = [[]]
    go d = [x:xs | x <- [3,5,7], xs <- go (d-1)]

isValid :: [Int] -> Bool
isValid xs = and . map (flip elem xs) $ [3,5,7]

digitsToInt :: [Int] -> Int
digitsToInt = foldl1 (\acc x -> acc*10 + x)

Measured memory_bytes: 2300
#include <cstdio>
#include <map>
#define mod 1000000007
#define LL long long
using namespace std;
map< pair<LL,LL>,pair<int,int> > mp;
LL gcd(LL a,LL b){//最大公约数
	return b?gcd(b,a%b):a;
}
LL quick_pow(LL a,LL b){//快速幂
	LL ret=1;
	while(b){
		if(b&1)ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret%mod;
}
int main(){
	int n,i;
	LL a,b,d,zero=0,sum=1;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%lld%lld",&a,&b);
		if(!a&&!b){zero++;continue;}//请注意，此句位置,请注意continue
		d=gcd(a,b);
		a/=d,b/=d;//让a,bi互质
		if(b<0)a=-a,b=-b;//目标，让b>0
		if(a<=0)mp[make_pair(b,-a)].second++;//请注意，此处是a<=0，注意=
		else mp[make_pair(a,b)].first++;
	}
	for(map< pair<LL,LL>,pair<int,int> >::iterator it=mp.begin();it!=mp.end();it++)
		sum=(quick_pow((LL)2,(LL)it->second.first)-1+quick_pow((LL)2,(LL)it->second.second)-1+1)%mod*sum%mod;
	sum=(sum+zero-1)%mod;
	sum=(sum%mod+mod)%mod;
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 15700
#include <iostream>
#include <string>
#include <deque>
#include <map>
using namespace std;

int main() {
    string str1, str2;
    map<char, int> digit = {{'m', 1000}, {'c', 100}, {'x', 10}, {'i', 1}};
    int n;
    cin >> n;
    for(int n_=0; n_<n; ++n_) {
        cin >> str1 >> str2;
        int tmp = 1;
        int ans = 0;
        for(int i=0; i<str1.size(); ++i) {
            char c = str1[i];
            if('2' <= c && c <= '9') {
                tmp = static_cast<int>(c - '0');
            } else {
                ans += tmp * digit[c];
                tmp = 1;
            }        
        }
        for(int i=0; i<str2.size(); ++i) {
            char c = str2[i];
            if('2' <= c && c <= '9') {
                tmp = static_cast<int>(c - '0');
            } else {
                ans += tmp * digit[c];
                tmp = 1;
            }        
        }

        char digit_c[4] = {'i', 'x', 'c', 'm'};
        deque<char> ans_str;
        for(int i=0; i<4; ++i) {
            int tmp2 = ans%10;
            ans /= 10;
            if(tmp2 == 0) continue;
            else if(tmp2 == 1) {
                ans_str.push_front(digit_c[i]);
            } else {
                ans_str.push_front(digit_c[i]);
                ans_str.push_front(static_cast<char>(tmp2 + '0'));
            }
        }
        for(auto c : ans_str) {
            cout << c;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3120
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    
    int N = scan.nextInt();
    int K = scan.nextInt();
    
    int sunuke[] = new int[N];
    int num;
    
    for(int k = 0; k < K; k++){
      num = scan.nextInt();
      for(int n = 0; n < num; n++){
        if(sunuke[scan.nextInt()-1]++ == 0){
          N--;
        }
      }
    }
    
    System.out.println(N);
  }
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int dp[999999];

int n;
vec<int> cand;

signed main() {
	cin >> n;

	rep (i, 999999) {
		dp[i] = 1e18;
	}
	dp[0] = 0;

	cand.push_back(1);
	int num = 6;
	while (1) {
		if (num > n) break;
		cand.push_back(num);
		num *= 6;
	}
	num = 9;
	while (1) {
		if (num > n) break;
		cand.push_back(num);
		num *= 9;
	}

	rep (i, n) {
		rep (j, cand.size()) {
			chmin(dp[i+cand[j]], dp[i] + 1);
		}
	}

	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 8064
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

int nums[200];

int solve(int n){
	int cnt = 0;
	while(n > 1){
		rep(i, n-1){
			if(nums[i] > nums[i+1]) {
				cnt++;
				swap(nums[i], nums[i+1]);
			}
		}
		n--;
	}
	return cnt;
}

int main(){
	int n;
	while(cin >> n && n){
		rep(i, n) cin >> nums[i];
		cout << solve(n) << endl;
	}
	return 0;
}

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

#define MOD 10000000
using namespace std; 
typedef long long LL;

long long quickpow(long long n, long long base) {
    long long res = 1;
    while(n) {
        if(n & 1) {
            res = res * base % MOD;
        }
        n >>= 1;
        base = base * base % MOD;
    }
    return res;
}//¿ìËÙÃÝ 
char A[100050];
char B[100050];
int main()
{
    cin>>A+1;
    while(A[1]!='.')
    {
		cin>>B+1;
    	int lenA=strlen(A+1);
    	int lenB=strlen(B+1);
    	int i=1,j=1;
    	int flag=0;
    	int k=0;
    	while(i<=lenA&&j<=lenB)
    	{
	    	if(A[i]==B[j])
	    	{
	     	    if(A[i]=='"'&&k){k=0;}
		        else if(A[i]=='"'&&!k){k=1;}


            	i++;j++;
	    	}
	    	else if(k==1)
	    	{
	    		while(A[i]!='"'&&i<=lenA)
	    		    i++;
   			    while(B[j]!='"'&&j<=lenB)
	    		    j++;
	    		    flag++;
	    		    i++;j++;
    		    k=0;
   
	    	}
	    	else if(k==0)
	    	{


	    		flag+=2;break;
	    	}
	    }
	    if(k==0&&i>lenA&&j<=lenB)flag+=2;
	    if(k==0&&j>lenB&&i<=lenA)flag+=2;
	    if(j>lenB&&A[i]=='"')flag+=2;
	    else if(i>lenA&&B[j]=='"')flag+=2;
	    else if(i>lenA&&j<=lenB)flag++;
	    else if(j>lenB&&i<=lenA)flag++;
    	if(flag==0)cout<<"IDENTICAL"<<endl;
    	if(flag==1)cout<<"CLOSE"<<endl;
    	if(flag>1)cout<<"DIFFERENT"<<endl;
    	cin>>A+1;
    }
} 






Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

const int N = 2e3+5;
int arr[N],z,w,n;

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n>>z>>w;
    FOR(i, 0, n) cin>>arr[i];
    int ans = abs(arr[n-1] - w);
    if(n > 1) {
    	ans = max(ans, abs(arr[n-2] - arr[n-1]));
    }
    cout<<ans;

    return 0;
}

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

using namespace std;

int main(){
  	int N, x;
  	cin >> N >> x;
  	vector<int> a(N);
  	for(int i=0;i<N;i++) cin >> a[i];
  	sort(a.begin(), a.end());
  	int counter = 0;
  	for(int i=0;i<N;i++){
      	x -= a[i];
	    if(x == 0){
    	    ++counter;
	        break;
        }
        else if(x < 0) break;
      	else ++counter;
    }
  	if(x > 0) --counter;
  	cout << counter << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,d,h,i,j,k,l,m,n,v,w,x,y,z;
	ll		ans = 0;
	string	s;
	cin >> a >> b >> c >> d;
	//vector<ll>	aa(n);
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));

	ans = -INFL;
	ans = max(ans , a*c);
	ans = max(ans , a*d);
	ans = max(ans , b*c);
	ans = max(ans , b*d);
	cout << ans << endl;
	return 0;
}


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


int main()
{

int n;
cin >> n;
bool mrk = 0;
int lastx = 0 , lasty = 0 , lastt = 0;
for(int i=1; i<=n; i++)
{
    int x,y,t;
    cin >> t >> x >> y;
    int dif = abs(x-lastx)+abs(y-lasty);
    int td = t - lastt ;
   // cout << dif << endl;
     lastx = x;
     lasty = y;
     lastt = t;
    if(dif && td>=dif && td%dif==0)
    {

        continue;
    }
    else mrk = 1;

}
if(!mrk)cout << "Yes" << endl;
else cout << "No" << endl;

}


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

int main() {
  int a, b; cin >> a >> b;
  int A=a, B=b;
  rep(i,b-1) {
    A = A*10+a;
  }
  rep(i,a-1) {
    B = B*10+b;
  }
  string sa = to_string(A);
  string sb = to_string(B);
  if (sa<sb) cout << sa << endl;
  else cout << sb << endl;
  
  return 0;
}

Measured memory_bytes: 256
arr = []
result = 0

5.times do
	temp = gets.chomp.to_i
	temp2 = temp % 10 != 0 ? temp % 10 : 100 
	arr << [temp,temp2]
end

arr.sort_by!{|i| i[1]}

arr.each_with_index do |item,idx|
	if idx == 0
		result += item[0]
		next
	end

	result += (item[0] / 10) * 10
	result += 10 if item[0] % 10 > 0

end

puts result

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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(){
  ll n;
  cin >> n;
  bool ans = false;
  vector<char> s(n);
  rep(i,n){
    cin >> s[i];
    if(s[i]=='Y'){
      ans = true;
    }
  }
  if(!ans){
    print("Three");
  }
  else{
    print("Four");
  }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int a, b, c,ans=0;
	cin >> a >> b >> c;
	if ((a == b) && (b == c) && (c == a))cout << 1 << endl;
	else {
		ans = (a != b) + (b != c) + (c != a);
		cout << ans << endl;
	}
		return 0;
}

Measured memory_bytes: 256
N, M, K = gets.split.map(&:to_i)
G = Array.new(N + 1){ [] }
C = [] 
USED = Array.new(N + 1)

M.times do
  a,b = gets.split.map(&:to_i)
  G[a] << b
  G[b] << a
end
B = K.times.map{gets.split.map(&:to_i)}

def dfs(s, c)
  stack = [s]
  size = 0

  until stack.empty?
    v = stack.pop

    if USED[v]
      next 
    else
      USED[v] = c
      size += 1
    end
    
    G[v].each do |u|
      if !USED[u]
        stack << u
      end
    end
  end
  size
end

(0 .. N).each do |s|
  C << dfs(s, C.size) if !USED[s]
end

A = USED.each_with_index.map do |c, v|
  C[c] - G[v].size - 1
end

B.each do |a,b|
  if USED[a] == USED[b]
    A[a] -= 1
    A[b] -= 1
  end
end

puts A[1 .. N].join(' ')



Measured memory_bytes: 21608
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int R0, W0, C, R;
  while(cin>>R0>>W0>>C>>R) {
    if(R0 == 0) return 0;
    cout << max(0, (W0 * C - R0 + R - 1) / R) << endl;
  }
  return 0;
}

Measured memory_bytes: 3056
#include<cstdio>
#include<iostream>
using namespace std;
long long i,n,ans,sum;
int main()
{
	scanf("%lld",&n);
	if(n<10)
	{
		printf("%lld\n",n);
		return 0;
	}
	while(n>=10)
	{
		ans+=9;
		sum+=n%10;
		n/=10;
	}
	sum+=n;
	printf("%lld\n",max(sum,ans+n-1));
}

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

X = [input() for _ in range(h)]

Y = [[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
    for j in range(w):
        if X[i][j] == '#':
            Y[i][j] = 1
# print(Y)

ans=0
for j in range(2**h):
    H=[]
    for _h in range(h):
        if (j>>_h)&1:
            H.append(Y[_h])
    # print(H)
    for l in range(2**w):
        _ans = 0
        for _w in range(w):
            if (l>>_w)&1:
                _ans += sum([_H[_w] for _H in H])
        if _ans == k:
            ans += 1

print(ans)


Measured memory_bytes: 68756
package main

import "fmt"

func main() {
	var (
		a uint64
		b float32
	)

	fmt.Scanln(&a, &b)

	if a == 0 {
		fmt.Println(0)
		return
	}

	fmt.Println((a * uint64(b*100+0.5)) / 100)
}

Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  vector<int> h(N);
  vector<int> C(N);
  cin >> h.at(0) >> h.at(1);
  C.at(0) = 0, C.at(1) = max(h.at(0)-h.at(1),h.at(1)-h.at(0));
  
  for(int i = 0; i < N; ++i){
    if(i<2) continue;
    else{
      cin >> h.at(i);
      int cost1 = C.at(i-1) + max(h.at(i)-h.at(i-1),h.at(i-1)-h.at(i));
      int cost2 = C.at(i-2) + max(h.at(i)-h.at(i-2),h.at(i-2)-h.at(i));
      C.at(i) = min(cost1,cost2);
    }
  }
  
  cout << C.at(N-1) << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define TC int tt; cin >> tt; for(int t=0; t<tt; t++)
#define ll long long
#define pb push_back
#define mp make_pair
#define Mod 1000000007
using namespace std;

void solve(int t)
{
    int i,j,n,m,k,temp,c=0;
    cin >> n >> k;
    int D[n+5],cnt[n+5];
    D[0]=0;
    for(i=1; i<=n; i++)
    {
        cin>> D[i];
    }
    sort(D,D+n+1);
    int left=0,right=1000000005,mid;
    while(left<=right)
    {
        c++;
        if(c>100) break;
        mid = (left+right)/2;
        int ct=0;
        for(i=1; i<=n; i++)
        {
            ct += ceil((double)D[i]/(double)mid);
            ct--;
        }
           //cout <<left<<" "<<right<<" "<<mid<<" "<<ct<<endl;
        if(ct<=k)
            right = mid;
        else if(ct>k)
            left = mid;
        else
            break;
    }
    cout <<right<<endl;
}
int  main()
{
//    Fast
//    Freed
//    Fout
    int tt=1,t;
//    cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
  return 0;
}


Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int H, N;
int A[1010], B[1010];
int dp[10010];

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

    cin >> H >> N;
    REP (i, N) cin >> A[i] >> B[i];
    fill_n((int*)dp, 10010, INT_MAX);
    dp[0] = 0;
    REP (i, N) {
        REP (j, H + 1) {
            dp[j] = min(dp[j], dp[max(0LL, j - A[i])] + B[i]);
        }
    }
    cout << dp[H] << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define mod 998244353
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n,k;
int arr[100000+9][4];
ll dp[100000][5];
ll solve(int ind , int last) {
    if(ind == n){
        return 0;
    }
    if(dp[ind][last] != -1)
        return dp[ind][last];
    ll a = 0;
    for(int i = 0;i<3;i++){
        if(i != last)
            a = max(a , solve(ind+1,i)+arr[ind][i]);
    }
    return dp[ind][last] = a;
}
int main() {
    cin>>n;
    memset(dp,-1, sizeof(dp));
    for(int i = 0;i<n;i++){
        for(int j = 0;j<3;j++){
            cin>>arr[i][j];
        }
    }
    cout<<solve(0,3);
    return 0;
}


Measured memory_bytes: 11904
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int K = scanner.nextInt();
    long res = K;
    for (int i = 1; i < N; i++) res *= K - 1;
    System.out.println(res);
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

int main() {
  int n; cin >> n;
  vec a(n);
  rep(i,n) {
    cin >> a[i];
  }

  ll k=0, m=1000; // kabu, money
  int d = 0;

  rep(i,n-1) {
    if (i == 0) {

    } else if (a[i-1] < a[i]) {
      d = 1;
    } else if (a[i-1] > a[i]) {
      d = -1;
    }

    if (d <= 0 && a[i] < a[i+1]) {
      // a[i]が極小
      k += m / a[i];
      m %= a[i];
    } else if (d >= 0 && a[i] > a[i+1]) {
      // a[i]が極大
      m += k * a[i];
      k = 0;
    }
  }
  m += k * a[n-1];

  cout << m << endl;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP2_8_B
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            Dictionary<string, int> di = new Dictionary<string, int>();
            for (int i = 0 ; i < n ; i++)
            {
                string[] line = ReadStAr();
                switch (int.Parse(line[0]))
                {
                    case 0:
                        if (di.ContainsKey(line[1]))
                        {
                            di[line[1]] = int.Parse(line[2]);
                        }
                        else
                        {
                            di.Add(line[1], int.Parse(line[2]));
                        }
                        break;
                    case 1:
                        if (di.ContainsKey(line[1]))
                        {
                            Console.WriteLine(di[line[1]]);
                        }
                        else
                        {
                            Console.WriteLine(0);
                        }                           
                        break;
                    case 2:
                        di.Remove(line[1]);
                        break;
                }

            }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 43264
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
const ll INF = 101010101000;
ll dp[110][101010]; //N*Vの配列。最低の重さ。

int main(){
  int n, W;
  ll max_v = 0;
  cin >> n >> W;
  vector<ll> w(n), v(n);
  rep(i,n) cin >> w[i] >> v[i];
  rep(i,n) max_v += v[i];
  //初期化
  rep(i,n+1){
    rep(j,max_v+1){
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  
  rep(i,n+1){
    ll w_i = w[i];
    ll v_i = v[i];
    rep(j,max_v+1){
      if(j-v_i>=0) dp[i+1][j] = min(dp[i][j],dp[i][j-v_i]+w_i);
      else dp[i+1][j] = min(dp[i][j],dp[i+1][j]);
    }
  }
  /*rep(i,n+1){
    rep(j,max_v+1){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }*/
  ll ans = 0;
  rep(i,max_v+1){
    if(dp[n][i]<=W){
      ans = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 82176
import sys
input = sys.stdin.readline
#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

a, b = map(int, input().split())
print(a*b)

Measured memory_bytes: 9156
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 5100000;
const int MOD = 1e9 + 7;

const double PI=3.14159265358979323846;


long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b == 0) return a;
    if(a%b == 0) return b;
    else return gcd(b, a%b);
}

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}



int main(){
    cin >> N;
    ll a = N/500 * 1000;
    ll b = (N%500)/5 * 5;
    cout << a + b << "\n";
    return 0;
}

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

int main(){
 string s,t;
  cin >> s >>t;
  int S, T;
  S= s.size();
  T= t.size();
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  for(int i=0;i<min(S,T);i++){
   if(s.at(i)==t.at(i))continue;
  else if(s.at(i)<t.at(i)){
    cout << "Yes" <<endl;
    return 0;
  }
  else if(s.at(i)>t.at(i)){
    cout << "No" <<endl;
    return 0;
  }
  }
  
  if(S<T){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
}
  

Measured memory_bytes: 3568
#include<stdio.h>
int main()
{
    char a;
    scanf("%c", &a);

    switch(a)
    {
    case 'a' :
        printf("vowel");
        break;
    case 'e' :
        printf("vowel");
        break;
    case 'i' :
        printf("vowel");
        break;
    case 'o' :
        printf("vowel");
        break;
    case 'u' :
        printf("vowel");
        break;
    default :
        printf("consonant");
        break;
    }
    return 0;
}


Measured memory_bytes: 128
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy
a, b = input().split()
c = int(a + b)

def ok(x):
    i = 2
    while i * i < x:
        i += 1

    return i * i == x

print("Yes" if ok(c) else "No")

Measured memory_bytes: 3572
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        // int TC = Integer.parseInt(sc.next(), 10);
        
        while (true) {
            int PC = sc.nextInt();
            int S = sc.nextInt();
            if (PC == 0 && S == 0) break;
            
            Student[] students = new Student[S];
            for (int i = 0; i < S; i++) {
                students[i] = new Student();
            }
            
            int R = sc.nextInt();
            for (int i = 0; i < R; i++) {
                int t = sc.nextInt();
                int pc = sc.nextInt();
                int stud = sc.nextInt() - 1;
                int s = sc.nextInt();
                
                if (s == 1) {
                    students[stud].startUsage(t, pc);
                } else {
                    students[stud].endUsage(t, pc);
                }
            }
            
            int Q = sc.nextInt();
            for (int i = 0; i < Q; i++) {
                int t1 = sc.nextInt();
                int t2 = sc.nextInt();
                int stud = sc.nextInt() - 1;
                int total = students[stud].getRentalTime(t1, t2);
                
                System.out.println(total);
            }
        }
    }
    
    public static class Student {
        Vector<Record> records;
        boolean[] table;
        
        public Student() {
            records = new Vector<Record>();
            table = new boolean[1261];
        }
        
        public void startUsage(int t, int pc) {
            records.add(new Record(t, pc));
        }
        
        public void endUsage(int t, int pc) {
            for (int i = records.size() - 1; i >= 0; i--) {
                Record r = records.get(i);
                if (r.ongoing && r.pc == pc) {
                    r.ongoing = false;
                    r.end = t;
                    break;
                }
            }
        }
        
        public int getRentalTime(int s, int e) {
            if (!table[0]) {
                table[0] = true;
                for (Record rec : records) {
                    Arrays.fill(table, rec.start, rec.end, true);
                }
            }
            
            int total = 0;
            while (s < e) {
                if (table[s]) total++;
                s++;
            }
            
            return total;
        }
    }
    
    public static class Record {
        int start;
        int end;
        int pc;
        boolean ongoing;
        
        public Record(int t, int pc) {
            ongoing = true;
            start = t;
            this.pc = pc;
        }
    }
    
}




Measured memory_bytes: 114868