akhauriyash/Code-Regression huggingface dataset:
Scanf.scanf "%s %d" (fun s k ->
    let n = String.length s in

    let rec loop st en k1 k2 k3 k4 k5 =
        if st = n then [| k1; k2; k3; k4; k5 |] else
            if en = n || en - st > 4 then loop (st + 1) (st + 1) k1 k2 k3 k4 k5 else
                let ss = String.sub s st (en - st + 1) in
                if ss = k1 || ss = k2 || ss = k3 || ss = k4 || ss = k5 then loop st (en + 1) k1 k2 k3 k4 k5 else
                    if ss < k1 then loop st (en + 1) ss k1 k2 k3 k4 else
                    if ss < k2 then loop st (en + 1) k1 ss k2 k3 k4 else
                    if ss < k3 then loop st (en + 1) k1 k2 ss k3 k4 else
                    if ss < k4 then loop st (en + 1) k1 k2 k3 ss k4 else
                    if ss < k5 then loop st (en + 1) k1 k2 k3 k4 ss else
                                    loop st (en + 1) k1 k2 k3 k4 k5
    in
    let ans = loop 0 0 "~" "~" "~" "~" "~" in

    print_endline ans.(k - 1)
)

Measured memory_bytes: 4156
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<max(10*a+b+c, max(10*b+a+c,10*c+a+b))<<endl;
}

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

int main() {
  long long N,A;
  cin>>N>>A;
  vector<long long> x(N);
  rep(i,N){
    cin>>x[i];
    x[i] -= A;
  } 
  long long dp[51][5001];
  //dp[j][t]は、j=0のとき1枚も選べない。
  //j>0のときx[0]~x[j-1]から0枚以上選んで合計t-N*A（t=0~2*N*A）となる組み合わせ
  dp[0][N*A]=1;
  for(long long j=0;j<=N;j++){
    for(long long t=0;t<=2*N*A;t++){//合計=t-N*A=-N*A~N*A
      if(j>=1&&t-x[j-1]>=0&&t-x[j-1]<=2*N*A) dp[j][t]=dp[j-1][t]+dp[j-1][t-x[j-1]];
      else if(j>=1) dp[j][t]=dp[j-1][t];
    }
  }
  //ans=t=N*Aとなる組み合わせ（つまり、合計0となる組み合わせ）
  cout<<dp[N][N*A]-1<<endl;//j=0の場合を除く
  return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  int ans = 0;
  FOR(i, 1, n - 1) {
    vector<bool> x(26, false), y(26, false);

    rep(j, i) x[s[j] - 'a'] = true;
    FOR(j, i, n) y[s[j] - 'a'] = true;

    int res = 0;
    rep(j, 26) {
      if (x[j] && y[j]) res++;
    }
    ans = max(ans, res);
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < int(n);++i)
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define sz(x) (int)x.size()

void solve() {

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin >> n;
    vi b(n, 0);
    for (int i = 1; i < n; i++) {
        cin >> b[i];
    }
    ll ans = b[n - 1];
    for (int i = n - 2; i >= 1; --i) {
        ans += min(b[i], b[i + 1]);
    }
    ans += b[1];
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
// Rustで競技プログラミングの入力をスッキリ記述するマクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

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

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

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

use std::cmp::max;

fn main() {
    input! {
        n: usize,
        inp: [[usize; 3]; n]
    };
    let mut dp = vec![vec![0; 3]; n];
    dp[0][0] = inp[0][0];
    dp[0][1] = inp[0][1];
    dp[0][2] = inp[0][2];
    for i in 1..n {
        for j in 0..3 {
            dp[i][j] = inp[i][j]
                + if j == 0 {
                    max(dp[i - 1][1], dp[i - 1][2])
                } else if j == 1 {
                    max(dp[i - 1][0], dp[i - 1][2])
                } else {
                    max(dp[i - 1][0], dp[i - 1][1])
                };
        }
    }
    println!("{}", max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])));
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;


int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)   cin >> a[i];

    map<ll, ll> m;
    for(auto e : a) m[e]++;

    for(auto iter = m.begin(); iter != m.end(); iter++){
        if(3 <= iter->second){
            iter->second -= 2 * ((iter->second - 1)/2);
        }
    }

    ll all = 0;
    ll cnt = 0;
    for(auto iter = m.begin(); iter != m.end(); iter++){
        all++;
        if(iter->second == 2)   cnt++;
    }

    if(cnt % 2 == 0){
        cout << all << endl;
    }
    else{
        cout << all - 1 << endl;
    }

    return 0;
}


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

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    if (a >= k) {
        cout << a - k << ' ' << b << endl;
    } else if (a + b >= k) {
        cout << 0 << ' ' << a + b - k << endl;
    } else {
        cout << 0 << ' ' << 0 << endl;
    }
    return 0;
}


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split(" ")
                .Select(i => int.Parse(i)).ToArray();
            var n = nk[0];
            var k = nk[1];

            var people = new Boolean[n];

            for (var i = 0; i < k; i++)
            {
                var d = int.Parse(Console.ReadLine());
                foreach (var pi in Console.ReadLine().Split(" ").Select(i => int.Parse(i)).ToArray())
                {
                    people[pi - 1] = true;
                }
            }

            var count = people.Count(b => b == false);
            Console.WriteLine(count);
        }
    }
}

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

typedef long long ll;

int main(){
        int h,n;
        cin>>h>>n;
        vector<int>a(n);
        ll sum=0;
        for(int i=0;i<n;i++){
                cin>>a[i];
                sum+=a[i];
        }
        if(sum>=h){
                cout<<"Yes"<<endl;
        }else{
                cout<<"No"<<endl;
        }
        return 0;
}


Measured memory_bytes: 640
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
a = I()
s = input()
print(s if a >= 3200 else 'red')


Measured memory_bytes: 10416
#include <iostream>
#include <algorithm>

long long getLength(long long a, long long b) {
	if (a == 0 || b == 0) {
		return 0;
	}
	if (a == b) {
		return a;
	}
	long long u = a < b ? a : b;
	long long v = a > b ? a : b;
	if (v % u == 0) {
		return (v / u) * u * 2 - u;
	}
	return (v / u) * u * 2 + getLength(u, v % u);
}

int main() {
	std::ios_base::sync_with_stdio(0);
	std::cin.tie(0);
	std::cout.tie(0);

	long long n, x;
	std::cin >> n >> x;
	long long res = n;
	res += getLength(x, n - x);
	std::cout << res << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for (int i = 0; i < n; ++i) cin >> p[i];
    for (int i = 0; i < n; ++i) cin >> q[i];
    vector<int> perm;
    for (int i = 1; i <= n; ++i) perm.emplace_back(i);
    int a = 1, b = 1, c = 1;
    do {
        if (perm == p) a = c;
        if (perm == q) b = c;
        ++c;
    } while (next_permutation(perm.begin(), perm.end()));
    cout << abs(a-b) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main()
{
    char st[100];int ans=0;
    scanf("%s",st);
    int tmp=0;
    while(st[tmp])
    {
        if(st[tmp]=='o') ans++;
        tmp++;
    }
    for (int i=tmp;i<15;i++) ans++;
    if (ans>=8) printf("YES\n");else printf("NO\n");

}


Measured memory_bytes: 128
fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val a = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
  val m = mutableMapOf<Int, Long>()
  var ans = 0L
  for (i in a.indices) {
    val d = a[i]-i
    val s = -a[i]-i
    ans += m[d] ?: 0
    m[s] = (m[s] ?: 0)+1
  }
  println(ans)
}

Measured memory_bytes: 73104
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//setprecision(15)有効数字15桁
//-std=c++14
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; }
int n, m;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    for (int i = 0; i < n; i++)
    {
        if (a[i] % 2 == 0)
        {
            if (a[i] % 3 != 0 && a[i] % 5 != 0)
            {
                return cout << "DENIED"
                            << "\n",
                       0;
            }
        }
    }
    return cout << "APPROVED"
                << "\n",
           0;
}


Measured memory_bytes: 384
use std::io;

const INF :i64 = 1000000000;

fn next_int() -> i64 {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn main() {
    let n = next_int();
    let k = next_int();

    let mut ans = INF;
    for i in 0..(2 << n) {
        let mut work = i;
        let mut board = 1;
        for _ in 0..n {
            if (work & 1) == 0 {
                board *= 2;
            } else {
                board += k;
            }
            work >>= 1;
        }
        ans = if ans > board {board} else {ans};
    }

    println!("{:?}", ans);
}


Measured memory_bytes: 4352
//be naame khodaa
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef complex<ld> PT;
typedef pair<PT, PT> LS;
#define F first
#define S second
#define X real()
#define Y imag()

inline int in(){int x, y; y = scanf("%d", &x); return x; }

const int N = -1;
const ld EPS = 1e-12;

bool eq(ld a, ld b){
	return abs(a-b) < EPS;
}

istream& operator>> (istream& is, complex<ld>& p){
	ld val;
	is >> val;
	p.real(val);
	is >> val;
	p.imag(val);
	return is;
}

PT proj(PT a, PT b, PT c){
	b -= a, c -= a;
	return a + b*real(c/b);
}

PT reflect(PT a, PT b, PT c){
	b -= a, c -= a;
	return a + conj(c/b)*b;
}

string pos(PT a, PT b, PT c){
	b -= a, c -= a;
	c /= b;
	if (c.imag() > EPS)
		return "COUNTER_CLOCKWISE";
	if (c.imag() + EPS < 0)
		return "CLOCKWISE";
	if (c.real() + EPS < 0)
		return "ONLINE_BACK";
	if (c.real() > 1 + EPS)
		return "ONLINE_FRONT";
	return "ON_SEGMENT";
}

int sgn(PT a, PT b, PT c){
	b -= a, c -= a;
	ld cr = (c/b).Y;
	return cr > EPS ? 1 : (cr + EPS < 0 ? -1 : 0);
}

bool intersect(PT a, PT b, PT c, PT d){
	int as = sgn(c, d, a),
		bs = sgn(c, d, b),
		cs = sgn(a, b, c),
		ds = sgn(a, b, d);
	if (as && as == bs || cs && cs == ds)
		return false;
	else if (as || bs || cs || ds)
		return true;
	for (int j = 0; j < 2; j++){
		ld mx = min(a.X, b.X),
		   Mx = max(a.X, b.X),
		   my = min(a.Y, b.Y),
		   My = max(a.Y, b.Y);
		for (int k = 0; k < 2; k++){
			if (c.X + EPS > mx && c.X < Mx + EPS && c.Y + EPS > my && c.Y < My + EPS)
				return true;
			swap(c, d);
		}
		swap(a, c);
		swap(b, d);
	}
	return false;
}


int main(){	
	for (int i = in(); i; i--){
		PT a, b, c, d;
		cin >> a >> b >> c >> d;
		cout << intersect(a, b, c, d) << endl;
	}
	return 0;
}


Measured memory_bytes: 3284
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld long double
#define pp pair<ll,ll>
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell 1000000007
#define F first
#define S second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree<ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
void solve()
{
    ll n , k ;
    cin >> n >> k ;
    vector<ll> dp(n+1,hell) , h(n+1);
    rep( i , 1 , n + 1 )
        cin >> h[i] ;
    dp[n]=0;
    for(ll i = n - 1 ; i >= 1 ; i-- )
    {
        for( ll j = 1 ; i + j <= n && j <= k ; j++ )
        {
            dp[i] = min(dp[i],abs(h[i]-h[i+j])+dp[i+j]);
        }
    }
    cout << dp[1] ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


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

// one-based numbering
template<class T> struct Fenwick {
    vector<T> bit; int N;
    Fenwick(int n) {
        N = n;
        bit.resize(n+1, 0);
    }
    void add(int a, T w) {
        for (int x = a; x <= N; x += x & -x) bit[x] += w;
    }
    T sum(int a) {
        T ret = 0;
        for (int x = a; x > 0; x -= x & -x) ret += bit[x];
        return ret;
    }
};

int main() {
    int n; cin >> n;
    int b[n+1][n+1]; int w[n+1][n+1];
    Fenwick<int> fb(n+1), fw(n+1);
    int bcount = 0; int wcount = 0;
    for (int i = 1; i <= 2*n; i++) {
        char c; int t; cin >> c >> t;
        if (c == 'B') {
            int tmp = (t-1) - fb.sum(t);
            b[t][0] = tmp + wcount;
            for (int j = 1; j <= n; j++) {
                b[t][j] = tmp + wcount - fw.sum(j);
            }
            fb.add(t, 1);
            bcount++;
        } else {
            int tmp = (t-1) - fw.sum(t);
            w[0][t] = tmp + bcount;
            for (int j = 1; j <= n; j++) {
                w[j][t] = tmp + bcount - fb.sum(j);
            }
            fw.add(t, 1);
            wcount++;
        }
    }
    vector<vector<int>> dp(n+1, vector<int>(n+1, 1e9));
    dp[0][0] = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            if (i != 0) dp[i][j] = min(dp[i][j], dp[i-1][j] + b[i][j]);
            if (j != 0) dp[i][j] = min(dp[i][j], dp[i][j-1] + w[i][j]);
        }
    }
    cout << dp[n][n] << endl;
    return 0;
}

Measured memory_bytes: 47232
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

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

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する


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

    int n;
    cin >> n;
    int ans = 0;

    rep(i,0,n+1){
        if(i % 2 == 0) continue;
        int cnt = 0;
        for(int j = 1;j <= n; ++j) if(i % j == 0) cnt++;
        if(cnt == 8) ans++;
    }

    cout << ans << endl;



    return 0;
}


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    B=LI()
    
    ans=0
    
    for i in range(N):
        if A[i]>=B[i]:
            ans+=B[i]
        else:
            ans+=A[i]
            rem=B[i] - A[i]
            if A[i+1]>=rem:
                ans+=rem
                A[i+1]-=rem
            else:
                ans+=A[i+1]
                A[i+1]=0
                
                
    print(ans)
            
        

main()


Measured memory_bytes: 96480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define Check system("pause")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)



int main()
{
	ios::sync_with_stdio(false);
	int a,b,k;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
LL gcd(LL m,LL n)
{
	if(m<n)swap(m,n);
	LL r;
	while(n!=0)
	{
		r=m%n;
		m=n;
		n=r;
	}
	//printf("****%lld\n",m);
	return m;
}

int main()
{
    LL i,a[105],n,x,y,num,z,t;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
    	scanf("%lld",&a[i]);
    /*
	sort(a,a+n);
    if(n>=2)
    {
    	x=gcd(a[1],a[0]);
    	if(a[1]%a[0]==0)y=a[1];
		else y=a[0]*a[1]/x;
		num=y;
		for(i=2;i<n-1;i++)
		{
			if(x<a[i])swap(x,a[i]);
			num=x;
			x=gcd(x,a[i]);
			if(x%a[i]==0)y=x;
			else y=num*a[i]/x;
		}
	}
	else num=a[0];
    */
    num=a[0];
	for(i=0;i<n-1;i++)
	{
		x=num;
		y=a[i+1];
		t=gcd(x,y);
		num/=t;
		num*=y;
	}
	
    printf("%lld\n",num);
    
    return 0;
}

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

int main(){
  int D, T, S;
  cin >> D >> T >> S;

  double time = (double)D / S;

  if (time <= T) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 h = 0;
    cin >> h;
    int64 enemy = 1;
    int64 ans = 0;
    while(h > 1){
        ans += enemy;
        h /= 2;
        enemy *= 2;
    }
    ans += enemy;
    ANS(ans);
    return 0;
}

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

int main()
{
    int a, b;
    char op;

    while( cin >> a >> op >> b )
    {
        switch(op) 
        {
            case '+':
                cout << a + b << endl;
                break;
            case '-':
                cout << a - b << endl;
                break;
            case '*':
                cout << a * b << endl;
                break;
            case '/':
                cout << a / b << endl;
                break;
            case '?':
                break;
 
        }
    }
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	int a[n],b[n],c[n-1];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	for(int i=0;i<n-1;i++){
		cin >> c[i];
	}
	
	int score = 0;
	for(int i=0;i<n-1;i++){
		score += b[a[i]-1];
		if((a[i+1]-a[i])==1){
			score += c[a[i]-1];
		}
	}
	

	score += b[a[n-1]-1];
	
	cout << score << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using lnt = long long;
using Real = long double;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)
 
#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)
 
constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;
 
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}
 
using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	int N; string S; cin >> N >> S;
	int red = 0;
	REP(i, N) if(S[i] == 'R') red++;
	int ans = 0;
	REP(i, red){
		if(S[i] == 'W') ans++;
	}
	cout << ans << ln;
}

Measured memory_bytes: 3772
import math
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
cnt = 0
for i in range(n):
    for j in range(i+1, n):
        tmp = 0
        for k in range(d):
            tmp += (x[i][k] - x[j][k]) ** 2
        tmp = math.sqrt(tmp)
        if tmp == int(tmp):
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
  int S, h, m, s;

  scanf("%d",&S);
  h = S / 3600;
  m = S % 3600 / 60;
  s = S % 3600 % 60;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}


Measured memory_bytes: 2080
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define si3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define sl3(a,b,c)  scanf("%lld%lld%lld",&a,&b,&c)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)


int main()
{
   ll t,n,a,b,i,j,k,l,mn=0, mx=0;

   cin>>a>>b;
   cout<<a*b<<endl;

}






Measured memory_bytes: 3636
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K = MI()
    TD = LLIN(N)
    TD.sort(key = lambda x:x[1], reverse=True)

    neta = set()
    double = []
    ans = 0
    S = 0
    for i,(t,d) in enumerate(TD):
        if i < K:
            if t in neta:
                double.append(d)
            else:
                neta.add(t)
            S += d
        else:
            if t not in neta and double:
                S -= double.pop()
                S += d
                neta.add(t)
        ans = max(ans, S + len(neta)**2)
    print(ans)
if __name__ == '__main__':
    main()

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

int main(){
    int N;
    cin >> N;
    string s,tmp;
    vector<string> S;
    int i;
    long long int count=0;
    long long int tmp_count=1;
    for(i=0;i<N;i++){
        cin >> s;
        sort(s.begin(),s.end());
        S.push_back(s);
    }
    sort(S.begin(),S.end());
    tmp="0000000000";
    for(string t : S){
        if(tmp!=t){
            tmp=t;
            count += (tmp_count)*(tmp_count-1)/2;
            tmp_count=1;
        }
        else tmp_count++;
    }
    count += (tmp_count)*(tmp_count-1)/2;
    cout << count << endl;
}

Measured memory_bytes: 5748
#include<stdio.h>
int main(void)
{
  int now,ans;
  char str[8];
  
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&now);
  
  ans = (24 - now) + 24;
  
  printf("%d",ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <utility>
using namespace std;

typedef long long ll;

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


int d[20][20];
int cost[20][20];
int n;
int numTown;
int t;
void show(){
  for(int i=0;i<t;i++){
    for(int j=0;j<t;j++){
      printf("%10d ",cost[i][j]);
    }
    cout<<endl;
  }
  cout<<endl;
}

void solve(){
  for(int i=0;i<t;i++)for(int j=0;j<t;j++)cost[i][j]=d[i][j];
  for(int k=0;k<t;k++){
    for(int i=0;i<t;i++){
      for(int j=0;j<t;j++){
	if(i==j||i==k||j==k)continue;
	cost[i][j]=cost[j][i]=min(cost[i][j],cost[i][k]+cost[k][j]);
	//	show();
      }
    }
  }
  int ans=INT_MAX;
  int p=0;
  for(int i=0;i<t;i++){
    int sum=0;
    for(int j=0;j<t;j++){
      sum+=cost[i][j];
    }
    if(ans>sum){
      ans=sum;
      p=i;
    }
  }
  cout<<p<<" "<<ans<<endl;

}

int main(void){
  
  while(cin>>n,n){
    t=0;
    for(int i=0;i<22;i++){
      for(int j=0;j<22;j++){
	if(i==j)d[i][j]=0;
	else d[i][j]=10000000;
      }
    }
    for(int i=0;i<n;i++){
      int a,b,c;
      cin>>a>>b>>c;
      d[a][b]=d[b][a]=c;
      t=max(t,max(a+1,b+1));
    }
    solve();
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int i[3][110000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a=0,b,c,d=0,e=0,f,g;
  string s;
  cin >>c;
  a=c/100,b=c%100;
  if(a<=12&&a>0){
    if(b<=12&&b>0) cout <<"AMBIGUOUS\n";
    else cout <<"MMYY\n";
  }
  else{
    if(b<=12&&b>0) cout <<"YYMM\n";
    else cout <<"NA\n";
  }
  return (0);
}


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

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

void Main();

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

void Main() {
    int a;
    cin >> a;
    cout << (a == 0 ? 1 : 0) << endl;
}


Measured memory_bytes: 3608
// Hopcroft-Karp Algorithm
// O(|E| * |V|^(1/2))
// http://en.wikipedia.org/wiki/Hopcroft%E2%80%93Karp_algorithm
// aoj 1163

#include <vector>
#include <queue>
#include <iostream>
using namespace std;

int NIL;
const int inf = 1<<29;

typedef vector<int> vi;
typedef vector<vector<int> > Graph;

bool bfs(const Graph &g,vi &dist,const vi &pair,int m) {
    queue<int> q;

    for(int i=0; i<m; ++i)
        if(pair[i] == NIL) {
            dist[i] = 0;
            q.push(i);
        }else
            dist[i] = inf;
    dist[NIL] = inf;

    while(!q.empty()) {
        int v = q.front(); q.pop();
        if(v == NIL) continue;
        for(int i=0; i<g[v].size(); ++i) {
            int u = g[v][i];
            if(dist[pair[u]] == inf) {
                dist[pair[u]] = dist[v]+1;
                q.push(pair[u]);
            }
        }
    }
    return dist[NIL] != inf;
}

bool dfs(int v,const Graph &g,vi &dist,vi &pair) {
    if(v != NIL) {
        for(int i=0; i<g[v].size(); ++i) {
            int u = g[v][i];
            if(dist[pair[u]] == dist[v]+1) {
                if(dfs(pair[u],g,dist,pair)) {
                    pair[u] = v, pair[v] = u;
                    return true;
                }
            }
        }
        dist[v] = inf;
        return false;
    }
    return true;
}

// 0ツつゥツづァm-1ツづ慊づづ個静淞点ツづツつゥツづァn-1ツづ慊づづ個静淞点ツづづ個催妥・ツマツッツチツδ督グツづーツ仰づ淞づゥ
int hopcroft_karp(Graph &graph,int m) {
    const int n = graph.size();
    NIL = n;
    vi pair(n+1, NIL), dist(n+1, 0);
    int ret = 0;
    while(bfs(graph,dist,pair,m)) {
        for(int i=0; i<m; ++i)
            if(pair[i] == NIL)
                if(dfs(i,graph,dist,pair)) ret++;
    }
    return ret;
}

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

int main() {
    ios::sync_with_stdio(false);
    int m,n;
    while(cin>>m>>n, m|n) {
        Graph g(m+n);
        vector<int> b(m), r(n);
        for(int i=0; i<m; ++i) cin>>b[i];
        for(int i=0; i<n; ++i) cin>>r[i];

        for(int i=0; i<m; ++i)
            for(int j=0; j<n; ++j)
                if(gcd(b[i],r[j]) > 1)
                    g[i].push_back(j+m);
        cout<<hopcroft_karp(g,m)<<endl;
    }
}

Measured memory_bytes: 1628
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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

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 double PI = acos(-1.0);
const double EPS = 1e-10;

int b[202020];

void divisor(int n){
    vector<int> res;
    for(int i=1; i*i <= n; i++){
        if(n % i == 0){
            b[i]++;
            if(i != n / i) b[n/i]++;
        }
    }
    b[n] %= 2;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    vector<int> a(N+1);
    REP(i,N) cin>>a[i+1];
    int ans = 0;
    vector<int> ans_v;
    for(int i=N;i>0;--i){
        b[i] %= 2;
        if(a[i]==b[i]) continue;
        else{
            divisor(i);
            ans_v.push_back(i);
            ans++;
        }
    }
    reverse(ans_v.begin(),ans_v.end());
    if(a[1]!=b[1]) cout<<-1<<endl;
    else{
        cout<<ans<<endl;
        if(ans_v.size()==0) return 0;
        for(auto x:ans_v) cout<<x<<" ";
        cout<<endl;
    }
}


Measured memory_bytes: 3192
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;

#[fastout]
fn main() {
    input! {
        n: usize,
        cx: Chars,
    }

    let mut w = 0;
    let mut r = cx.iter().filter(|&&c| c == 'R').count();
    let mut ans = r;
    for i in 0..n {
        if cx[i] == 'W' {
            w += 1;
        } else {
            r -= 1;
        }
        ans = ans.min(w.max(r));
    }

    println!("{}", ans);
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int maxn = 3e5 + 5;
int a, b, c, k;
int rek(int A, int B, int C, int kLeft){
    if(kLeft == 0){
        return A + B + C;
    }
    int ret = 0;
    if(kLeft  > 0){
        ret = max(ret, rek(2 * A, B, C, kLeft - 1));
        ret = max(ret, rek(A, 2 * B, C, kLeft - 1));
        ret = max(ret, rek(A, B, 2 * C, kLeft - 1));
    }
    return ret;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> a >> b >> c >> k;
    cout << rek(a, b, c, k) << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int>dp(1e5+5,-1);
int n;
int dfs(vector<int>adj[],int i)
{
    if (adj[i].size()==0)return dp[i] = 0;
    int ans = 0;
    for (int child:adj[i]){
        if (dp[child]==-1)ans = max(ans,dfs(adj,child));
        else ans = max(ans,dp[child]);
    }
    return dp[i] = ans+1;
}
int32_t main()
{
    int m;
    cin>>n>>m;
    vector<int>adj[n+1];
    for (int i = 0;i<m;i++){
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
    }
    for (int i = 1;i<=n;i++){
        if (dp[i]==-1)dfs(adj,i);
    }
    int fin = 0;
    for (int i = 1;i<=n;i++)fin = max(fin,dp[i]);
    cout<<fin<<endl;
    return 0;
}

Measured memory_bytes: 12216
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Your code here!

const gcdArr = function(arr) {
  let gcdres = gcd(arr[0], arr[1])
  for (let i=2; i<arr.length; i++) {
    gcdres = gcd(gcdres, arr[i])
  }
  return gcdres
}

function gcd_impl(n,m) {
        for( let i = 0; i < 10; ++i ) {
                let t = n - m;
                let q = m > t;
                n = q ? m : t;
                m = q ? t : m;
                if( m == 0 ) { return n; }
        }
        return gcd_impl( m, n % m );
}

function gcd( n, m ) {
        return n > m ? gcd_impl( n, m ) : gcd_impl( m, n );
}

const Main = (p)=>{
	// 1行目がinput[0], 2行目がinput[1], …に入る
	p = p.split("\n");
	let N = parseInt(p[0])//p.split(" ").map(Number);
	let S = p[1].split("").map(e=>{
	    if(e=="R")return 1;
	    if(e=="G")return 2;
	    if(e=="B")return 4;
	});
	//console.log(S);return;
	
	//文字列から10進数に変換するときはparseIntを使います
	
	let s=0;
	let nr=0,ng=0,nb=0;
	for(let i=0;i<N;i++){
	    if(S[i]==1)nr++;else if(S[i]==2)ng++;else nb++;
	}
	for(let i=0;i<N;i++){
	    switch(S[i]){
            case 1:nr--;break;
            case 2:ng--;break;
            case 4:nb--;break;
        }
        let tr=nr,tg=ng,tb=nb;
	    for(let j=i+1;j<N;j++){
	        
	        switch(S[j]){
                case 1:tr--;break;
                case 2:tg--;break;
                case 4:tb--;break;
            }
            let ttr=tr,ttg=tg,ttb=tb;
	        if(S[i]!=S[j]){
	                if(j+j-i<N)
	                switch(S[j+j-i]){
                        case 1:ttr--;break;
                        case 2:ttg--;break;
                        case 4:ttb--;break;
                    }
	                switch(S[i]+S[j]){
	                    case 3:s+=ttb;break;
	                    case 5:s+=ttg;break;
	                    case 6:s+=ttr;break;
	                }
	                
	            
	        }
	        
    	}
	}
	console.log(s);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 36028
while True:
    t = input()
    if t == 0:
        break
    studied = 0
    n = input()
    for i in range(n):
        s = raw_input().split(" ")
        f_s = int(s[1]) - int(s[0])
        studied += f_s
    if studied >= t:
        print "OK"
    else:
        print "%d" % (t - studied)

Measured memory_bytes: 6360
#include<stdio.h>
int main(){
  int ire[10]={0};
  int n;
  int i=0;

  while(scanf("%d",&n)!=EOF){
    if(n==0){
      i--;
      printf("%d\n",ire[i]);
    }
    else{
      ire[i]=n;
      i++;
    }
  }
  return 0;
}

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




def main():
    h,w,k = map(int, input().split())
    s = [input() for i in range(h)]
    l = [[0]*w for i in range(h)]
    
    from collections import deque

    d = deque()
    c = 1
    for i in range(h):
        for j in range(w):
            if s[i][j] == '#':
                d.append([i, j])
                l[i][j] = c
                c += 1
    

    while len(d) > 0:
        x,y = d.pop()
        c = l[x][y]
        l[x][y] = c
        f1 = True
        f2 = True
        for i in range(1,w):
            if y+i < w and l[x][y+i] == 0 and s[x][y+i] != '#' and f1:
                l[x][y+i] = c
            else:
                f1 = False

            if 0 <= y-i and l[x][y-i] == 0 and s[x][y-i] != '#' and f2:
                l[x][y-i] = c
            else:
                f2 = False


    for i in range(h):
        if all(l[i]) == 0:
            k1 = 1
            while 0 < i+k1 < h and all(l[i+k1]) == 0:
                k1 += 1
            # print("test: ", i, k1)
            if i+k1 < h:
                for j in range(i, i+k1):
                    for r in range(w):
                        l[j][r] = l[i+k1][r]

    for i in range(h-1, -1, -1):
        if all(l[i]) == 0:
            k1 = 1
            while 0 < i-k1 < h and all(l[i-k1]) == 0:
                k1 += 1
            # print("test: ", i, k1)
            if 0 <= i-k1 < h:
                for j in range(i, i-k1, -1):
                    for r in range(w):
                        l[j][r] = l[i-k1][r]
    

                    
    for i in range(h):
        print(' '.join(map(str, l[i])))
            

    

if __name__ == '__main__':
    main()


Measured memory_bytes: 51696
#include <iostream>
//#include <array>

int main()
{
    int n, T;
    std::cin >> n >> T;
    int min = 1001;
    for (int i = 0; i < n; i++) {
        int c, t;
        std::cin >> c >> t;
        if (t <= T && c < min) {
            min = c;
        }
    }
    if (min == 1001) {
        std::cout << "TLE" << std::endl;
    } else {
        std::cout << min << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const ll MOD=1e9+7;

ll fc[200010], ifc[200010];
bool is_prime[200010];

ll add(ll x, ll y){return (x+y)%MOD;}
ll mlt(ll x, ll y){return (x*y)%MOD;}

ll power(int x, int n){
  ll ans=1;
  while(n>0){
    if(n&1) ans=mlt(ans, x);
    x=mlt(x,x);
    n/=2;
  }
  return ans;
}

ll inv(ll x){return power(x,MOD-2);}

void fct(){
  fc[0]=1;
  for(int i=0;i<200009;++i) fc[i+1]=mlt(fc[i], i+1);
}

void ifct(){
  ifc[200009]=inv(fc[200009]);
  for (int i=200009;i>=1;--i) ifc[i-1]=mlt(ifc[i], i);
}


ll comb(int n, int k){
  if(n<0||k<0||n<k) return 0;
  return mlt(fc[n], mlt(ifc[k], ifc[n-k]));
}

map<int, int> prime_factorization(int x){
  map<int, int> res;
  for (int i=2;i*i<=x;++i){
    while(x%i==0){
      res[i]++;
      x/=i;
    }
  }
  if(x!=1) res[x]++;
  return res;
}


int main(){
  int N, M;cin>>N>>M;
  fct();ifct();
  map<int, int> prime_factors=prime_factorization(M);
  ll ans=1;

  for (auto p:prime_factors){
    int q=p.second;
    ll c=comb(q+N-1, q);
    ans=mlt(ans, c);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    int N,K;
    cin>>N>>K;
    set<int> s;
    for(int i=0;i<K;i++){
        int a;
        cin>>a;
        s.insert(a);
    }
    for(int i=N;;i++){
        int a=i;
        while(a){
            int b;
            b=a%10;
            if(s.count(b)) break;
            a/=10;
            if(a==0){
                cout<<i<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b[100],i,j,n,key;
  scanf("%d",&a);
  if(1<=a && a<=100){
    for(i=0;i<a;i++){
      scanf("%d",&b[i]);
    }

    for(i=0;i<a;i++){
      key=b[i];
      j=i-1;
      while(j>=0 && b[j]>key){
	b[j+1]=b[j];
	j-=1;
	b[j+1]=key;
      }
     for(n=0;n<a-1;n++){
	printf("%d ",b[n]);
      }
     printf("%d\n",b[n]);
    }
  }
  return 0;
}



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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  ll n;
  string s;
  cin>>n>>s;

  vector<vector<ll>> dp (n+1,vector<ll>(n+1,0));
  reps(i,n-1){
    if(s[0]==s[i])dp[0][i]++;
  }
  for(ll i=1;i<n;++i){
    for(ll j=i+1;j<n;++j){
      if(s[i]==s[j]){
        dp[i][j]++;
        dp[i][j]+=dp[i-1][j-1];
        chmin(dp[i][j],j-i);
      }
    }
  }

  ll ans=0;
  for(const auto& y:dp){
    for(const auto& x:y){
      chmax(ans,x);
    }
  }
  cout<<(ans)<<endl;


}


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

using namespace std;

int main() {
  int a = 0;
  int A, B, C;
  
  cin >> A >> B >> C;
  
  bool isMatched[3];
  
  isMatched[0] = (A == B);
  isMatched[1] = (B == C);
  isMatched[2] = (C == A);
  
  for (int i = 0; i < 3; i++) {
    a += isMatched[i] ? 0 : 1;
  }
  
  cout << (a == 2 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	char s[200];
	char p[100];
	int i,k,j=0;
	scanf("%s",s);
	scanf("%s",p);
	k = strlen(s);
	for(i = k;i <= 2*k;i++){
		s[i]=s[i-k];
	}
	if(strstr(s,p) != NULL){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 524
Q = int(input())
maxn = 10**5
is_prime = [True if i%2 == 1 else False for i in range(0, maxn+1) ]
is_prime[0] = False
is_prime[1] = False
is_prime[2] = True
for i in range(3, int(maxn**0.5) + 1, 2):
    if not is_prime[i]:
        continue
    for j in range(i*2, maxn+1, i):
        is_prime[j] = False

ps = [i for i in range(maxn+1) if is_prime[i]]
ps = set(ps)

c = [0] * 10**5
for i in range(3, 10**5+1, 2):
    if i in ps and (i+1)//2 in ps:
        c[i] = 1

from itertools import accumulate
cs = list(accumulate(c))

for _ in range(Q):
    l, r = map(int, input().split())
    print(cs[r] - cs[l-1])


Measured memory_bytes: 8900
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int n = in.nextInt();
		int x = in.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for (int i=0; i<n; i++) {
			a[i] = b[i] = in.nextInt();
		}

		long ans = 0;
		for (int i=1; i<n; i++) {
			long s = a[i] + a[i-1];
			long t = Math.max(0, s - x);
			long y = Math.min(t, a[i]);
			a[i] -= y;
			ans += t;
		}

		long ans2 = 0;
		for (int i=n-2; i>=0; i--) {
			long s = b[i] + b[i+1];
			long t = Math.max(0, s - x);
			long y = Math.min(t, b[i]);
			b[i] -= y;
			ans2 += t;
		}

		out.println(Math.min(ans, ans2));
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 47480