akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N,M;
    cin >> N >> M;
    vector<pair<int,int> > student(N);
    vector<pair<int,int> > check(M);
    rep(i,N){
        cin >> student[i].first >> student[i].second;
    }
    rep(i,M){
        cin >> check[i].first >> check[i].second;
    }
    vector<int> visit(N,1);
    vector<int> nearest(N,0);
    rep(i,N){
        nearest[i] = max(student[i].first - check[0].first, check[0].first - student[i].first) + max(student[i].second - check[0].second, check[0].second - student[i].second);
    }
    rep(i,N){
        rep(j,M - 1){
            if (nearest[i] > max(student[i].first - check[j + 1].first, check[j + 1].first - student[i].first) + max(student[i].second - check[j + 1].second, check[j + 1].second - student[i].second)){
                visit[i] = j + 2;
                nearest[i] = max(student[i].first - check[j + 1].first, check[j + 1].first - student[i].first) + max(student[i].second - check[j + 1].second, check[j + 1].second - student[i].second);
            }
        }
    }
    rep(i,N){
        cout << visit[i] << endl;
    }
}

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


int main()
{
	string s,t;  cin>>s>>t;
	
	int n=s.size();
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]!=t[i]) cnt++;
	}
	
	cout<<cnt<<endl;
}


Measured memory_bytes: 3872
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int N, X, T;
  cin >> N >> X >> T;
  if (N%X != 0) cout << (N/X + 1) * T << endl;
  else cout << (N/X) * T << endl;
}


Measured memory_bytes: 3616
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragme GCC target("avx2");
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#define int long long
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define f first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>

using namespace std;
//using namespace __gnu_pbds;

/*
	st.insert(k);
	st.find_by_order(k); iterator on k-th from 0
	st.order_of_key(k); strictly more than k
*/

//typedef
//tree<
//  ll,
//  null_type,
//  less_equal<ll>,
//  rb_tree_tag,
//  tree_order_statistics_node_update>
//ordered_set;


const int N = 4e5 + 19;
const int M = 2e6 + 19;
const int
 mod = 998244353;
const int inf = 2e9;
const int blocksz = 300;
const ll INF = 1e18;


inline int modulo(int x) {x %= mod; return (x + mod) % mod; }
inline int mult(int x, int y) { ll x1 = modulo(x), y1 = modulo(y); return (x1 * y1) % (ll)mod; }
inline void add(int &x, int y) { x = modulo(x + y); }
inline void Max(int &x, int y) { x = max(x, y); }
inline void Min(int &x, int y) { x = min(x, y); }


int n, m, ans = 0, fact[M];


int pw(int x, int y) {
	int cur = 1, pwx = x;
	for (int i = 0; i < 30; i++) {
		if (y & 1)
			cur = mult(cur, pwx);
		pwx = mult(pwx, pwx);
		y = (y >> 1);
	}
	return cur;
}


inline int C(int n, int k) {
	if (n < k)
		return 0;
	int t1, t2, t3;
	t1 = fact[n];
	t2 = pw(fact[k], mod - 2);
	t3 = pw(fact[n - k], mod - 2);
	return mult(t1, mult(t2, t3));
}


inline int F(int n, int m, int i) {
	if ((m - i) % 2)
		return 0;
	return mult(C(n, i), C((m - i) / 2 + n - 1, n - 1));
}


inline int G(int n, int m, int i) {
	return mult(n, modulo(F(n, m, i) - F(n - 1, m, i)));
}


void precalc() {
	fact[0] = 1;
	for (int i = 1; i < M; i++)
		fact[i] = mult(fact[i - 1], i);
}


main() {
	ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
//	freopen("input.txt", "r", stdin);
	precalc();
	cin >> n >> m;
//	cout << C(3, 1) << endl;
//	cout << F(2, 6, 2) << endl;
	for (int i = 0; i <= min(n, m); i++)
		add(ans, modulo(F(n, 3 * m, i) - G(n, m, i)));
	cout << ans;	
	return 0;
}
/*
3 5
1 3 2 1 3
10 5 7
3
4 2 4
1 3 1
3 5 2
*/



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

int main() {
  int N;
  char S;
  cin >> N;
  int ay=0,ag=0,ap=0,aw=0;

  int i;
  for (i=0;i<N;i++){
    cin >>S;
	if (S=='Y')
      ay=1;
    else if (S=='G')
      ag=1;
    else if (S=='W')
      aw=1;
    else if (S=='P')
      ap=1;
  }
  i=ay+ag+aw+ap;
  if (i==3)
    cout <<"Three"<<endl;
  else
    cout <<"Four"<<endl;
}

Measured memory_bytes: 256
def func(n, a):
    mx = max(a)
    x = [0] * (mx + 1) # len(x)
    for i in a:
        x[i] += 1
    for i in range(1, mx + 1):
        if x[i] != 0:
            for j in range(2 * i, mx + 1, i):
                x[j] = 0
        if x[i] > 1:
            x[i] = 0
    print(sum(x)) # 31401

n = int(input())
a = list(map(int, input().split()))
func(n, a)


Measured memory_bytes: 32240
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		
		// 計算
		int result = 0;
		if(n <= 111){
		    result = 111;
		}else if(n <= 222){
		    result = 222;
		}else if(n <= 333){
		    result = 333;
		}else if(n <= 444){
		    result = 444;
		}else if(n <= 555){
		    result = 555;
		}else if(n <= 666){
		    result = 666;
		}else if(n <= 777){
		    result = 777;
		}else if(n <= 888){
		    result = 888;
		}else if(n <= 999){
		    result = 999;
		}
		
		
		// 出力
		System.out.println(result);
		
	}
}

Measured memory_bytes: 21972
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	lint n=read<lint>();
	lint m=read<lint>();

	for(int i=1;i<=m;i++)
	{
		n-=read<lint>();
		if(n<0) break;
	}

	if(n<0) puts("-1");
	else printf("%lld\n",n);

	return 0;

}

Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string.h>
using namespace std;
typedef long long int llint;
int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 1;
	for (int i = 1;i < n;i++) {
		if (a[i - 1] != a[i]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int temp=0;
    if (a>b){
        temp=a;
        a=b;
        b=temp;
    }
    if (b>c){
        temp=b;
        b=c;
        c=temp;
    }
    if (a>b){
        temp=a;
        a=b;
        b=temp;
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


Measured memory_bytes: 3100
n, m = list(map(int, input().split()))
max_l = 1
min_r = 100000
for _ in range(m):
    l, r = list(map(int, input().split()))
    if l > max_l:
        max_l = l
    if r < min_r:
        min_r = r
ans = min_r - max_l + 1
if ans < 0:
    print(0)
else:
    print(ans)

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

int N,D,X;
int p[10][10];

int dp[100010];

signed main(){
    cin>>N>>D>>X;
    rep(i,D)rep(j,N)cin>>p[i][j];
    fill_n(dp,100010,-1001001001);
    dp[X]=X;

    rep(i,D-1){
        for(int j=100000;j>=0;j--){
            rep(k,N){
                if(j-p[i][k]<0)continue;
                chmax(dp[j-p[i][k]],dp[j]-p[i][k]+p[i+1][k]);
            }
            if(dp[j]>j){
                dp[dp[j]]=dp[j];
                dp[j]=-1001001001;
            }
        }
    }
    for(int j=100000;j>=0;j--){
        if(dp[j]==j){
            cout<<j<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3872
class Card:
    def __init__(self):
        self.suit = ''
        self.value = 0

def partition(A, p, r):
    x = A[r].value
    i = p
    for j in range(p, r):
        if A[j].value <= x:
            A[i], A[j] = A[j], A[i]
            i += 1
    A[i], A[r] = A[r], A[i]
    return i

def quickSort(A,p,r):
    if p < r:
        q = partition(A,p,r)
        quickSort(A, p, q-1)
        quickSort(A, q+1, r)

def main():
    n = int(input())
    A = []
    for _ in range(n):
        card = Card()
        _input = input().split(" ")
        card.suit = _input[0]
        card.value = int(_input[1])
        A.append(card)
    
    ind = dict((e, i) for i, e in enumerate(A))
    quickSort(A, 0, n-1)
    
    for i in range(n - 1):
        if A[i].value == A[i + 1].value:
            if ind[A[i]] > ind[A[i + 1]]:
                print('Not stable')
                break
    else:
        print('Stable')
    
    for i in range(n):
        print(A[i].suit, A[i].value)
             
if __name__ == "__main__":
    main()


Measured memory_bytes: 36704
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int[] hight_list = new int[10];

        for(int i = 0; i < 10; i++){
            hight_list[i] = sc.nextInt();
        }

        Arrays.sort(hight_list);

        for(int i = 9; i > 6; i--){
            System.out.println(hight_list[i]);
        }

    }
}

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

int main(){

  int a[101] = {};

  for(int i = 0; i < 12; i++){
    int e;
    cin >> e;

    a[e]++;
  }

  int count = 0;

  for(int i = 1; i < 101; i++){
    if(a[i] == 4)count++;
  }

  cout << (count==3 ? "yes" : "no") << endl;

  return 0;
}
*/

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

int main(){

  vector<int> V;
  vector<int>::iterator p = V.begin();

  for(int i = 0; i < 12; i++){
    int e;
    cin >> e;
    V.push_back(e);
  }

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

  //cout << V[1] << " " << V[4] << endl;
  //cout << *p+1 << endl;//error why
  cout << ((V[0]==V[3]&&V[4]==V[7]&&V[8]==V[11])?"yes":"no") << endl;
  return 0;
}



Measured memory_bytes: 3144
i=61,c,f[],m,x,s;main(y){for(;s?++f[y*12+x+"=>?2J13IK<@V&"[--s]]:~scanf("%d,%d,%d",&x,&y,&s)?s=s*4+1:++i<180?i%12>1?m=fmax(m,f[i]),f[i]?1:++c:1:!printf("%d\n%d\n",c,m););}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }

  bool flag = false;
  for (int i = 0; i < n; i++) {
    if (i + 2 >= n) break;
    if (a[i] == b[i] and a[i + 1] == b[i + 1] and a[i + 2] == b[i + 2]) flag = true;
  }

  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3160
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    total = 0
    p = 0
    for a in A:
        total += abs(p-a)
        p = a
    total += abs(p)
    
    print(total - abs(A[0]) - abs(A[0]-A[1]) + abs(A[1]))
    for n in range(1,N-1):
        print(total - abs(A[n-1]-A[n]) - abs(A[n]-A[n+1]) + abs(A[n-1]-A[n+1]))
    print(total - abs(A[N-2]-A[N-1]) - abs(A[N-1]) + abs(A[N-2]))


if __name__ == '__main__':
    solve()

Measured memory_bytes: 14176
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}

int n,m;
vector<vector<int>> to;

signed main(){
	int k;cin>>k;
	int n=50;
	cout<<n<<endl;
	vector<int> a(n);
	rep(i,n) a[i]=i;
	int f=k/n;
	rep(i,n) a[i]+=f;
	int s=k%n;
	rep(i,s) a[i]+=n-s+1;
	rep(i,s,n) a[i]-=s;
	rep(i,n) cout<<a[i]<<" \n"[i==n-1];
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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 ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int a,b,c;cin>>a>>b>>c;
  if(a <= c && a+b >= c)print("YES");
  else print("NO");
  return 0;
}


Measured memory_bytes: 256
//订正中 
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<=s.size()-1;i++){
		string t=s;
		t.erase(i,s.size()-7);
		if(t=="keyence"){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
const char ss[]="CODEFESTIVAL2016";

int main()
{
  char s[20];
  scanf("%s",s);
  int tot=0;
  for(int i=0;i!=16;++i)
    if(s[i]!=ss[i])
      ++tot;
  printf("%d\n",tot);
}


Measured memory_bytes: 128
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    char al; cin >> al;
    if((int)('a') <= (int)al and (int)al <= (int)('z')) cout << "a" << endl;
    else cout << "A" << endl;
    return 0;
}


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

int main(){
    string s;
    char ans='1';
    long long K;
    cin >> s;
    cin >> K;
    if(K>=100)
	K=100;
    for(int i=0; i<min((int)s.size(), (int)K); i++){
	if(s[i] != '1'){
	    ans = s[i];
	    break;
	}
    }

    
    
    cout << ans <<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           ((ll)x.size())
#define hell            (1000000007)
#define inf             ((ll)5e18 + 5)
#define PI              ((double)3.14159265358979323844)
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll x, k, d;
    cin>>x>>k>>d;
    x=abs(x);
    if (log(k)+log(d)<log(x)) {
        x-=(k*d);
        cout<<x<<endl;return;
    }
    ll meow=x%d;
    ll meow2=d-meow;
    ll n1=(x-meow)/d;
    if (meow<meow2) {
        ll xxx=k-n1;
        if (xxx%2) {
            cout<<meow2<<endl;
            return;
        }
        else {
            cout<<meow<<endl;
            return;
        }
    }
    n1++;
    ll xxx=k-n1;
    if (xxx%2) {
        cout<<meow<<endl;
        return;
    }
    cout<<meow2<<endl;

}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 3848
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int b = sc.nextInt();
        int a = sc.nextInt();
        sc.nextLine();
        List<String> list = new ArrayList<String>();
        for(int i = 0;i<b;i++){
            list.add(sc.nextLine());
        }
        Collections.sort(list);
        list.forEach(System.out::print);
    }
}

Measured memory_bytes: 26580
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		long N = stdIn.nextLong();
		long X = stdIn.nextLong();
		
		long ans = N;
		
		if(N - X < X){
			ans += square(N - X, X);
		} else{
			ans += square(X, N - X);
		}
		
		System.out.println(ans);
	}
	
	private static long square(long S, long L){
		
		long Q = L/S;
		long R = L%S;
		
		if(R == 0){
			return S*(2*Q - 1);
		} else{
			return S*(2*Q) + square(R, S);
		}
	}
}

Measured memory_bytes: 8788
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int n,x;
    cin>>n;
    vector <int> arr(n+1,0);
    for(int i =0;i<n-1;i++)
    {
        cin>>x;
        arr[x]++;
    }
    for(int i =1;i<n+1;i++)
    {
        cout<<arr[i]<<"\n";
    }
    return 0;
}

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

const int MAXN = 100005;
int dp[MAXN];
int h[MAXN];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> h[i];
    dp[0] = 0;
    for (int i = 1; i < n; i++)
        dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1],
                    i >= 2 ? (abs(h[i] - h[i-2]) + dp[i-2]) : 2000000000);
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
    int aiHeight[10];
    int iSwapTmp;
    int iCnt1, iCnt2;

    // 入力：山の高さ(10個)
    for(iCnt1=0; iCnt1<10; iCnt1++)
    {
        scanf("%d", &aiHeight[iCnt1]);
    }

    // 処理：並べ替え
    for(iCnt1=0; iCnt1<10; iCnt1++)
    {
        for(iCnt2=0; iCnt2<10-1-iCnt1; iCnt2++)
        {
            if(aiHeight[iCnt2] < aiHeight[iCnt2+1])
            {
                iSwapTmp = aiHeight[iCnt2];
                aiHeight[iCnt2] = aiHeight[iCnt2+1];
                aiHeight[iCnt2+1] = iSwapTmp;
            }
        }
    }

    // 出力：標高高い順に3個
    for(iCnt1=0; iCnt1<3; iCnt1++)
    {
        printf("%d\n", aiHeight[iCnt1]);
    }

    return(0);
}


Measured memory_bytes: 2100
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

const int maxn = 1e5 + 5;

int a[maxn];

typedef long long LL;
LL suf[maxn], suf1[maxn];
int n;
int op[maxn];
int nxt[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    string s;
    for(int i = 1;i <= n;i++){
        if(i != 1){
            cin >> s;
            if(s[0] == '-'){
                op[i] = 0;
            }else{
                op[i] = 1;
            }
        }
        cin >> a[i];
    }
    op[1] = 1;
    suf[n + 1] = 0;
    suf1[n + 1] = 0;
    for(int i = n;i >= 1;i--){
        suf[i] = suf[i + 1] + a[i];
        if(op[i] == 0)
            suf1[i] = suf1[i + 1] - a[i];
        else
            suf1[i] = suf1[i + 1] + a[i];
        //cout << suf[i] << " " << suf1[i] << endl;
    }
    int j = n + 1;
    for(int i = n;i >= 1;i--){ nxt[i] = j;
        if(op[i] == 0){
            j = i;
        }
    }
    long long ans = 0;
    for(int i = 1;i <= n;i++){
        if(op[i] == 1)
            ans += a[i];
        else
            ans -= a[i];
    }
    for(int i = 1;i <= n;i++){
        if(op[i] == 1)
            continue;
        long long tmp = suf1[1] - suf1[i + 1];
        long long tmp1 = suf1[i + 1] - suf1[nxt[i]];
        long long tmp2 = suf[nxt[i]];
        ans = max(ans, tmp - tmp1 + tmp2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2944
D = int(input())
c = list(map(int, input().split()))
sdi = [list(map(int, input().split())) for i in range(D)]

lastdi = [0 for i in range(26)]
ans_c = []
for d in range(D):
  
  day_s = sdi[d]
  
  sloss = [day_s[i] + c[i]*(d - lastdi[i]) for i in range(26) ]
  ans = sloss.index(max(sloss))
  ans_c.append( ans+1 )
  
  lastdi[ans] = d

for i in range(D):
  print(ans_c[i])


Measured memory_bytes: 9232
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

d,g = LI()
pc = [LI() for _ in range(d)]
ans = inf
for i in range(2**d):
    b = [0]*d
    for j in range(d):
        if (i >> j) & 1:
            b[j] = 1
    tmp = 0
    cnt = 0
    for j in range(d):
        if b[j]:
            tmp += pc[j][0]*(j+1)*100 + pc[j][1]
            cnt += pc[j][0]
    if tmp >= g:
        ans = min(ans,cnt)
        continue
    tmp2 = 0
    for j in range(d):
        if not b[j]:
            tmp2 = max(tmp2,j)
    x,y = divmod((g-tmp),(tmp2+1)*100)
    if x > pc[tmp2][0]:
        continue
    cnt += x + (y != 0)
    ans = min(ans,cnt)
print(ans)


Measured memory_bytes: 43504
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var constants = ReadInts();
        var N = constants[0];
        var M = constants[1];

        var A = new long[N];
        var B = new long[N];

        for (var i = 0; i < N; i++)
        {
            var inputs = ReadLongs();
            A[i] = inputs[0];
            B[i] = inputs[1];
        }

        var pair = A.Zip(B, (a, b) => Tuple.Create(a, b)).OrderBy(_ => _.Item1);
        long ans = 0;
        var remain = M;

        foreach (var p in pair)
        {
            if (remain <= p.Item2) { ans += remain * p.Item1; break; }
            else { ans += p.Item1 * p.Item2; remain -= (int)p.Item2; }
        }

        Console.WriteLine(ans);
    }

    public static string Read() { return Console.ReadLine(); }
    public static int ReadInt() { return int.Parse(Read()); }
    public static long ReadLong() { return long.Parse(Read()); }
    public static double ReadDouble() { return double.Parse(Read()); }

    public static string[] Reads() { return Console.ReadLine().Split(' '); }
    public static int[] ReadInts() { return Reads().Select(_ => int.Parse(_)).ToArray(); }
    public static long[] ReadLongs() { return Reads().Select(_ => long.Parse(_)).ToArray(); }
    public static double[] ReadDoubles() { return Reads().Select(_ => double.Parse(_)).ToArray(); }
}


Measured memory_bytes: 23216
#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 <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 <regex>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int mod = 1e+7;

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

  Real a, b;
  cin >> a >> b;
  cout << (Bint)(a*b) << endl;
  return 0;
}

Measured memory_bytes: 3912
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
public static void main(String[] args){
Scanner s = new Scanner(System.in);
  int a = s.nextInt();
  int b = s.nextInt();
  int c = s.nextInt();

  
  
  if((a>c && b<c) ||(b>c && a<c)){
  System.out.print("Yes");
  }
  else{
  System.out.print("No");
  }
}
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  ll A[N]; rep(i,N) cin >> A[i]; sort(A,A+N);
  ll sum[N] = {}; rep(i,N) sum[i] = i==0 ? A[i]  : sum[i-1]+A[i];
  // debug(A,A+N); debug(sum,sum+N);

  int result = 1; while(sum[(N-1)-result]*2>=A[N-result]&&result<N) result++;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1792
def ask?(i)
  puts i
  $stdout.flush
  gets[0].to_sym
end

N = gets.to_i
A = Array.new(N + 1)

A[0] = A[N] = ask?(0)
exit if A[0] == :V

l = 0
r = N

20.times do 
  m = (l + r) / 2
  A[m] = ask?(m)
  exit if A[m] == :V
  
  if (l - m).even? ^ (A[l] != A[m])
    l = m 
  else
    r = m
  end
end


Measured memory_bytes: 5196
// Odds of Oddness
#include <stdio.h>

int main(void){
    int n, i, cnt=0;
    scanf("%d", &n);
    for (i = 1; i <= n; i++){
        if(i%2==1){
            cnt++;
        }
    }
    double odd = (double)cnt / n;
    printf("%f\n", odd);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.SortedMap;
import java.util.TreeMap;

public class Main {
 public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	while (in.hasNext()) {
	 String[] line = in.next().split(",");
	 SortedMap<Integer, Integer> cards = new TreeMap<Integer, Integer>();
	 for (String s : line) {
		Integer key = Integer.valueOf(s);
		int count = 1;
		if (cards.containsKey(key)) {
		 count += cards.get(key).intValue();
		}
		cards.put(key, Integer.valueOf(count));
	 }
	 if (cards.containsValue(Integer.valueOf(4))) {
		System.out.println("four card");
	 } else {
		boolean hasThree =
		  (cards.containsValue(Integer.valueOf(3)));
		boolean hasPeir =
		  (cards.containsValue(Integer.valueOf(2)));
		if (hasThree) {
		 System.out.println(
			 (hasPeir) ? "full house" : "three card");
		} else if (hasPeir) {
		 System.out.println(
			 (cards.keySet().size() == 3) ?
			   "two pair" : "one pair");
		} else {
		 int firstKey = cards.firstKey().intValue();
		 int lastKey = cards.lastKey().intValue();
		 if (lastKey - firstKey == 4 ||
			 (firstKey == 1 && cards.tailMap(10).size() == 4)) {
			System.out.println("straight");
		 } else {
			System.out.println("null");
		 }
		}
	 }
	}
 }
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)

/*
*/

bool ok=true;
ll n,h[100010];

void init(){
	cin>>n;
	h[0]=-99999;
	reg(i,1,n)cin>>h[i];
}

int main(void){
	init();
	reg(i,1,n-1){
		if(h[i-1]>=h[i]){
			//
		}else{
			h[i]--;
		}
	}
	reg(i,1,n){
		if(h[i-1]>h[i]){
			ok=false;
		}
	}
	cout<<(ok?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 1024
import sys
from fractions import gcd
input = sys.stdin.readline

class DisjointSparseTable:
    def __init__(self, a):
        self.level = (len(a) - 1).bit_length()
        self.size = 2**self.level
        self.table = [[0] * self.size for _ in range(self.level)]
        # Set bottom first
        for i, item in enumerate(a): 
            self.table[-1][i] = item
        self.build()

    def build(self):
        for lv in range(1, self.level):
            step = 2**lv
            level = self.level - 1 - lv
            for mid in range(step, self.size, step*2):
                # Calc forward
                val = 0
                for i in range(step):
                    val = gcd(self.table[-1][mid + i], val)
                    self.table[level][mid + i] = val
                # Calc backward
                val = 0
                for i in range(step):
                    val = gcd(self.table[-1][mid - 1 - i], val)
                    self.table[level][mid - 1 - i] = val
    
    # Returns f[l:r)
    def query(self, l, r):
        if l == r:
            return 0
        elif l == r - 1:
            return self.table[-1][l]
        level = self.level - (l ^ r-1).bit_length()
        return gcd(self.table[level][l], self.table[level][r-1])

if __name__ == "__main__":
    n = int(input())
    a = [int(item) for item in input().split()]
    DST = DisjointSparseTable(a)
    ans = 0
    for i in range(0, n):
        ans = max(ans, gcd(DST.query(0, i), DST.query(i+1, n)))
    print(ans)

Measured memory_bytes: 30488
#!/usr/bin/env python3
import sys, math, fractions, itertools


def eratosthenes_sieve(n: int):
    """
    エラトステネスの篩を用いてn以下の素数を求める
    """
    table = [0] * (n + 1)
    prime_list = []
    
    for i in range(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in range(i + i, n + 1, i):
                table[j] = 1
    
    return prime_list

def solve(N: int):
    L = eratosthenes_sieve(55555)
    S = []
    for l in L:
        if l % 5 == 1:
            S.append(l)
    print(' '.join([str(l) for l in S[:N]]))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5844
def main():
    S = input()

    check = []
    for i in ["A", ""]:
        for j in ["A", ""]:
            for k in ["A", ""]:
                for l in ["A", ""]:
                    check.append(i + "KIH" + j + "B" + k + "R" + l)

    for C in check:
        if C == S:
            print("YES")
            exit()

    print("NO")
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import itertools

def checker(data, h, w, k, h_ax, w_ax):
  flag = {i: {j: 0 for j in range(w)} for i in range(h)}
  for i in h_ax:
    for j in range(w):
      flag[i][j] = 1
  for i in w_ax:
    for j in range(h):
      flag[j][i] = 1
  c = 0
  for i in range(h):
    for j in range(w):
      if data[i][j] == "#" and flag[i][j] == 0:
        c += 1
  if c == k:
    return True
  else:
    return False

h, w, k = map(int, input().split())
data = [input() for _ in range(h)]

counter = 0
for i in range(h):
  for j in range(w):
    for h_ax in itertools.combinations(range(h), i):
      for w_ax in itertools.combinations(range(w), j):
        if checker(data, h, w, k, h_ax, w_ax):
          counter += 1

print(counter)

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
int n;
void count2(int n)
{
	int cnt = 0;
	while(n)
	{
		int x = n % 10;
		if(x == 2) cnt++;
		n /= 10;
	}
	cout << cnt << endl;
}
int main()
{
	cin >> n;
	count2(n);
	return 0;
}


Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val (a,b,x) =  readLine()!!.split(" ").map { it.toLong() }
    val min = (a / x + (if(a%x == 0L) 0 else 1)) * x
    if(min > b) {
        println(0)
        return
    }
    val max = b - (b % x)
    val ans = (max-min)/x + 1
    println(ans)


}

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

ll n, k;
ll min1, min2;
ll ans;

int main() {
  cin >> n >> k;
  min1 = n % k;
  min2 = abs(n % k - k);
  ans = min(min1, min2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()

a = 0
for i in range(n):
    d,dd = na()
    if d == dd:
        a += 1
    else:
        a = 0
    if a >= 3:
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
int main(){
    int K,l;
    string S;
    cin >> K >> S;
    l = S.size();
    if(l<=K)cout << S << endl;
    else {
        S = S.erase(K) + "...";
        cout << S << endl;
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    for(int i=1;i<=b;i++){
        if(a*i%b==c){
            cout<<"YES"<<endl;
            ans=1;
            break;
        }
    }
    if(ans==0){
        cout<<"NO"<<endl;
    }
    return 0;
}


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

int main(){
  int R,G,B,N;
  int count = 0;
  
  cin >> R >> G >> B >> N;
  
  for(int r=0; r <= N; r++){
    for(int g=0; g <= N; g++){
      if(N - r * R - g * G < 0)
        continue;
      if((N - r * R - g * G) % B == 0){
        count++;
        continue;
      }
    }
  }

  cout << count << endl;

}








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

using namespace std;

int main()
{
    long long N;
    
    cin >> N;
    
    string s;

    cin >> s;
    
    long long c=0;

    for(long long i = 0;i<N;++i)
    {
        if(s[i] == 'R')
        {
            c++;
        }
    }

    if(c > (N-c))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;    
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int L = s.length();
        String A = s.substring(0, L/2);
        String A2 = s.substring(((L+3)/2)-1, L);
        if(A.equals(A2)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35608
#include<cstdio>
#include<cmath>
#include<algorithm>
#define MAXN 200+5

typedef long long ll;

const int INF=0x7fffffff;

using namespace std;


int main() {
	int n;
	scanf("%d",&n);
	int sum=0,t=n;
	while(n!=0){
		sum+=n%10;
		n/=10;
	}
	if(t%sum==0){
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); ++i)
  {
    if (s[i] == '7')
    {
      cout << "Yes";
      exit(0);
    }
  }
  cout << "No" ;

}


Measured memory_bytes: 3648
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#endif

const double PI = 3.1415926535897932384626433;
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
	cinll(a);
	cinll(b);

	int g = __gcd(a, b);
	ll ans = a * b / g;
	cout << ans << endl;
}

int main() {
	cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	solve();
}



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

#define pb push_back
#define fr first
#define sc second
typedef pair<int,int> pii;
typedef vector<int> vi;
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
  int a,b;
  while(scanf("%d %d",&a,&b) != EOF){
    int c=a+b;
    int cnt=0;
    while(c/10>0){
      c/=10;
      cnt++;
    }
    cout<< cnt+1<< endl;
  }
}

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

void solve(long long N, long long M, std::vector<pair<ll, ll>> s,
           std::vector<tuple<ll, ll, int>> c) {
    sort(c.begin(), c.end());
    for (int i = 0; i < N; i++) {
	ll minDist = numeric_limits<ll>::max();
	ll res = -1;
	for (int j = 0; j < c.size(); j++) {
	    auto curr = c[j];
	    ll dist = abs(s[i].first - get<0>(curr)) + abs(s[i].second - get<1>(curr));
            if (dist < minDist) {
		minDist = dist;
		res = get<2>(curr);
            }
        }
	cout << res << endl;
    }
}

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

  std::vector<pair<ll, ll>> s(N);
  for (int i = 0; i < N; i++) {
      ll a, b;
      cin >> a >> b;
      s[i] = {a, b};
  }
  
  std::vector<tuple<ll, ll, int>> c(M);
  for (int i = 0; i < M; i++) {
      ll a, b;
      cin >> a >> b;
      c[i] = make_tuple(a, b, i+1);
  }

  solve(N, M, std::move(s), std::move(c));
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8

N, M = map(int, input().split())
L_R = [tuple(map(int, input().split())) for _ in range(M)]

l, r = 0, N
for l_r in L_R:
    if l < l_r[0]:
        l = l_r[0]
    if l_r[1] < r:
        r = l_r[1]

print(max(r - l + 1, 0))


Measured memory_bytes: 16620
//
//  main.cpp
//  T2020B
//
//  Created by TakahiroUryu on 2020/06/15.
//  Copyright © 2020 TakahiroUryu. All rights reserved.
//

#include <iostream>
using namespace std;
using ll=long long;
int main(int argc, const char * argv[]) {
    ll a,v,b,w,t;
    bool ok=true;
    cin>>a>>v>>b>>w>>t;
    if (w>=v) {
        ok=false;
    } else {
        ll d=abs(a-b);
        ll s=v-w;
        if (d>s*t) {
            ok=false;
        }
    }
    if(ok){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <queue>
using namespace std;
typedef pair<int,int> P;
int H,W;
int A[100][100],dist[100][100] = {};
int dx[4] = {-2,2,0,0},dy[4] = {0,0,-2,2};

bool in(int x,int y){
	return 1<=x && x<=2*H-1 && 1<=y && y<=2*W-1;
}

int main(){
	while(cin >> W >> H && W>0){
		for(int i=1;i<=2*H-1;i++){
			for(int j=1;j<=2*W-1;j++){
				A[i][j] = -1;
				dist[i][j] = -1;
			}
		}
		for(int i=1;i<=2*H-1;i++){
			if(i%2==1){
				for(int j=1;j<=W-1;j++) cin >> A[i][2*j];
			}else{
				for(int j=1;j<=W;j++) cin >> A[i][2*j-1];
			}
		}
		dist[1][1] = 1;
		queue<P> Q;
		Q.push(P(1,1));
		while(!Q.empty()){
			P p = Q.front(); Q.pop();
			int x = p.first,y = p.second;
			for(int i=0;i<4;i++){
				int nx = x+dx[i],ny = y+dy[i];
				if(in(nx,ny) && A[x+dx[i]/2][y+dy[i]/2]==0 && dist[nx][ny]==-1){
					dist[nx][ny] = dist[x][y]+1;
					Q.push(P(nx,ny));
				}
			}
		}
		cout << (dist[2*H-1][2*W-1]!=-1? dist[2*H-1][2*W-1]:0) << endl;
	}
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string a;
    cin >> a;

    int sum = 0;
    for(int i=0; i<a.length(); i++){
        sum += (a[i] - '0');
    }

    if(sum%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
   
    return 0;
}


Measured memory_bytes: 3736
#include <cstdio>
#include <fstream>
#include <vector>

using namespace std;

struct linSearch {
	vector <int> list;
	vector <int> findThis;
	int size = 0;
	int size2 = 0;
	int counter = 0;
	linSearch(int Size, vector <int> List, int Size2, vector <int> FindThis){
		size = Size;
		list = List;
		size2 = Size2;
		findThis = FindThis;
		search();
	}
	void search() {
		for (int i = 0; i < size2; i++) {
			for (int j = 0; j < size; j++) {
				if (findThis[i] == list[j]) {
					counter++;
					break;
				}
			}
		}
		printf("%d\n", counter);
	}
};

int main() {
	char oinput[20000];
	int size = 0;
	int size2 = 0;
	int num = 0;
	
	scanf("%d%*c", &size);
	vector<int> list(size);
	for (int i = 0; i < size; i++) {
		scanf("%d", &list[i]);
	}
	scanf("%d%*c", &size2);
	vector <int> findThis(size2);
	for (int i = 0; i < size2; i++) {
		scanf("%d", &findThis[i]);
	}
	linSearch* l = new linSearch(size, list, size2, findThis);
}



Measured memory_bytes: 2840
#include <cstdio>

using namespace std;

long long ans = 0;
long long n,k;

const long long MOD = 1000000007;
long long pow(long long b,long long p){
    long long ret = 1;
    long long cur = b;
    while (p){
        if (p % 2 == 1){
            ret *= cur;
            ret %= MOD;
        }
        cur *= cur;
        cur %= MOD;
        p /= 2;
    }
    return ret;
}

long long a[100005];
long long cnt[100005];
int main(){
    scanf("%lld %lld", &n,&k);

    for (int i = k; i >= 1; i--){
        long long cur = 0;
        // long long cur_cnt = 0;
        long long num = 1;
        for (int j = 2*i; j <= k; j+= i){
            num ++;
            cur = (cur + MOD - a[j]) % MOD;
        }
        cur = (cur + pow(num,n)) % MOD;

        a[i] = cur;
        ans = (ans + i*cur) % MOD;
    }
    printf("%lld", ans);
}

Measured memory_bytes: 2508
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int X,Y,Z,K;
    cin>>X>>Y>>Z>>K;
    vint a(X),b(Y),c(Z);
    REP(i,X) cin>>a[i];
    REP(i,Y) cin>>b[i];
    REP(i,Z) cin>>c[i];

    vint ab;
    REP(i,X) REP(j,Y) ab.push_back(a[i]+b[j]);
    sort(ALL(ab),greater<int>());

    vint abc;
    REP(i,min(SZ(ab),K)) REP(j,Z){
        abc.push_back(ab[i]+c[j]);
    }
    sort(ALL(abc),greater<int>());
    REP(i,K) cout<<abc[i]<<endl;
}


Measured memory_bytes: 43240