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



int main() {
    int N,M;
    int K[100];
    int A[100][100];
    cin>>N>>M;
    for(int i=1;i<N+1;++i){
        cin>>K[i];
        for(int j=1;j<K[i]+1;++j){
            cin>>A[i][j];
        }
    }
    
    bool B[100];
    for(int i=1;i<M+1;++i){
        B[i]=true;
    }
    for(int i=1;i<N+1;++i){
        for(int p=1;p<M+1;++p){
            bool flag=false;
        
        for(int j=1;j<K[i]+1;++j){
            if(A[i][j]==p){
                flag=true;
            }
        
    }
            if(flag==false){
                B[p]=false;
            }
        }
    }
    int counter=0;
    for(int i=1;i<M+1;++i){
        if(B[i]==true){
            counter+=1;
        }
    }
    cout<<counter<<endl;
    
    
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = min(b, d) - max(a, c);
    if(ans <= 0){
        cout << 0 << endl;
        return 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	int N; cin >> N;
	int odd = 0;
	int ev = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 2 == 0) ev++;
		else odd++;
	}
	printf("%.8lf\n", (double)odd / (double)(ev + odd));
	






	return 0;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
A = []
N.times do
  A << gets.chomp.to_i
end
# S = gets.chomp.chars

sorted = []
A.each do |i|
  if sorted.size == 0
    sorted << i
    next
  end
  
  r = sorted.bsearch_index { |x| x >= i }
  if r.nil?  # i is larger than all value
    sorted[sorted.size-1] = i
  elsif r == 0  # i is equal or smaller than first value
    sorted.unshift(i)
  else 
    sorted[r-1] = i
  end
end

p sorted.size

Measured memory_bytes: 4036
#include<stdio.h>
main(){
  int a,b,c,d,e,i,j,temp;
  scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
  int n[]={a,b,c,d,e};
  for(i=0;i<4;i++){
    for(j=4;j>i;j--){
      if(n[j-1]<n[j]){
	temp=n[j-1];
	n[j-1]=n[j];
	n[j]=temp;
      }
    }
  }
  for(i=0;i<5;i++){
    printf("%d",n[i]);
    if(i!=4){
      printf(" ");
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
fast_io
vi a(3); 
for(int& i:a) cin>>i;
sort(a);
cout<<(a[0]+a[1]);
 return 0;
}

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

int main(){
    int n;
    vector<int> a;
    int out = 1;
    cin >> n;
    a.resize(n);
    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int i=0;i<n;i++){
        if(a[i] % 2 == 0){
            if (a[i] % 3 != 0 && a[i] % 5 != 0){
                out = 0;
            }
        }
    }
    if(out == 1){
        cout << "APPROVED";
    }else{
        cout << "DENIED";
    }
    return 0;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    static void Main()
    {
        char[] words = Console.ReadLine().ToCharArray();
        bool result = true;

        for(int i = 0; i < words.Length - 1; i++)
        {
            for(int j = i + 1; j < words.Length; j++)
            {
                //Console.WriteLine("{0}, {1}", words[i], words[j]);
                //同じ文字があったら、ループを抜ける。noと表示
                if (words[i] == words[j])
                {
                    result = false;
                    break;
                }
            }
            if (result == false)
            {
                break;
            }
        }

        if (result == true)
        {
            //同じ文字が含まれていないとき
            Console.WriteLine("yes");
        }
        else
        {
            //同じ文字が含まれているとき
            Console.WriteLine("no");
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
void margesort(int *, int, int);
void marge(int *, int, int, int);
int count = 0;
int S[5000000];
int L[2500001];
int R[2500001];
int main(){
    int n, i;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &S[i]);
    }
    margesort(S, 0, n);
    for(i = 0; i < n-1; i++){
        printf("%d ", S[i]);
    }
    printf("%d\n", S[i]);
    printf("%d\n", count);
    return 0; }
void margesort(int *S, int left, int right){
    int mid;
    if(left+1 < right){
        mid = (left + right)/2;
        margesort(S, left, mid);
        margesort(S, mid, right);
        marge(S, left, mid, right);
    } }
void marge(int *S, int left, int mid, int right){
    int b1, b2;
    int i, j=0, k;
    b1 = mid - left;
    b2 = right - mid;
    for(i = 0; i < b1; i++){
        L[i] = S[left+i];
    }
    L[b1] = 1000000001;
    for(i = 0; i <b2; i++){
        R[i] = S[mid+i];
    }
    R[b2] = 1000000001;
    i = 0;
    for(k = left; k < right; k++){
        if(L[i] <= R[j]){
            S[k] = L[i];
            i++;
        } else{
            S[k] = R[j];
            j++;
        } count++; }
}


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

using namespace std;

using ll = long long;

const int MOD = 1e9 + 7;

int main() {
   ios_base::sync_with_stdio(false);
   int N, M;
   cin >> N >> M;
   vector<int> adj(N);
   for (int i = 0; i < M; ++i) {
      int v, u;
      cin >> v >> u;
      --v, --u;
      adj[v] |= (1 << u);
   }
   vector<int> popcnt(1 << N);
   for (int i = 1; i < (1 << N); ++i) {
      popcnt[i] = popcnt[i >> 1] + (i & 1);
   }
   vector<int> dp(1 << N);
   for (int mask = 1; mask < (1 << N); ++mask) {
      if ((mask & 3) == 1 || (mask & 3) == 2) continue;
      dp[mask] = 1;
      for (int posMask = (mask - 1) & mask; posMask > 0; posMask = (posMask - 1) & mask) {
         if ((posMask & 3) == 1 || (posMask & 3) == 2) continue;
         int zeroMask = mask ^ posMask;
         int ways = dp[posMask];
         for (int i = 0; i < N; ++i) {
            if (posMask >> i & 1) {
               ways = ll(ways) * ((1 << popcnt[adj[i] & zeroMask]) - 1) % MOD;
            } else if (zeroMask >> i & 1) {
               ways = ll(ways) * (1 << popcnt[adj[i] & posMask]) % MOD;
            }
         }
         dp[mask] += ways;
         if (dp[mask] >= MOD) dp[mask] -= MOD;
      }
   }
   int ans = 1;
   for (int i = 0; i < M; ++i) {
      ans += ans;
      if (ans >= MOD) ans -= MOD;
   }
   ans -= dp[(1 << N) - 1];
   if (ans < 0) ans += MOD;
   cout << ans << "\n";
   return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Numerics;

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());

        var count = 0;
        for (int i = 0; i < N; i++)
        {
            var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var D1 = line[0];
            var D2 = line[1];
            if (D2 == D1)
            {
                count++;
                if (count == 3) break;
            }
            else { count = 0; }
        }

        Console.WriteLine(count == 3 ? "Yes" : "No");
    }
}

Measured memory_bytes: 28240
//IOI 2021

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 2 * 1000 + 17;

string s, x;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s;
	for (auto i : s) {
		if (x.empty()) {
			x += i;
		}
		else {
			if (x.back() == 'S' && i == 'T') {
				x.pop_back();
			}
			else
				x += i;
		}
	}
	cout << x.size() << endl;
	return 0;
}


Measured memory_bytes: 916
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

n = I()
a = LI()
a.sort()
alice = 0
bob = 0
for i in range(n):
    if i%2:
        bob += a.pop()
    else:
        alice += a.pop()

print(alice-bob)

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
using namespace std;

int main(){
  char p[8][9];
  char p90[8][9],p180[8][9],p270[8][9];
  int i,j;
 
  for(i=0;i<8;i++)scanf("%s",p[i]);
 
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      p90[i][j] = p[7-j][i];
      p180[i][j] = p[7-i][7-j];
      p270[i][j] = p[j][7-i];
    }
  }
  for(i=0;i<8;i++){
    p90[i][8] = '\0';
    p180[i][8] = '\0';
    p270[i][8] = '\0';
  }
  cout << "90" << endl;
  for(i=0;i<8;i++)printf("%s\n",p90[i]);
  cout << "180" << endl;
  for(i=0;i<8;i++)printf("%s\n",p180[i]);
  cout << "270" << endl;
  for(i=0;i<8;i++)printf("%s\n",p270[i]);
 
  return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie acos(-1)
#define loop(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x) for(auto &a:x)
#define vi vector<int>
#define vl vector<ll>
#define pii pair<ll,ll>
#define endl "\n"
#define w 1e5

void solve()
{
    int n;
    cin>>n;
    vector<double>a(n+1);
    loop(i,1,n+1)
    cin>>a[i];
    vector<double>dp(n+1);
    dp[0]=1;
    for(int coins=1;coins<=n;coins++)
    {
        for(int i=coins;i>=0;i--)
        {
            dp[i]=dp[i-1]*a[coins]+dp[i]*(1-a[coins]);
        }
    }
    double ans=0;
    for(int heads=0;heads<=n;heads++)
    {
        int tails = n-heads;
        if(tails<heads)
        ans+=dp[heads];
    }
    cout<<fixed<<setprecision(10)<<ans;
}
int main() {
	// your code goes here
	io;
    solve();
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int i=0,n,k;
    char s[50];
    scanf("%d%d",&n,&k);
    //gets(s);
    scanf("%s",s);
    while(s[i]!='\0')
    {
        if(i==(k-1))
        {
            s[i]=s[i]+32;
        }
        i++;
    }
    printf("%s",s);
    return 0;
}


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

int main() {
  long long int H;
  cin >> H;
  long long int ans = 1;
  for (int i = 0; i < 10000; i++) {
    if (ans >= H) {
      cout << ans << endl;
      break;
    }
    else {
      ans += 1;
      ans *= 2;
      ans -= 1;
    }
  }
}


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

int main()
{
	string S;
	cin >> S;

	int N = S.size() + 1;
	vector<int> A( N );
	vector<int> v;
	for( int i = 0; i < N - 1; i++ ) {
		if( i == 0 && S[i] == '<' ) {
			int j = i;
			int n = 0;
			while( j < N - 1 && S[j] == '<' ) {
				A[j] = n;
				n++;
				j++;
			}
			if( j < N ) A[j]  = max( A[j], n );
		}
		if( i == N - 2 && S[i] == '>' ) {
			int j = i;
			int n = 0;
			while( j >= 0 && S[j] == '>' ) {
				A[j + 1] = n;
				n++;
				j--;
			}
			if( j + 1 >= 0 ) A[j + 1] = max( A[j + 1], n );
		}
		else if( i + 1 < N - 1 && S[i] == '>' && S[i + 1] == '<' ) {
			int j = i;
			int n = 0;
			while( j >= 0 && S[j] == '>' ) {
				A[j + 1] = n;
				n++;
				j--;
			}
			if( j + 1 >= 0 ) A[j + 1] = max( A[j + 1], n );
			j = i + 1;
			n = 1;
			while( j < N - 1 && S[j] == '<' ) {
				A[j + 1] = n;
				n++;
				j++;
			}
			if( j + 1 < N ) A[j + 1]  = max( A[j + 1], n );
		}
	}
	long long ans = 0;
	for( int i = 0; i < N; i++ ) {
		ans += A[i];
	}

	cout << ans << endl;
}


Measured memory_bytes: 5792
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N=int(input())
    cnt=0
    for i in range(N):
        l,r=map(int,input().split())
        cnt+=r-l+1
    print(cnt)


resolve()

Measured memory_bytes: 38768
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main(){
    ll N;
    cin >> N;
    vll L(N);
    cin >> L;

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

    ll ans = 0;
    for(int i=0; i<N-2; i++){
        for(int j=i+1; j<N-1; j++){
            ll bc = L[i] + L[j];
            vll::iterator itr_bc = lower_bound(L.begin(), L.end(), bc);
            ans += itr_bc-L.begin()-j-1;
            
        }
    }
    cout << ans << endl;
}

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

using namespace std;

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> poss;
    vector<pair<int, int>> negs;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        int tot_o = 0, tot_c = 0;
        int max_d = 0;
        for (char c : s) {
            if (c == '(')
                tot_o++;
            else {
                tot_c++;
                max_d = max(max_d, tot_c - tot_o);
            }
        }
        if (tot_o >= tot_c) {
            poss.emplace_back(max_d, tot_o - tot_c);
        } else {
            negs.emplace_back(tot_c - tot_o - max_d, max_d);
        }
    }
    int curr = 0;
    sort(poss.begin(), poss.end());
    for (auto pos : poss) {
        if (pos.first > curr) {
            cout << "No" << endl;
            return 0;
        }
        curr += pos.second;
    }
    sort(negs.begin(), negs.end());
    for (auto neg : negs) {
        if (neg.second > curr) {
            cout << "No" << endl;
            return 0;
        }
        curr -= neg.first + neg.second;
    }
    if (curr == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 11272
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	
#include<list>

using namespace std;

int main() {
	int N;
	cin >> N;
	double ans = 0;
	double bunbo = 0;
	double bunshi = 1;
	vector<double> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		bunshi *= A[i];
	}
	for (int i = 0; i < N; ++i) {
		bunbo += bunshi / A[i];
	}
	ans = bunshi / bunbo;
	printf("%lf", ans);
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
dd=defaultdict(int)
n=int(input())
for _ in range(n):
    s=input()
    x=[]
    for i in range(10):
        x.append(s[i])
    x.sort()
    s="".join(x)
    dd[s]+=1
ans=0
for s in dd:
    p=dd[s]
    ans+=p*(p-1)//2
print(ans)

Measured memory_bytes: 66136
import math
n = int(raw_input())
ans = 0

for i in range(2, int(math.sqrt(n) + 1)):
	if n % i == 0:
		p = i
		cnt = 0
		while n % i == 0:
			n /= i
			cnt += 1
		start = 1
		while start <= cnt:
			ans += 1
			cnt -= start
			start += 1
if n > 1:
	ans += 1
print ans

Measured memory_bytes: 85736
#include "bits/stdc++.h"
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n;
    cin >> n;
    
    vector<int> h;
    for(int i=0; i<n; i++){
        int c;
        cin >> c;
        h.push_back(c);
    }
    reverse(h.begin(), h.end());

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

    // for (int i = 0; i < n; i++)
    // {
    //     cout << h.at(i) << " : ";
    // }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 892
fun main(args: Array<String>) {
    val S = readString().map { it - '0' }

    fun f(sum: Long, tmp: Long, i: Int): Long {
        if (i == S.size) return sum + tmp
        return f(sum + tmp, S[i].toLong(), i + 1) + f(sum, 10 * tmp + S[i], i + 1)
    }

    println(f(0, S[0].toLong(), 1))
}

fun readString() = readLine()!!

Measured memory_bytes: 31920
#include <iostream>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<vector>
#include<set>
#include<list>

using namespace std;
typedef long long ll;
int modulo = 1e9 + 7;
int main() {
    int rows,cols;
    cin>>rows>>cols;
    ll dp[rows+1][cols+1], arr[rows+1][cols+1];
    for(int i = 0; i<=rows; i++){
        for(int j = 0; j<=cols; j++){
            dp[i][j] = 0;
        }
    }
    char c;
    for(int i = 0; i<rows; i++){
        for(int j = 0; j<cols; j++){

            cin>>c;
            if(c == '.'){
                arr[i][j] = 0;
            }
            else{
                arr[i][j] = 1;
            }
        }
    }
    if(arr[0][0]!=0){
        cout<<"0"<<"\n";
        return 0;
    }
    dp[0][0] = 1;
    for(int i = 1; i<rows; i++){
        if(arr[i][0] == 0){
            dp[i][0] = (dp[i-1][0])%modulo;
        }
        else{
            dp[i][0] = 0;
        }
    }
    for(int i = 1; i<cols; i++){
        if(arr[0][i] == 0){
            dp[0][i] = dp[0][i-1]%modulo;
        }
        else{
            dp[0][i] = 0;
        }
    }
    for(int i = 1; i<rows; i++){
        for(int j = 1; j<cols; j++){
            if(arr[i][j] == 0){
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%modulo;
            }
            else{
                dp[i][j] = 0;
            }
        }
    }
    dp[rows-1][cols-1] = dp[rows-1][cols-1]%modulo;
    cout<<(dp[rows-1][cols-1])<<"\n";
}


Measured memory_bytes: 19172
using System;
using System.Collections;


namespace AOJ.intro
{
    namespace ITP_1_3_B
    {
        public static class PrintTestCase
        {
            public static void Main()
            {
                // テストケース入力部
                ArrayList testCase = new ArrayList();
                for (int i = 0; i < 10000; ++i )
                {
                    int inputData = int.Parse(Console.ReadLine());

                    if(inputData != 0){
                        testCase.Add(inputData);
                    }
                    else{
                        break;
                    }
                }

                // テストケース出力部
                int index = 0;
                foreach(int result in testCase){
                    index++;
                    Console.WriteLine("Case " + index + ": " + result);
                }

            }
        }
    }
}


Measured memory_bytes: 9916
import Control.Applicative
import Data.Bool (bool)

main :: IO ()
main = getLine >> solve <$> f >>= putStrLn
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> String
solve xs = let mx = maximum xs
               rs = sum xs - mx
           in bool "No" "Yes" (mx < rs)


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	while(cin>>s)
	{
		if(s.length()%2)
		{
			cout<<"No\n";
			continue;
		}
		bool f=1;
		for(int i=0;i<s.length();i+=2)
		{
			if(s[i]!='h'||s[i+1]!='i') {f=0;break;
			}
		}
		if(f) cout<<"Yes\n";
		else cout<<"No\n";
	}
 } 

Measured memory_bytes: 256
package main

import "fmt"

func main(){
	var s,ans string
	fmt.Scan(&s)
	for i:=len(s)-1 ; i>=0 ; i-- {
//fmt.Println(s[i:i+1])
		if s[i:i+1] == "?"{
			ans = "D" +ans
			/*if i != len(s)-1 && ans[0:1] == "D" {
				//fmt.Printf("P")
				ans = "P" + ans
			} else {
//fmt.Printf("else %v",s[i:i+1])
				//fmt.Printf("D")
				ans = "D" + ans
			}*/
		} else {
			ans = s[i:i+1] + ans
			//fmt.Printf("%v",s[i:i+1])
		}
	}
	/*for i:=len(ans)-1 ; i>=0 ; i-- {
		fmt.Printf("%v",ans[i:i+1])
	}*/
	fmt.Println(ans)
}


Measured memory_bytes: 7952
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = (1 << 31) - 1;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, ans = 0, w, l;
vl A;

void input() {
	cin >> x>> y;
}


void solve() {
	if (x > 9 || y > 9) {
		cout << -1 << endl;
		return;
	}
	cout << x * y << endl;

}

int main() {
	input();
	solve();
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;



int main()
{
    int s;
    cin>>s;
    int a=s/100; int b=s%100;
    if ((a<=0)||(a>12))
        {if ((b<=0)||(b>12))
            cout<<"NA";
        else
            cout<<"YYMM";}
    else
        {if ((b>0)&&(b<13))
            cout<<"AMBIGUOUS";
        else
            cout<<"MMYY";}

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#define Rep(i,n)for(int i=0;i<n;i++)
#define ret return 0
using namespace std;
int main()
{
	int a, b;
	vector<vector<int>> vect;
	while ((cin >> a >> b && (a != 0 || b != 0)))
	{
		vector<int> tmp = { a,b };
		vect.push_back(tmp);

		string ans;

		Rep(i, a)
		{
			Rep(j, b)
			{
				if (i == 0 || j == 0 || a - i == 1 || b - j == 1)
					ans += "#";
				else
					ans += ".";
			}
			ans += "\n";
		}
		cout << ans << endl;
	}
	ret;
}


Measured memory_bytes: 3124
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	string s;
	int cnt = 0;
	while(cin >> s) {
		int len = s.length();
		bool f = 1;
		rep(i,len / 2 + 1) {
			if(s[i] != s[len - i - 1]) {
				f = 0;
				break;
			}
		}
		if(f) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1184
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

n,m=map(int,input().split())
to=[[] for i in range(n)]

visited = [False]*n
calculated = [False]*n
dp = [1]*n# Vからスタートしたときの最長経路。頂点の個数ベースで経路の長さを数えるので、初期値は1

def dfs(v):
    if visited[v]:
        if not calculated[v]:
            return -1 # 計算が終わっていない頂点を2度訪れるのはループがあるということ
        return dp[v]
    visited[v] = True
    for u in to[v]: # 全ての辺をなめる
        res = dfs(u)
        if res == -1: return -1 # ループがあれば-1を返す
        dp[v] = max(dp[v], res+1)
    calculated[v] = True
    return dp[v]

def main():
    for i in range(m):
        a,b=map(int,input().split())
        a-=1
        b-=1
        to[a].append(b)
    ans = 0
    for i in range(n):
        res = dfs(i)
        ans = max(ans, res)
    print(ans-1)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 113952
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)

int main() {
  int N;
  int d[110];
  cin >> N;
  REP(i,N) cin >> d[i];
  
  int num[110] = {0};
  REP(i,N) {
    num[d[i]]++;
  }
  
  int res = 0;
  REP(i,101) {
    if (num[i]) res++;
  }
  
  cout << res << endl;
}

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

using namespace std;

vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

int main() {
  char cline[1023];
  cin.getline(cline, sizeof(cline));
  string input(cline);
  //cout << "input: " << input << endl;

  vector<string> ss = split(input, ' ');
  //cout << "ss[0]: " << ss[0] << ", ss[1]: " << ss[1] << ", ss[2]: " << ss[2] << endl;

  int a, b, x;
  a = stoi(ss[0]);
  b = stoi(ss[1]);
  x = stoi(ss[2]);

  if (a <= x && x - a <= b) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

using namespace std;

int n;
char s[220000];
int pre[220000] , suf[220000];
int ans;
void work () {
	int i;
	scanf ( "%d" , &n );
	scanf ( "%s" , s + 1 );
	for ( i = 1 ; i <= n ; i++ ) {
		if ( s[i] == '.' ) suf[i] = 1;
		else pre[i] = 1;
	}
	for ( i = 1 ; i <= n + 1 ; i++ ) {
		pre[i] += pre[i-1];
	}
	for ( i = n ; i >= 0 ; i-- ) suf[i] += suf[i+1];
	ans = n;
	for ( i = 0 ; i <= n ; i++ ) {
		ans = min ( ans , pre[i] + suf[i+1] );
	}
	printf ( "%d\n" , ans );
}
int main () {
	work ();
	return 0;
}


Measured memory_bytes: 1920
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		int n = Integer.parseInt(str);
		str = scan.next();
		int h = Integer.parseInt(str);
		int[] a = new int[n];
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			str = scan.next();
			a[i] = Integer.parseInt(str);
			str = scan.next();
			b[i] = Integer.parseInt(str);
		}
		int max = a[0];
		for (int i = 1; i < n; i++) {
			if (a[i] > max) {
				max = a[i];
			}
		}

		ArrayList<Integer> katana = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			if (b[i] > max) {
				katana.add(b[i]);
			}
		}

		Collections.sort(katana);

		int answer = 0;

		while (h>0) {
			int max_ = katana.size();
			if (max_>0) {
				h-=katana.get(max_-1);
				katana.remove(max_-1);
				answer++;
			} else {
				answer+=(int) Math.ceil((double)h/max);
				break;
			}
		}

		
		System.out.println(answer);
	}
}

Measured memory_bytes: 57652
n = int(input())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]
tobasu = 0
one = 0
two = 0
for i in range(len(a) - 1):
    if tobasu == 1:
        tobasu = 0
        continue
    if a[i] == a[i + 1] and one == 0:
        tobasu = 1
        one = a[i]
    elif a[i] == a[i + 1] and one != 0 and two == 0:
        two = a[i]
        break
print(one * two)


Measured memory_bytes: 14252
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        BellmanFord bf = new BellmanFord(n);
        
        for(int i=0; i<m; i++){
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            int c = Integer.parseInt(sc.next());
            bf.addEdge(a-1, b-1, -c);
        }
        
        boolean isInf = bf.bellmanford(0);
        long ans = -bf.getDist(n-1);
        
        if(isInf){
            System.out.println("inf");
        }else{
            System.out.println(ans);
        }
    }
}

class BellmanFord{
    
    public final long INF = (long)1e18;
    private int n;
    private List<Edge>[] graph;
    private long[] dist;
    
    public BellmanFord(int n){
        this.n = n;
        graph = new List[n];
        for(int i=0; i<n; i++){
            graph[i] = new ArrayList<>();
        }
    }
    
    public void addEdge(int from, int to, int cost){
        graph[from].add(new Edge(to, cost));
    }
    
    public boolean bellmanford(int from){
        dist = new long[n];
        Arrays.fill(dist, INF);
        dist[from] = 0;
        
        for(int i=0; i<n; i++){
            for(int v=0; v<n; v++){
                for(int k=0; k<graph[v].size(); k++){
                    Edge e = graph[v].get(k);
                    if(dist[v] != INF && dist[e.to] > dist[v] + e.cost){
                        dist[e.to] = dist[v] + e.cost;
                        /*if(i==n-1){
                            //n回目にも更新があるなら負の閉路が存在
                            return true;
                        }*/
                        if(i==n-1 && e.to==n-1){
                            //n回目に頂点Nへ更新があるならスコアINF
                            return true;
                        }
                    }
                }
            }
        }
        
        return false;
    }
    
    public long getDist(int to){
        if(dist != null){
            return dist[to];
        }
        return -1;
    }
}

class Edge implements Comparable<Edge>{
    public int to = 0;
    public int cost = 0;
    
    public Edge(int to, int cost) {
        this.to = to;
        this.cost = cost;
    }
    
    @Override
    public int compareTo(Edge o) {
        return this.cost - o.cost;
    }
}


Measured memory_bytes: 27688
#include<bits/stdc++.h>
using namespace std;
#define nl cout<<'\n';
int main()
{
    int h,w,i=0;
    cin>>h>>w;
    string s[h];
    while(i<h)
    {
       cin>>s[i];
       i++;
    }
    for(int i=0;i<h;i++)
    {
       cout<<s[i]<<'\n'<<s[i];
       nl;
    }
    return 0;
}


Measured memory_bytes: 256
ARGF.each_line do |line|
  h, w = line.split.map(&:to_i)
  break if [h, w].eql? [0, 0]
  1.upto(h) { |i|
    case i
    when 1, h
      puts '#' * w
    else
      print "#", ("." * (w - 2)), "#\n"
    end
  }
  puts
end

Measured memory_bytes: 6092
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef vector<iil> viil;
 
#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 1000000000

ll modpow(ll n, ll md) {
    ll k = md - 2;
    ll fin = 1;
    ll ans = n;
    rep(i, 32) {
        if ((1 << i) & k) {
            fin = (fin * ans) % md;
        }
        ans = (ans * ans) % md;
    }
    return fin;
}

ll fac[200005];
ll md = 998244353;

ll comb(ll n, ll k) {
    return (fac[n] * modpow((fac[k] * fac[n - k]) % md, md)) % md;
}
 
void solve() {
    ll n, m, k;
    cin >> n >> m >> k;
    ll prec[n];
    ll MOD = 998244353;
    ll nm = 1;
    rep(i, n) {
        prec[i] = nm;
        nm = (nm * (m - 1)) % MOD;
    }
    ll ans = 1;
    rep(i, n + 1) {
        fac[i] = ans;
        ans = (ans * (i + 1)) % MOD;
    }
    ll ct = 0;
    ct = ct + (prec[n - 1] * m) % MOD;
    for (int i = 1 ; i <= k ; i++) {
        ct = (ct + ((prec[n - i - 1] * m) % MOD) * comb(n - 1, i)) % MOD;
    }
    cout << ct << endl;
}
 
void querySolve() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    solve();
    //querySolve();
}



Measured memory_bytes: 6712
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int n, a[107], dp[107][107], K[107][107];
int main() {
	int t; cin >> t;
	for (int p = 0; p < t; p++) {
		for (int i = 0; i < 11449; i++)dp[i / 107][i % 107] = 0;
		cin >> n; if (n == 0)break;
		for (int i = 0; i < n; i++)cin >> a[i];
		int maxn = 0;
		for (int u = 0; u < n; u++) {
			int G = a[0];
			for (int v = 1; v < n; v++)a[v - 1] = a[v];
			a[n - 1] = G;
			for (int v = 0; v < 11449; v++)dp[v / 107][v % 107] = 0;
			for (int v = 0; v < n; v++) {
				for (int w = 0; w < n; w++)K[v][w] = abs(a[v] - a[w]);
			}
			for (int v = 1; v <= n; v++) {
				for (int w = 0; w < n; w++) {
					int I = w, J = v + w;
					if (I >= J || J >= n)continue;
					for (int k = I; k < J; k++) {
						dp[I][J] = max(dp[I][J], dp[I][k] + dp[k + 1][J] + K[I][k + 1]);
					}
				}
			}
			maxn = max(maxn, dp[0][n - 1]);
		}
		cout << maxn << endl;
	}
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds; 
		//order_of_key (k) : Number of items strictly smaller than k .
		//find_by_order(k) : K-th element in a set (counting from zero) (returns an iterator)           


void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int32_t main()
{
	fastIO
	inp_out();

	int R, C, k; 

	cin >> R >> C >> k; 

	mii mp1, mp2; 
	map < int, vi >  mp; 
	map < pii, int >  mp3; 
	for(int i = 0; i < k; ++ i)
	{
		int x, y; 
		cin >> x >> y; 
		mp[x].pb(y); 
		mp1[x]++ ; 
		mp2[y]++ ; 
		mp3[{x, y}]++ ; 
	}	

	multiset < int , greater < int > > st; 
	for(auto i : mp2)
		st.insert(i.se); 

	int ans = 0; 

	int mx1 = 0, mx2 = 0; 
	for(auto i : mp3)
	{
		ans = max(ans, mp1[i.fi.fi] + mp2[i.fi.se] - i.se); 
	}

	for(auto i : mp1)
	{
		int can = 0; 
		can += i.se; 

		for(auto j : mp[i.fi])
		{
			st.erase(st.find(mp2[j])); 
			mp2[j]-- ; 
			st.insert(mp2[j]); 
		 // 	db(mp2[j], j); 
		}

	 // 	db(i.fi, can); 

		can +=  * st.begin(); 

	 // 	db(can); 

		for(auto j : mp[i.fi])
		{
			st.erase(st.find(mp2[j])); 
			mp2[j]++ ; 
			st.insert(mp2[j]); 
		}

		ans = max(ans, can); 
	}

	cout << ans; 

	return 0;
}

Measured memory_bytes: 106732
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
na=sorted(a)
nb=sorted(b)
c=[0]*n
for i in range(n):
  c[i]=a[i]-b[i]
if sum(c)<0:
  print(-1)
else:
  c.sort()
  ans=0
  s=0
  for i in range(n):
    if c[i]<0:
      s=s+abs(c[i])
      ans=ans+1
  for i in range(n):
    if s<=0:
      break
    else:
      s=s-c[n-i-1]
      ans=ans+1
  print(ans)

Measured memory_bytes: 24260
N = int(input())
L = ['3','5','7']
K = str(N)
for i in range(len(K)):
  T = len(L)
  for j in range(T):
    L.append(L[j]+'3')
    L.append(L[j]+'5')
    L.append(L[j]+'7')
  L = list(set(L))
ans = 0
for i in range(len(L)):
  cnt3 = 0
  cnt5 = 0
  cnt7 = 0
  for j in range(len(L[i])):
    if L[i][j] == '3':
      cnt3 += 1
    elif L[i][j] == '5':
      cnt5 += 1
    else:
      cnt7 += 1
  if cnt3 > 0 and cnt5 > 0 and cnt7 > 0:
    if int(L[i]) <= N:
      ans += 1
print(ans)

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

int paper[10][10];

void drop(int x, int y) {
    if (x >= 0 && x < 10 && y >= 0 && y < 10) {
        paper[x][y]++;
    }
}

int main() {
    int x1, y1, size;
    char temp;
    int zeroDensity = 0, maxDensity = 0;

    for (int i = 0; i != 10; ++i) {
        for (int j = 0; j != 10; ++j) {
            paper[i][j] = 0;
        }
    }

    while (cin >> x1 >> temp >> y1 >> temp >> size) {        
        switch (size) {
            case 1:
                drop(x1, y1);    // center
                drop(x1, y1-1);  // top
                drop(x1+1,y1);  // right
                drop(x1,y1+1);  // bottom
                drop(x1-1,y1);  // left
                break;
            case 2:
                for (int i = -1; i != 2; ++i) { drop(x1 + i, y1-1); }
                for (int i = -1; i != 2; ++i) { drop(x1 + i, y1); }
                for (int i = -1; i != 2; ++i) { drop(x1 + i, y1+1); }
                break;
            case 3:
                for (int i = -1; i != 2; ++i) { drop(x1 + i, y1-1); }
                for (int i = -1; i != 2; ++i) { drop(x1 + i, y1); }
                for (int i = -1; i != 2; ++i) { drop(x1 + i, y1+1); }
                drop(x1, y1-2);  // top
                drop(x1+2, y1);  // right
                drop(x1, y1+2);  // bottom
                drop(x1-2, y1);  // left
                break;
        }
    }

    for (int i = 0; i != 10; ++i) {
        for (int j = 0; j != 10; ++j) {
            if (paper[i][j] == 0) {
                ++zeroDensity;
            }
            if (paper[i][j] > maxDensity) {
                maxDensity = paper[i][j];
            }
        }
    }
    cout << zeroDensity << endl;
    cout << maxDensity << endl;
    return 0;
}

Measured memory_bytes: 1160
while True:
	N, T, L, B = map(int, input().split(' '))
	if N == 0:
		break
	l = set([int(input()) for _ in range(L)])
	b = set([int(input()) for _ in range(B)])

	memo = [[0.0] * (N+1) for _ in range(T+2)]
	memo[0][0] = 1
	for t in range(T):
		for n in range(N):
			for i in [1,2,3,4,5,6]:
				next_pos = n + i
				if next_pos > N:
					next_pos = 2*N - next_pos

				if next_pos in l:
					memo[t+2][next_pos] += memo[t][n]/6
				elif next_pos in b:
					memo[t+1][0] += memo[t][n]/6
				else:
					memo[t+1][next_pos] += memo[t][n]/6

	print('{:.6f}'.format(sum([memo[t][N] for t in range(T+1)])))




Measured memory_bytes: 5992
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input {(source=$s:expr,$($r:tt)*) => {let mut iter=$s.split_whitespace(); let mut next=||{iter.next().unwrap()}; input_inner! {next,$($r)*}};($($r:tt)*) => {let stdin=std::io::stdin();let mut bytes=std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next=move||->String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()}; input_inner! {next,$($r)*}};}
#[allow(unused_macros)]
macro_rules! input_inner {($next:expr) => {}; ($next:expr,) => {}; ($next:expr,$var:ident:$t:tt$($r:tt)*) => {let $var=read_value!($next,$t); input_inner! {$next$($r)*}};}
#[allow(unused_macros)]
macro_rules! read_value {($next:expr,($($t:tt),*)) => {($(read_value! ($next,$t)),*)}; ($next:expr, [$t:tt; $len:expr]) => {(0..$len).map(|_|read_value! ($next,$t)).collect::<Vec<_>>()}; ($next:expr,chars) => {read_value! ($next,String).chars().collect::<Vec<char>>()}; ($next:expr,usize1) => {read_value! ($next,usize)-1}; ($next:expr,$t:ty) => {$next().parse::<$t>().expect("Parse error")};}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX: usize = 100006;
#[allow(dead_code)]
const INF_U32: u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32: i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64: u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64: i64 = 1 << 62;
#[allow(dead_code)]
const MOD: i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(unused_imports)]
use std::f64;

fn gcd(a:i64,b:i64) -> i64 {
    if b==0 {return a;}
    gcd(b, a%b)
}

fn lcm(a:i64,b:i64) -> i64 {
    a / gcd(a,b) * b
}

fn main() {
    input!{a:i64,b:i64};
    println!("{}", lcm(a,b));
}


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

#define N 201000
#define ll long long
#define RG register
#define pr pair<ll,int> 
#define mkp make_pair
#define fi first
#define sc second

using namespace std;

inline int read(){
    RG int x=0,t=1;RG char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=-1,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return x*t;
}

int n,Q,top,rem[N],fa[N];
struct mona { int x,y,w; } s[N<<3];
inline bool cmp(mona x,mona y) { return x.w<y.w; }
inline int Find(int x) { if(fa[x]!=x) fa[x]=Find(fa[x]); return fa[x]; }

int main(){
	n=read(),Q=read();
	for(RG int i=1;i<=n;++i) rem[i]=2e9,fa[i]=i;
	while(Q--){
		int A=read()+1,B=read()+1,C=read();
		s[++top]=(mona) { A,B,C };
		rem[A]=min(rem[A],C+1),rem[B]=min(rem[B],C+2);
	}
	for(RG int i=1;i<=n;++i) { int j=i==1?n:i-1; rem[i]=min(rem[j]+2,rem[i]); }
	for(RG int i=1;i<=n;++i) { int j=i==1?n:i-1; rem[i]=min(rem[j]+2,rem[i]); }
	for(RG int i=1;i<=n;++i) { int j=i==n?1:i+1; s[++top]=(mona) { i,j,rem[i] }; }
	sort(s+1,s+1+top,cmp); ll ans=0;
	for(RG int i=1;i<=top;++i){
		int fx=Find(s[i].x),fy=Find(s[i].y);
		if(fx!=fy) fa[fx]=fy,ans+=s[i].w;
	}   printf("%lld\n",ans);
}


Measured memory_bytes: 9856
import java.util.Scanner;
 
class Main{
          public static void main(String [] args){
                      Scanner scan = new Scanner(System.in);
                      int i = 1;
                      while(scan.hasNext()){
                          int x = Integer.parseInt(scan.next());
                          if(x == 0){break;
                          }
                          System.out.println("Case " + i + ": " + x);
                          i++;
                      }
          }
}

Measured memory_bytes: 31320
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<stack>
#include<cassert>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x,y,sizeof x)
#define sqr(x) ((x)*(x))
//debug
#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...)
#endif
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
const int INF=2e9;
const db eps=1e-12;
template<typename T>
inline void read(T &x) {
  x=0; int f=1; char ch=getchar();
  while( (ch<'0' || ch>'9') && ch!='-') ch=getchar(); if(ch=='-') {f=-1; ch=getchar();}
  while(ch>='0' && ch <='9') x=x*10+ch-'0',ch=getchar();
  x*=f;
}
//==========================head template==========================
const int N=100010;
int a[N],n;
int ans=0;
signed main() {
  read(n); n<<=1;
  for(int i=1;i<=n;i++) read(a[i]);
  sort(a+1,a+n+1);
  for(int i=1;i<=n;i+=2) {
    ans+=a[i];
  }
  printf("%d\n",ans);
	
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func factorial(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		// fact = fact * i
		fact = fact * i % 1000000007
	}
	return fact
}

func main(){
	var dog,monkey int
	fmt.Scan(&dog,&monkey)
	if dog-monkey > 1 || monkey-dog > 1{
		fmt.Println("0")
	}else if dog == monkey{
		n := factorial(dog)
		fmt.Println(n*n*2%1000000007)
	}else{
		fmt.Println(factorial(dog)*factorial(monkey)%1000000007)
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int a,b,c,d,cnt=0;
	cin>>a>>b>>c>>d;
	if(a<0)
	cnt++;
	if(b<0)
	cnt++;
	if(c<0)
	cnt++;
	if(d<0)
	cnt++;
	if(cnt==0 || cnt==1)
	cout<<b*d<<endl;
	else if(cnt==3)
	cout<<c*a<<endl;
	else if(cnt==4)
	cout<<a*c<<endl;
	else
	{
		if(c>=0 && d>=0)
		cout<<b*c<<endl;
		else if(b>=0 && d>=0)
		{
			if(b*d>a*c)
			cout<<b*d<<endl;
			else
			cout<<a*c<<endl;
		}
		else
		cout<<d*a<<endl;
	}
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define fi              first
#define se              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define endl			"\n"
void fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int n, capacity;
int dp[101][100001];
vector<int> w, v;

int solve(int max_profit)
{
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= max_profit; j++)
		{
			if (i == 0 and j == 0)
				dp[i][j] = 0;
			else if (i == 0)
				dp[i][j] = inf;
			else if (v[i - 1] <= j)
				dp[i][j] = min(w[i - 1] + dp[i - 1][j - v[i - 1]], dp[i - 1][j]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
	int ans = 0;
	for (int j = 0; j <= max_profit; j++)
	{
		if (dp[n][j] <= capacity)
			ans = j;
	}
	return ans;
}
int32_t main()
{
	fast();
	cin >> n >> capacity;
	w.resize(n);	v.resize(n);
	int max_profit = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> w[i] >> v[i];
		max_profit += v[i];
	}
	cout << solve(max_profit);
	return 0;
}


Measured memory_bytes: 82400