akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T int
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

const int N = 51;
const int LG = 20;

int n, m;
vector<int>g[N];
int depth[N];
int anc[N][LG+1];
map<pair<int,int>,int>edges;
ll edge_mask[N];

void dfs(int u, int p){
    anc[u][0] = p;
    for(int v:g[u]){
        if(v != p){
            depth[v] = depth[u] + 1;
            dfs(v, u);
        }
    }
}

void pre(){
    FOR(i,1,LG){
        FOR(j,1,n){
            anc[j][i] = anc[anc[j][i-1]][i-1];
        }
    }
}

int lca(int a, int b){
    if(depth[a] < depth[b]){
        swap(a, b);
    }
    int d = depth[a] - depth[b];
    FOR(i,0,LG){
        if(d & (1<<i)){
            a = anc[a][i];
        }
    }
    if(a == b){
        return a;
    }
    ROF(i,LG,0){
        if(anc[a][i] != anc[b][i]){
            a = anc[a][i];
            b = anc[b][i];
        }
    }
    return anc[a][0];
}
    
ll dp[(1<<LG)];

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cin >> n;
    int u, v;
    FOR(i,1,n-1){
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
        if(u > v){
            swap(u, v);
        }
        edges[mp(u,v)] = i;
    }
    dfs(1,0);
    pre();
    cin >> m;
    FOR(i,0,m-1){
        cin >> u >> v;
        int l = lca(u, v);
        //cout << u << " " << v << " " << l << endl;
        int p;
        while(u != l){
            p = anc[u][0];
            edge_mask[edges[mp(min(u, p), max(u, p))]] |= (1<<i);
            u = anc[u][0];
        }
        while(v != l){
            //cout << v << endl;
            p = anc[v][0];
            //cout << p << endl;
            edge_mask[edges[mp(min(v, p), max(v, p))]] |= (1<<i);
            v = anc[v][0];
        }
    }
    /*FOR(i,1,n-1){
        cout << edge_mask[i] << endl;
    }*/
    dp[0] = 1;
    FOR(i,1,n-1){
        ROF(j,(1<<m)-1,0){
            dp[j|edge_mask[i]] += dp[j];
        }
    }
    cout << dp[(1<<m)-1];

    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

Measured memory_bytes: 8448
#include<stdio.h>
#define N 2000001
#define M 10001
int n,A[N],B[N],C[M];
void countingSort(void);
int main(){
  int i,cnt=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  countingSort();
  for(i=1;i<=n;i++){
    if( (i-1)!=0 ){
      printf(" ");
    }
    printf("%d",B[i]);
    cnt++;
  }
  printf("\n");
  return 0;
}


void countingSort(void){
  int i;
  for(i=0;i<M;i++){
    C[i] = 0;
  }
  for(i=1;i<=n;i++){
    C[A[i]]++;
  }
  for(i=1;i<M;i++){
    C[i] += C[i-1];
  }
  for(i=1;i<=n;i++){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
}



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

int main()
{

  int N;
  int count = 0;

  cin >> N;

  if (N / 1000 == 2)
    count++;
  if ((N / 100) % 10 == 2)
    count++;
  if ((N / 10) % 10 == 2)
    count++;
  if (N % 10 == 2)
    count++;

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  vector<ll> v;
  for(ll i=1; i*i<=n; i++) {
    if(n%i==0) {
      v.pb(i);
      if(i*i!=n) v.pb(n/i);
    }
  }
  sort(all(v));
  ll ans=0;
  REP(i,1,v.size()) {
    ll x=v[i]-1;
    if(n/x==n%x) ans+=x;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 384
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cassert>
//---------------------------------------------------------------
#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 rep2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n;cin>>n;

    ll cnt4=0,cnt2=0;
    rep(i,n){
        int ai;
        cin>>ai;
        if(ai%4==0){cnt4++;}
        else if(ai%2==0){cnt2++;}
    }    

    ll cnt3=n-cnt4-cnt2;
    if(cnt2==0){
        if(cnt3<=cnt4+1)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }else{
        if(cnt3<=cnt4)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;        
    }
}

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

int main()
{
  int n,l;
  cin>>n>>l;
  vector<int> v;
  int sum=0;
  for(int i=1;i<=n;i++)
  {
    v.push_back(i+l-1);
   // cout<<i+l-1<<"\n";
    sum+=i+l-1;
  }
  int ans,diff=int(1e9);
  for(auto i:v)
    if(abs(i)<diff)
      ans = sum-i,diff=abs(i);
  cout<<ans<<"\n";
 // cout<<diff;
  return 0;
}


Measured memory_bytes: 256
/*
 * written by Yaqi Zhang (zhang623@wisc.edu)
 * University of Wisconsin-Madison
 * 2020
 */
#include <bits/stdc++.h>

#define INF 0x3f3f3f3f

using namespace std;

void dfs(int node, int parent, int path, 
        const vector<vector<pair<int, int>>> & tree, vector<int> * colors) {
    if(path % 2) (*colors)[node] = 1;
    for(auto &  p : tree[node]) {
        int v = p.first, w = p.second;
        if(v != parent) dfs(v, node, path + w, tree, colors);
    }
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> tree(n);
    for(int i = 0; i < n - 1; ++i) {
        int u, v, w;
        cin >> u >> v >> w;
        --u;
        --v;
        tree[u].emplace_back(v, w);
        tree[v].emplace_back(u, w);
    }
    vector<int> colors(n, 0);
    dfs(0, -1, 0, tree, &colors);
    for(int color : colors) cout << color << "\n";
    // need to know distance of two nodes
    return 0;
}



Measured memory_bytes: 9728
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

signed main(void)
{
  VVI v(3, VI(3));
  REP(i, 3) REP(j, 3) cin >> v[i][j];

  REP(i, 2) {
    int tmp = v[0][i+1] - v[0][i];
    bool flag = true;
    FOR(j, 1, 3) {
      if(v[j][i+1] - v[j][i] != tmp) flag = false;
    }
    if(!flag) {
      cout << "No" << endl;
      return 0;
    }
  }

  REP(i, 2) {
    int tmp = v[i+1][0] - v[i][0];
    bool flag = true;
    FOR(j, 1, 3) {
      if(v[i+1][j] - v[i][j] != tmp) flag = false;
    }
    if(!flag) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int x[123456], y[123456], xm=mod, ym=mod;
int ans = mod * 2, m;
signed main() {
	int a, b; cin >> a >> b >> m;
	for1(i, a) { cin >> x[i]; xm = min(xm, x[i]); }
	for1(i, b) { cin >> y[i]; ym = min(ym, y[i]); }
	for0(z, m) {
		int c, d, e; cin >> c >> d >> e;
		ans = min(ans, x[c] + y[d] - e);
	}
	cout << min(ans, xm + ym) << endl;
}

Measured memory_bytes: 1792
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<f64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut dp: Vec<Vec<f64>> = vec![vec![0.0; n + 1]; n + 1];
    dp[0][0] = 1.0;
    for i in 0..n {
        for num in 0..i + 1 {
            dp[i + 1][num + 1] += dp[i][num] * a[i];
            dp[i + 1][num] += dp[i][num] * (1.0 - a[i]);
        }
    }

    let mut ans: f64 = 0.0;
    for omote in 0..n + 1 {
        if omote > (n - omote) {
            ans += dp[n][omote];
        }
    }
    println!("{:.10}", ans);
}


Measured memory_bytes: 90364
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

int n;
bitset<2000> table[2000];
bitset<2000> dpl[2000];
bitset<2000> dpr[2000];

int main() {
    cin >> n;
    rep(i,n-1) {
        rep(j,i+1) {
            char c; cin >> c;
            if (c == '1') table[i+1].set(j);
            else table[j].set(i+1);
        }
    }
    rep(i,n) {
        dpl[i].set(i);
        dpr[i].set(i);
    }
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < n-i; j++) {
            if ((((table[j]&dpr[j+i]&dpl[j+1])<<(n-j-i))>>(n-i-1)).any()) {
                dpr[j+i].set(j);
            }
            if ((((table[j+i]&dpr[j+i-1]&dpl[j])<<(n-j-i))>>(n-i-1)).any()) {
                dpl[j].set(j+i);
            }
            if (table[j][j+i] && dpl[j+1][j+i]) dpr[j+i].set(j);
            if (table[j+i][j] && dpr[j+i-1][j]) dpl[j].set(j+i);
        }
    }
    int ans = 0;
    rep(i,n) {
        if (dpl[0][i] && dpr[n-1][i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
/* ***********************************************
Author        :devil
************************************************ */
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <stdlib.h>
#define inf 0x3f3f3f3f
#define LL long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dec(i,a,b) for(int i=a;i>=b;i--)
#define ou(a) printf("%d\n",a)
#define pb push_back
#define mkp make_pair
template<class T>inline void rd(T &x){char c=getchar();x=0;while(!isdigit(c))c=getchar();while(isdigit(c)){x=x*10+c-'0';c=getchar();}}
#define IN freopen("in.txt","r",stdin);
#define OUT freopen("out.txt","w",stdout);
using namespace std;
const int mod=1e9+7;
const int N=510;
char s1[N][N],s2[N][N],s[N][N];
int main()
{
    int n,m;
    rd(n),rd(m);
    rep(i,1,n)
    {
        s1[i][1]='#',s1[i][m]='.';
        s2[i][m]='#',s2[i][1]='.';
        rep(j,2,m-1) (i%2)?(s1[i][j]='#',s2[i][j]='.'):(s2[i][j]='#',s1[i][j]='.');
    }
    rep(i,1,n) scanf("%s",s[i]+1);
    rep(i,2,n-1) rep(j,2,m-1) if(s[i][j]=='#') s1[i][j]=s2[i][j]='#';
    rep(i,1,n)
    {
        rep(j,1,m) printf("%c",s1[i][j]);
        puts("");
    }
    puts("");
    rep(i,1,n)
    {
        rep(j,1,m) printf("%c",s2[i][j]);
        puts("");
    }
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){

  ll n,m;
  cin >> n >> m;
  ll p[n+1] = {};
  bool f[n+1] = {};
  REP(i,n+1){
    if(i > 0)
      p[i] = 1;
  }
  f[1] = true;
  REP(i,m){
    ll a,b;
    cin >> a >> b;
    p[a]--;
    p[b]++;
    if(f[a])
      f[b] = true;
    if(p[a] == 0){
      f[a] = false;
    }
  }
  int sum = 0;
  REP(i,n+1){
    if(f[i])
      sum++;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1152
/**
 * @author torith
 * @date 2018-11-08
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K; cin >> N >> K;

    ll ans = 0;
    ll tmp = N/K;
    ans += tmp * tmp * tmp;

    if (K % 2 == 0) {
        tmp = N / (K/2) - N/K;
        ans += tmp * tmp * tmp;
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		long A=stdIn.nextInt();
		long B=stdIn.nextInt();
		long C=stdIn.nextInt();
		if(A%2==0||B%2==0||C%2==0)
			System.out.println(0);
		else
			if(A>=B&&A>=C)
				System.out.println(B*C);
			else
				if(B>=A&&B>=C)
					System.out.println(A*C);
				else
					System.out.println(A*B);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rep1(i,n) for (int i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;
int main(){
  char a; cin >> a;
  cout << (isupper(a) ? 'A':'a');
  return 0;
}

Measured memory_bytes: 3648
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner scn=new Scanner(System.in);
    int x=scn.nextInt();
    int x_=x;
    int ans=0;
    int n=scn.nextInt();
    ArrayList<Integer> p=new ArrayList<>();
    boolean flg=true;
    
    for(int i=0;i<n;i++){
		p.add(scn.nextInt());
    }
    
    while(flg){
      for(int i=0;i<p.size();i++){
        if(x_==p.get(i)){
          x_--;
          p.remove(i);
          i=-1;
        }
      }
        ans=x_;
        x_=x+1;
      
        for(int i=0;i<p.size();i++){
        	if(x_==p.get(i)){
        		x_++;
         		p.remove(i);
          		i=-1;
      		}
        }
        if(Math.abs(x_-x)<Math.abs(ans-x)) ans=x_;
        break;
    }
    System.out.println(ans);
  }
}
        
      

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

INF = float("inf")


def warshall_floyd(n, d):
    for k in range(n):
        for i in range(n):
            d_ik = d[i][k]
            # if d_ik == INF:
            #     continue
            for j in range(n):
                if d[i][j] > d_ik + d[k][j]:
                    d[i][j] = d_ik + d[k][j]


def main():
    H, W = map(int, input().split())
    c = [None] * 10
    for i in range(10):
        c[i] = list(map(int, input().split()))
    A = [None] * H
    for i in range(H):
        A[i] = list(map(int, input().split()))

    warshall_floyd(10, c)

    ans = 0
    for h in range(H):
        for w in range(W):
            if A[h][w] != -1:
                ans += c[A[h][w]][1]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    double a, b, x;
    cin >> a >> b >> x;

    if(x == a*a*b){
        printf("%lf", (double)0);
        return 0;
    }

    double ans;
    double l;
    if(a*a/2*b <= x){
        l = 2/(a*a)*(x-a*a*b/2);
        ans = 90- atan(a/(b-l))/M_PI*180;
    }else{
        l = 2*x/(a*b);
        ans = 90- atan(l/b)/M_PI*180;
    }

    printf("%lf\n", ans);

    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] v = new int[5];
            for (int i = 0; i < 5; i++)
            {
                v[i] = int.Parse(Console.ReadLine());
            }
            int K = int.Parse(Console.ReadLine());

            for (int i = 0; i < 5; i++)
            {
                for (int j = i + 1; j < 5; j++)
                {
                    if (v[j] - v[i] > K)
                    {
                        Console.WriteLine(":(");
                        return;
                    }
                }
            }

            Console.WriteLine("Yay!");
        }
    }
}

Measured memory_bytes: 11092
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	string s;
	while(cin>>N) {
		VI n(26);
		REP(i, N) {
			cin>>s;
			n[s[0]-'A']++;
		}
		string tb="MARCH";
		sort(ALL(tb));
		set<string> se;
		do {
			se.insert(tb.substr(0, 3));
		} while(next_permutation(ALL(tb)));
//		DD(n);
//		DD(se);
		ll ans=0;
		for(auto e: se) {
			ans+=n[e[0]-'A']*n[e[1]-'A']*n[e[2]-'A'];
		}
		ans/=6;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=2005;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0',ch=getchar();}
    return x*f;
}
int n;
void solve()
{
	int d=read(),t=read(),s=read();
	if(s*t>=d) puts("Yes"); else puts("No");
}
int main()
{
	int T=1;
	while(T--) solve();
}

Measured memory_bytes: 3636
def s():
 import sys
 r=sys.stdin.readline
 for e in iter(r,'0 0\n'):
  N,M=map(int,e.split())
  k,p=1,0
  S=[int(r()) for _ in[0]*N]
  for d in[int(r())for _ in[0]*M]:
   p+=d if N<=p+d else d+S[p+d]
   if N<=p+1:break
   k+=1
  print(k)
if'__main__'==__name__:s()


Measured memory_bytes: 5644
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

#define inf 1e9
#define max_n 123456
#define mod 1000000007

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

int n;
int a[123];
int dp[123456];

int memo(int k) {
	if(k == 0) return 0;
	if(dp[k] != -1) return dp[k];
	for(int i=0; i<n; i++) {
		if(k - a[i] >= 0) {
			if(memo(k-a[i]) == 0) return dp[k] = 1;
		}
	}
	return dp[k] = 0;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int k;
	cin >> n >> k;
	for(int i=0; i<n; i++) cin >> a[i];
	memset(dp, -1, sizeof dp);
	cout << (memo(k) ? "First" : "Second") << endl;
	return 0;
}

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

  int N,M;
  cin >> N;
  cin >> M;
  
  if (M == 1){
    cout << 0 << endl;
  }else  if (N >= M){
    cout << 1 << endl;
  }else{
    bool hantei = true;
    int count = 1;
    int k = N;
    while(hantei){
      k += N - 1;
      count += 1;

      if (k >= M){
        hantei = false;
      }
    }
    cout << count << endl;
  }
  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	vector<int> N(3);
	int K;
	for (auto i = 0; i < 3; ++i)
	{
		cin >> N[i];
	}
	cin >> K;

	sort(N.begin(), N.end(), greater<int>());

	auto sum = 0;
	for (auto i = 0; i < K; ++i)
	{
		N[0] *= 2;
	}

	for (auto i = 0; i < 3; ++i)
	{
		sum += N[i];
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] arg) {
		Scanner scan = new Scanner(System.in);
		int n  = scan.nextInt();
		int[] a = new int[n-1];
		int[] count = new int[n];
		for(int i = 0; i < n; i++){
			count[i] = 0;
		}
		int sum = 0;
		for(int i = 0; i < n-1; i++){
			a[i] = scan.nextInt();
			count[a[i]-1]++;
		}
		for(int i = 0; i < n; i++){
			System.out.println(count[i]);
		}
	}
}


Measured memory_bytes: 61468
#include <cstdio>
#include <iostream>
#include <bitset>

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i]; 
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
            if(a[j] < a[j+1]){
                int temp;
                temp = a[j];
                a[j] = a[j+1];
                a[j+1] = temp;
            }
        }
    }
    int sa=0,sb=0;
    for(int i=0;i<n;i++){
        if(i%2 == 0) sa += a[i];
        else sb += a[i];   
    }
    
    cout << (sa - sb) << endl;
    return 0;
}

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

int main()
{
	int n, t, a;
	vector<int> h;
	cin >> n;
	cin >> t >> a;
	for (int i = 0; i < n; i++) {
		int hh;
		cin >> hh;
		h.push_back(hh);
	}

	double nearest = 100000;
	int point = -1;
	for (int i = 0; i < n; i++) {
		double avet = t - 0.006*h[i];
		double dif = abs(avet - a);
		if (dif < nearest) {
			nearest = dif;
			point = i + 1;
		}
	}

	cout << point;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#include <sstream>
#include <string>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=100001;
bool vis[N];
vector <int> adj[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll binaryNum[32];
void decToBinary(ll n) 
{ 
    binaryNum[32]={0};
    int i = 0; 
    while (n > 0) { 
        binaryNum[i] = n % 2; 
        n = n / 2; 
        i++; 
    } 
} 

void solve(){
    ll n;
    cin>>n;
    vc c(n);
    ll count=0;
    rep(i,n){
        cin>>c[i];
        if(c[i]=='W')
            count++;
    }
    ll count2=0;
    loop(i,(n-count),n-1){
        if(c[i]=='W')
            count2++;
    }
    cout<<count-count2;

}


int main()
{
    // cout<<1<<endl;
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 6196
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n; cin>>n;

	vector<int> a(n+1);
	for(int i=1; i<=n; i++) {
		cin>>a[i];
	}
	sort(a.begin()+1,a.end());
	int ans=1e9;
	int d=0;
	int cur=(a[n]+(a[n]%2))/2;
	for(int i=1; i<n; i++) {
		if(abs(a[i]-cur)<ans) {
			ans=abs(a[i]-cur);
			d=a[i];
		}
	}
	cout<<a[n]<<" "<<d<<endl;

	return 0;
}


Measured memory_bytes: 3732
#include                        <bits/stdc++.h>
#include                        <ext/pb_ds/assoc_container.hpp>
#define lb                      lower_bound
#define ub                      upper_bound
#define fe(x)                   (*(x.begin()))
#define le(x)                   (*(x.rbegin()))
#define pb                      push_back
#define load(node,n)            bool operator < (const node &n) const
#define fbo(x,id)               (*(x.find_by_order(id)))
#define ook(y)                  order_of_key(y)
#define all(x)                  (x).begin(),(x).end()
#define FOR(i,n)                for(int i = 1; i<=n; i++)
#define REP(i,n)                for(int i = 0; i<n;  i++)
#define TT                      long long TC;  scanf("%lld",&TC);  while(TC--)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define set(x)                  tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>
using                           namespace __gnu_pbds;
using                           namespace std;
typedef                         long long ll;
typedef                         pair<ll,ll> pll;
typedef                         pair<int,int> pii;

#define mx 200005

ll dp[mx],pref[2][mx],suff[2][mx];
ll ar[mx];

ll fn(ll n){
    if(n==0)    return 0;
    ll &ans = dp[n];
    if(ans!=-1) return ans;
    ll x = __builtin_popcountll(n);
    return ans = 1 + fn(n%x);
}

ll bigmod(ll n,ll p,ll m){
    if(p==0)    return 1;
    if(p==1)    return n%m;
    ll x = bigmod(n,p/2,m)%m;
    if(p%2==0)  return (x*x)%m;
    return (((x*x)%m)*(n%m))%m;
}


main(){
//read;
ll n;
string s;
cin>>n;
cin>>s;
n = s.size();
memset(dp,-1,sizeof dp);
dp[0] = 0;
for(ll i = 1; i<mx; i++)    dp[i] = fn(i);
ll x = 0;
for(ll i = 0; i<n; i++) x+=s[i] - '0';

if(x==0){
    for(ll i = 0; i<n; i++)
        puts("1");
    return 0;
}

ll cnt = 0;
for(ll i = 0,j = n-1; i<n; i++,j--){
    if(s[i] - '0'){
        if(x>1) pref[0][i] = bigmod(2,j,x-1);
        pref[1][i] = bigmod(2,j,x+1);
    }

    if(i){
        pref[0][i] = pref[0][i-1] + pref[0][i];
        pref[1][i] = pref[1][i-1] + pref[1][i];
        if(x>1)
        pref[0][i]%=(x-1);
        pref[1][i]%=(x+1);
    }
}

for(ll i = n-1,j = 0; j<n; j++, i--){
    cnt+=s[i] - '0';
    if(s[i] - '0'){
        if(x>1) suff[0][i] = bigmod(2,j,x-1);
        suff[1][i] = bigmod(2,j,x+1);
    }
    suff[0][i]+=suff[0][i+1];
    suff[1][i]+=suff[1][i+1];
    if(x>1)
    suff[0][i]%=(x-1);
    suff[1][i]%=(x+1);
    ar[i] = bigmod(2,j,x+1);
}

vector<ll> v;
//cout<<"HI : "<<x<<endl;
//cout<<dp[0]<<endl;

for(ll i = 0; i<n; i++){
    ll a = 0,b = 0;
    if(i)   a = pref[0][i-1],b = pref[1][i-1];
    a+=suff[0][i+1];
    b+=suff[1][i+1];
    ll ans = 0;

    b%=(x+1);

    if(s[i]=='1'){
    	
        if(x==1)	ans = 0;
        else{
        	if(x>1) ans = dp[a%(x-1)] + 1;
        	else ans = dp[a] + 1;
		}
//        cout<<"HI " << i<<" "<<a<<" "<< ans<<endl;
		v.pb(ans);
    }
    else{
        ans = dp[(ar[i]+b)%(x+1)] + 1;
        v.pb(ans);
    }

}

for(ll i:v)
    cout<<i<<endl;


return 0;
}

Measured memory_bytes: 14812
n = gets.to_i
l = []
n.times do
    l<<gets.split.map(&:to_i)
end
l.sort_by!{|a| a[1]}
t = 0
for i in 0 .. n - 1
    if t + l[i][0] > l[i][1]
        puts "No"
        exit
    end
    t += l[i][0]
end
puts "Yes"

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

public class Main{

    static final FastReader in = new FastReader();
    static final FastWriter out = new FastWriter();

    public static void main(String[] args) throws IOException{
        int a, b;
        a = in.nextInt();
        b = in.nextInt();
        out.pl(Math.abs(a-b)<=1?"Yay!":":(");
        out.close();
    }
}
class FastReader{
    BufferedReader br;
    StringTokenizer st;
    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in)); 
    } 
    String next(){ 
        while (st == null || !st.hasMoreElements()) { 
            try{ 
                st = new StringTokenizer(br.readLine()); 
            }catch (IOException  e){ 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 
    int nextInt(){ 
        return Integer.parseInt(next()); 
    } 
    long nextLong(){ 
        return Long.parseLong(next()); 
    } 
    double nextDouble(){ 
      return Double.parseDouble(next()); 
    }
    String nextLine(){ 
        String str = ""; 
        try{ 
            str = br.readLine(); 
        } 
        catch (IOException e){ 
            e.printStackTrace(); 
        } 
        return str; 
    }
}
class FastWriter{
    PrintWriter out;
    FastWriter(){
        out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	out.flush();
    }
    void pl(Object o){
        out.write(o.toString());
	    out.write("\n");
        out.flush();
    }
    void pl(){
        out.write("\n");
    }
    void p(Object o){
        out.write(o.toString());
    }
    void close(){
        out.flush();
        out.close();
    }  
}


Measured memory_bytes: 32644
#include<stdio.h>
#include<stdlib.h>
struct DICE {
		int data;
		struct DICE *N;
		struct DICE *E;
		struct DICE *S;
		struct DICE *W;
		struct DICE *B;
		};

struct DICE *turn(struct DICE *NOW,char com);
int dice_check(struct DICE *NOW,struct DICE *A);

int main(void){
struct DICE A[6],B[6],*NOW;
int i,j,k,c,up,front,data[200][7];

scanf("%d",&c);
if(c==100){c=90;}
for(i=0;i<c;i++){
	scanf("%d %d %d %d %d %d",&data[i][0],&data[i][1],&data[i][2],&data[i][3],&data[i][4],&data[i][5]);
}
for(k=0;k<c-1;k++){
	A[0].data=data[k][0];
	A[1].data=data[k][1];
	A[2].data=data[k][2];
	A[3].data=data[k][3];
	A[4].data=data[k][4];
	A[5].data=data[k][5];

	A[0].N=&A[4];
	A[0].E=&A[2];
	A[0].S=&A[1];
	A[0].W=&A[3];
	A[0].B=&A[5];

	for(j=k+1;j<c;j++){

	B[0].data=data[j][0];
	B[1].data=data[j][1];
	B[2].data=data[j][2];
	B[3].data=data[j][3];
	B[4].data=data[j][4];
	B[5].data=data[j][5];

	B[0].N=&B[4];
	B[0].E=&B[2];
	B[0].S=&B[1];
	B[0].W=&B[3];
	B[0].B=&B[5];

NOW=&B[0];
up=A[0].data;
front=A[0].S->data;

while(1){
	for(i=0;i<4;i++){
		if(NOW->S->data==front){break;}
		NOW=turn(NOW,'S');
		}
	if(i==4){NOW=turn(NOW,'E');}else{break;}
	}
for(i=0;i<4;i++){
	if(NOW->data==up){break;}
    NOW=turn(NOW,'E');
	}
	if(dice_check(NOW,&A[0])!=0){printf("No\n");return 0;}
//	if(dice_check(NOW,&A[0])!=0){printf("??????\n");break;}else{printf("%d %d??????\n",k,j);}

	}
}
printf("Yes\n");
return 0;
}

struct DICE *turn(struct DICE *NOW,char com){
	struct DICE *TEMP;
	TEMP=NOW;
	switch(com){
	case 'N':
		NOW=NOW->S;
		NOW->N=TEMP;
		NOW->S=TEMP->B;
		NOW->E=TEMP->E;
		NOW->W=TEMP->W;
		NOW->B=TEMP->N;
		break;
	case 'S':
		NOW=NOW->N;
		NOW->N=TEMP->B;
		NOW->S=TEMP;
		NOW->E=TEMP->E;
		NOW->W=TEMP->W;
		NOW->B=TEMP->S;
		break;
	case 'E':
		NOW=NOW->W;
		NOW->N=TEMP->N;
		NOW->S=TEMP->S;
		NOW->E=TEMP;
		NOW->W=TEMP->B;
		NOW->B=TEMP->E;
		break;
	case 'W':
		NOW=NOW->E;
		NOW->N=TEMP->N;
		NOW->S=TEMP->S;
		NOW->E=TEMP->B;
		NOW->W=TEMP;
		NOW->B=TEMP->W;
		break;
	}
	return(NOW);
}
int dice_check(struct DICE *NOW,struct DICE *A){

	if(NOW->data==A->data && NOW->S->data==A->S->data && NOW->N->data==A->N->data && NOW->E->data==A->E->data && NOW->W->data==A->W->data && NOW->B->data==A->B->data){return 1;}else{return 0;}

}

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

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

	vector<pair<unsigned int,bool>>a(n+1);
	for (int i = 0; i < m; i++){
		int b;
		cin >> b;
		a[b].second = true;
	}
	a[0].first = 1;
	for (int i = 1; i <= n; i++){
		if (!a[i - 1].second)
			a[i].first = (a[i].first + a[i - 1].first) % 1000000007;
		if (i!=1&&!a[i - 2].second)
			a[i].first = (a[i].first + a[i - 2].first) % 1000000007;
	}

	cout << a[n].first << endl;
		

	return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
vector<bool> check(string S, string T, int lim) {
	vector<bool> res(2 * lim + 1, true);
	for (int i = -lim; i <= lim; ++i) {
		for (int j = 0; j < S.size(); ++j) {
			int t = j - i;
			if (0 <= t && t < int(T.size()) && S[j] != '?' && T[t] != '?' && S[j] != T[t]) {
				res[i + lim] = false;
				break;
			}
		}
	}
	return res;
}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	string A, B, C;
	cin >> A >> B >> C;
	int len = A.size() + B.size() + C.size();
	vector<bool> resab = check(A, B, len);
	vector<bool> resbc = check(B, C, len);
	vector<bool> resac = check(A, C, len);
	int ans = (1 << 30);
	for (int i = -len; i <= len; ++i) {
		if (!resab[i + len]) continue;
		for (int j = -len; j <= len; ++j) {
			if (!resbc[j + len]) continue;
			int k = i + j;
			if (-len <= k && k <= len && resac[k + len]) {
				int sa = 0, sb = sa + i, sc = sb + j;
				int pl = min({ sa, sb, sc });
				int pr = max({ sa + int(A.size()), sb + int(B.size()), sc + int(C.size()) });
				ans = min(ans, pr - pl);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;


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

    vector<int> N(3);

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

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

    cout << N[0] + N[1] << endl;
}

Measured memory_bytes: 256
N = int(input())
p = list(map(int, input().split()))
if p == list(range(1, N + 1)):
    result = True
else:
    result = False
    for i in range(N):
        for j in range(i + 1, N):
            q = [p[k] for k in range(N)]
            q[i], q[j] = q[j], q[i]
            if q == list(range(1, N + 1)):
                result = True
print("YES" if result else "NO")


Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
int kazu;
int a,b,c;
scanf("%d",&kazu);
for(int i = 0; i < kazu; i++){
scanf("%d %d %d",&a,&b,&c);
if(a * a + b * b == c * c || a * a + c * c == b * b || a * a == b * b + c * c){
printf("YES\n");
}
else{
printf("NO\n");
}
}
return 0;
}


Measured memory_bytes: 2076
#include<iostream>
using namespace std;
long long gcd(long long a, long long b)
{
    if(a==0)
        return b;
    return gcd(b%a,a);
}
long long lcm(long long a, long long b)
{
    return (a*b)/gcd(a,b);
}
int main()
{
    long long x,y;
    while(cin>>x>>y)
    {
        cout<<gcd(x,y)<<" "<<lcm(x,y)<<endl;
    }
}



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

int main(void) {
    int N;
    cin >> N;
    int ans = INT_MAX;
    for (int i = 0; i <= N; i++) {
        int tmp = i;
        int current = 0;
        while (tmp > 0) {
            current += tmp % 6;
            tmp /= 6;
        }
        tmp = N - i;
        while (tmp > 0) {
            current += tmp % 9;
            tmp /= 9;
        }
        ans = min(current, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	x := ReadInt()
	if x < 600 {
		fmt.Println(8)
	} else if x < 800 {
		fmt.Println(7)
	} else if x < 1000 {
		fmt.Println(6)
	} else if x < 1200 {
		fmt.Println(5)
	} else if x < 1400 {
		fmt.Println(4)
	} else if x < 1600 {
		fmt.Println(3)
	} else if x < 1800 {
		fmt.Println(2)
	} else {
		fmt.Println(1)
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
N=int(input())
import sys
input=sys.stdin.readline

a=list(map(int,input().split()))
b=list(map(int,input().split()))

A=0
B=0
for i in range(N):
    if a[i]==b[i]:
        pass
    elif a[i]>b[i]:
        B+=a[i]-b[i]
    else:
        if (b[i]-a[i])%2==1:
            A+=b[i]-a[i]+1
            B+=1
        else:
            A+=b[i]-a[i]
if A<B*2:
    print("No")
else:
    print("Yes")
#print(A,B)
    
        

Measured memory_bytes: 4596
n, m = map(int, input().split())
l = [0]*m

for _ in range(n):
    a = list(map(int, input().split()))[1:]
    for j in range(len(a)):
        l[a[j]-1] += 1


count = 0
for i in range(m):
    if l[i] == n:
        count += 1

print(count)


Measured memory_bytes: 3060
n = int(input())
h = list(map(int, input().split()))
h.insert(0, float("inf"))

dp = [0 for _ in range(n+1)]

for i in range(2, n+1):
    dp[i] = min( (dp[i-1] + abs(h[i] - h[i-1])), (dp[i-2] + abs(h[i] - h[i-2]))  )

print(dp[-1])

Measured memory_bytes: 13928
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int kakuinowa(int num) {
	int dig, sum = 0;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	return sum;
}

int main() {
	int N, A, B;
	cin >> N;
	ll mn = INF;
	rep1(i, N) {
		A = i;
		B = N - A;
		//kakuinowa
		//cout << ll(kakuinowa(A) + kakuinowa(B)) << endl;
		chmin(mn, ll(kakuinowa(A) + kakuinowa(B)));
	}
	cout << mn << endl;
	return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
if n % 2 == 1:
    print(0)
    exit()
else:   
    ten_list = []
    five = 5
    while five*2 <= n:
        ten_list.append(five*2)
        five = five * 5
    count = 0
    for f in ten_list:
        count += n//f
    print(int(count))


Measured memory_bytes: 38384
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!T;r.popFront;}}

const inf = 10^^9;

void main()
{
  int n; readV(n);
  int[] t; readA(n, t);
  int[] v; readA(n, v);

  t[] *= 2; v[] *= 2;
  foreach (i; 0..n-1) t[i+1] += t[i];
  auto te = t[$-1];

  auto l = [Line(1, 0, 0, te), Line(-1, te, 0, te)];

  foreach (i; 0..n)
    l ~= Line(0, v[i], i == 0 ? 0 : t[i-1], t[i]);

  foreach (i; 0..n-1)
    if (v[i] < v[i+1])
      l ~= Line(1, v[i]-t[i], t[i], te);
    else
      l ~= Line(-1, v[i+1]+t[i], 0, t[i]);

  auto u = new int[](te+1);
  foreach (i; 0..te+1)
    u[i] = l.map!(li => li.v(i)).reduce!min;

  auto r = 0.0L;
  foreach (i; 0..te)
    if      (u[i] < u[i+1]) r += 0.5 + u[i];
    else if (u[i] > u[i+1]) r += 0.5 + u[i+1];
    else                    r += u[i];

  writefln("%.4f", r/4);
}

struct Line
{
  int a, b, ts, te;
  auto v(int t) { return (t < ts || t > te) ? inf : a*t+b; }
}


Measured memory_bytes: 2428
#include <cstdio>
int ans[300005]; 
int main()
{
	// freopen("ARC084-E.in", "r", stdin); 
	int k, n; 
	scanf("%d%d", &k, &n); 
	if (k & 1 ^ 1)
	{
		printf("%d%c", k >> 1, " \n"[n == 1]);
		for (int i = 1; i < n; i++)
			printf("%d%c", k, " \n"[i + 1 == n]);
	}
	else
	{
		for (int i = 0; i < n; i++)
			ans[i] = k + 1 >> 1; 
		int cur = n - 1; 
		for (int i = 0; i < n >> 1; i++)
		{
			if (ans[cur] == 1)
				cur--; 
			else
			{
				ans[cur]--; 
				while (cur < n - 1)
					ans[++cur] = k; 
			}
		}
		for (int i = 0; i <= cur; i++)
			printf("%d%c", ans[i], " \n"[i == cur]);
	}
	return 0; 
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
using namespace std;
typedef long long ll;
template <class T> inline bool dpmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool dpmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

//  < > > <
// 0 2 1 0 1
void solve(string S) {
    ll n = S.size(), ans = 0;
    vector<ll> a(n+1, 0);

    for (int i = 0; i <= n - 1; i++) {
        if (S[i] == '<') {
            dpmax(a[i+1], a[i]+1);
        }
    }

    for (int i = n - 1; i >= 0; i--) {
        if (S[i] == '>') {
            dpmax(a[i], a[i+1]+1);
        }
    }

    for (int i = 0; i <= n; i++) {
        ans += a[i];
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  string S;
  cin >> S;
  solve(S);
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    vector<int> ans;
    int m, nmin, nmax, res, temp;
    while(true){
        temp = 0;
        res = 0;
        cin >> m >> nmin >> nmax;
        if(m == 0) break;
        vector<int> A(m);
        rep(i, m) cin >> A[i];
        sort(A.begin(), A.end(), greater<int>());
        for(int i = nmin; i <= nmax; i++){
            if(temp <= A[i-1] - A[i]){
                temp = A[i-1] - A[i];
                res = i;
            }
        }
        ans.push_back(res);
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s[i] =='1') {
      cout << '9';
    }
    else {
      cout << '1';
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
//席0との距離の偶奇と性別に注目すると、2分探索が生える。
#include <iostream>
#include <string>
using namespace std;

int query(int x) {
	cout << x << endl;
	cout.flush();
	string res;
	cin >> res;
	if (res == "Male") return 0;
	if (res == "Female") return 1;
	return -1;
}

int main() {
	int n;
	cin >> n;
	
	int q0 = query(0);
	if (q0 == -1) { return 0; }
	
	int st = 0, ed = n, mid;	//[st, ed)
	while (ed - st >= 2) {
		mid = (st + ed) / 2;
		int qMid = query(mid);
		if (qMid == -1) { return 0; }
		if (mid % 2 == (q0 == qMid)) ed = mid;
		else st = mid;
	}
	int hoge = query(st);
	if (hoge == -1) { return 0; }
	cout << "Not Found" << endl;
	return 0;
}

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

int main(){
  int k, s;
  cin >> k >> s;
  int count = 0;
  
  for(int i = 0; i<=k; i++){
    for(int j = 0; j<=k; j++){
      if(0 <= s-(i+j) && s-(i+j) <= k)
        count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256