akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ll;


using Graph = vector<vector<int>>;//グラフ型
void dfs(const Graph& G, int v/*根*/, vector<bool>& seen) {
	seen[v] = true;  //vを訪問済にする
	for (auto next_v : G[v]) { //訪問済にしたvとつながっている場所を順番に探す
		if (seen[next_v]) continue; //もし探索済みならスルー
		dfs(G, next_v, seen); //再帰的に探索
	}
}

void bfs(const Graph& G, queue<int>& que/*発見したが訪問はしていない*/, vector<int>& dist/*開始地点からの距離*/) {

	while (!que.empty()) {
		int v = que.front();//queのうち先頭のものからスタート
		que.pop();//先頭を削除

		for (int nv : G[v]) {//vとつながっている点を列挙
			if (dist[nv] != -1) continue;//発見済(=距離が格納されている)であればスルー
			dist[nv] = dist[v] + 1;//vとつながっている点に距離の情報を追加
			que.push(nv);//vとつながっている点を発見済にする
		}
	}
}

template<typename T>
T gcd(T a, T b) {
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}

template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}


template<typename T>
bool same(T x_b, T x_e, T y_b, T y_e) {
	for (auto i = x_b, j = y_b; i != x_e && j != y_e; ++i, ++j) {
		if (*i != *j) {
			return false;
		}
	}
	return true;
}

int main(void) {
	ll n, m, all = 0;
	cin >> n >> m;
	vector<int>a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		all += a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	if (a[m - 1] >= double(all / double(4 * m))) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

/*
*/


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
}
pair<int,int> a[214514];
int b[214514];
int c[214514];
int ans[214514];
int iti[214514];
signed main(){
	ic(n)
	rep(0,i,n)cin>>a[i].f;
	rep(0,i,n)a[i].s=i;
	sort(a,a+n);
	int sum=0;
	b[0]=-1;
	rep(0,i,n-1){
		if(a[i].f!=a[i+1].f){
			sum++;
			b[sum]=i;
		}
	}
	b[sum+1]=n-1;
	rep(0,i,sum+1)c[i]=b[i+1]-b[i];
	int souwa=0;
	rep(0,i,sum+1)souwa+=sankaku(c[i]-1);
	int cnt=0;
	rep(0,i,sum+1){
		rep(cnt,j,cnt+c[i]){
			iti[j]=c[i];
		}
		cnt+=c[i];
	}	
	rep(0,i,n)ans[a[i].s]=souwa-iti[i]+1;
	rep(0,i,n)c(ans[i])	
}	


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

int N, T;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> T;
	int prv = 0;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int t; cin >> t;
		ans += min(t - prv, T);
		prv = t;
	}
	ans += T;
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define rp(i,n) for(long long i=1;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 1000000007;
vel rui(19, 1);
vel kai(1000007, 1);
vel ink(1000007, 1);
vel par;
int root(int ser) {
	if (par[ser] == -1) { return ser; }
	int ans = root(par[ser]);
	par[ser] = ans;
	return ans;
}
bool marge(pin a) {
	int x = root(a.first);
	int y = root(a.second);
	if (x != y) {par[x] = y;}
	return x != y;
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	if (b == 0) { return a; }
	return gcd(b, a%b);
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; ans %= p; }
	return ans;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 1000006) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 1000007) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p;
	return ans;
}
signed main() {
	int k, n; cin >> n>>k;
	if (k == 1) { cout << 0 << endl; return 0; }
	cout << n - k << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  string S;
  cin >> S;
  
  
  int ans = 0;
  
  for (int i = 0; i < S.size(); i++) {
    int count = 0;
    bool left,right;

    for (char c = 'a'; c <= 'z'; c++) {
      left = false;
      right = false;
      
      for (int j = 0; j < i; j++) {
        if (S.at(j) == c) left = true;
      }
      for (int j = i; j < S.size(); j++) {
        if (S.at(j) == c) right = true;
      }
      
      if (left && right) count++;
    }
    
    if (count > ans) ans = count;
  }
   
  cout << ans << endl;
}

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



 int main()
{
	int x,n;
	cin>>x>>n;
	vector<int> take(102,0);
	
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		take[a]++;
	}
	int i=x;
	int j=x;
	while(true){
		if(take[j]==0){
			cout<<j;
			return 0;
		}
		if(take[i]==0){
			cout<<i;
			return 0;
		}
		i++;
		j--;
	}
	
}


Measured memory_bytes: 3628
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


class UnionFind:
    def __init__(self,n):
        self.par = [i for i in range(n+1)]  # 親のノード番号
        self.rank = [0]*(n+1)
    def find(self,x):  # xの根のノード番号
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def same_check(self,x,y):  # x,yが同じグループか否か
        return self.find(x) == self.find(y)
    def unite(self,x,y):  # x,yの属するグループの併合
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            x,y = y,x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        self.par[y] = x


N,M = MI()
edges = [tuple(MI()) for _ in range(M)]

ans = 0
for i in range(M):
    U = UnionFind(N)
    for j in range(M):
        if j != i:
            a,b = edges[j]
            U.unite(a,b)
    x,y = edges[i]
    if not U.same_check(x,y):
        ans += 1

print(ans)


Measured memory_bytes: 73820
N, K = map(int, input().split())
p = list(map(int, input().split()))

def get_e(p):
    return p*(p+1)/2/p

e_list = [get_e(p[i]) for i in range(N)]
c_e_list = [0 for i in range(N)]
c_e_list[0] = e_list[0]
for i in range(1, N):
    c_e_list[i] = c_e_list[i-1] + e_list[i]

max_e = c_e_list[K-1]
for i in range(1, N-K+1):
    e = c_e_list[i+K-1] - c_e_list[i-1]
    if e > max_e:
        max_e = e

print(max_e)

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	ll N, A, B; cin >> N >> A >> B;

	ll ans = N/(A+B)*A + min(N%(A+B), A);

	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

long long as[200001];
int indices[200001];

int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", as + i);
  }

  int isLeft = 1;
  int leftIdx = 0;
  int rightIdx = N - 1;
  for (int i = N - 1; i >= 0; i--) {
    if (isLeft == 1) {
      indices[leftIdx] = i;
      leftIdx++;
      isLeft = 0;
    } else {
      indices[rightIdx] = i;
      rightIdx--;
      isLeft = 1;
    }
  }

  for (int i = 0; i < N; i++) {
    if (i != 0) printf(" ");
    printf("%lld", as[indices[i]]);
  }
  printf("\n");

  return 0;
}


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

int main() {
    int k;
    cin >> k;
    vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << vec[k-1] << endl;
    return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define INPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in"
#define OUTPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

set<char> s;
void solve()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        char c;
        cin >> c;
        s.insert(c);
    }
    int m = (int) s.size();
    if(m == 1)
        cout << "One";
    else if(m == 2)
        cout << "Two";
    else if(m == 3)
        cout << "Three";
    else
        cout << "Four";
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    //freopen(INPUT, "r", stdin);freopen(OUTPUT, "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}



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

int main(){
    int m, f, r;
    char score;
    for (int i = 0; i < 50; i++){
        cin >> m >> f >> r;
        if (m == -1 && f == -1) break;
        if (m == -1 || f == -1) {
            score = 'F';
            cout << score << endl;
            continue;
        }
        if (m + f >= 80) score = 'A';
        else if (m + f >= 65) score = 'B';
        else if (m + f >= 50) score = 'C';
        else if (m + f >= 30){
            if (r >= 50) score = 'C';
            else score = 'D';
        }
        else score = 'F';
        cout << score << endl;
    }
}


Measured memory_bytes: 3108
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void){

    int n;
    
   cin >> n;
    
    if (n % 1000 == 0) {
        cout << 0;
    } else {
        
        cout << 1000 - (n % 1000);
    }
}

Measured memory_bytes: 3548
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in); 
    int n  = sc.nextInt();
    
    int b = 0;
    int c = 0;
    int d = 0;
    int e = 0;

    
    for(int i = 0; i < n; i++)
    {
      String str = sc.next();
      if(str.equals("AC"))
          b++;
      if(str.equals("WA"))
    		  {
          c++;
    		  }
      if(str.equals("TLE"))
          d++;
      if(str.equals("RE"))
          e++;
    }
    System.out.println("AC x "+b);
    System.out.println("WA x "+c);
    System.out.println("TLE x "+d);
    System.out.println("RE x "+e);
  }
}                          


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

int main() {
	string s[3];
	for (int i = 0; i < 3; i++)
		cin >> s[i];
	int i = 0;
	for (;;) {
		string& str = s[i];
		if (str.size() == 0) {
			cout << char('A' + i) << endl;
			return 0;
		}
		i = str[0] - 'a';
		str.erase(0, 1);
	}
}

Measured memory_bytes: 256
def medians(lst):
    if len(lst) == 1:
        return lst[0]
      
    last = lst.pop()
    second = lst.pop()
    lst.append((last + second) / 2)
    return medians(lst)


N = int(input())
v = list(map(int, input().split()))

v.sort(reverse=True)
print(medians(v))

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

int main() {
	int arr[5];
	int k;
	for(int i = 0; i < 5; i++) cin >> arr[i];
	cin >> k;
	for(int i = 0; i < 5; i++) {
		for(int j = i+1; j < 5; j++) {
			if(abs(arr[i]-arr[j])>k) {
				cout << ":(" << endl;
				return 0;
			}
		}
	}
	cout << "Yay!" << endl;
	return 0;
}


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

int main(){
  int n, a, b;
  std::cin >> n >> a >> b;
  int c = n * a;
  if(c >= b){
    std::cout << b<< '\n';
  }
  else{
    std::cout << c << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#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 ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

// A binary search function to return 
// the number of elements less than 
// or equal to the given key 
int binarySearchCount(long long int arr[], int n, long long int key) 
{ 
	int left = 0; 
	int right = n - 1; 

	int count = 0; 

	while (left <= right) { 
		int mid = (right + left) / 2; 

		// Check if middle element is 
		// less than or equal to key 
		if (arr[mid] <= key) { 

			// At least (mid + 1) elements are there 
			// whose values are less than 
			// or equal to key 
			count = mid + 1; 
			left = mid + 1; 
		} 

		// If key is smaller, ignore right half 
		else
			right = mid - 1; 
	} 

	return count; 
} 


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    long long int k;
    cin>>n>>m>>k;
    long long int a[n];
    for (int i=0;i<n;i++) cin>>a[i];
    long long int b[m];
    for (int i=0;i<m;i++) cin>>b[i];
    long long int prefix1[n+1];
    prefix1[0]=0;
    for (int i=1;i<=n;i++) prefix1[i]=prefix1[i-1]+a[i-1];
    long long int prefix2[m+1];
    prefix2[0]=0;
    for (int i=1;i<=m;i++) prefix2[i]=prefix2[i-1]+b[i-1];
    int ans=0;
    for (int i=0;i<=n;i++){
        if(prefix1[i]<=k){
            int temp=binarySearchCount(prefix2,m+1,k-prefix1[i]);
            ans=max(ans,i+temp-1);
        }    
    }
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 9900
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define inf 1000000000000000000
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}


//edge cases when n=1,m=1.wrong variable in loop.if<->while;merge resize;LLONG_MAX
signed main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //#endif
    speed
    //global var
    int h,w,m;cin>>h>>w>>m;
    map<pair<int,int> ,bool> mp;
    map<int,int> row, col;
    set<int> r,c;
    int maxr=0,maxc=0;
    for(int i=0;i<m;++i){
        int hi,wi;cin>>hi>>wi;
        mp[{hi,wi}]=true;
        ++row[hi];
        maxr=max(maxr,row[hi]);
        r.insert(hi);
        ++col[wi];
        maxc=max(maxc,col[wi]);
        c.insert(wi);
    }
    
    vector<int> rlist,clist;
    for(auto it:r){
        if(row[it]==maxr){rlist.push_back(it);}
    }
    for(auto it:c){
        if(col[it]==maxc){clist.push_back(it);}
    }
    
    int ans=maxr+maxc-1;
    bool brk=false;
    for(int it:rlist){
        for(int pp:clist){
            if(mp[{it,pp}]==false){
                ++ans;brk=true;break;
            }
        }
        if(brk){break;}
    }
    cout<<ans<<"\n";
    
}
//try thinking from a different angle after spending some time


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

int main() {
	int n;
	cin >> n;
	vector <int> v(n);
	vector <int> c(n);
	vector <int> r(n);
	for (int i=0; i<n; i++){
		cin >> v[i];
	}
	for (int i=0; i<n; i++){
		cin >> c[i];
		r[i]=v[i]-c[i];
	} 
	int ans=0;
	sort(r.begin(),r.end());
	n--;
	int sum=0;
	while (r[n]>0){
		sum+=r[n];
		n--;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> A(n);
  for(int i=0;i<n;i++)
    cin>>A[i];
  sort(A.begin(), A.begin()+n);
  int sum=0;
  for(int i=0;i<k;i++)
  {
    sum+=A[i];
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3640
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    var a = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    val b = IntArray(N)

    /*
    (0 until (2.shl(N))).forEach {bit ->
        val c = IntArray(N)
        c.fill(0)

        (0 until N).forEach {
            c[it] = bit.shr(it).and(1)
        }

        var isCorrect = true
        (1..N).forEach {
            var sum = 0
            (it - 1 until N).step(it).forEach {
                sum += c[it]
            }
            if (sum.mod(2) != a[it - 1]) {
                isCorrect = false
            }
        }
        if (isCorrect) {
            actual = c.clone()
        }
    }
    */



    b.fill(0)
    // O(N)
    var wrong = false
    (N - 1 downTo 0).forEach {
        // O(N^0.5)
        val n = it + 1
        // Fix bi
        b[it] += a[it]
        b[it] %= 2

        // Update others (diviors exept self)
        for (i in 1..(Math.sqrt(n.toDouble())).toInt()) {
            if (n % i == 0) {
                if (i != n) {
                    b[i - 1] = (b[i - 1] + b[it]).mod(2)
                }
                if (i != n / i&& n/i != n) {
                    b[n/i - 1] = (b[n/i - 1] + b[it]).mod(2)
                }
            }
        }
    }

    val ans = b.mapIndexed { index, i -> if (i == 1) index + 1 else - 1 }.filter { it != -1 }
    println(ans.size)
    ans.forEach {
        print(it)
        print(' ')
    }
}

Measured memory_bytes: 67408
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P,P> P2;
const int INF = 1 << 30;
const double EPS = 1E-9;

struct data{
	int w, ts, tf;
};

data d[100];

int main(){
	int n;
	while(cin >> n && n){
		for(int i = 0; i < n; i++){
			cin >> d[i].w >> d[i].ts >> d[i].tf;
		}
		int mw = 0;
		for(int i = 0; i < n; i++){
			int w1, w2;
			w1 = w2 = d[i].w;
			for(int j = 0; j < n; j++){
				if(i == j) continue;
				if(d[i].tf <= d[j].tf && d[i].tf > d[j].ts) w1 += d[j].w;
				if(d[i].ts < d[j].tf && d[i].ts >= d[j].ts) w2 += d[j].w;
			}
			mw = max(mw, max(w1, w2));
		}
		if(mw > 150) cout << "NG" << endl;
		else cout << "OK" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <complex>
#include <cstdio>
using namespace std;
typedef complex<double> P;

const double inf = 1e100;

double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

const int MAXN = 401;

int N;
P ps[MAXN];
bool used[MAXN];

int main() {
  while(cin >> N && N) {
    for(int i = 0; i < N; ++i) {
      cin >> ps[i].real() >> ps[i].imag();
    }
    fill(used, used+MAXN, false);
    P s(0,-1);
    P t(0,0);
    double sum = 0;
    for(int tc = 0; tc < N; ++tc) {
      int j = -1;
      for(int i = 0; i < N; ++i) {
        if(used[i]) continue;
        if(j == -1) {
          j = i; continue;
        }
        P p = ps[i];
        P q = ps[j];
        if(cross(t-s,p-s) > 0.0) continue;
        if(cross(q-t,p-t) > 0.0 ||
           cross(q-t,p-t) == 0.0 && norm(q-t) > norm(p-t)) {
          j = i;
        }
      }
      used[j] = true;
      P u = ps[j];
      sum += abs(u-t);
      s = t;
      t = u;
    }
    printf("%.1f\n", sum);
  }
  return 0;
}

Measured memory_bytes: 1264
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    String s = sc.next();
    int counterA = 0;
    int counterB = 0;
    int total = 0;
    for(int i=0; i<n; i++) {
      switch(s.substring(i, i+1)){
        case "a":
          counterA++;
          if(total<a+b) {
            System.out.println("Yes");
            total++;
          } else {
            System.out.println("No");
          }
          
          break;
        case "b":
          counterB++;
          if(total<a+b && counterB<=b){
            System.out.println("Yes");
            total++;
          } else {
            System.out.println("No");
          }
          break;
        default:
          System.out.println("No");
          break;
      }
    }
  }
}

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

int main() {
  int N, Q;
  string S;
  cin >> N >> S >> Q;
  vector<set<int>> is(26);
  rep(i, N) is[S[i] - 'a'].insert(i); 
  rep(qi, Q) {
    int ty;
    cin >> ty;
    if (ty == 1) {
      int i; char c;
      cin >> i >> c;
      --i;
      is[S[i] - 'a'].erase(i);
      S[i] = c;
      is[S[i] - 'a'].insert(i);
    }
    else {
      int l, r;
      cin >> l >> r;
      --l;
      int ans = 0;
      rep(i, 26) {
        auto it = is[i].lower_bound(l);
        if (it != is[i].end() && *it < r) ans++;
      }
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 24324
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 2005, MOD = 924844033;
typedef long long i64;

i64 C[MAX_N][MAX_N], f[MAX_N], fac[MAX_N], g[MAX_N];
bool vis[MAX_N];

int N, K;

int get(int col, int sgn) {
  int x = col, y = col + sgn * K, len = 0;
  while (x <= N && y <= N) {
    vis[x] = 1, len++;
    if (sgn == -1) y += 2 * K;
    else x += 2 * K;
    sgn = -sgn;
  }
  return len;
}

int main() {
  scanf("%d%d", &N, &K);
  for (int i = 0; i <= N; ++i) {
    C[i][0] = 1;
    for (int j = 1; j <= i; ++j)
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
  }
  
  fac[0] = 1;
  for (int i = 1; i <= N; ++i) fac[i] = fac[i - 1] * i % MOD;

  f[0] = 1;
  for (int i = 1; i <= N; ++i) 
    if (!vis[i]) {
      int len = get(i, i > K ? -1 : 1);
      memset(g, 0, sizeof g);
      for (int j = (len + 1) / 2; j >= 0; --j) {
	i64 num = C[len - j + 1][j];
	for (int k = N; k >= j; --k)
	  g[k] = (g[k] + f[k - j] * num % MOD) % MOD;
      }
      memcpy(f, g, sizeof f);
    }

  i64 result = 0;

  for (int i = 0; i <= N; i += 2)
    result = (result + f[i] * fac[N - i] % MOD) % MOD;
  for (int i = 1; i <= N; i += 2)
    result = (result - f[i] * fac[N - i] % MOD) % MOD;

  printf("%lld\n", (result + MOD) % MOD);
  return 0;
}


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

int main() {

        int n;
        std::cin >> n;

        if (n == 1) {
                std::cout << "Hello World" << std::endl;
                return 0;
        }
        else {
                int a, b;
                std::cin >> a;
                std::cin >> b;
                std::cout << a + b << std::endl;
        }

        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	int a;
	int flag = 0;
	if ((A == B&&A!=C) || (B == C&&A!=B) || (A == C&&A!=B))
		flag = 1;
	Yn(flag);
	return 0;
}

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

int main()
{
	int k, n;
	std::cin >> k >> n;
	std::vector<int> a(n);
	for (auto &e : a) std::cin >> e;
	
	std::vector<int> b(n);
	b[0] = a.front() + k - a.back();
	for (int i = 1; i < n; i++) {
		b[i] = a[i] - a[i - 1];
	}
	
	std::cout << k - *std::max_element(b.begin(), b.end()) << std::endl;
	
	return 0;
}


Measured memory_bytes: 4364
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
template <class T>
bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
template <class T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion
lint ans[250100];

int main(void) {
	lint n; cin >> n;
	lint cnt = 0;
	vector<pair<lint, lint>> d(n);
	for (int i = 1; i <= n; i++) {
		cin >> d[i - 1].first;
		d[i - 1].second = i;
		ans[d[i - 1].first] = i;
	}
	sort(d.begin(), d.end());
	lint count = 1;
	for (int i = 0; i < n; i++) {
		cnt = 0;
		while (cnt < d[i].second - 1) {
			if (ans[count] == 0) 
				cnt++, ans[count] = d[i].second;
			count++;
		}
		if (count - 1 >= d[i].first) {
			printf("No\n");
			return 0;
		}
	}
	count = pow(n, 2);
	for (int i = d.size() - 1; i >= 0; i--) {
		cnt = 0;
		while (cnt < n - d[i].second) {
			if (ans[count] == 0) 
				cnt++, ans[count] = d[i].second;
			count--;
		}
		if (count + 1 <= d[i].first) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	for (int i = 1; i <= pow(n, 2); i++) {
		printf("%lld", ans[i]);
		if (i != pow(n, 2)) printf(" ");
	}
	printf("\n");

    return 0;
}

Measured memory_bytes: 5688
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<ll> v(n);
    REP(i,n) {
        cin >> v[i];
        v[i] -= i+1;
    }


    sort(ALL(v));
    ll d;
    if (n % 2 == 0) d = (v[n/2] + v[n/2-1]) / 2;
    else d = v[n/2];


    cout << accumulate(ALL(v),0LL,[&](ll acc,ll x){return acc + abs(x-d);}) << '\n';


    return 0;
}

Measured memory_bytes: 1792
from collections import deque
import numpy as np
h, w = map(int,input().split())
s = [input() for _ in range(h)]
result = []
for xx in range(h):
    for yy in range(w):
        if s[xx][yy]==".":
            visit = np.array([np.array([-1 for _ in range(w)]) for __ in range(h)])
            visit[xx][yy] = 0

            q = deque([[xx,yy]])
            while q:
                x, y = q.popleft()
                for i in [-1, 1]:
                    if 0 <= x+i and x+i < h:
                        if s[x+i][y] != "#" and visit[x+i][y] < 0:
                            visit[x+i][y] = visit[x][y]+1
                            q.append([x+i, y])
                    if 0 <= y+i and y+i < w:
                        if s[x][y+i] != "#" and visit[x][y+i] < 0:
                            visit[x][y+i] = visit[x][y]+1
                            q.append([x, y+i])
            result.append(max(visit.flatten()))
print(max(result))

Measured memory_bytes: 13008
a = [int(input()) for i in range(5)]
b = [0,0,0,0,0]
for i in range(5):
    b[i] = 10-int(a[i]%10)
    if b[i] == 10:
        b[i] = 0
ans = 0
for i in range(5):
    ans += a[i]
    ans += b[i]
ans -= max(b)
print(ans)

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

template <class F>
int lower_bound(int i0, int i1, F f) {
    while (i0 < i1) {
        int i = (i0 + i1) / 2;
        if (f(i)) i1 = i; else i0 = i + 1;
    }
    return i0;
}

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

    pair<int, int> p[50];
    for (int i = 0; i < n; i++) {
        cin >> p[i].first >> p[i].second;
    }

    int b[2][50], c[2];
    for (int j = 0; j < 2; j++) {
        sort(p, p + n);

        int a = p[0].first - 1, x = -1;
        for (int i = 0; i < n; i++) {
            if (p[i].first != a) a = b[j][++x] = p[i].first;
            p[i].first = x;
        }
        c[j] = x + 1;

        if (j == 1) break;

        for (int i = 0; i < n; i++) {
            swap(p[i].first, p[i].second);
        }
    }

    int s[51][51] = {};
    for (int i = 0; i < n; i++) {
        s[p[i].second + 1][p[i].first + 1]++;
    }
    for (int i = 1; i <= c[0]; i++) {
        for (int j = 1; j <= c[1]; j++) {
            s[i][j] += s[i][j - 1];
        }
    }
    for (int j = 1; j <= c[0]; j++) {
        for (int i = 1; i <= c[1]; i++) {
            s[i][j] += s[i - 1][j];
        }
    }

    int64_t m = 1LL << 62;
    for (int i = 0; i < c[0]; i++) {
        for (int j = 0; j < c[1]; j++) {
            for (int x = i + 1; x < c[0]; x++) {
                int y = lower_bound(j + 1, c[1], [&](int y) {
                    int l = s[x + 1][y + 1] - s[x + 1][j] - s[i][y + 1] + s[i][j];
                    return l >= k;
                });
                if (y == c[1]) continue;
                int64_t t = (int64_t)(b[0][x] - b[0][i]) * (b[1][y] - b[1][j]);
                if (t < m) m = t;
            }
        }
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
ekis = []
for _ in range(N - 1):
  c, s, f = map(int, input().split())
  ekis.append((c, s, f))

for ikimasuyo in range(N):
  t = 0
  for i in range(ikimasuyo, N - 1):
    c, s, f = ekis[i]
    if t < s:
      t = s + c
    elif t >= s:
      t = -((s - t) // f) * f + s + c
    #print(ikimasuyo, t)
  print(t)

Measured memory_bytes: 40304
import sys
input = sys.stdin.readline

def main():
  h, w = map(int, input().split())
  A = [list(map(int, input().split())) for _ in range(h)]
  B = [list(map(int, input().split())) for _ in range(h)]
  M = 80*(h+w)
  dp = [[0]*w for i in range(h)]
  d = abs(A[0][0] - B[0][0])
  mask = (1 << (2*M)) - 1
  dp[0][0] |= 1 << (M-d)
  dp[0][0] |= 1 << (M+d)
  for i in range(h):
    for j in range(w):
      d = abs(A[i][j] - B[i][j])
      if i:
        dp[i][j] |= (dp[i-1][j] << d) & mask
        dp[i][j] |= dp[i-1][j] >> d
      if j:
        dp[i][j] |= (dp[i][j-1] << d) & mask
        dp[i][j] |= dp[i][j-1] >> d
  t = dp[-1][-1] >> M
  ans = (t & (-t)).bit_length() - 1
  print(ans)
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 56668
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>  // std::greater<T>()

using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから

// func declaration
template <class T> void printVec(vector<T>);
template <class T> void calcVec(vector<T>&, int, char);
bool checkMultiple(vector<int>&, int);

// const
const int INF = 10000000;

/*MEMO
辞書順
abc < abcd, atcoder < atlas
*/

int main() {
    int A, B, C, X;  // A:500, B:100, C:50, X:summation
    cin >> A >> B >> C >> X;

    int count = 0;
    for (int i = 0; i <= A; ++i) {
        int num = X - 500*i;  // 500yen を引く
        if (num > 0) {
            for (int j = 0; j <= B; ++j) {
                int num1 = num - 100*j;
                if (num1 > 0) {
                    for (int k = 0; k <= C; ++k) {
                        int num2 = num1 - 50*k;
                        if (num2 == 0) count++;
                    }
                } else if (num1 == 0) {
                    count++;
                }
            }
        } else if (num == 0) {
            count++;
            continue;
        }
    }
    cout << count << endl;

    return 0;
}


// function
template <class T> void printVec(vector<T> vec) {
    // 1要素ずつ、空白・改行なしで出力
    REP(i, vec.size()) {
        cout << vec.at(i);
    }
    cout << endl;
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    if (ch == '+') {
        REP(i, vec.size()) {
            vec.at(i) += num;
        }
    } else if (ch == '-') {
        REP(i, vec.size()) {
            vec.at(i) -= num;
        }
    } else if (ch == '*') {
        REP(i, vec.size()) {
            vec.at(i) *= num;
        }
    } else if (ch == '/'){
        REP(i, vec.size()) {
            vec.at(i) /= num;
        }
    } else if (ch == '%') {
        REP(i, vec.size()) {
            vec.at(i) %= num;
        }
    }
}

bool checkMultiple(vector<int> &vec, int num) {
    // vecの中身が、numの倍数かどうかのチェック
    int count = 0;
    REP(i, vec.size()) {
        if (vec.at(i)%num != 0) count++;
    }
    return (count == 0);
}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    ll N;
    cin >> N;
    vector<ll> A(N+1);
    REP(i,N+1) cin >> A[i];

    // for corner
    if (N == 0) {
        if (A[0]==1) cout << 1 << endl;
        else cout << -1 << endl;
        return;
    }

    // for corner
    if (A[0] == 1) {
        cout << -1 << endl;
        return;
    }
    // その深さより↓の葉の数の合計
    vector<ll> dv(N+1,0);
    REPR(i,N-1) dv[i] = dv[i+1] + A[i+1];

    vector<ll> not_leaf_node(N+1,0);
    not_leaf_node[0] =1 ;
    ll ans = 1;
    FOR(i,1,N+1) {
        ll node = min(not_leaf_node[i-1] * 2,dv[i]+A[i]);
        if (node - A[i] < 0 ) {
            cout << -1 << endl;
            return;
        }
        not_leaf_node[i] = node - A[i];
        ans += node;
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


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

using namespace std;

int main(){
	int N, Y ,x, y, count = 0;
	cin >> N >> Y;
	for(x = 0; x <= N; x++){
		for(y = 0; y <= N; y++){
			if((N - x - y) >= 0 && (N - x - y) <= N && (10000 * x + 5000 * y + (N - x - y) * 1000 == Y)){
				cout << x << " " << y << " " << N - x - y;
				exit(0);
			}
		}
	}
	cout << "-1" << " " << "-1" << " " << "-1";
	return 0;
}

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

using namespace std;

int main(){
    int N;
    while(cin >> N){
        vector<pair<int,int>> A;
        for(int i=0;i<N;i++){
            int a; cin >> a;
            A.emplace_back(a, i);
        }
        sort(A.begin(), A.end());
        int res = 0;
        for(int i=0;i<N;i++){
            if(A[i].second%2 != i%2) ++res;
        }
        cout << res/2 << endl;        
    }
}

Measured memory_bytes: 1400
#include <stdio.h>

int euclid(int, int);

int main(void) {
    int a, b, gcd, lcm;
    while(~scanf("%d %d", &a, &b)) {
        gcd = a > b ? euclid(a, b) : euclid(b, a);
        lcm = a / gcd * b;
        printf("%d %d\n", gcd, lcm);
    }
    return 0;
}

int euclid(int a, int b) {
    return a % b ? euclid(b, a % b) : b;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define mem(a,v) memset((a), (v), sizeof (a))
#define ni(n) scanf("%d", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
using namespace std;
const int MAXN = 1e5 + 5;
int t[MAXN], v[MAXN], ans = 0, n;
int miB[MAXN], miF[MAXN], mi[MAXN];

int main() {
	ni(n); mem(miB, 0x3f), mem(miF, 0x3f);
	nai(t, n); nai(v, n); mem(mi, 0x3f);
	for (int i = 0; i < n; i++) t[i] *= 2, v[i] *= 2;
	for (int i = 1; i < n; i++) t[i] += t[i-1];
	for (int i = 1; i < n; i++) miB[t[i-1]] = v[i];
	miB[t[n-1]] = miF[0] = 0;
	for (int i = t[n-1]-1; ~i; i--) miB[i] = min(miB[i], miB[i+1]+1);
	for (int i = 0; i < n; i++) miF[t[i]] = v[i];
	for (int i = 1; i <= t[n-1]; i++) miF[i] = min(miF[i], miF[i-1]+1);
	for (int i = 0; i < n; i++) for (int j = !i?0:t[i-1]; j <= t[i]; j++) mi[j] = min(mi[j], v[i]);
	for (int i = 0; i <= t[n-1]; i++) mi[i] = min(mi[i], min(miF[i],miB[i]));
	for (int i = 0; i < t[n-1]; i++) ans += (mi[i+1]+mi[i]);
	printf("%.20f\n", (double)ans/8.);
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define pb push_back 
 #define fo(i,n) for(int i=0;i<n;i++)
#define ll long long 
#define int long long 
#define Mod 10000000000007 
#define maxn 200005
#define MAX 4294967296  // 2^32
const int M=1e9+7;
#define ip pair<int,int>
#define test(t) ll t;cin>>t;while(t--)
  
using namespace std;

long long gcd(int x,int y){
    if(y>x)swap(x,y);
    if(y==0)return x;
    return gcd(y,x%y);
}


void solve(){
int n;
cin>>n;
int f=0;
int t=0;
while(n--){
int a,b;
cin>>a>>b;
if(a==b)f++;
else f=0;
t=max(t,f);



}
if(t>=3)cout<<"Yes";
else cout<<"No";
}

signed main(){


    // std::string binary = std::bitset<8>(n).to_string();
    ios::sync_with_stdio(0);
    cin.tie(0);
   
solve();


  


}

Measured memory_bytes: 3608
<?php
// $n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$n = (int)$input[0];
$l = (int)$input[1];

$min = 1000;
$sum = 0;
for ($i=0; $i < $n; $i++) { 
	$tmp = $l + $i;
	$sum += $tmp;
	if (abs($tmp) < abs($min)) {
		$min = $tmp;
	}
}
echo $sum - $min;

Measured memory_bytes: 4856
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
#include <random>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;\
                    c>0?i<b:\
                    i>b;\
                    i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif
 
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
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;
}
 
template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

int N;

void solve() {
	cin >> N;
	int ans = N * 800 - N / 15 * 200;
	cout << ans << endl;
}

signed main() {
	cout << fixed << setprecision(20);
	while(true) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}


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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    string S;
    cin >> S;
    if (S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int x;
    cin >> x;
    int a[2] = {0};
    for(long i=-118; i<=119; i++) {
        for(long j=-118; j<=119; j++) {
            if(i*i*i*i*i - j*j*j*j*j == x) {cout << i << " " << j << endl; return 0;}
        }
    }
    
    return 0;
}

Measured memory_bytes: 3620
// 1_gcdlib_a
#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>// C++
#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>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int gcd(int x, int y){
    if(x < y) swap(x, y);

    while(y > 0){
        int r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << gcd(a, b) << endl;
    return 0;
}



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

template<typename T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

constexpr int MAX_N = 1e5 + 9;
constexpr int MAX_K = 1e2;
constexpr int INF = 1e9 + 9;

int N, K;
int h[MAX_N];
int dp[MAX_N + MAX_K];

int main() {
  fill_n(dp, MAX_N + MAX_K, INF);
  cin >> N >> K;
  for (int i{}; i < N; ++i) cin >> h[i];

  dp[0] = 0;
  for (int i{0}; i < N; ++i) {
    for (int j{1}; j <= K; ++j) {
      chmin(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
    }
  }

  cout << dp[N - 1] << endl;
}


Measured memory_bytes: 4296
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include <cctype>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;

int main(){
     string s;
     cin >> s;
     cout << (s=="ABC" ? "ARC" : "ABC") << endl;
}


Measured memory_bytes: 3628