akhauriyash/Code-Regression huggingface dataset:
#177B

S=input()
T=input()

Ss=[]
Ts=[]
Us=[]
Vs=[]

len_T=len(T)
len_S=len(S)

s=0

#初期配列を作成
for t in range(len_T):
    Ts.append(T[t])
    Ss.append(S[t])

#一致していない箇所の個数を数え、記録
for t in range(len_T):
    Us.append(Ts[t]!=Ss[t])
Vs.append(sum(Us))


for s in range(1,len_S-len_T+1):
    #Ss配列をずらす
    Ss.append(S[len_T+s-1])
    Ss.remove(S[s-1])
    #Usをリセットして、一致していない箇所の個数を数え、記録
    Us=[]
    for t in range(len(T)):
        Us.append(Ts[t]!=Ss[t])
    Vs.append(sum(Us))
    
print(str(min(Vs)))



Measured memory_bytes: 9156
n=int(input())
dic=dict()
l=list(map(int,input().split()))
for i in l:
	if i not in dic.keys():
		dic[i]=1
	else:
		dic[i]+=1
p=[k for k,v in dic.items() if v>=2]
f=0
s=0
for i in p:
	if i>f:
		f,s=i,f
	elif i>s:
		s=i
print(0 if f==0 else f**2 if dic[f]>=4 else f*s)

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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	string c[2];
	cin >> c[0] >> c[1];
	reverse(c[1].begin(),c[1].end());
	if(c[0]==c[1]) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

int
main(int argc, char** argv)
{
	/*                       1    2    3    4    5    6    7    8    9   10   11   12 x*/
	static int mday[12] = {  0,  31,  60,  91, 121, 152, 182, 213, 244, 274, 305, 335};
	static char* week[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

	while (true)
	{
		int month, date;

		scanf("%d %d", &month, &date);
		if (month == 0)
			break;

		int wd = (3 + mday[month - 1] + date - 1) % 7;
		printf("%s\n", week[wd]);
	}

	return 0;
}

Measured memory_bytes: 584
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	vi num(10000+1);
	num[0] = 0;
	num[1] = 2;
	FOR(i, 2, 10000) {
		num[i] = num[i-1]+i;
	}
	
	int n;
	while(cin >> n) {
		cout << num[n] << endl;
	}

	return 0;
}

Measured memory_bytes: 1232
import java.io.*;

public class Main {
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String input = br.readLine();
        int A = Integer.parseInt(input.substring(0, input.indexOf(" ")));
        input = input.substring(input.indexOf(" ")+1);
        String op = input.substring(0, input.indexOf(" "));
        boolean isPlus = op.equals("+");
        input = input.substring(input.indexOf(" ")+1);
        int B = Integer.parseInt(input);

        if(isPlus){
            System.out.println(A + B);
        }
        else{
            System.out.println(A - B);
        }
    }
}

Measured memory_bytes: 20692
#include <iostream>
#include <set>
#include <string>
using namespace std;

int main(){
  //typedef set<int> set_t;
  typedef set<string> set_t;
  set_t A;
  int i_max;
  cin >> i_max;
  string word;
  while(cin >> word){
    if(word == "insert"){
      string key;
      cin >> key;
      A.insert(key);
    }
    else if(word == "find"){
      string key;
      cin >> key;
      if(A.count(key)){
        cout << "yes" <<endl;
      }
      else{
        cout << "no" <<endl;
      }

    }
  }
  return 0;

}


Measured memory_bytes: 32212
import numpy as np
from fractions import gcd
def lcm(a,b):
  return a*b//gcd(a,b)
N,M=map(int,input().split())
a=[i//2 for i in map(int,input().split())]
b=np.array(a)
cnt=0
while all(b%2==0):
  b//=2
if any(b%2==0):
  print(0)
  exit()
ans=1
for i in a:
  ans=lcm(ans,i)
print((M//ans+1)//2)


Measured memory_bytes: 24932
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] A = new int[N+2];
		int sum=0;
		A[0] = 0;
		for(int i=1;i<N+1;i++) {
			A[i] = sc.nextInt();
			sum += Math.abs(A[i] - A[i-1]);
		}
		A[N+1] = 0;
		sum += Math.abs(A[N+1] - A[N]);

		for(int i=1;i<N+1;i++) {
			int ans = sum - Math.abs(A[i] - A[i-1]) - Math.abs(A[i+1] - A[i]) + Math.abs(A[i+1] - A[i-1]);
			System.out.println(ans);
		}
	}
}


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

#define rep(i, n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define repr(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define repf(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define inf 1e9

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; }

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<vector<int>> 
        a(2, vector<int> (n));

    for (size_t i = 0; i < 2; i++)
    {
        for (auto &&x : a[i])
        {
            cin >> x;
        }
    }

    int ans = 0;
    int tate = 0;

    for (int down = 0; down < n; down++)
    {
        int tmp = 0;
        int tate = 0;

        for (int right = 0; right < n; right++)
        {
            if (down == right)
            {
                tmp += a[tate][right];
                tate++;
            }

            tmp += a[tate][right];
        }

        chmax(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI32()]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI64()]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF32()]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF64()]

    member public __.Tuple2List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]]
    
    member public __.Tuple3List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]]

end

[<EntryPoint>]
let main _ =
    let scanner = Scanner()
    let n = scanner.NextI32()
    let m = scanner.NextI32()
    if n > m then "No" else "Yes"
    |> printfn "%s"

    0


Measured memory_bytes: 13916
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; i++)
    {
        cin >> l[i];
    }
    sort(ALL(l));
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            for (int k = j + 1; k < n; k++)
            {
                if (l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[j] + l[k] > l[i])
                {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
value = [0] * N
weight = [0] * N

for i in range(N):
    value[i], weight[i] = map(int, input().split())

DP = [[0] * (W + 1) for _ in range(N + 1)]
DP[0][W] = 0

for i in range(N):
    for w in range(W + 1):
        if w >= weight[i]:
            DP[i + 1][w] = max(DP[i][w - weight[i]] + value[i], DP[i][w])
            DP[i + 1][w] = max(DP[i + 1][w - weight[i]] + value[i], DP[i][w])
        else:
            DP[i + 1][w] = DP[i][w]

print(DP[N][W])


Measured memory_bytes: 41900
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b){
        cout << c << endl;
    }else if(a==c){
        cout << b << endl;
    }else{
        cout << a << endl;
    }
    return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  string ans="Yes";
  for (int i=0; i<S.size(); i++) {
    if (S.at(i) != T.at(i)) {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int ans[10001];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N;
    cin >> N;
    for(int x = 1; x <= 100; x++){
        for(int y = 1; y <= 100; y++){
            for(int z = 1; z <= 100; z++){
                int s = x*x+y*y+z*z+x*y+y*z+z*x;
                if(s <= 10000) ans[s]++;
            }
        }
    }
    for(int i = 1; i <= N; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 3644
import itertools
a = input()
length = len(a)
alphabet = [chr(i) for i in range(ord('a'), ord('a') + 26)]
count = 0
l = [a.count(c) for c in alphabet if a.count(c) != 0]

for comb in itertools.combinations(l, 2):
    count += comb[0] * comb[1]

print(count + 1)


Measured memory_bytes: 3500
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    _ <- B.getLine
    as <- map (fst . fromJust . B.readInt) . B.lines <$> B.getContents
    print $ groupCount 0 $ sort as
    where
        groupCount c []  = c
        groupCount c [_] = c + 1
        groupCount c (x:y:xs)
            | x == y = groupCount c xs
            | otherwise = groupCount (c + 1) (y:xs)


Measured memory_bytes: 15612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
/*-------------------Basis Functions----------------------*/
template<class T> inline void dmin(T& x,T y){ y<x?x=y:0; }
template<class T> inline void dmax(T& x,T y){ y>x?x=y:0; }
template<class T> inline void dmin(T& x,vector<T> y){ 
	for(auto t:y) t<x?x=t:0;
}
template<class T> inline void dmax(T& x,vector<T> y){
	for(auto t:y) t>x?x=t:0;
}
int to_min(pair<int,int> a){
	return a.first*60+a.second;
}
pair<int,int> to_pair(int x){
	return make_pair(x/60,x%60);
}
vector<int> a;
ll check2(int mid,ll k){
	ll ret=0;
	for(int i=mid-1;i>=0;--i){
		k=(k+1)/2+a[i];
		ret+=k;
	}
	if(k!=1) return -1;
	else return ret;
}
ll check(int m){
	ll ret=0,k=0;
	for(int i=a.size()-1;i>m;--i){
		k+=a[i];
		ret+=k;
	}
	ll left=0,right=k/2;
	while(left<right){
		ll mid=left+right>>1;
		if(check2(m,k-mid+a[m])!=-1) right=mid;
		else left=mid+1;
	}
	if(check2(m,k-right+a[m])==-1) return -1;
	k=k-right+a[m]; ret+=k;
	ret+=check2(m,k);
	return ret;
}
//int f[1005][1005];
int main(){
	int n; ll sum=0; scanf("%d",&n);
	a.resize(n+1);
	for(int i=0;i<=n;++i) scanf("%d",&a[i]),sum+=a[i];
	if(sum==0){
		puts("0");
		exit(0);
	}
	int left=0,right=n;
	while(left<right){
		int mid=left+right>>1;
		if(check(mid)==-1) left=mid+1;
		else right=mid;
	}
//	printf("|%d|",left);
	printf("%lld\n",check(right));
	return 0;
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    long long A,B,K;
    cin >> A >> B >> K;
    cout << max((long long)0,A-K) << " " << max((long long)0,B-(max(K-A,(long long)0))) << endl;
    return 0;
}

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

typedef long long ll;
using namespace std;

/// 通常の階乗でpで割り切れる数の数
ll g1(ll n, int p) {
    if (n == 0) return 0;
    return n / p + g1(n / p, p);
}

// 二重階乗でpで割り切れる数の数
ll g2(ll n, int p) {
    if (n % 2 == 1) {
        return g1(n, p) - g2(n - 1, p);
    }
    ll res = g1(n / 2, p);
    if (p == 2) res += n / 2;
    return res;
}

int main() {
    ll n;
    cin >> n;
    ll ans = min(g2(n, 2), g2(n, 5));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
H,W,K=gets.split.map(&:to_i)
S=H.times.map{gets.chop.chars.map(&:to_i)}
ans=H*W
(2**(H-1)).times do |b|
  cut=0
  H.times do |i|
    cut+=1 if b[i]==1
  end
  n=[0]*H
  W.times do |j|
    k=0
    H.times do |i|
      n[k]+=1 if S[i][j]==1
      k+=1 if b[i]==1
    end
    next if n.all?{|i|i<=K}
    cut+=1
    n=[0]*H
    k=0
    H.times do |i|
      n[k]+=1 if S[i][j]==1
      k+=1 if b[i]==1
    end
    next if n.all?{|i|i<=K}
    cut=H*W
    break
  end
  ans=[ans,cut].min
end
p ans

Measured memory_bytes: 14500
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int k;
vector<int>a[26];
set<string > p;
char s[5005];
string cat(int t,int len,char ch)
{
    string a;
    for(int i=t; i<t+len; i++)
    {
        if(s[i]=='\0')
            return "";
        a+=s[i];
    }
    return a;
}
void fun()
{
    int len;
    string str;
    for(int i=0; i<26; i++)
    {
        int lena=a[i].size();
        for(int len=1; len<6; len++)
        {

            for(int j=0; j<lena; j++)
            {
                int t=a[i][j];
                str=cat(t,len,s[t]);
                if(str!="")
                    p.insert(str);
            }
        }
    }

}
int main()
{
    scanf("%s%d",s,&k);
    for(int i=0; s[i]; i++)
    {
        a[s[i]-'a'].push_back(i);
    }
    fun();
	for(int i=0;i<k-1;i++)
		p.erase(p.begin());
	cout<<*p.begin()<<endl;
    return 0;
}


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


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


    int n = sc.nextInt();
    boolean flag = true;
    String s;
    char[][] c =  new char[n][2];
    String[] ss = new String[n];
    for(int i=0; i<n; i++){
      s = sc.next();
      c[i][0] = s.charAt(0);
      c[i][1] = s.charAt(s.length()-1);
      if(Arrays.asList(ss).contains(s)){
        flag = false;
      }
      ss[i] = s;

    }

    for(int i=0; i<n-1; i++){
      if(c[i][1] != c[i+1][0]){
        flag = false;
      }
    }
    if(flag){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }






  }
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int n, t, e;
  cin >> n >> t >> e;
  for (int i = 0; i < n; i++) {
    int x, sum;
    cin >> x;
    sum = x;
    while (true) {
      if (t-e <= sum && sum <= t+e) {
        cout << i+1 << endl;
        return 0;
      } else if (t+e < sum) {
        break;
      } else {
        sum += x;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
ll mod = 1e9 + 7;
#define EPS 1e-1
#define PI 3.14159265

#define iofile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
using namespace std;

ll fastpow(ll base, ll pow)
{
    if (!base)
        return 0;
    if (!pow)
        return 1;
    if (pow == 1)
        return base;
    ll x = fastpow(base, pow / 2) % mod;
    x *= x;
    x %= mod;
    if (pow % 2)
        x *= base;
    return x % mod;
}

ll inverse(ll x)
{
    return fastpow(x, mod - 2) % mod;
}

ll fact[(int)1e6 + 5], inv[(int)1e6 + 5];
void init()
{
    fact[0] = inv[0] = 1;
    for (int i = 1; i <= 1e6; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = inverse(fact[i]);
    }
}

void factorize(ll x, map<int, int> &ss)
{
    while (x % 2 == 0)
        ss[2]++, x /= 2;
    for (int i = 3; i <= sqrt(x); i += 2)
        while (x % i == 0)
            ss[i]++, x/= i;
    if (x > 2)
        ss[x]++;
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

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



int main()
{
    fastio
    int n, m;
    cin >> n >> m;
    char grid[n][m];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> grid[i][j];
    ll dp[n][m];
    memset(dp, 0, sizeof dp);
    for (int i = 0; i < n; i++)
    {
        if (grid[i][0] == '#')
            break;
        dp[i][0] = 1;
    }
    for (int j = 0; j < n; j++)
    {
        if (grid[0][j] == '#')
            break;
        dp[0][j] = 1;
    }

    for (int i = 1; i < n; i++)
    {
        for (int j = 1; j < m; j++)
        {
            if (grid[i][j] == '#')
                dp[i][j] = 0;
            else
                dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % mod;
        }
    }

    cout << dp[n - 1][m - 1];
    return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	string S, ans = "Yes";
	cin >> S;
	if (S[2] != S[3] || S[4] != S[5])
		ans = "No";

	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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s1,s2;
    cin>>s1>>s2;
    string ans="YES";
    REP(i,3){
        if(s1[i]!=s2[2-i]) ans="NO";
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,m;cin >> n >>m;
    vvl v(n,vl(n,INF/2));
    rep(i,n)v[i][i]=0;
    rep(i,m){
        ll x,y,e;cin >> x >>y >>e;
        v[x][y]=e;
    }
    rep(k,n){
        rep(i,n){
            rep(j,n){
                v[i][j]=min(v[i][k]+v[k][j],v[i][j]);
            }
        }
    }
    bool neg=false;
    rep(i,n){
        if(v[i][i]<0)neg=true;
    }
    if(neg){
        cout << "NEGATIVE CYCLE" <<endl;
        return 0;
    }
    rep(i,n){
        rep(j,n){
            if(v[i][j]>=INF/10)cout << "INF";
            else cout << v[i][j];
            if(j!=n-1)cout <<" ";
        }
        cout <<endl;
    }
}


Measured memory_bytes: 3196
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
	t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])


Measured memory_bytes: 9284
N = int(input())
lis = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    lis[u] += [v * [-1, 1][w % 2]]
    lis[v] += [u * [-1, 1][w % 2]]
colors = [-1 for _ in range(N + 1)]

q = [1]
colors[1] = 0
while q:
    start = abs(q.pop(0))
    nodes = lis[start]
    for node in nodes:
        if colors[abs(node)] < 0:
            if node < 0:
                colors[abs(node)] = colors[start]
            else:
                colors[abs(node)] = int(colors[start] == 0)
            q.append(abs(node))

for c in colors[1:]:
    print(c)

Measured memory_bytes: 23728
//Selection Sort

#include <iostream>
#include <vector>

void myswap( int& a, int& b );

int main(){
    //----Input Section----
    int n;
    std::cin >> n;
    std::vector<int> vec(n);
    for( auto& e : vec ){
        std::cin >> e;
    }

    //----Sort Section----
    int i = 0;
    int numOfSwap = 0;
    int minj;
    int j;
    for( ; i < n; ++i ){
        minj = i;
        for( j = i; j < n; ++j ){
            if( vec[j] < vec[minj] ){
                minj = j;
            }
        }
        if( i != minj ){
            myswap( vec[i], vec[minj] );
            ++numOfSwap;
        }
    }

    //----Output Section----
    for( i = 0; i < n; ++i ){
        std::cout << vec[i] << ( (i < n - 1)? " " : "" );
    }
    std::cout << '\n' << numOfSwap << '\n';

}

void myswap( int& a, int& b ){
    int tmp = std::move(a);
    a = std::move(b);
    b = std::move(tmp);
}


Measured memory_bytes: 3096
ny = input().split()
n = int(ny[0])
y = int(ny[1])

def solve(n,y):
    Y = y/1000
    p = int((Y - n) // 9)
    for v in range(p+1):
        if (Y - n - 9*v)%4 == 0:
            b = int((Y - n - 9*v)//4)
            c = int((Y - 10*v - 5*b))
            if c*b < 0:
                continue
            else:
                return str(v), str(b), str(c)


ans = solve(n,y)
if ans != None:
    print(' '.join(ans))
else:
    print(-1, -1, -1) 

Measured memory_bytes: 3188
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    N = int(input())

    #output
    #ある整数nの素因数を列挙

    import math
    from collections import Counter

    def prime_factors(n):
        i = 2
        factors = []
        while i * i <= n:
            if n % i:
                i += 1
            else:
                n //= i
                factors.append(i)
        if n > 1:
            factors.append(n)
        return factors

    s = Counter(prime_factors(N))

    def triangle(n):
        i = 1
        while i*(i+1)//2 <= n:
            i += 1
        return i-1

    answer = 0
    for l in s.values():
        answer += triangle(l)

    print(answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll D;
    cin >> D;
    if(D == 25) cout << "Christmas";
    else if(D == 24) cout << "Christmas Eve";
    else if(D == 23) cout << "Christmas Eve Eve";
    else if(D == 22) cout << "Christmas Eve Eve Eve";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main(void)
{
	int N, M, X;
	cin >> N >> M >> X;
	vector<int>arr(N*2, 0);
	for (int i = 0; i < M; i++)
	{
		int j;
		cin >> j;
		arr[j]++;
	}
	if (X == 0 ||X ==N)
	{
		cout << "0" << "\n";
	}
	else 
	{
		int count = 0;
		int count2 = 0;
		for (int i = 0; i <= X; i++)
		{
			count+= arr[i];
		}
		for (int i = X; i <= N; i++)
		{
			count2 += arr[i];
		}
		cout << min(count, count2) << "\n";
	}
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N, W = na()
INF = 10 ** 12
dp = [[-INF] * (N*3+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    w, v = na()
    if i == 0:
        w1 = w
    w -= w1
    for j in range(N, 0, -1):
        for k in range(N*3, -1, -1):
            if k >= w:
                dp[j][k] = max(dp[j][k], dp[j-1][k-w] + v)

ans = 0
for i in range(1, N+1):
    wmax = W - w1 * i
    if wmax < 0:
        break
    ans = max(ans, max(dp[i][0:min(N, wmax) + 1]))

print(ans)


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	string s[100];
	for(int i=0; i<100; i++){
		for(int j=0; j<100; j++){
			if(i<50) s[i]+='#';
			else s[i]+='.';
		}
	}

	int a, b;
	cin >> a >> b;

	int x=0, y=0;
	for(int i=0; i<a-1; i++){
		s[x][y]='.';
		y+=2;
		if(y>=100){
			x+=2; y=0;
		}
	}
	x=51, y=0;
	for(int i=0; i<b-1; i++){
		s[x][y]='#';
		y+=2;
		if(y>=100){
			x+=2; y=0;
		}
	}

	cout << 100 << " " << 100 << endl;
	for(int i=0; i<100; i++) cout << s[i] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
string s;
int ans;
int main() 
{
    cin>>s;
    int l=s.size();
    for(int i=1;i<l;i++) 
       ans+=9;
    int flag=1;
    for(int i=1;i<l;i++) 
       if(s[i]!='9') 
        flag=0;
    if(flag) 
         cout<<ans+s[0]-'0'<<endl;
    else 
         cout<<ans+s[0]-'1'<<endl;
    return 0;
}

Measured memory_bytes: 256
#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, m;
  ll ans = 0;
  cin >> n;
  vector<string> s(n);
  rep(i,n){
    cin >> s[i];
  }
  sort(all(s));
  cin >> m;
  vector<string> t(m);
  rep(i,m){
    cin >> t[i];
  }
  sort(all(t));
  s.pb("aaaaaaaaaaaaaaaaa");
  ll count = 1;
  for (ll i = 1; i < n + 1; i++){
    if(s[i]==s[i-1]){
      count++;
    }
    else{
      for (ll j = 0; j < m;j++){
        if(t[j]==s[i-1]){
          count--;
        }
      }
      chmax(ans, count);
      count = 1;
    }
  }
  print(ans);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int n;
vector<int> vs[100005];
lli A[100005];
lli pn[100005];

bool dfs(int no,int pa){
	lli cs=0,mcs=0;
	bool isha=true;
	rep(i,vs[no].size()){
		int to=vs[no][i];
		if(to==pa)continue;
		if(!dfs(to,no))return false;
		cs += pn[to];
		mcs = max(mcs,pn[to]);
		isha=false;
	}
	if(isha){
		pn[no]=A[no];
		return true;
	}
	pn[no]=A[no]*2-cs;
	mcs = max(mcs,pn[no]);
	//printf("%d :: %lld %lld %lld %lld\n",no,A[no],pn[no],cs,mcs);
	
	if(pn[no]<0 || mcs>A[no])return false;
	return true;
}

int main(){
	scanf("%d",&n);
	rep(i,n)scanf("%lld",&A[i]);
	rep(i,n-1){
		int a,b;
		scanf("%d%d",&a,&b); a--; b--;
		vs[a].push_back(b);
		vs[b].push_back(a);
	}
	int st=0;
	rep(i,n){
		if(vs[i].size()==1)st=i;
	}
	
	puts((dfs(st,-1) && pn[st]==A[st])?"YES":"NO");
	
	return 0;
}


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

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

struct student {
    int idx;
    int order;
    bool operator<(const student &next) {
        return this->order < next.order;
    }
};

int main() {
    int n;
    cin >> n;
    vector<student> clss(n);
    rep(i, 0, n) {
        int _order;
        cin >> _order;
        clss[i] = {i, _order};
    }

    sort(clss.begin(), clss.end());

    rep(i, 0, n) {
        cout << clss[i].idx + 1;
        if (i == n - 1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }

    return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>
#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

int d[N],f[N],color[N];
int time;

void visit(int Adj[N][N],int u,int n){
  int v;
  color[u]=GRAY;
  d[u]=++time;
  for(v=1;v<=n;v++){
    if(Adj[u][v]==1 && color[v]==WHITE)
      visit(Adj,v,n);
  }
  color[u]=BLACK;
  f[u]=++time;
}

void dfs(int Adj[N][N],int n){
  int i,j;
  for(i=1;i<=n;i++){
    color[i]=WHITE;
  }
  time=0;
  for(i=1;i<=n;i++)
    if(color[i]==WHITE)
      visit(Adj,i,n);
}

int main(){
  int n,i,j,Adj[N][N],u,k,v;
  scanf("%d",&n);
  for(i=0;i<N;i++){
    for(j=0;j<N;j++)
      Adj[i][j]=0;
    d[i]=f[i]=0;
  }

  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      Adj[u][v]=1;
    }
  }
  dfs(Adj,n);

  for(i=1;i<=n;i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  }
  return 0;
}



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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int h,w;
    int d[4] = {-1,0,1,0};
    cin >> h >> w;
    string s[20];
    vector<vector<int>> g(h*w,vector<int>(h*w,100000));
    for (int i = 0;i < h;++i) cin >> s[i];
    for (int i = 0;i < h;++i) for (int j = 0;j < w;++j) if (s[i][j] == '.') for (int k = 0;k < 4;++k) {
        int x = i+d[k],y = j+d[k^1];
        if (x < 0 || x >= h || y < 0 || y >= w || s[x][y] == '#') continue;
        g[i*w+j][x*w+y] = 1;
    }
    for (int i = 0;i < h*w;++i) g[i][i] = 0;
    // for (int i = 0;i < h*w;++i) p_ary(g[i],0,h*w);
    for (int i = 0;i < h*w;++i) for (int j = 0;j < h*w;++j) for (int k = 0;k < h*w;++k) g[j][k] = min(g[j][k],g[j][i]+g[i][k]);
    int ans = 0;
    // for (int i = 0;i < h*w;++i) p_ary(g[i],0,h*w);
    for (int i = 0;i < h*w;++i) for (int j = 0;j < h*w;++j) if (g[i][j] < 100000) ans = max(ans,g[i][j]);
    cout << ans << endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
  while(1){
  ll sum,t,a=0;cin>>sum;
    if(sum==0)break;
    rep(i,9) {
    cin>>t; a+=t;
    }
  cout<<sum-a<<endl;
  
  }
  
  
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	string s;
	cin>>s;
	if(s.length()<4)cout<<"No"<<endl;
	else if(s.substr(0,4)=="YAKI")cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

vector<bool> eratosthenes(ll n) {
    vector<bool> sieve(n+1, true);
    vector<ll> table;
    sieve[0] = sieve[1] = false;
    for (ll i = 2; i <= n; i++) {
        if (sieve[i]) {
            table.push_back(i);
            for (ll j = 2; i * j <= n; j++) {
                sieve[i * j] = false;
            }
        }
    }

    return sieve;
}

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

    vector<bool> sieve = eratosthenes(100000);
    // Rep (i, 101) cout << i << " " << sieve[i] << endl;

    vector<ll> s(100001, 0);
    for (ll i = 1; i <= 100000; i ++) {
        s[i+1] = s[i];
        if (i % 2 == 1 && sieve[i] && sieve[(i+1)/2]) {
            s[i+1]++;
            // cout << "2017-like number:" << i << endl;
        }
    }

    // Rep (i, 30) cout << s[i] << " ";
    // cout << endl;

    ll Q;
    cin >> Q;
    Rep (i, Q) {
        ll l, r;
        cin >> l >> r;
        cout << s[r+1] - s[l] << "\n";
    }
}

Measured memory_bytes: 1588
#include <iostream>
#include <vector>
#include <stack>

using namespace std;
typedef long long ll;

int main(){
    ll n, q;
    cin >> n >> q;
    vector<vector<ll>> net(n);
    for(int i = 0; i < n - 1; ++i){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        net.at(a).push_back(b);
        net.at(b).push_back(a);
    }
    vector<ll> count(n, 0);
    for(int i = 0; i < q; ++i){
        ll p, x;
        cin >> p >> x;
        p--;
        count.at(p) += x;
    }

    vector<bool> visited(n, false);
    stack<ll> s;
    s.push(0);
    visited.at(0) = true;
    while(!s.empty()){
        ll x = s.top();
        s.pop();
        visited.at(x) = true;
        for(ll y : net.at(x)){
            if(visited.at(y)){ continue; }
            count.at(y) += count.at(x);
            s.push(y);
        }
    }

    for(int i = 0; i < n; ++i){
        cout << count.at(i);
        if(i < n - 1){
            cout << ' ';
        }else{
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 17904
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Wed Aug 28 19:09:38 2019
//
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	total := 0.0
	for i := 0; i < n; i++ {
		var a float64
		fmt.Scan(&a)
		total += 1 / a
	}
	fmt.Println(1 / total)
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;
int gcd(int a,int b){
    if(a < b){
        int c = a;
        a = b;
        b = c;
    }
    if(a%b == 0) return b;
    else return gcd(b,a%b);
}

/*----------------------------------------------------------------*/
signed main(){

	int n,m;
	cin >> n >> m;
	
	cout << n*m/gcd(n,m) << endl;

   
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://abc148.contest.atcoder.jp/tasks/abc148_b

Measured memory_bytes: 256
// author:  Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
	fastio;
	//#ifndef ONLINE_JUDGE 
	  //  freopen("input.txt","r",stdin);
	   // freopen("output.txt","w",stdout);
	//#endif
	ll n=0,w=0;
	cin>>n>>w;
	vector<ll>wt(n),val(n);
	for(ll i=0;i<n;++i){
		cin>>wt[i]>>val[i];
	}
	ll dp[w+1]={0};
	for(ll i=0;i<n;++i){
		for(ll j=w;j>=wt[i];--j)
			dp[j]=max(dp[j],val[i]+dp[j-wt[i]]);
	}
	cout<<dp[w];
   return 0;
}

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

int n, a[1010];
int dp[1010][1010], dp2[1010] = {};

int ok(int l, int r){
    int &res = dp[l][r];
    if(res != -1) return res;
    res = false;
    if(l == r) return res = true;
    for(int i = l+2; i < r; i += 2) if(ok(l,i) && ok(i,r)) return res = true;
    if(abs(a[l] - a[r-1]) <= 1 && ok(l+1, r-1)) return res = true;
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    while(cin >> n && n){
        rep(i, n) cin >> a[i];
        memset(dp, -1, sizeof dp);
        memset(dp2, 0, sizeof dp2);
        rep(i, n){
            dp2[i+1] = max(dp2[i+1], dp2[i]);
            for(int j = i + 2; j <= n; j += 2){
                if(ok(i, j)) dp2[j] = max(dp2[j], dp2[i] + j - i);
            }
        }
        cout << dp2[n] << '\n';
    }
}

Measured memory_bytes: 7088
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
int t;
int n,a,b;
pair<int,int> p[200000];
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    p[i]=make_pair(b,a);
  }
  sort(p,p+n);
  for(int i=0;i<n;i++){
    t+=p[i].second;
    if(p[i].first<t){
      cout<<"No\n";
      return 0;
    }
  }
  cout<<"Yes\n"<<endl;
  return 0;
}

Measured memory_bytes: 1792
n = int(input())
l = list(map(int, input().split()))

l = l+l
xl = []
for i in range(2):
    a = 0
    m = False
    for j in range(i, n+i):
        if m is False:
            a += l[j]
            m = True
        else:
            a -= l[j]
            m = False
    xl.append(a)
    
for i in range(2, n):
    xl.append(xl[-2] - l[i-2]*2 + l[i-1]*2)
    
print(" ".join(map(str, xl)))

Measured memory_bytes: 19912
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000


int main() {
	int n, x;
	cin >> n >> x;
	int l[110];
	l[0] = 0;
	int s = 0;
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> l[i];
		s += l[i];
		if (s <= x) ans++;
	}
	cout << ans+1 << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vf80 xs(n), ys(n);
  rep(i, n) cin >> xs[i] >> ys[i];
  auto rad = [&](f80 x, f80 y) {
    f80 ret = 0;
    rep(i, n) {
      amax(ret, sqrt(pow(x - xs[i], 2) + pow(y - ys[i], 2)));
    }
    return ret;
  };
  auto ysearch = [&](f80 x) {
    f80 yl = -10000, yr = 10000;
    rep(_, 100) {
      auto yl_ = yl + (yr - yl) / 3;
      auto yr_ = yr - (yr - yl) / 3;
      if (rad(x, yl_) <= rad(x, yr_)) {
        yr = yr_;
      } else {
        yl = yl_;
      }
    }
    return yl;
  };
  f80 xl = -10000, xr = 10000;
  rep(_, 100) {
    auto xl_ = xl + (xr - xl) / 3;
    auto xr_ = xr - (xr - xl) / 3;
    if (rad(xl_, ysearch(xl_)) <= rad(xr_, ysearch(xr_))) {
      xr = xr_;
    } else {
      xl = xl_;
    }
  }
  cout << rad(xl, ysearch(xl)) << endl;
}


Measured memory_bytes: 384