akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque




def run():
    X = int(input())
    if 400 <= X <= 599:
        print(8)
    elif 600 <= X <= 799:
        print(7)
    elif 800 <= X <= 999:
        print(6)
    elif 1000 <= X <= 1199:
        print(5)
    elif 1200 <= X <= 1399:
        print(4)
    elif 1400 <= X <= 1599:
        print(3)
    elif 1600 <= X <= 1799:
        print(2)
    elif 1800 <= X <= 1999:
        print(1)



if __name__ == "__main__":
    run()

Measured memory_bytes: 9460
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

    static class Pair {
        int left;
        int right;

        Pair(int l, int r) {
            left = l;
            right = r;
        }
    }

    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int[] as = new int[n];
        int[] bs = new int[n];
        PriorityQueue<Pair> pq = new PriorityQueue<>(new Comparator<Pair>() {
            @Override
            public int compare(Pair o1, Pair o2) {
                return o1.right - o2.right;
            }
        });
        for (int i = 0; i < n; i++) {
            as[i] = std.nextInt();
            bs[i] = std.nextInt();
            pq.add(new Pair(as[i], bs[i]));
        }

        long current = 0;
        boolean ans = true;
        while (!pq.isEmpty()) {
            Pair p = pq.poll();
            current += p.left;
            if (current > p.right) {
                ans = false;
                break;
            }
        }

        if (ans) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 104872
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;

class Scanner{
  string[] s;
  int i;
 
  char[] cs = new char[] { ' ' };
 
  public Scanner(){
    s = new string[0];
    i = 0;
  }
 
  public string next(){
    if (i < s.Length) return s[i++];
    string st = Console.ReadLine();
    while (st == "") st = Console.ReadLine();
    s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
    if (s.Length == 0) return next();
    i = 0;
    return s[i++];
  }
 
  public int nextInt(){
    return int.Parse(next());
  }
  public int[] ArrayInt(int N, int add = 0){
    int[] Array = new int[N];
    for (int i = 0; i < N; i++){
      Array[i] = nextInt() + add;
    }
    return Array;
  }
 
  public long nextLong(){
    return long.Parse(next());
  }
 
  public long[] ArrayLong(int N, long add = 0){
    long[] Array = new long[N];
    for (int i = 0; i < N; i++){
      Array[i] = nextLong() + add;
    }
    return Array;
  }
 
  public double nextDouble(){
    return double.Parse(next());
  }

  public double[] ArrayDouble(int N, double add = 0){
    double[] Array = new double[N];
    for (int i = 0; i < N; i++){
      Array[i] = nextDouble() + add;
    }
    return Array;
  }
}

public class procon {
  public procon(){}
  
  Scanner cin;
  public static int Main(){
    new procon().calc();
    return 0;
  }
  
  void calc(){
    cin=new Scanner();
    int n=cin.nextInt();
    Console.WriteLine(n*(n+1)/2);
  }
}

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

ll dp[3001][3001][3], a[3001][3001];
int vis[3001][3001][3];

ll func(int r, int c, int cnt) {
    if(r < 0 || c < 0 || cnt < 0) return 0;
    if(vis[r][c][cnt]) return dp[r][c][cnt];
    vis[r][c][cnt] = 1;
    return dp[r][c][cnt] = max({func(r-1, c, 2) + a[r][c], func(r, c-1, cnt), func(r, c-1, cnt-1) + a[r][c]});
}

int main() {
    ll r,c,items, x , y, v, maxi = 0;
    cin >> r >> c >> items;
    while(items--) {
    	cin >> x >> y >> v;
    	a[x-1][y-1]=v;
    }
    maxi = func(r-1, c-1, 2);
    cout << maxi;
	return 0;
}

Measured memory_bytes: 390696
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
int X, Y, Z;

int main() {
   cin >> X >> Y >> Z;
   cout << (X - Z) / (Z + Y) << endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    ll c=0;
    for(ll i=0;i<3;i++)
    {
        if(s[i]==t[i])
        c++;
    }
    cout<<c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }

bool edge[10][10];

int main() {
  int n,m;
  cin >> n >> m;
  int a[m],b[m];
  FOR(i,0,m-1){
    cin >> a[i] >> b[i];
    --a[i]; --b[i];
    edge[a[i]][b[i]] = true;
    edge[b[i]][a[i]] = true;
  }

  vector<int> perm(n);
  FOR(i,0,n-1) perm[i] = i;

  int ans = 0;

  do{
    if(perm[0]!=0) break;

    bool ok = true;
    FOR(i,0,n-2) {
      if(!edge[perm[i]][perm[i+1]]) ok = false;
    }
    if(ok) ++ans;

  } while (next_permutation(perm.begin(),perm.end()));

  cout << ans << endl;

}



Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N, M; cin >> N >> M;
    vi A(N), B(N); REP(i, N) cin >> A[i] >> B[i];

    map<int, ll> mp;
    REP(i, N) {
        if (mp.count(A[i]) > 0) mp[A[i]] += B[i];
        else mp[A[i]] = B[i];
    }

    ll ans = 0;
    ll cnt = 0;
    for(auto m : mp) {
        if (cnt >= M) break;

        ll buy = min(m.second, M - cnt);
        ans += m.first * buy;
        cnt += buy;
    }

    cout << ans << endl;

    return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


void aryan_p() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}


int32_t main() {


	char x ; 
	cin>>x;

	if(isupper(x)){
		cout<<"A";
	}
	else{
		cout<<"a";
	}






	return 0;
}

Measured memory_bytes: 3628
import math
x = input().split()

A = int(x[0])
B = int(x[1])

T = "n"
for i in range(1500):
  if math.floor(0.08*i) == A and math.floor(0.1*i) == B:
    print(i)
    T = "y"
    break
if T == "n":
  print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
ll calc(ll h) {
	if (h == 1) return 1;
	else return 2 * calc(h / 2) + 1;
}
int main() {
	ll h;
	cin >> h;
	cout << calc(h) << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

vector<pint> v[200020];
int a[200020];
int cnt[200020];

void dfs(int from,int color,int now){
//  cout << v[now].size() << endl;
  for(int i=0;i<v[now].size();i++){
    if(v[now][i].first!=from){
      if(cnt[now]==color)cnt[now]++;
      a[v[now][i].second]=cnt[now];
      
//      cout << cnt[now] << endl;
      dfs(now,cnt[now],v[now][i].first);
      cnt[now]++;
    }
  }
}



int main(){
  for(int i=0;i<200020;i++)cnt[i]++;
  int n;
  cin >> n;
  rep(j,n-1){
    int x,y;
    cin >> x >> y;
    x--,y--;
    v[x].push_back({y,j});
    v[y].push_back({x,j});
    if(j==n-2)dfs(-1,0,y);
  }
  ll m=0;
  rep(i,n-1)m=max(m,(ll)a[i]);
  cout << m << endl;
  rep(i,n-1)cout << a[i] << endl;
return 0;}

Measured memory_bytes: 12160
#include <iostream>
#include <cstdio>
#include <cassert>
#include <bitset>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
const int MAXN = 100005;
long long n,c;
pair<long long,long long> pt[MAXN];
long long front[MAXN],back[MAXN];
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> c;
    for(int i = 1; i <= n; i++){
        cin >> pt[i].first >> pt[i].second;
    }
    sort(pt + 1, pt + n +1);
    long long sum = 0;
    long long ans = 0;
    priority_queue<pair<long long,long long > > fpq,bpq;
    for(int i = 1; i <= n; i++){
        front[i] = -pt[i].first + sum + pt[i].second;
        sum += pt[i].second;
        ans = max(ans,front[i]);
        fpq.push(make_pair(front[i],i));
    }
    
    sum = 0;
    for(int i = n; i >= 1; i--){
        back[i] = -(c - pt[i].first) + sum + pt[i].second;
        sum += pt[i].second;
        ans = max(ans,back[i]);
        bpq.push(make_pair(back[i],i));
    }
    for(int i = 1; i <= n - 1; i++){
        while(bpq.size() && bpq.top().second <= i) bpq.pop();
        long long temp = front[i] - pt[i].first + bpq.top().first;
        ans = max(ans,front[i] - pt[i].first + bpq.top().first);
    }
    for(int i = n; i > 1; i--){
        while(fpq.size() && fpq.top().second >= i) fpq.pop();
        ans = max(ans,back[i] - (c - pt[i].first) + fpq.top().first);
    }
    cout << ans;
    
    
//    cout << ans;
    
    return 0;
}


/*
 15 10000000000
 400000000 1000000000
 800000000 1000000000
 1900000000 1000000000
 2400000000 1000000000
 2900000000 1000000000
 3300000000 1000000000
 3700000000 1000000000
 3800000000 1000000000
 4000000000 1000000000
 4100000000 1000000000
 5200000000 1000000000
 6600000000 1000000000
 8000000000 1000000000
 9300000000 1000000000
 9700000000 1000000000
 */


Measured memory_bytes: 8816
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
string s,tar = "AKIHABARA";
bool Solve() {
    cin >> s;
    if(s.length() > 9) {
	return false;
    }
    for(int i = 0 ; i < 9 ; ++i) {
	if(s.length() <= i) s += "A";
	if(s[i] != tar[i]) {
	    if(tar[i] == 'A') {
		s.insert(i,1,'A');
	    }
	    else return false;
	}
    }
    if(s != tar) return false;
    return true;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    if(Solve()) puts("YES");
    else puts("NO");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    vector<pair<ll,ll>> xy(N);
    for(int i=0; i<N; i++) cin >> xy[i].first >> xy[i].second;

    sort(xy.begin(), xy.end());
    map<pair<ll,ll>, int> mp;

    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(i == j) continue;

            ll p = xy[i].first - xy[j].first;
            ll q = xy[i].second - xy[j].second;
            mp[{p, q}]++;
        }
    }

    int maxv = 0;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        if(itr->second > maxv){
            maxv = itr->second;
        }
    }

    cout << N-maxv << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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

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

    int N;
    cin >> N;
    vector<int> v(N), c(N);
    rep(i, 0, N) cin >> v[i];
    rep(i, 0, N) cin >> c[i];

    int rsl = -1e9;
    for(int mask = 0; mask < 1 << N; mask++) {
        int tmp = 0;
        rep(i, 0, N) {
            if(mask & (1 << i)) {
                tmp += v[i] - c[i];
            }
        }

        chmax(rsl, tmp);
    }

    cout << rsl << endl;
}


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

int main(void) 
{
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];

    int ans = x;
    int base = 1;
    while(1)
    {
        bool exist = false;
        rep(i,n)
        {
            if(ans == p[i])
            {
                exist = true;
                break;
            }
        }
        if(!exist) break;
        if(base%2 != 0) ans -= base;
        else ans += base;
        base++;
    }

    cout << ans << endl;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            double answer =0.0;

            double oddNumber = input / 2;
            if(input % 2 > 0.4)
            {
                oddNumber++;
            }

            answer = oddNumber / input;

            Console.WriteLine(answer);
        }
    }
}

Measured memory_bytes: 13140
import sys

a,b,c=map(int,input().split())
k=int(input())
cnt=0

if a>=b:
    while a>=b:
        b*=2
        cnt+=1
        if cnt>k:
            print('No')
            sys.exit()
if b>=c:
    while b>=c:
        c*=2
        cnt+=1
        if cnt>k:
            print('No')
            sys.exit()
            
print('Yes')

Measured memory_bytes: 9124
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec; }
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::vector<ll> va(3, 0LL);
  for (ll i = 0; i < 3; i++) std::cin >> va[i];
  std::sort(va.begin(), va.end());

  std::vector<ll>::iterator last = std::unique(va.begin(), va.end());
  if (std::distance(va.begin(), last) == 2) {
    print("Yes");
  } else {
    print("No");
  }

  return 0;
}


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type / Class / Struct Definitions:
using ll = long long;
using ull = unsigned long long;

//Constants:
const int INF = (1ll << 30) - 1;  //nearly 1.07e9
const ll INFLL = 1ll << 60;       //nearly 1.15e18
const int MOD = 1e9 + 7;
const long double EPS = 1.0e-14;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

//================ Main Loop ================
int main() {
    string s;
    cin >> s;
    int n = s.size();

    rep(i, n) {
        if(s[i] == s[n - 1 - i])
            continue;
        else {
            cout << "No" << endl;
            return 0;
        }
    }

    rep(i, (n - 1) / 2) {
        if(s[i] == s[(n - 1) / 2 - i - 1])
            continue;
        else {
            cout << "No" << endl;
            return 0;
        }
    }

    for(int i = (n + 3) / 2; i < n; i++) {
        if(s[i] == s[n - i - 1])
            continue;
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string X;
string Y;
void lcs( int m, int n ) 
{ 
   int L[m+1][n+1]; 
  
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
  

   int index = L[m][n]; 
   char lcs[index+1]; 
   lcs[index] = '\0';  
  
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1]; 
          i--; j--; index--;     
      } 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
   if(strlen(lcs)==0)
    cout<<" ";
   cout<<lcs; 
} 

int main()
{
    cin>>X;
    cin>>Y;
    int len_x=X.length();
    int len_y=Y.length();
    lcs(len_x,len_y);
    return 0;
}
  

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

int main() {
int n,k,q,d;cin>>n>>k>>q;int a[q+1],p[n+1]; for(int i=1;i<n+1;i++)p[i]=k-q;
  for(int i=1;i<q+1;i++){
    cin>>a[i];p[a[i]]++;
  }
  
 for(int i=1;i<n+1;i++){
   //cout<<i<<" ";
   if(p[i]>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
   
  }
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int a, b, c, ans = 0, box[3] = {};

int main(){
	cin >> a >> b >> c;

	if (a == b && b == c && a % 2 == 0){
		cout << -1 << endl;
	}
	else{
		while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
			box[0] = (b + c) / 2;
			box[1] = (c + a) / 2;
			box[2] = (a + b) / 2;
			a = box[0];
			b = box[1];
			c = box[2];
			ans++;
		}

		cout << ans << endl;
	}

	return 0;
}

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

int main() {
  int s;
  cin >> s;
  int s1, s2, s3;
  s1 = s / 100;
  s2 = s % 100 / 10;
  s3 = s % 100 % 10;
  cout << s1 + s2 + s3 << endl;
}

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

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

typedef long long ll;



int main() {
    string S;
    int K;
    cin >> S;
    cin >> K;
    char first = S[0];
    char before = '0';
    char beforeT = S[0];
    char last = S[S.size()-1];

    ll needChange = 0;

    int sameCount = 1;
    int firstSameCounter = 0;
    bool allSame = true;
    REP(i,S.size()) {
        // cout << "same count "<< sameCount << " ind" << i << " v " << S[i] << endl;
        if (beforeT != S[i]) {
            allSame = false;
        } else {
            if (allSame) {
                firstSameCounter++;
            }
        }
        if (before==S[i]) {
            sameCount++;

        } else {
            needChange += int(sameCount/2);
            sameCount=1;
            // cout << needChange << endl;
        }
        before = S[i];
        beforeT = S[i];
    }
    if (allSame) {
        cout << ll((S.size()*K)/2) << endl;
        return 0;
    }
    needChange += int(sameCount/2);

    needChange*=K;
    if (S.size() > 2) {
        if (last==first) {
            char lastBef = S[S.size()-2];
            char firstFor = S[1];
            int backSameCounter = 0;
            char lastT=S[S.size()-1];
            REP(i,S.size()) {
                int backIndex = S.size()-1-i;
                if (S[backIndex]==lastT) {
                    backSameCounter++;
                } else {
                    break;
                }
                lastT = S[backIndex];
            }
            // cout << firstSameCounter  << " " << backSameCounter << endl;
            if ((firstSameCounter%2==1) && (backSameCounter%2==1)) {
                needChange += K-1;
            }
        }
    }
    cout << needChange << endl;

    return 0;
}


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

int main() {
	set<tuple<int, int, int> > tpls;
	int a, b, c; cin >> a >> b >> c;
	int res = 0;
	while (a % 2 + b % 2 + c % 2 == 0) {
		int na = (b + c) / 2, nb = (a + c) / 2, nc = (a + b) / 2;
		a = na;
		b = nb;
		c = nc;
		if (!tpls.emplace(a, b, c).second) return cout << -1, 0;
		++res;
	}
	cout << res;
	return 0;
}


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

using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        a[i] = s[i] == 'R' ? 0 : s[i] == 'G' ? 1 : 2;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        int cnt[3] = {};
        for(int j = n-1; i < j; j--) {
            if(a[i] != a[j]) {
                int d = 0;
                for(; ; d++) {
                    if(d != a[i] && d != a[j]) {
                        break;
                    }
                }
                ans += cnt[d];
                int k = 2*j - i;
                if(k < n && a[k] == d) {
                    ans--;
                }
            }
            cnt[a[j]]++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

int main()
{
	int N,M;
	int i,j,k;
	int d[100010] = {0};
	ll t[100010]  = {0};
	cin >> N >> M;
	for(i=0;i<M;++i)
	{
		cin >> j;
		d[j] = 1;
	}
	t[0]=1;
	for(i=1;i<=N;++i)
	{
		if(d[i])
			continue;
		t[i]+=t[i-1];
		if(i>1)
			t[i]+=t[i-2];
		t[i]%=1000000007;
	}
	cout << t[N] << endl;
	return 0;
}




































Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int N;
vector<int> G[200005];
vector<int> color;
vector<int> ans;
void dfs(int now){
  color[now]=1;
  for(int next:G[now]){
    if(color[next]==0){ans[next]+=ans[now];dfs(next);}
  }
  color[now]=2;
}
int main() {
  cin>>N;
  int Q;
  cin>>Q;
  color.resize(N);
  ans.resize(N);
  for(int i=0;i<N-1;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for(int i=0;i<Q;i++){
    int p,x;
    cin>>p>>x;
    p--;
    ans[p]+=x;
  }
  dfs(0);
  for(int i=0;i<N;i++){
    cout<<ans[i]<<endl;
  }
  return 0;  
}

Measured memory_bytes: 21908
using System;
using System.Collections.Generic;
using System.Linq;

public class AtCoderB
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        int count = 0;
        for (int i = 1; i <= n; i++)
        {
            if ((1 <= i && i < 10) || (100 <= i && i < 1000) || (10000 <= i && i < 100000))
            {
                count++;
            }
        }

        Console.WriteLine(count);
    }
}

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


typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
  //cout.precision(10);
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int H,W;
  cin >> H >> W;
  
  int G[10][10];
  rep(i,10)rep(j,10) cin >> G[i][j];

  int V = 10;
  //ワーシャルフロイド法
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
  
  /*rep(i,10){
    rep(j,10){
      cout << G[i][j] << ' ';
    }
    cout << endl;
  }*/
  
  vector<vector<int>> a(H,vector<int>(W,0));
  
  int ans = 0;
  
  rep(i,H)rep(j,W){
    cin >> a[i][j];
    if(a[i][j] == -1 || a[i][j] == 1)continue;
    ans += G[a[i][j]][1];
  }

  cout << ans << endl;
  
  
  
}

  
  


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		long[] ans = new long[n];
		for (int i = 0; i < n; i++) {
			if (i % 2 == 0) {
				ans[0] += a[i];
			} else {
				ans[0] -= a[i];
			}
		}
		for (int i = 1; i < n; i++) {
			ans[i] = (a[i - 1] - ans[i - 1] / 2) * 2;
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append(ans[i]).append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 53796
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
/*cout <<"Debug"
cout <<x-30<<' '<<y-30<<endl;*/
typedef pair<pair<int ,int>, int> P;
vector<pair<pair<int ,int>, int> > v_ans;
vector<long int>v;
vector<long int>v_ansl;
/*taro tenn,hanako_ten,sum*/

bool cmp(P h, P r){
  return h.second < r.second;
}
int main(){
    int N;
    cin >>N;
    while(N != 0){
      for (int i = 0;i<N;i++){
        long int x;
        cin >>x;
        v.push_back(x);
      }
      for(int i = 0;i < N;i++){
        for(int j = i+1; j < N;j++){
          if(i == j)continue;
          v_ansl.push_back(abs(v[i]-v[j]));
        }
      }
      sort(v_ansl.begin(),v_ansl.end());
      cout <<v_ansl[0]<<endl;

      v_ansl.clear();
      v.clear();


      cin >>N;
    }
  return 0;
}



Measured memory_bytes: 7044
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
 
//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end

int mod = 1e9+7;
struct Mint {
  int val;
  Mint inv() const {
    int tmp, a = val, b = mod, x = 1, y = 0;
    while(b) tmp = a / b, a -= tmp * b, swap(a, b), x -= tmp * y, swap(x, y);
    return Mint(x);
  }
public:
  Mint() :val(0) {}
  Mint(ll x) :val(x >= 0 ? x % mod : x % mod + mod) {}
  int mtoi() { return this->val; }
  Mint pow(ll t) { Mint res = 1,b = *this; while(t){if(t&1)res *= b;b *= b;t >>= 1;}return res; }
  Mint& operator+=(const Mint& x) { if ((val += x.val) >= mod) val -= mod; return *this; }
  Mint& operator-=(const Mint& x) { if ((val += mod - x.val) >= mod) val -= mod; return *this; }
  Mint& operator*=(const Mint& x) { val = (ll)val * x.val % mod; return *this; }
  Mint& operator/=(const Mint& x) { return *this *= x.inv(); }
  bool operator==(const Mint& x) const { return val == x.val; }
  bool operator!=(const Mint& x) const { return val != x.val; }
  bool operator<(const Mint& x) const { return val < x.val; }
  bool operator<=(const Mint& x) const { return val <= x.val; }
  bool operator>(const Mint& x) const { return val > x.val; }
  bool operator>=(const Mint& x) const { return val >= x.val; }
  Mint operator+(const Mint& x) const { return Mint(*this) += x; }
  Mint operator-(const Mint& x) const { return Mint(*this) -= x; }
  Mint operator*(const Mint& x) const { return Mint(*this) *= x; }
  Mint operator/(const Mint& x) const { return Mint(*this) /= x; }
};
struct factorial {
  vector<Mint> Fact, Finv;
public:
  factorial(int maxx) {
    Fact.resize(maxx+1,Mint(1)),Finv.resize(maxx+1); rep(i,0,maxx)Fact[i+1]=Fact[i]*Mint(i+1);
    Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*Mint(i);
  }
  Mint fact(int n,bool inv) { if(inv) return Finv[n]; else return Fact[n]; }
  Mint nPr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[n-r]; }
  Mint nCr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[r]*Finv[n-r]; }
};
int cnt(int mask){
  int res=0;
  while(mask){
    if(mask&1)res++;
    mask>>=1;
  }
  return res;
}

int main(){
  int n; scanf("%d",&n);
  int a[25][25];
  rep(i,0,n)rep(j,0,n)scanf("%d",&a[i][j]);
  Mint dp[1<<22]={}; dp[0]=1;
  rep(mask,1,1<<n){
    int i=cnt(mask);
    rep(j,0,n)if(((mask>>j)&1)&&a[i-1][j]){
      dp[mask]+=dp[mask-(1<<j)];
    }
  }
  printf("%d\n",dp[(1<<n)-1].mtoi());
  return 0;
}


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

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()

#define ll long long
#define ld long double

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for (auto &x : h) cin >> x;
    vector<vector<int>> g(n);
    while (m--) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        bool good = 1;
        for (auto x : g[i]) {
            if (h[x] >= h[i]) good = 0;
        }
        if (good) ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 8724
import fractions as f
n=int(input())
c=list(map(int, input().split()))
for i in range(1,n):
    c[i]=f.gcd(c[i-1],c[i])
ans=0
while True:
    if c[n-1]/2==c[n-1]//2:
        ans+=1
        c[n-1]/=2
    else:
        break
print(ans)

Measured memory_bytes: 5048
function Main(input) {
  const numbers = input.split(' ').map(n => Number(n));
  const p1 = numbers[0] * numbers[1];
  const p2 = numbers[2];

  if (p1 > p2) {
    console.log(p2);
  } else {
    console.log(p1);
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())

int main(){
	int n;
	cin>>n;
	cout<<n*n*n<<endl;
    return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
al = list(map(int,input().split()))

for _ in range(k):
    imos = [0 for i in range(n+1)]
    for idx, a in enumerate(al):
        imos[max(idx-a, 0)] += 1
        imos[min(idx+a+1, n)] -= 1
    al = []
    now = 0
    for i in imos:
        now += i
        al.append(now)
    if len(set(al[:-1])) == 1 and al[0] == n:
        break

print(*al[:-1])


Measured memory_bytes: 181440
#include <stdio.h>

int main()
{
	char A[51][51],B[51][51];
	int i,j,k,l,n,m,c;
	bool flag=0;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++) scanf("%s",A[i]);
	for(i=0;i<m;i++) scanf("%s",B[i]);
	for(i=0;i<n-m+1 && flag==0;i++)
	{
		for(j=0;j<n-m+1 && flag==0;j++)
		{
			if(A[i][j]==B[0][0])
			{
				for(c=i;c<i+m;c++)
				{
					for(k=j,l=0;A[c][k]==B[c-i][l] && l<m;k++,l++) ;
					if(l!=m) break; 
				}
				if(c==i+m) flag=1;
			}
		}
	}
	printf("%s\n",flag ? "Yes" : "No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#ifdef _debug
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#define dout(i) //
#endif
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
string s, t;
int cnt[256];
vector<int> pos[256];
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> s >> t;
	for(char &i : t)++cnt[i];
	for(char &i : s)cnt[i] = 0;
	for(int i = 0;i < s.size();++i){
		pos[s[i]].push_back(i);
	}
	for(int i = 0;i < 256;++i)if(pos[i].size())pos[i].push_back(pos[i].front());
	for(int i = 0;i < 256;++i)if(cnt[i])return cout << -1 << '\n', 0;
	ll res = 0;
	for(int i = 0;i < t.size();++i){
		int cur = res % s.size(), next = 
			*lower_bound(pos[t[i]].begin(), pos[t[i]].end()-1, cur);
		if(next < cur)res += next + s.size() - cur;
		else res += next - cur;
		++res;
	}
	cout << res << '\n';
}

Measured memory_bytes: 1228
from collections import Counter
N, K = map(int, input().split(' '))
A = Counter(map(int, input().split(' ')))
if len(A) <= K:
    print(0)
else:
    print(N - sum([
        v for _, v in sorted(A.items(), key=lambda x: x[1], reverse=True)[:K]
    ]))


Measured memory_bytes: 41500
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const ll N=3005;
ll mod=1e9+7;
ll a[N];
ll dp[N][N];
ll n;
ll helper(int start,int end)
{
	if(start>end)
	return 0;
	if(start==end)
	return a[start];
	if(start==end-1)
	return max(a[start],a[end]);
	
	if(dp[start][end]!=-1)
	return dp[start][end];
	ll x=helper(start+2,end);
	ll y=helper(start+1,end-1);
	ll z=helper(start,end-2);
	
	return dp[start][end]=max(a[start]+min(x,y),a[end]+min(y,z));
	
	
}
int main()
{
    memset(dp,-1,sizeof(dp));
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	
	ll x=helper(0,n-1);
	ll sum=0;
	for(int i=0;i<n;i++)
	sum+=a[i];
	ll y=sum-x;
	cout<<x-y<<endl;
	
	return 0;
}

Measured memory_bytes: 70912
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

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

int main(){
	ios::sync_with_stdio(false);

	llong a, b, gcd, lcm, tmax, tmin;
	vl ar(2);

	while (cin >> a >> b){
		ar[0] = a;
		ar[1] = b;

		while (ar[1]!=0){
			VSORT(ar);
			ar[1] = (int)fmod(ar[1], ar[0]);
		}
		gcd = ar[0];
		lcm = a*b / gcd;

		cout << gcd << " " << lcm << endl;
	}
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

void solve(int h,int w) {
    vector<string> s(h);
    cin>>s;
    REP(i,h) {
        REP(j,w) {
            if(s[i][j]=='@') {
                queue<pii> q;
                vector<vector<bool>> vis(h,vector<bool>(w,false));
                vis[i][j]=true;
                q.push({i,j});
                int ans=1;
                while(!q.empty()) {
                    int y=q.front().first;
                    int x=q.front().second;
                    q.pop();
                    REP(d,4) {
                        int yy=y+DY[d];
                        int xx=x+DX[d];
                        if(OUTOFRANGE(yy,xx,h,w)) continue;
                        if(vis[yy][xx]) continue;
                        if(s[yy][xx]=='#') continue;
                        q.push({yy,xx});
                        vis[yy][xx]=true;
                        ans++;
                    }
                }
                cout<<ans<<endl;
                return;
            }
        }
    }
}
signed main() {
    while(1) {
        int h,w;
        cin>>w>>h;
        if(h+w==0) break;
        solve(h,w);
    }
    return 0;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int ans = min(B / A, C);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct aaa{
	int x,y,w;
}a[1010];
const int p=1e9+7;
vector<int>zh[1010];
int n,m,i,j,x,sz,k,l,ans,f[302][302][302];
int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].w);
		zh[a[i].y].push_back(i);
	}
	f[1][0][0]=3;
	for(i=1;i<=n;i++){
	 for(j=1;j<i;j++)
	  for(k=0;k<j;k++){
	  	for(l=0;l<zh[i].size();l++){
	  		x=zh[i][l];
	  		sz=1;
	  		if(a[x].x<=j)sz++;
	  		if(a[x].x<=k)sz++;
	  		if(sz!=a[x].w)f[i][j][k]=0;
	  	}
	  	if(!f[i][j][k])continue;
	  	(f[i+1][j][k]+=f[i][j][k])%=p;
	  	(f[i+1][i][k]+=f[i][j][k])%=p;
	  	(f[i+1][i][j]+=f[i][j][k])%=p;
	  }
	  for(l=0;l<zh[i].size();l++){
	  	x=zh[i][l];
	  	if(a[x].w!=1)f[i][0][0]=0;
	  }
	(f[i+1][0][0]+=f[i][0][0])%=p;
	 (f[i+1][i][0]+=f[i][0][0]*2%p)%=p;
  }
  for(j=0;j<n;j++)
   for(k=0;k<=j;k++)ans=(ans+f[n][j][k])%p;
  printf("%d",ans);
}

Measured memory_bytes: 105856
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> A(N+1), B(N);
    rep(i,0,N+1)cin >> A[i];
    rep(i,0,N)cin >> B[i];
    ll ans = 0;
    rep(i,0,N){
        if(A[i] > B[i]){
            A[i] -= B[i];
            ans += B[i];
        }else{
            ans += A[i];
            B[i] -= A[i];
            A[i] = 0;
            if(A[i+1] > B[i]){
                ans += B[i];
                A[i+1] -= B[i];
            }else{
                ans += A[i + 1];
                A[i+1] = 0;
            }
        }
    }   
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    string x="",y="";
    for(int i=1;i<=b;i++){
        x+=(a+'0');
    }
    for(int i=1;i<=a;i++){
        y+=(b+'0');
    }
    if(x<y) cout<<x<<endl;
    else cout<<y<<endl;
}

Measured memory_bytes: 256