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

#[allow(unused_macros)]
macro_rules ! vec_md { ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) } ; ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] } ; ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] } ; }

fn main() {
    input! {
        n: usize,
        p: [f64;n]
    }

    let mut dp = vec_md![0f64;n+1;n+1];
    dp[0][0] = 1.0;
    for i in 0..n {
        for j in 0..dp[0].len() {
            if j+1 < dp[0].len() {
                dp[i+1][j+1] += dp[i][j] * p[i];
            }
            dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
        }
    }
    let mut ret = 0.0;
    for i in n/2+1..n+1 {
        ret += dp[n][i];
    }
    println!("{}", ret);
}


Measured memory_bytes: 90364
#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define ROR(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define F first
#define S second
#define sz size()
#define mp make_pair
#define p(x) cout<< x << " ";
#define pe(x) cout<< x << endl ;
typedef long long ll;
const ll N = 1e5 + 5;
#define M 1000000007

int main()
{
    FAST
    ll a,b,c;
    cin>>a>>b>>c;
    ll sum=a+b+c;
    ll ma=max(a,max(b,c));
    sum=sum-ma;
    cout<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define mod 1000000007
int main ()
{
    int n;
    char a[110][11];
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%s",a[i]);
        getchar();
    }
    for(int i=1;i<n;i++){
        /*printf("%c\n",a[i][strlen(a[i])-1]);*/
        if(a[i][0]!=a[i-1][strlen(a[i-1])-1]){
            printf("No\n");
            return 0;
        }
        for(int j=i-1;j>=0;j--){
            if(strcmp(a[i],a[j])==0){
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n, k;
    while(cin>>n>>k){
        if((n+1)/2 >= k)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;

    }
  return 0;
}




Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    //    ifstream in("input.txt");
    //    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    int num = ((n-1) + (k-1) - 1)  / (k-1);
    cout << num << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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; }
const int INF = 1001001001;
const long long INFL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int n;
  cin >> n;
  vector<int> L(n);
  rep(i, n) cin >> L[i];
  sort(ALL(L));
  ll ans = 0;
  for (int i = 0; i< n-1; i++) {
    for (int j = i+1; j < n; j++) {
      int a = L[i];
      int b = L[j];
      auto l = upper_bound(ALL(L), b-a);
      auto r = lower_bound(ALL(L), b+a);
      int num = r - l;
      num -= 1;  // b は必ず範囲に含まれる
      if (b-a < a) num-= 1;
      if (num > 0) ans += num;
    }
  }

  cout << ans/3 << endl;

  return 0;
}


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

struct Recipe;

struct Item {
  int buy_cost;
  Recipe* recipe;
  int calced_min_cost;

  void init() {
    recipe = NULL;
    calced_min_cost = -1;
  }

  bool is_calced() {
    return calced_min_cost != -1;
  }
};

struct Recipe {
  int n;
  Item* parts[100];
};

map<string, Item> imap;

int calc_min_cost_of(Item& item) {
  if (item.is_calced()) return item.calced_min_cost;
  if (item.recipe == NULL) return item.calced_min_cost = item.buy_cost;
  auto& recipe = *item.recipe;
  int gen_cost = 0;
  for (int i = 0; i < recipe.n; i++) {
    gen_cost += calc_min_cost_of(*recipe.parts[i]);
    if (gen_cost >= item.buy_cost) return item.calced_min_cost = item.buy_cost;
  }
  return item.calced_min_cost = gen_cost;
}

// buff
Recipe recipes[100];

int main() {
  int n;
  while (cin >> n, n) {
    for (int i = 0; i < n; i++) {
      string name;
      int buy_cost;
      cin >> name >> buy_cost;
      imap[name] = {buy_cost, NULL, -1};
    }

    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
      auto& recipe = recipes[i];

      string target_name;
      cin >> target_name >> recipe.n;
      imap[target_name].recipe = &recipe;
      
      for (int j = 0; j < recipe.n; j++) {
        string part_name;
        cin >> part_name;
        recipe.parts[j] = &imap[part_name];
      }
    }
    
    string name;
    cin >> name;
    cout << calc_min_cost_of(imap[name]) << endl;
  }
  return 0;
}

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

bool isPair(int i, int a, int b){
  int ansa = 0;
  int ansb = 0;
  for(int j = 0;j < a+b;j++){
    if(i & 1){
      ansa++;
    }else{
      ansb++;
    }
    i >>= 1;
  }

  return a == ansa && b == ansb;
}

string makeBit(int i, int hoge){
  stack<char> st;
  char tmp;
  for(int j = 0;j < hoge;j++){
    if(i & 1){
      tmp = 'A';
    }else{
      tmp = 'B';
    }
    st.push(tmp);
    i >>= 1;
  }

  string ans = "";
  while(!st.empty()){
    ans += st.top();
    st.pop();
  }

  return ans;
}


bool check(string s){
  int a_cnt = 0;
  int b_cnt = 0;
  for(int i = 0;i < s.size()-1;i++){
    if(s[i] == 'A'){
      a_cnt++;
    }else{
      b_cnt++;
    }

    if(max(a_cnt,b_cnt) >= 5 && min(a_cnt,b_cnt) <= 3){
      return false;
    }
  }
  return true;
}

int main(){
  int l,r;
  vector<string> v;
  cin >> l >> r;
  int tmp = 1 << (l+r);

  for(int i = 0;i < tmp;i++){
    if(isPair(i,l,r)){
      v.push_back(makeBit(i,l+r));

    }
  }

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

  for(int i = 0;i < v.size();i++){
    if(check(v[i])){
      cout << v[i] << endl;
    }
  }

  return 0;
}




Measured memory_bytes: 3220
double n,p[333][333][333],r;
c[4];
f(i,j,k,I){I=i+j+k;r=p[i][j][k]?:(p[i][j][k]=(i*(i?f(i-1,j,k),r+n/I:0)+j*(j?f(i+1,j-1,k),r+n/I:0)+k*(k?f(i,j+1,k-1),r+n/I:0))/I);}
main(a)
{
	for(***p=scanf("%lf",&n);~scanf("%d",&a);)c[a]++;
	printf("%.9f",r-1,f(c[1],c[2],c[3]));
}

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

int main(void){
    int N;
    cin >> N;
    int a,b,c;
    c = N % 10;
    N /= 10;
    b = N % 10;
    N /= 10;
    a = N;
    
    if(a >= b && a >= c){
       cout << a << a << a << endl; 
    }else{
        cout << a+1 << a+1 << a+1 << endl;
    }
    
}

Measured memory_bytes: 3596
n=int(input())
A=list(map(int,input().split()))
x=1000
k=0
flag=False
def buy(x,k,cost):
    k+=x//cost
    x-=(x//cost)*cost
    return x,k

def sell(x,k,cost):
    x+=k*cost
    k=0
    return x,k

for i in range(n-1):
    today=A[i]
    tomorrow=A[i+1]
    if flag:
        if today<=tomorrow:
            pass
        else:
            x,k=sell(x,k,today)
            flag=False
    else:
        if today<=tomorrow:
            x,k=buy(x,k,today)
            flag=True
        else:
            pass
        
print(x+k*A[n-1])

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

int main() {
  int n;
  cin >> n;
  long long int a[n], b[n];
  for (int i = n - 1; i >= 0; i--)
    cin >> a[i] >> b[i];

  long long int count = 0;
  for (int i = 0; i < n; i++) {
    long long int t = b[i] - ((a[i] + count) % b[i]);
    if (t == b[i]) continue;
    count += t;
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int ret;
	int A, B, C, D;
	ret = scanf("%d %d %d %d", &A, &B, &C, &D);

	do {
		/* takahashi */
		C -= B;
      if (C <= 0) break;
		/* aoki */
		A -= D;
	} while (A > 0 || C > 0);
	
	if (A > 0 && C <= 0)
		printf("Yes\n");
	else
		printf("No\n");
	
	fflush(stdout);
	return EXIT_SUCCESS;
}


Measured memory_bytes: 1660
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()
ans = 1
c = collections.Counter(A)
for key in c.keys():
    if c[key] > 1:
        ans = 0
        break

if ans:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 35208
#include <algorithm>
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;

int n, c[100010], a, b, k = 0;
vector<int> v[100010];
vector<pair<int, int> > e;

void dfs(int x) {
  int p = -1, color = 1;
  for (int i = 0; i < v[x].size(); i++) {
    if (c[v[x][i]]) {
      p = c[v[x][i]];
    }
  }
  for (int i = 0; i < v[x].size(); i++) {
    if (!c[v[x][i]]) {
      if (color == p) {
        color++;
      }
      c[v[x][i]] = color;
      k = max(k, color);
      color++;
      if (e[v[x][i]].first != x) {
        dfs(e[v[x][i]].first);
      } else {
        dfs(e[v[x][i]].second);
      }
    }
  }
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &a, &b);
    e.push_back({a, b});
    v[a].push_back(i);
    v[b].push_back(i);
  }
  dfs(1);
  printf("%d\n", k);
  for (int i = 0; i < n - 1; i++) {
    printf("%d\n", c[i]);
  }
}

Measured memory_bytes: 9720
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
double a,b,h,m;
int32_t main(){
CODE_START;
cout<<fixed;
cin>>a>>b>>h>>m;
double x=0,y=0;
x=double(360/60*m);
y=double(360/12*h+30*m/60);
double val=double(360/12*h+double(30*m/60))-double(360/60*m);
if(val<0){
    val=double(abs(val));
}
long double ans=double(sqrt(a*a+b*b-double(2*a*b*cos(double(PI/180*val)))));
cout<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 4240
#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int digitsum(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(int argc, const char * argv[]) {
    
    int N, M;
    cin >> N >> M;
    vector<int> path(2 * M);
    for (int i = 0; i < M; i++) {
        cin >> path.at(2 * i) >> path.at(2 * i + 1);
    }
    
    vector<int> degree(N, 0);
    for (int i = 0; i < 2 * M; i++) {
        degree.at(path.at(i) - 1)++;
    }
    
    for (int i = 0; i < N; i++) {
        cout << degree.at(i) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, m; cin >> n >> m;
  vector<vi> edge(n);

  rep(i, m) {
    int a, b; cin >> a >> b;
    edge[a-1].eb(b-1);
    edge[b-1].eb(a-1);
  }

  vi used(n,0);
  queue<int> que;
  que.em(0);
  used[0] = 1;

  while (!que.empty()) {
    int v = que.front(); que.pop();

    for (auto to : edge[v]) {
      if (used[to]) continue;
      que.em(to);
      used[to] = v+1;
    }
  }

  cout << "Yes" << endl;
  rep2(i, 1, n-1) cout << used[i] << endl;

  return (0);
}


Measured memory_bytes: 10280
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n;
    cin >> n;
    vector<int> a;
    REP(i,n) {
        int x, y;
        cin >> x;
        y = 0;
        while(x%2 == 0) {
            x /= 2;
            y++;
        }

        a.push_back(y);
    }

    sort(ALL(a));
    cout << a[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(int& a){printf("%d",a);}
//void print(long long& a){printf("%lld",a);}
void print(double& a){printf("%.15lf",a);}
template<class T> void print(T& a){cout<<a;}
template<class T> void print(vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(Head& head, Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(T& a){cerr<<a;}
template<class T> void dprint(vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(Head& head, Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    string s;
    in(s);
    reverse(all(s));
    out(s);
}


Measured memory_bytes: 3024
N,A,B = list(map(int,input().split()))

cnt = 0
for n in range(1,N+1):
    val = n % 10
    tmp = n
    while tmp // 10 > 0:
        
        tmp = tmp // 10
        val += tmp % 10
    if val >= A and val <= B:
        cnt += n
print(cnt)

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

using namespace std;

int n, m, q;
int ans = 0;

vector<int> a, b, c, d;


void dfs(vector<int> A)
{
    if (A.size() == n + 1)
    {
        int cnt = 0;
        for (int i = 0; i < q; i++)
        {
            if(A[b[i]]-A[a[i]]==c[i])
            {
                cnt += d[i];
            }
        }
        ans = max(ans, cnt);
        return;
    }
    A.push_back(A.back());
    while (A.back()<=m)
    {
        dfs(A);
        A.back()++;
    }
}

int main(){
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    for (int i = 0; i < q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1, 1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = put n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStr n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

main = do
  [x] <- readInt
  if x < 1200 then putStrLn "ABC" else putStrLn "ARC"


Measured memory_bytes: 380
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vec cnt(3,0);
  REP(i,n){
    int x;
    cin >> x;
    if(x % 4 == 0) cnt[2]++;
    else if(x % 2 == 0) cnt[1]++;
    else cnt[0]++;
  }

  if(cnt[1]) cnt[0]++;

  if(cnt[2]+1 < cnt[0]) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}

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

int main()
{
	string s;
	cin >> s;
	if(s == "Sunny")
		cout << "Cloudy" << endl;
	else if(s == "Cloudy")
		cout << "Rainy" << endl;
	else
		cout << "Sunny" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

N, A, B, C = map(int, readline().split())
S = [readline().strip() for i in range(N)]

AB, AC, BC = 'AB', 'AC', 'BC'

n0 = [A, B, C].count(0)

F = [A, B, C]
H = ['A', 'B', 'C']
G = {AB: (0, 1), BC:(1,2), AC:(0, 2)}

if n0 == 3:
    print('No')
elif n0 == 2 and sum([A, B, C]) == 1:
    path = []
    for com in S:
        a,b = G[com]
        if F[a] == F[b] == 0:
            print('No')
            exit(0)
        else:
            if F[a] == 1:
                a,b = b,a
            path.append(H[a])
            F[a] += 1
            F[b] -= 1
    print('Yes')
    for p in path:
        print(p)
else:
    if (S[0] == AB and A == 0 and B == 0) or \
     (S[0] == AC and A == 0 and C == 0) or (S[0] == BC and B == 0 and C == 0):
        print('No')
        exit(0)

    path = []
    for i,com in enumerate(S):
        a,b = G[com]
        if F[a] == 0 or F[b] == 0:
            if F[b] == 0:
                a,b = b,a
            path.append(H[a])
            F[a] += 1
            F[b] -= 1
        else:
            if i < len(S) - 1 and F[a] == F[b]:
                if b in G[S[i + 1]]:
                    a, b = b, a
                path.append(H[a])
                F[a] += 1
                F[b] -= 1
            else:
                if F[a] > F[b]:
                    a,b = b,a
                path.append(H[a])
                F[a] += 1
                F[b] -= 1
        assert all(v >= 0 for v in F)
    print('Yes')
    for p in path:
        print(p)
                




Measured memory_bytes: 16920
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using ll = long long;
using P = pair<int,int>;

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

  cout << n*n*n << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

//---------------------------------------------------------------------------------------------------


int n;
double x[1010], y[1010];

double dist(double a, double b) {
	return a * a + b * b;
}

double smallestEnclosingCircle(){
	double X, Y, d, e;
	X = Y = d = e = 0;
	for (int i = 0; i < n; i++) {
		X += x[i]; Y += y[i];
	}
	X /= n; Y /= n;
	double P = 0.1;
	for (int i = 0; i < 30000; i++) {
		int f = 0;
		d = dist(X - x[0], Y - y[0]);
		for (int j = 1; j < n; j++) {
			e = dist(X - x[j], Y - y[j]);
			if (d < e) { d = e; f = j; }
		}
		X += (x[f] - X)*P;
		Y += (y[f] - Y)*P;
		P *= 0.999;
	}
	return sqrt(d);
}

// 例: ABC151 F
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf%lf", &x[i], &y[i]);
	}
	printf("%.12lf\n", smallestEnclosingCircle());
}

Measured memory_bytes: 256
import sys
import numpy as np
from numba import njit, void, i8
input = sys.stdin.readline

def main():
    R, C, K = map(int, input().split())

    L_INF = int(1e17)
    dp = np.full((R+1, C+1, 4), -L_INF, dtype=np.int64)
    cell = np.full((R+1, C+1), 0, dtype=np.int64)

    for i in range(K):
        x, y, c = map(int, input().split())
        cell[x-1][y-1] = c

    f(dp, cell, R, C)

    print(dp[R][C][3])

@njit(void(i8[:,:,:],i8[:,:],i8,i8))
def f(dp, cell, R, C):
    dp[0][1][0] = dp[1][0][0] = 0
    for i in range(1, R + 1):
        for j in range(1, C + 1):
            for k in range(4):
                if k > 0:
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j][k-1])
                dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k])
                if k > 0:
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k-1] + cell[i-1][j-1])
                if k == 1:
                    dp[i][j][k] = max(dp[i][j][1], dp[i-1][j][3] + cell[i-1][j-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 469168
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF){
		int T1=0,x1=0,y1=0,flag=true,T2,x2,y2;
		for(int i = 0; i < n; i++){
			scanf("%d %d %d",&T2,&x2,&y2);
			int c = max(x2,x1) - min(x2,x1);
			int d = max(y2,y1) - min(y2,y1);
			c = c + d;
			int e = T2-T1-c;
			if(e%2!=0||e<0){
				flag = false;
			}
			x1 = x2;	y1 = y2;	T1 = T2;
		}
		if(flag)	printf("Yes\n");
		else	printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

SIZE = 3501

def main():
    N = Z()
    for i in range(1, SIZE):
        for j in range(1, SIZE):
            x = N * i * j
            y = 4*i*j - N * (i+j)
            if y > 0 and x%y == 0:
                print(i, j, x//y)
                break
        else: continue
        break

    return

if __name__ == '__main__':
    main()



Measured memory_bytes: 39024
import bisect

A, B, Q = map(int, input().split())
INF = 10**18
S = [-INF] + [int(input()) for i in range(A)] + [INF]
T = [-INF] + [int(input()) for i in range(B)] + [INF]
X = [int(input()) for i in range(Q)]


for x in X:
    d = float("inf")
    i = bisect.bisect_right(S, x)
    j = bisect.bisect_right(T, x)
    for s in [S[i-1], S[i]]:
        for t in [T[j-1], T[j]]:
            d1 = abs(s-x) + abs(t-s)
            d2 = abs(t-x) + abs(t-s)
            d = min(d, d1, d2)
    print(d)


Measured memory_bytes: 20772
import numpy as np
n, m, c = map(int, input().split())
b = np.array(list( map(int, input().split()) ))
cnt = 0
for _ in range(n):
    a = np.array(list( map(int, input().split()) ))
    if np.sum(np.multiply(a, b)) + c > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 12500
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
using graph = vector<vector<int>>;
typedef long long ll;


int main() {
	ll n,ansmem,mem;
	cin >> n;
	vector<ll> a;
	vector<ll> kosu(n+1,0);
	for (ll i = 0; i < n; i++) {
		cin >> mem;
		a.push_back(mem);
		kosu[a[i]] ++;
	}
	ansmem = 0;

	for (ll j = 0; j <= n; j++) {
		if (kosu[j] > 1) {
			ansmem = ansmem + kosu[j] * (kosu[j] - 1) / 2;
		}
	}

	for (ll i = 0; i < n; i++) {
		cout << ansmem - kosu[a[i]] * (kosu[a[i]] - 1) / 2 + (kosu[a[i]] - 1) * (kosu[a[i]] - 2) / 2 << endl;
	}


	return 0;
}

Measured memory_bytes: 5872
#pragma GCC optimize("03")
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> pi;
ll const N=200005;
ll tr[4*N+10],br[N],t_cnt,ar[N];
vec adj[N];
bool vis[N];
map<ll,ll> mp;
void update(ll node,ll l,ll r,ll id,ll val,ll x)
{
	if(l == r && id == l)
	{
		if(x == 0)
			tr[node]=max(tr[node],val);
		else
			tr[node]=val;
		return;
	}
	ll mid=(l+r)/2;
	if(id <= mid)
		update(2*node,l,mid,id,val,x);
	else
		update(2*node+1,mid+1,r,id,val,x);
	tr[node]=max(tr[2*node],tr[2*node+1]);
}
ll query(ll node,ll l,ll r,ll ql,ll qr)
{
	if(l > qr || r < ql)
	{
		return 0;
	}
	if(l >= ql && r <= qr)
		return tr[node];
	ll mid=(l+r)/2;
	ll p1,p2;
	p1=query(2*node,l,mid,ql,qr);
	p2=query(2*node+1,mid+1,r,ql,qr);
	return max(p1,p2);
}
void dfs(ll s,ll p,ll cnt)
{
	vis[s]=true;
	ll d,val,mx=0;
	d=query(1,1,t_cnt,1,cnt-1);
	val=query(1,1,t_cnt,cnt,cnt);
	update(1,1,t_cnt,cnt,d+1,0);
	mx=query(1,1,t_cnt,1,t_cnt);
	br[s]=mx;
	for(auto it=adj[s].begin();it != adj[s].end();it++)
	{
		if(*it == p)
			continue;
		if(!vis[*it])
		{
			dfs(*it,s,mp[ar[*it]]);
		}
	}
	update(1,1,t_cnt,cnt,val,1);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,x,u,v,cnt=0;
	cin>>n;
	set<ll> ss;
	for(ll i=1;i<=n;i++)
	{
		cin>>x;
		ar[i]=x;
		ss.insert(x);
	}
	for(auto it=ss.begin();it != ss.end();it++)
	{
		cnt+=1;
		mp[*it]=cnt;

	}
	t_cnt=cnt;
	//cout<<cnt<<endl;
	for(ll i=1;i<n;i++)
	{
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	//update(1,1,t_cnt)
	dfs(1,-1,mp[ar[1]]);
	for(ll i=1;i<=n;i++)
		cout<<br[i]<<endl;
	return 0;
}

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


int main()
{
    ll x;
    cin>>x;
    ll ans = x/11 *2;
    if( x%11 >0 && x%11 <= 6 )
        ans++;
    if( x%11 > 6)
        ans +=2;
    cout<<ans;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
string n;
int u[20];
int main()
{
    cin>>n;
    for(int s=2;s<n.size();s++)
    {
        if(n[s]==n[s-1]&&n[s]==n[s-2])
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;

int n;
int cnt[3];

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int tmp;
		scanf("%d",&tmp);
		if(tmp%4==0) cnt[2]++;
		else if(tmp%2==0) cnt[1]++;
		else cnt[0]++;
	}
	
	if(cnt[2]<cnt[0]-1) puts("No");
	else if(cnt[2]==cnt[0]-1) puts((cnt[1])?"No":"Yes");
	else puts("Yes");
	return 0;
}


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

using namespace std;

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

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
    string s;
    cin >> s;
    int f = 0;
    for(int i = 0; i < s.size()-1; i++){
        if(s[i] == s[i+1]) f = 1;
    }
    if(f) PRINT(Bad);
    else PRINT(Good);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

using namespace std;

int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}



long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


ll a[100010];
ll b[100010];
ll c[100010];
int main() {
	int N;cin>>N;
	REP(i,N){
		cin>>a[i];
	}
	ll cnt1=0;
	b[0]=0;
	FOR(i,1,N+1){
		b[i]=b[i-1]+a[i-1];
		if(i%2!=0){
			if(b[i]<=0){
				cnt1+=1-b[i];
				b[i]=1;
			}
		}
		if(i%2==0){
			if(b[i]>=0){
				cnt1+=b[i]+1;
				b[i]=-1;
			}
		}
	}
	ll cnt2=0;
	c[0]=0;
	FOR(i,1,N+1){
			c[i]=c[i-1]+a[i-1];
			if(i%2==0){
				if(c[i]<=0){
					cnt2+=1-c[i];
					c[i]=1;
				}
			}
			if(i%2!=0){
				if(c[i]>=0){
					cnt2+=c[i]+1;
					c[i]=-1;
				}
			}
		}
	ll ans=min(cnt1,cnt2);
	cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000
int n;
void CountingSort(short *A,short *B,int k);

int main(){
  unsigned short *A, *B;
  int  i, j, k;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=1; i<=n; i++){
    scanf("%d",&A[i]);
  }

  
  k=0;
  for(i=1; i<=n; i++){
       if(k < A[i]){
	 k=A[i];
       }
  }

  CountingSort(A,B,k);


  return 0;
}


void CountingSort(short *A,short *B,int k){
  int i,j;
   int C[VMAX+1];

   
  for(i=0; i<=k; i++){
    C[i] = 0;
  }

  
  for(j=1; j<=n; j++){
    C[A[j]]++;
  }

  for(i=1;i<=k; i++){
    C[i] = C[i] + C[i-1];
  }

  

  
  
  for(j=n; j>=1 ; j--){
    
    B[C[A[j]]]=A[j];
    
    C[A[j]]--;
  }
  

  for(i=1;i<=n;i++){
    if(i==n)printf("%d\n",B[i]);
    else   printf("%d ",B[i]);

}
}



Measured memory_bytes: 9564
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

void solve(){
    int N, M, S;
    cin >> N >> M >> S;
    vector<vector<tuple<int, int, int>>> G(N);
    vector<int> C(N), D(N);
    REP(i,M){
        int U, V, A, B;
        cin >> U >> V >> A >> B;
        --U, --V;
        G[U].emplace_back(V, A, B);
        G[V].emplace_back(U, A, B);
    }
    REP(i,N) cin >> C[i] >> D[i];
    vector<vector<ll>> dp(N, vector<ll>(2525, LINF));
    chmin(S, 2524);
    dp[0][S] = 0;
    priority_queue<tuple<ll, int, int>,vector<tuple<ll, int, int>>, greater<tuple<ll, int, int>>> pq; //cost, coins, cur;
    pq.emplace(0, S, 0);
    while(!pq.empty()){
        auto[cost, coins, cur] = pq.top(); pq.pop();
        // cerr << cost << " " << coins << " " << cur << endl;
        if(dp[cur][coins] < cost) continue;
        // 今いる地点で銀貨にする
        if(chmin(dp[cur][min(2524, coins + C[cur])], cost + D[cur])){
            pq.emplace(dp[cur][min(2524, coins + C[cur])], min(2524, coins + C[cur]), cur);
        }

        for(auto [to, a, b] : G[cur]){
            if(coins < a) continue;
            if(chmin(dp[to][coins-a], cost + b)){
                pq.emplace(dp[to][coins-a], coins - a, to);
            }
        }
    }
    vector<ll> ans(N, LINF);
    for(int i=1;i<N;i++) REP(j,2525) chmin(ans[i], dp[i][j]);
    for(int i=1;i<N;i++) cout << ans[i] << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}


Measured memory_bytes: 6312
import math

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

N=int(input())

T = []
for i in range(N):
    inp = int(input())
    T.append(inp)

cal = T[0]

i = 1
now = T[0]
while(i<N):
    m = T[i] * now
    now = m // gcd(now, T[i])
    i+=1
print(now)

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std; 
const int mod=1e9+7;
int n;

bool isprime(int x){
  for(int i=2;i*i<=x;i++){
    if(x%i==0){
      return false;
    }
  }
  return true;
}

int main(){
  cin>>n;
  vector<long long>a(n+1,1);
  for(int i=2;i<=n;i++){
    int ii=i;
    for(int j=2;j<=ii;j++){
      if(isprime(j)){
        while(ii%j==0){
          ii=ii/j;
          a[j]++;
        }
      }
    }
  }
  long long ans=1;
  for(int i=2;i<=n;i++){
    ans*=a[i];
    ans=ans%mod;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Mon Jan  7 00:09:03 2019
//
package main

import "fmt"

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	ans := 1 << 60
	for i := 0; i < (1 << uint8(N)); i++ {
		n := 1
		for j := uint8(0); j < uint8(N); j++ {
			if i&(1<<j) != 0 {
				n *= 2
			} else {
				n += K
			}
		}
		if n < ans {
			ans = n
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void){
  int a,b,c,d,n;

  while(scanf("%d %d",&a,&b),a|b){
    n=b-a,c=n%1000,d=n%500;
    printf("%d %d %d\n",d/100,c/500,n/1000);
  }
  return 0;
}

Measured memory_bytes: 600
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <complex>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#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())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

const LL mod = 1000000007;


#define Yes_ cout<<"Yes"<<endl; return 0;
#define No_ cout<<"No"<<endl; return 0;


#define YES_ cout<<"YES"<<endl; return 0;
#define NO_ cout<<"NO"<<endl; return 0;

int main() {

	string s;
	cin >> s;

	while (SZ(s) > 1) {

		string s2 = s.substr(0, 5);
		int index = 5;
		if (s2 == "dream") {
			
			if (SZ(s) >= 12) {
				string s3 = s.substr(5, 2);
				string s4 = s.substr(7, 5);

				if (s3 == "er" && (s4 == "dream" || s4 == "erase")) {
					index += 2;
				}
			}
			else if (SZ(s) == 7) {
				string s3 = s.substr(5, 2);
				if (s3 == "er") {
					index += 2;
				}
			}
		}
		else if (s2 == "erase") {

			if (SZ(s) >= 11) {

				string s3 = s.substr(5, 1);
				string s4 = s.substr(6, 5);

				if (s3 == "r" && (s4 == "dream" || s4 == "erase")) {
					index++;
				}
			}
			else if (SZ(s) == 6) {
				string s3 = s.substr(5, 1);
				if (s3 == "r") {
					index += 1;
				}
			}
		}
		else {
			NO_;
		}
		s = s.substr(index);
	}


	YES_;

}

Measured memory_bytes: 544
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Programming Contest
 * PCK2013
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);

			int N, R, L;
			N = parseInt(st.nextToken());
			R = parseInt(st.nextToken());
			L = parseInt(st.nextToken());

			Team[] team = new Team[N + 1];

			Queue<Team> pq = new PriorityQueue<>((x, y) -> {
				if (x.point == y.point) {
					return Integer.compare(x.id, y.id);
				} else {
					return Integer.compare(y.point, x.point);
				}
			});

			for (int i = 1; i <= N; i++) {
				team[i] = new Team(i);
			}

			int elapsed = 0;
			pq.offer(team[1]);

			for (int i = 0; i < R; i++) {
				st = new StringTokenizer(br.readLine());
				int d, t, x;
				d = parseInt(st.nextToken());
				t = parseInt(st.nextToken());
				x = parseInt(st.nextToken());
				pq.peek().time += t - elapsed;
				//
				pq.remove(team[d]);
				team[d].point += x;
				pq.offer(team[d]);
				//
				if (pq.size() > 5) {
					List<Team> list = new ArrayList<>();
					for (int j = 0; j < 5; j++) {
						list.add(pq.poll());
					}
					pq.clear();
					pq.addAll(list);
				}
				//
				elapsed = t;
			}

			pq.peek().time += L - elapsed;

			//
			Team ans = team[1];
			
			for (int i = 1; i <= N; i++) {
				if (team[i].time > ans.time) ans = team[i];
			}

			System.out.println(ans.id);
		}
	}
}

class Team {

	int id, time = 0, point = 0;

	Team(int id) {
		this.id = id;
	}
}

Measured memory_bytes: 115924
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

//---------------------------------------------------------------------------------------------------
int main() {
  string s;
  cin >> s;
  int Q;cin >> Q;

  string q;
  rep(i,Q){
    int t;
    cin >> t;
    if(t==1)swap(s,q);
    else {
      int f; char c;
      cin >> f >> c;
      if(f==1)q.push_back(c);
      if(f==2)s.push_back(c);
    }
  }
  reverse(ALL(q));
  s=q+s;
  cout << s;
}

Measured memory_bytes: 1116
sd = list(input())
t  = list(input())

change_list = []

for i in range(len(sd)-len(t)+1):
    cut = sd[i:i+len(t)]
    for j in range(len(cut)):
        if cut[j]==t[j]:
            continue
        elif cut[j]=="?":
            cut[j] = t[j]
        else:
            break
    if cut == t:
        change_s = sd[:i] + cut + sd[i+len(t):]
        change_list.append(change_s)
    
if len(change_list)>0:
    change_list = ["".join(x) for x in change_list ]
    change_list = [x.replace("?","a") for x in change_list]
    change_list.sort()
    print(change_list[0])
else:
    print("UNRESTORABLE")

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

#define all(x) x.begin(), x.end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, LN = 17, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

int N, K;
bool bad[11];
int nxt[11];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    cin >> N >> K;
    for (int i = 0, a; i < K; i++) {
        cin >> a;
        bad[a] = true;
    }
    for (int i = N; i <= 10 * N; i++) {
        string s = to_string(i);
        bool flag = false;
        for (char c : s) {
            if (bad[c - '0']) {
                flag = true;
                break;
            }
        }
        if (!flag) {
            cout << i << '\n';
            return 0;
        }
    }
    return 0;
}


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

ll best_split(int h, int w)
{
    ll ans = 10000000000000;
    rep(i, 1, w)
    {
        ll w2 = (w - i), w1 = h;
        ll cand1, cand2;
        // int cand1 = i * h;
        if (w1 > w2) swap(w1, w2);

        if (w2 % 2 == 0 or w1 % 2 ==0)
            cand1 = cand2 = w2 * w1 / 2;
        else
        {
            cand1 = w2 / 2 * w1;
            cand2 = cand1 + w1;
        }
        cand1 = min(cand1, (ll)i * h);
        cand2 = max(cand2, (ll)i * h);
        
        if (cand2 - cand1 < ans)
            ans = cand2 - cand1;
        // cout << w2 << ' ' << cand2 - cand1 << ' ' << cand2 << ' '<< cand1 <<  endl;
    }
    return ans;
}

int main()
{
    int h, w;
    cin >> h >> w;

    ll ans = min(best_split(h, w), best_split(w, h));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256