akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N;
unordered_map<ll,ll> um;

int main(){
    cin >> N;
    ll M = N;
    for(ll i=2;i*i<=N;i++){
        if(M % i != 0) continue;
        ll c = 0;
        while(M % i == 0){
            M /= i;
            c++;
        }
        um[i] = c;
    }
    if(M != 1) um[M] = 1;
    ll ans = 0;
    for(auto &e : um){
        ll t = e.second;
        for(int i=1;i<=t;i++){
            t -= i;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,f=0,s=0,i;


    for(i=0;i<3;i++)
    {
        cin >> n;
        if(n==5)
            f++;
        else if(n==7)
            s++;
    }

if(f==2 && s==1)
    cout << "YES";
else
cout << "NO";

}


Measured memory_bytes: 3568
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(void){

  int H,W;
  char C[111][111];
  int i,j;
  cin>>H>>W;
  for(j=1;j<=H;j++){
    for(i=1;i<=W;i++){
      cin>>C[j][i];
    }
  }

  for(j=1;j<=2*H;j++){
    for(i=1;i<=W;i++){

      cout<<C[(j+1)/2][i];
    }
    cout<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		int n = new Scanner(System.in).nextInt();
		int i=1;
		do{
			int x=i;
			if(x%3==0){
				System.out.print(" "+i);
			}else if(check3(i, Integer.toString(i).length())){
				System.out.print(" "+i);
			}
		}while(++i<=n);
		System.out.println("");
	}
	
	private static boolean check3(int n, int k){
		boolean res=false;
		int t=(int)Math.pow(10, k-1);
		if(n/t==3){
			res=true;
		}else if(k>1){
			res=check3(n%t, k-1);
		}
		return res;
	}
}

Measured memory_bytes: 24240
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    x = list(in_nn())
    ans = x.index(0)
    print(ans + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9108
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

S, C = list(map(int, sys.stdin.readline().split()))
if S * 2 >= C:
    ans = C // 2
    print(ans)
    exit()

ans = S
C -= S * 2
ans += C // 4
print(ans)


Measured memory_bytes: 13604
#include <bits/stdc++.h>
#define pi pair<int, int>
#define pb push_back
#define int long long

using namespace std;

const int maxn = 3e5 + 1;

int n, k, c;
string s;
int dp[maxn], p[maxn];
int md[maxn], mp[maxn];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> k >> c >> s; ++c;
    for (int i = n; i < n + c; i++)
        md[i] = n + c;
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'x') {
            dp[i] = dp[i + 1];
            md[i] = md[i + 1];
            continue;
        }
        dp[i] = 1 + dp[i + c];
        md[i] = (dp[i] == dp[i + 1] ? md[i + 1] : i);
    }
    for (int i = 0; i < n; i++ ){
        if (s[i] == 'x') {
            p[i] = (!i ? 0 : p[i - 1]);
            mp[i] = (!i ? -c : mp[i - 1]);
            continue;
        }
        p[i] = 1 + (i < c ? 0 : p[i - c]);
        if (i < c) {
            if (!i) mp[i] = 0;
            else if (p[i - 1] == 0) mp[i] = i;
            else mp[i] = mp[i - 1];
        } else {
            mp[i] = (p[i - 1] < p[i] ? i : mp[i - 1]);
        }
    }
    stack<int> st;
    for (int i = n - 1; i >= 0; i--)
        if (s[i] == 'o') st.push(i);
    int ls = -1000000;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'x') continue;
        int x = md[i + 1] - (!i ? -c : mp[i - 1]);
        int ass = (!i ? 0 : p[i - 1]) + dp[i + 1];
        if (x < c) --ass;
        if (ass < k)
            cout << i + 1 << '\n';
        ls = i;
    }
    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  
  int ans = 0;
  for (int i = 0; i < k; i++) ans += a.at(i);
  
  cout << ans << '\n';
}

Measured memory_bytes: 3636
#include <stdio.h>
 
char str[1005];
char p[1005];
 
int main()
{
    int q, a, b;
    char op[10], *x, *y, c;
     
    scanf("%s%d", str, &q);
    while (q--) {
        scanf("%s%d%d", op, &a, &b);
        if (op[2] == 'i') {             // print
            b++, c = *(str+b), *(str+b) = 0, puts(str+a), *(str+b) = c;
        } else if (op[2] == 'v') {      // reverse
            x = str+a, y = str+b;
            while (x < y) {
                c = *x, *x = *y, *y = c;
                x++, y--;
            }
        } else {                        // replace
            scanf("%s", p);
            x = str+a, y = p;
            while (*y) *x++ = *y++;
        }
    }
    return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string T;
    cin >> T;

    REP(i,T.size()){
        if (T.at(i) == '?'){
            T.at(i) = 'D';
        }
    }


    /*f(T.size()%2==0){
        REP(i, T.size())
        {
            if (T.at(i) == '?')
            {
                if (i % 2 == 0)
                {
                    T.at(i) = 'P';
                }
                else
                {
                    T.at(i) = 'D';
                }
            }
        }
    }
    else{
        REP(i, T.size()-1)
        {
            if (T.at(i) == '?')
            {
                if (i % 2 == 0)
                {
                    T.at(i) = 'P';
                }
                else
                {
                    T.at(i) = 'D';
                }
            }
        }
        if (T.at(T.size() - 1)=='?'){
            T.at(T.size() - 1) = 'D';
        }
    }*/
    cout << T << endl;

}


Measured memory_bytes: 3776
#include<iostream>
using namespace std;
int main(){
  int a,b,c,i;
  cin >> i; 
  for(int n = 0;n < i;n++){
    cin >> a >> b >> c;
    if(a*a == b * b + c * c){
      cout << "YES" << endl;
    } else if(b*b == a * a + c * c){
      cout << "YES" << endl;
    } else if(c*c == b * b + a * a){
      cout << "YES" << endl;
    } else {cout <<"NO" << endl;} 
  }
}

Measured memory_bytes: 1156
import itertools
def main():
    n = int(input())
    L = list(map(int, input().split()))


    comb = itertools.combinations(L, 3)
    ans = 0
    for a in list(comb):
        if len(a) == len(set(a)):
            max_len = max(a)
            sum_all = sum(a)
            if sum_all - max_len > max_len:
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20632
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

void dfs(VVI &es, vector<bool> &visited, int i) {
    visited[i] = true;
    for (int d: es[i]) {
        if (visited[d]) continue;
        dfs(es, visited, d);
    }
}

void solve() {
    int n,m;
    cin >> n >> m;
    VVI es(n);
    int x,y,z;
    REP(i,0,m) {
        cin >> x >> y >> z;
        --x; --y;
        es[x].push_back(y);
        es[y].push_back(x);
    }
    int ans = 0;
    vector<bool> visited(n);
    REP(i,0,n) {
        if (visited[i]) continue;
        ++ans;
        dfs(es, visited, i);
    }
    cout << ans << endl;
}

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

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

namespace ABC125C
{
    class MainClass
    {

        static int[] s;
        static long[] n;

        public static void Main(string[] args)
        {

            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            n = Array.ConvertAll(Console.ReadLine().Split().ToArray(), long.Parse);
            if (s[0] == 2)
            {
                Console.WriteLine(Math.Max(n[0], n[1]));
                return;
            }


            long[] l = new long[s[0]];
            long[] r = new long[s[0]];
            var alst = new List<long>();
            int j = 0;
            for(int i = 0; i < s[0]; i++)
            {
                j = s[0] - 1 - i;
                if (i == 0) 
                { 
                    l[i] = 0;
                    r[j] = 0;
                 }
                else
                {
                    l[i] = Gcd(l[i - 1], n[i - 1]);
                    r[j] = Gcd(r[j + 1], n[j + 1]);
                }
            }
            for(int i = 0; i < s[0]; i++)
            {
                alst.Add(Gcd(l[i], r[i]));
            }

            Console.WriteLine(alst.Max());

        }
        public static long Gcd(long a, long b)
        {
            long tmp;
            // a<bにする
            if (a >= b)
            {
                tmp = a;
                a = b;
                b = tmp;
            }

            if (a == 0)
            {
                return b;
            }

            tmp = a;
            a = b % a;
            b = tmp;
            return Gcd(a, b);

        }

    }
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  string s; cin >> s;
  int sum = 0;
  for(int i = 0; i < 11; ++i){
    for(int j = 0; j < 11; ++j){
      for(int k = 0; k < 11; ++k){
	int x = 0;
	for(int l = 0; l < n; ++l){
	  char c;
	  if(x == 0)c = '0'+i;
	  if(x == 1)c = '0'+j;
	  if(x == 2)c = '0'+k;
	  if(c == s[l])x++;
	}
	if(x >= 3)sum++;
      }
    }
  }
  cout << sum << endl;
  return 0;
}


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

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


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

int main (void){
	int n;
	while(~scanf("%d",&n)){
		int a,b,c,d,res=0;
		for(a=0;a<=9;a++)
			for(b=0;b<=9;b++)
				for(c=0;c<=9;c++)
					for(d=0;d<=9;d++)
						res += (a+b+c+d == n);
		std::cout << res << std::endl;
	}

	return 0;
}

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

int main() {
    vector<vector<int>> bingo(3,vector<int>(3));
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            cin >> bingo.at(i).at(j);
        }
    }
    int N;
    cin >> N;
    vector<int> deme(N);
    for (int i = 0; i < N; i++){
        cin >> deme.at(i);
    }
    int flag = 0;
    int b = 0;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < N; k++){
                if (bingo.at(i).at(j) == deme.at(k)) flag++;
            }
            if (flag == 3) b = 1;
        }
        flag = 0;
    }
    for(int j = 0; j < 3; j++){
        for(int i = 0; i < 3; i++){
            for(int k = 0; k < N; k++){
                if (bingo.at(i).at(j) == deme.at(k)) flag++;
            }
            if (flag == 3) b = 1;
        }
        flag = 0;
    }
    for(int i = 0; i < 3; i++){
        for (int k = 0; k < N; k++){
            if (bingo.at(i).at(i) == deme.at(k)) flag++;
        }
    }
    if (flag == 3) b = 1;
    flag = 0;
    for(int k = 0; k < N; k++){
        if (bingo.at(0).at(2) == deme.at(k)) flag++;
        if (bingo.at(1).at(1) == deme.at(k)) flag++;
        if (bingo.at(2).at(0) == deme.at(k)) flag++;
    }
    if (flag == 3) b = 1;
    if (b) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

bool sorter(const pair<int, int> p1, const pair<int, int> p2){
  if(p1.fi == p2.fi) return p1.se > p2.se;
  else return p1.fi < p2.fi;
}

int main(){
  int n;
  while(cin>>n, n){
    vector<pair<int, int> > vec(n);
    rep(i,n) scanf("%d %d", &vec[i].fi, &vec[i].se);
    int m;
    cin>>m;
    vec.resize(n+m);
    repl(i,n,n+m) scanf("%d %d", &vec[i].fi, &vec[i].se);
    sort(all(vec), sorter);
    vector<int> lis(n+m, INF);
    rep(i,n+m){
      int idx = lower_bound(all(lis), vec[i].se) - lis.begin();
      lis[idx] = vec[i].se;
    }
    cout << lower_bound(all(lis), INF) - lis.begin() << endl;
  }

  return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
#define ci(n,a)   vi a(n); rep(i,(n)) cin>>a[i];
#define rep(i,n)  for(ll i = 0; i < (n); ++i)
#define red(i,n)  for(ll i = (n)-1; i >= 0; --i)
#define all(a)    begin(a),end(a)
#define pb(a)     push_back(a)
#define mp(a,b)   make_pair(a,b)
#define yn(a)     cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;



int main(int argc,char* argv[]) 
{
    ll n,ans=0;
    cin>>n;
    ll a[n],b[n];
    rep(i,n)cin>>a[i]>>b[i];
    red(i,n) {
        a[i]+=ans;
        if(a[i]%b[i]) ans+=b[i]-a[i]%b[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define mod 1000000007
#define mk make_pair
#define ll long long 
#define fi first
#define se second 
#define pb push_back
using namespace std;
const int N=21,M=410;
int n,m,T,S,cnt[1<<N],mul[M][M],e[1<<N];
typedef pair<int,int>pii;
pii dp[1<<N];
vector<pii>G[N];
void inc(int&x,int y){x+=y;if(x>=mod)x-=mod;}
void adde(int u,int v,int w){
	G[u].pb(mk(v,w));
	G[v].pb(mk(u,w));
}
int dfs(int u,int fa=0){
	if(u==T)return 0;
	for(int i=0,t;i<(int)G[u].size();++i){
		int v=G[u][i].fi,w=G[u][i].se;
		if(v==fa||!~(t=dfs(v,u)))continue;
		return t|(1<<(w-1));
	}
	return -1;
}
int main(){
//	freopen("F.in","r",stdin);
//	freopen("F.out","w",stdout);
	scanf("%d%d",&n,&m);
	int all=1<<(n-1),tot=m-n+1;
	for(int i=1;i<n;++i){
		int u,v;
		scanf("%d%d",&u,&v);
		adde(u,v,i);
	}
	for(int i=1;i<=tot;++i){
		int u,v,t;
		scanf("%d%d",&u,&v);
		T=v;t=dfs(u);
		e[(all-1)^t]++;
	}
	for(int i=1;i<n;++i)
	for(int j=0;j<all;++j)if(j>>(i-1)&1){
		e[j^(1<<(i-1))]+=e[j];
	}
	for(int i=0;i<all;++i){
		cnt[i]=cnt[i>>1]+(i&1);
		e[i]=tot-e[i];
	}
	for(int i=1;i<=m+1;++i){
		mul[i][i-1]=1;
		for(int j=i;j<=m+1;++j){
			mul[i][j]=(ll)mul[i][j-1]*j%mod;	
		}
	}
	dp[0]=mk(1,0);
	for(int i=0;i<all;++i)
	for(int j=1;j<n;++j)if(!(i>>(j-1)&1)){
		int b=cnt[i],a=b+e[i],c=dp[i].fi,s=dp[i].se;
		int ni=i|(1<<(j-1)),k=e[ni]-e[i];
		c=(ll)c*mul[a+1][a+k]%mod;
		s=(ll)s*mul[a+2][a+k+1]%mod;
		inc(s,(ll)c*(b+1)%mod);
		inc(dp[ni].fi,c);
		inc(dp[ni].se,s);
	}
	cout<<dp[all-1].se<<endl;
	return 0;
}

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

// #undef DEBUG
// #define DEBUG
/// {{{ DEBUG --- ///
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { if(&o == &cerr) { o << '{'; for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? ", " : ""); o << "}"; } else { for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? " " : ""); } return o; }
#ifdef DEBUG
#ifdef USE_COUT
#define dump(...) (cout<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<make_tuple(__VA_ARGS__)<<"\n")
#else
#define dump(...) (cerr<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<make_tuple(__VA_ARGS__)<<"\n")
#endif
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream &o, tuple<T...> const &t){ o << "("; _ot<0>(o, t); o << ")"; return o; }
template<class T, class U> ostream & operator<<(ostream &o, pair<T, U> const &p) { o << "(" << p.first << ", " << p.second << ")"; return o; }
#else
#define dump(...) (0)
#endif
/// }}}--- ///

ll S(ll x) {
  ll s = 0;
  while(x) s += x % 10, x /= 10;
  return s;
}

ll fc(ll a, ll b) { return a * S(b) > b * S(a); }

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  ll k; cin >> k;
  ll t = 1;
  vector<ll> v(15);
  vector<ll> b(15);
  // for(int i = 0; i < 15; i++) {
  //   ll ok = 1, ng = 1e15 / t;
  //   while(ng - ok > 1) {
  //     ll mid = (ok + ng) / 2;
  //     ll mm = mid;
  //     if(mid % 10 == 9) mm++;
  //     ll n = mm * t + t - 1;
  //     if(S(n) * (n + t) <= n * (S(n + t))) ok = mid; else {ng = mid;if(i == 1)dump(ng, mm, n);}
  //   }
  //   v[i] = ok;
  //   b[i] = t;
  //   t *= 10;
  // }
  // dump(v, b);
  int head = 0;
  vector<ll> ans;
  ll n = 1;
  t = 1;
  while(n <= 1e15) {
    ans.emplace_back(n);
    if(ans.size() >= k) break;
    while(t <= 1e15 && fc(n + t, n + t + t)) t *= 10;
    n += t;
  }
  for(int i = 0; i < k; i++) cout << ans[i] << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <memory.h>
#include <algorithm>
#define case        printf("Case %d: ",++tc);
#define read        freopen("tst.txt","r",stdin)
#define write       freopen("out.txt","w",stdout)
typedef long long ll;
using namespace std;
#define pi acos(-1)
#define mx 100002
vector<ll> v;
ll dp[mx];

ll n;
ll fn(ll pos){
    if(pos>=n-1)    return 0;

    ll p = 1e9;
    if(dp[pos]!=-1) return dp[pos];

    for(ll i = 1;i<=2; i++){
        if(pos+i>=n)    continue;
        ll h = abs(v[pos+i]-v[pos]);
        p = min(p,h+fn(pos+i));
    }
    return dp[pos] = p;
}

int main(){
ll t,tc = 0;

scanf("%lld",&n);
memset(dp,-1,sizeof dp);
v = vector<ll> (n);

for(ll i = 0; i<n; i++)    scanf("%lld",&v[i]);

ll ans = fn(0);
printf("%lld\n",ans);

return 0;
}


Measured memory_bytes: 9600
import sys

def main():
  input = sys.stdin.readline
  N = str(input().strip())
  L = len(N)
  f = N[0]
  a = f * L
  b = str(int(f) + 1) * L
  
  if int(a) >= int(N):
    print(int(a))
  else:
    print(int(b))


if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  lint N,L;
  cin>>N>>L;
  lint a[N];
  REP(i,N)cin>>a[i];
  int ans[N-1];
  int l=1;
  int r=N-1;
  lint S=0;
  REP(i,N)S+=a[i];
  REP(i,N-1){
    if(S<L){
      cout<<"Impossible"<<endl;
      return 0;
    }
    if(a[l-1]+a[l]>a[r-1]+a[r]){
      ans[i]=r;
      S-=a[r];
      r--;
    }else{
      ans[i]=l;
      S-=a[l-1];
      l++;
    }
  }
  cout<<"Possible"<<endl;
  REP(i,N-1)cout<<ans[i]<<endl;

  return 0;
}


Measured memory_bytes: 2048
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <queue>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/
#if 0 //slow for large number
int main()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);

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

	ll h[N];
	//priority_queue<ll, std::vector<ll>, less<ll> > l_que;
	//priority_queue<ll, std::vector<ll>, greater<ll> > g_que;
	std::vector<ll> v;
	rep(i, N)
	{
		cin >> h[i];
		v.pb(h[i]);
	}

	sort(v.begin(), v.end(), greater<ll>());

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

	ll count = 0;
	//cout<<"st" << endl;
	while(!v.empty())
	{
		ll top = v[0] - A;
		int i = 1;
		for (i = 1; i < v.size(); i++)
		{
			v[i] -= B;
			if (v[i] <= 0)
			{
				break;
			}
		}

		//cout << "sfg" << endl;

		while(v.size() > i)
		{
			v.pop_back();
		}
		/*
		if (v.size() > 1)
		{
			cout << v.size() << endl;
		}
		*/
		

		if (top <= 0)
		{
			//cout << "top" << endl;
			//cout << v.size() << endl;
			v.erase(v.begin());
			//cout << v.size() << endl;
		}
		else
		{
			v[0] = top;
			sort(v.begin(), v.end(), greater<ll>());
		}
		count++;
	}

	cout << count << endl;

	
	return 0;
}
#endif 

// refer to tutorial
int main()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);

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

	ll h[N];

	ll left = 0;
	ll right = 1e9;

	rep(i, N)
	{
		cin >> h[i];
	}


	while(left < right - 1)
	{
		//cout << left << ", " << right << endl;
		ll mid = (left + right) >> 1;
		ll count = 0;
		rep(i, N)
		{
			ll rem = h[i] - B * mid;
			if (rem > 0)
			{
				if (rem % (A - B))
				{
					count += rem / (A - B) + 1;
				}
				else
				{
					count += rem / (A - B);
				}
			}
		}

		if (count <= mid)
		{
			right = mid;
		}
		else if (count > mid)
		{
			left = mid;
		}
	}

	
	cout << right << endl;
	
	return 0;
}

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

using ll = unsigned long long;

int main()
{
	ll H, W;
	std::cin >> H >> W;

	ll ans;
	if (H == 1ull || W == 1ull)
	{
		ans = 1ull;
	}
	else if (H % 2 == 0)
	{
		ans =  H / 2 * W;
	}
	else
	{
		ans = (H - 1) / 2 * W + (W + 1) / 2;
	}

	std::cout << ans;
}



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

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

    int n;
    cin >> n;

    for (int i = 1; i <= 50000; i++) {
        int nn = (int)floor(1.0 * i * 1.08);
        if (nn == n) {
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
}
int main(void)
{
    lli N;
    cin >> N;
    lli h[100010];
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    lli dp[100010];
    for (int i = 0; i < N; i++)
    {
        dp[i] = 100000000000000;
    }
    dp[0] = 0;
    for (int i = 1; i < N; ++i)
    {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1)
        {
            chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }
    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 5180
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    n = inputInt()
    a = inputList()
    aa = []
    for i,val in enumerate(a):
        if i == 0:
            aa.append(val)
        else:
            tmp = val + aa[i-1]
            aa.append(tmp)
            
    barans = 0
    ans = 0
    flg = True
    for i,val in enumerate(aa):
        if i == 0:
            if val <= 0:
                barans = 1 - val
                ans += barans
        else:
            val_sin = val + barans
            if flg == True:
                flg = False
                if val_sin >= 0:
                    tmp = 1 + val_sin
                    ans += tmp
                    barans -= tmp
            else:
                flg = True
                if val_sin <= 0:
                    tmp = 1 - val_sin
                    ans += tmp
                    barans += tmp
        
    barans = 0
    ansans = 0
    flg = False
    for i,val in enumerate(aa):
        if i == 0:
            if val >= 0:
                barans = 1 + val
                ansans += barans
                barans = -1 * barans
        else:
            val_sin = val + barans
            if flg == True:
                flg = False
                if val_sin >= 0:
                    tmp = 1 + val_sin
                    ansans += tmp
                    barans -= tmp
            else:
                flg = True
                if val_sin <= 0:
                    tmp = 1 - val_sin
                    ansans += tmp
                    barans += tmp
        
    #print("{} {}".format(ans, ansans))
    print(min(ans,ansans))
        
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 70428
//header file---{{{
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
//end.header file---}}}
using namespace std;


//template---{{{
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b); i > (a); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)

#define all(i) (i).begin(), (i).end();
//end.template ---}}}

int main() {

    int i;
    string S;
    int res = 700;

    cin >> S;

    REP(i, 3) {
        if (S[i] == 'o') res += 100;
    }

    cout << res << endl;

    return (0);
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
using namespace std;
ll q,h,s,d;


int main(){
	ll n;
	cin>>q>>h>>s>>d;
	cin>>n;
	h = min(2*q,h);
	s = min(2*h,s);
	d = min(2*s,d);
	ll ans = 0;
	if(n%2 == 0){
		ans = d*n/2;
	}
	else{
		ans = d*(n-1)/2;
		ans += s;
	}
	cout<<ans;
	
}

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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

vector<pair<ll,ll>> factorize(ll n){
	vector<pair<ll,ll>> res;
	for (ll i = 2; i*i <= n; ++i) {
		if(n % i) continue;
		res.emplace_back(i,0);
		while(n % i == 0){
			n /= i;
			res.back().second++;
		}
	}
	if(n != 1) res.emplace_back(n,1);
	return res;
}

int main() {
	ll n;
	cin >> n;
	ll ans = 0;
	for (ll i = 2; i * i <= n; ++i) {
		ll temp = n;
		if(temp % i) continue;
		while(temp % i == 0){
			temp /= i;
		}
		if(temp % i == 1) ans++;
	}
	auto v = factorize(n-1);
	ll yakusuu = 1;
	rep(i,v.size()){
		yakusuu *= v[i].second + 1;
	}
	yakusuu--;
	ans += yakusuu + 1;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define D 365
typedef long long ll;
ll calcSat(int *tmpt, int s[][26], int *c) {
	int last[26] = {0};
	ll tmpSat = 0;
	for (int i = 0; i < D; i++) {
		tmpSat += s[i][tmpt[i] - 1];
		last[tmpt[i] - 1] = i + 1;
		for (int j = 0; j < 26; j++) {
			tmpSat -= (c[j] * (i + 1 - last[j]));
		}
		/**
		printf("%lld\n", tmpSat);
		/**/
	}
	return tmpSat;
}
int main() {
	srand(628);
	scanf("%*d");
	int c[26], s[D][26];
	int t[D] = {0};
	ll bestSat = 0;
	for (int i = 0; i < 26; i++) {
		scanf("%d", &c[i]);
	}
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) {
			scanf("%d", &s[i][j]);
		}
	}
	/**/
	for (int i = 0; i < D; i++) {
		t[i] = rand() % 26 + 1;
		bestSat = calcSat(t, s, c);
	}
	/**/

	for (int cnt = 0; cnt < 200000; cnt++) {
		int tmpt[D];
		int pos = rand() % D;
		for (int i = 0; i < D; i++) {
			tmpt[i] = t[i];
		}
		tmpt[pos] = rand() % 26 + 1;
		ll tmpSat = calcSat(tmpt, s, c);
		if (tmpSat > bestSat) {
			bestSat = tmpSat;
			t[pos] = tmpt[pos];
		}
	}
	// printf("%lld\n", bestSat);

	for (int i = 0; i < D; i++) {
		printf("%d\n", t[i]);
	}
	return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

typedef long long i64;
typedef pair<i64, i64> pii;

const int INF = 0x3f3f3f3f;
const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t, n;
  rep(i, 4) {
    cin >> t >> n;
    if (t == 1) cout << 6000 * n << "\n";
    else if (t == 2) cout << 4000 * n << "\n";
    else if (t == 3) cout << 3000 * n << "\n";
    else cout << 2000 * n << "\n";
  }
  return 0;
}



Measured memory_bytes: 3164
#include <stdio.h>
#include <math.h>

#define PI 3.141592653589793

int main()
{
	double a, b, c, s, C;
	double S, L, h; 
	
	scanf("%lf%lf%lf", &a, &b, &C);
	c = sqrt(a*a + b*b - 2*a*b*cos(C*PI/180));
	L = a+b+c;
	s = L/2;
	S = sqrt(s*(s-a)*(s-b)*(s-c));
	h = 2*S/a;
	printf("%.8lf\n%.8lf\n%.8lf\n", S, L, h);
	return 0;
}


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (int) n; i++)
#define reps(i, n) for (int i = 1; i <= (int) n; i++)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << x << endl
typedef vector<int> vint;
typedef pair<int, int> pint;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> inline bool chmax(T1 &a, const T2 &b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, const T2 &b) { return b < a && (a = b, true); }
struct SetUp { SetUp() { cout << fixed << setprecision(20); }; } setUp;

int N, M;
int A[2200], B[2200];
vint G[1100], rev[1100];

vint bfs(int idx) {
    vint dist(1100, 1100);
    queue<pint> q;
    q.push({idx, 0});
    while (!q.empty()) {
        int cur = q.front().first;
        int d = q.front().second;
        q.pop();
        rep(i, G[cur].size()) {
            int next = G[cur][i];
            if (dist[next] != 1100) { continue; }
            dist[next] = d + 1;
            q.push({next, dist[next]});
        }
    }
    vint ret;
    if (dist[idx] == 1100) { return ret; }
    int cur = idx;
    while (true) {
        ret.push_back(cur);
        rep(i, rev[cur].size()) {
            int prev = rev[cur][i];
            if (dist[prev] == dist[cur] - 1 || prev == idx) {
                cur = prev;
                break;
            }
        }
        if (cur == idx) { break; }
    }
    return ret;
}

signed main() {
    cin >> N >> M;
    rep(i, M) {
        cin >> A[i] >> B[i];
        G[A[i]].push_back(B[i]);
        rev[B[i]].push_back(A[i]);
    }
    vint ans;
    reps(i, N) {
        vint cur = bfs(i);
        if (ans.size() == 0 || (cur.size() != 0 && cur.size() < ans.size())) { ans = cur; }
    }
    if (ans.size() == 0) {
        cout << -1 << endl;
        return 0;
    }
    cout << ans.size() << endl;
    rep(i, ans.size()) { cout << ans[i] << endl; }
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>

#pragma GCC optimize(2)
#define rep(i,a,n) for (int i=a;i<=n;i++)//i为循环变量，a为初始值，n为界限值，递增
#define per(i,a,n) for (int i=a;i>=n;i--)//i为循环变量， a为初始值，n为界限值，递减。

using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll<<60;
const int mod=1e9+7;

ll read()//快读
{
	ll w = 1, s = 0;
	char ch = getchar();
	while (ch < '0' || ch>'9') { if (ch == '-') w = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { s = s * 10 + ch - '0';    ch = getchar(); }
	return s * w;
}


int main(){
	string s;
	cin>>s;
	int len=s.size();
	if(s[len-1]=='s')
	cout<<s<<"es"<<endl;
	else cout<<s<<"s"<<endl;
    return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<algorithm>
#include<map>

#define MAX	300

using namespace std;



int main(void)
{
	int n;
	int a , b;
	int pizza;
	//今までの最高値を格納
	double ans = 0;

	int top[MAX];

	cin >> n;
	cin >> a >> b >> pizza;

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

	sort(top , top + n , greater<int>());

	//初期値
	ans = pizza / a;

	//貪欲法
	
	for (int i = 0; i < n; i++)
	{
		a += b;
		pizza += top[i];
		ans = max(ans , (double)pizza / a);
	}

	cout << (int)ans << endl;

	return 0;
}

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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;
    }

    public static string Solve()
    {
        int[] input = ReadInts();
        int N = input[0];
        int M = input[1];
        int min = 0;
        int max = N;
        for(int i=0;i<M;i++)
        {
            input = ReadInts();
            min = Math.Max(min, input[0]);
            max = Math.Min(max, input[1]);
        }
        int ans = max - min + 1;
        ans = Math.Max(ans, 0);
        return ans.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 15184
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int

#define M_DEBUG 1
#define PI 3.141592653589793

#define DEBUG 1

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

    cout << n * n << endl;


    return 0;
}

Measured memory_bytes: 256
li1 = list(map(int, input().split()))
li2 = list(map(int, input().split()))
re = li1[0]
n = 1
while True:
    if li1[0] not in li2:
        re = li1[0]
        break
    if li1[0] - n not in li2:
        re = li1[0] - n
        break
    if li1[0] + n not in li2:
        re = li1[0] + n
        break
    n += 1

print(re)


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

using namespace std;

typedef tuple<int, int, int> iii;

iii R[200005];

set<iii> s1;
set<iii> s2;

int main(){
	int N, Q;
	scanf("%d%d", &N, &Q);
	
	for(int i = 0; i < N; i ++){
		int s, t, x;
		scanf("%d%d%d", &s, &t, &x);
		R[i] = iii(s-x, t-x, x);
	}
	
	sort(R, R+N);
	int indx = 0;
	
	for(int i = 0; i < Q; i ++){
		int D;
		scanf("%d", &D);
		while(get<0>(R[indx]) <= D && indx < N){
			int s = get<0>(R[indx]);
			int t = get<1>(R[indx]);
			int x = get<2>(R[indx]);
			s1.insert(iii(t, s, x));
			s2.insert(iii(x, s, t));
			indx ++;
		}
		
		while(!s2.empty()){
			iii temp = *s1.begin();
			int t = get<0>(temp);
			int s = get<1>(temp);
			int x = get<2>(temp);
			if(D < t){
				break;
			}
			
			s1.erase(iii(t, s, x));
			s2.erase(iii(x, s, t));
		}
		
		if(!s2.empty()){
			iii temp = *s2.begin();
			printf("%d\n", get<0>(temp));
		}else{
			printf("-1\n");
		}
	}
	
	return 0;
}


Measured memory_bytes: 28544
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1005,M=1e6+5;
struct Node{
  int x,y;
  Node(int x=0,int y=0):x(x),y(y) {}
}q[M];
int n,m,he,tl,dis[N][N];
bool vis[N][N]; char s[N];
int main()
{
  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++)
    {
      scanf("%s",s+1);
      for(int j=1;j<=m;j++)
	if(s[j]=='#')
	  { vis[i][j]=1;q[++tl]=Node(i,j);}
    }
  while(he<tl)
    {
      Node cr=q[++he]; int x=cr.x,y=cr.y,k=dis[x][y];
      if(x>1&&!vis[x-1][y])
	vis[x-1][y]=1,q[++tl]=Node(x-1,y),dis[x-1][y]=k+1;
      if(y>1&&!vis[x][y-1])
	vis[x][y-1]=1,q[++tl]=Node(x,y-1),dis[x][y-1]=k+1;
      if(x<n&&!vis[x+1][y])
	vis[x+1][y]=1,q[++tl]=Node(x+1,y),dis[x+1][y]=k+1;
      if(y<m&&!vis[x][y+1])
	vis[x][y+1]=1,q[++tl]=Node(x,y+1),dis[x][y+1]=k+1;
    }
  printf("%d\n",dis[q[tl].x][q[tl].y]);
  return 0;
}


Measured memory_bytes: 12928
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  ll X,Y,A,B,C;
  cin>>X>>Y>>A>>B>>C;
  vector<ll> p(A),q(B),r(C);
  for (ll i(0);i<A;i++) cin>>p[i];
  for (ll i(0);i<B;i++) cin>>q[i];
  for (ll i(0);i<C;i++) cin>>r[i];
  sort(p.rbegin(),p.rend());
  sort(q.rbegin(),q.rend());
  sort(r.rbegin(),r.rend());
  vector<ll> xy;
  for(ll i(0);i<X;i++){
    xy.push_back(p[i]);
  }
  for(ll i(0);i<Y;i++){
    xy.push_back(q[i]);
  }
  for(int i(0);i<C;i++){
    xy.push_back(r[i]);
  }
  sort(xy.rbegin(),xy.rend());
  ll ans(0);
  for(int i(0);i<X+Y;i++){
    ans += xy[i];
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 8176
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int k, a, b;
    //string s;
    cin >> k;
    cin >> a >> b;
    FOR(i, a, b) {
        if(i%k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3636
'use strict'

function main(s) {

  s = s.split('\n').slice(1, -1);

  const ans = [];

  for (const line of s) {
    ans.push(line);
    ans.push(line);
  }

  console.log(ans.join('\n'));
}

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


Measured memory_bytes: 7372
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val t = LongArray(n){ readLine()!!.toLong() }
    var ans = t[0]
    for(i in 1 until n){
        ans = lcm(t[i], ans)
    }
    println(ans)
}

fun lcm(a: Long, b :Long): Long {
    return (a / gcd(a, b)) * b
}

fun gcd(a: Long, b: Long): Long {
    if (a < b) return gcd(b, a)
    if (b == 0L) return a
    return gcd(b, a % b)
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int H,W;
string S[222];

int dp[2][1<<16];
int pc[1<<16];
signed main(){
    cin.tie(0);ios_base::sync_with_stdio(0);

    for(int i=0;i<1<<16;i++)pc[i]=__builtin_popcount(i);
    cin>>H>>W;
    S[0]="";
    rep(i,H)cin>>S[i+1];

    fill_n(*dp,2*(1<<16),INT_MIN);
    dp[0][0]=0;
    int mask=(1<<W)-1;
    for(int t=0;t<H*W;t++){
            const int i=t/W,j=t%W,p=t&1,q=(t+1)&1;
            const int beet=(1<<(W-1));
            const int ei=(1<<W);
            for(int k=0;k<beet;k++){
                if(dp[p][k]==INT_MIN)continue;
                chmax(dp[q][(k<<1)&mask],dp[p][k]);

                int l=pc[k&((1<<j)-1)];
                if(l<S[i+1].size()){
                    int po=0;
                    if(j&&(k&1)&&S[i+1][l]==S[i+1][l-1])po++;
                    chmax(dp[q][((k<<1)&mask)+1],dp[p][k]+po*2);
                }
                dp[p][k]=INT_MIN;
            }

            for(int k=beet;k<ei;k++){
                if(dp[p][k]==INT_MIN)continue;
                chmax(dp[q][(k<<1)&mask],dp[p][k]);

                int l=pc[k&((1<<j)-1)];
                if(l<S[i+1].size()){
                    int po=0;
                    if(j&&(k&1)&&S[i+1][l]==S[i+1][l-1])po++;
                    if(S[i][S[i].size()-pc[k]+l]==S[i+1][l])po++;
                    chmax(dp[q][((k<<1)&mask)+1],dp[p][k]+po*2);
                }
                dp[p][k]=INT_MIN;
            }

        if(j==W-1)for(int k=0;k<1<<W;k++)if(pc[k]!=S[i+1].size())dp[q][k]=INT_MIN;
    }

    int ans=INT_MIN;
    rep(i,1<<W)chmax(ans,dp[(H*W)&1][i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4720
#include<stdio.h>
int main(void)
{
	char s[10];
	scanf("%s",s);
	
	if(s[0]=='S')
	puts("Cloudy");
	
	else if(s[0]=='C')
	puts("Rainy");
	
	else
	puts("Sunny");
	

	return 0;
}

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

class SegTree():
    def __init__(self, size, segfunc, ide_ele):
        self.size = 2**(size-1).bit_length()
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.tree = [ide_ele]*(self.size*2)
    def update(self, k, a):
        k += self.size
        self.tree[k] = a
        while k > 0:
            k >>= 1
            self.tree[k] = self.segfunc(self.tree[k * 2], self.tree[k * 2 + 1])
    def query(self, l, r):
        l += self.size
        r += self.size
        lres, rres = self.ide_ele, self.ide_ele
        while l<r:
            if(l&1):
                lres = self.segfunc(lres,self.tree[l])
                l+=1
            if(r&1):
                r-=1
                rres = self.segfunc(self.tree[r],rres)
            l >>= 1
            r >>= 1
        res = self.segfunc(lres,rres)
        return res

n, k = map(int, input().split())

seg = SegTree(700000, max, 0)
memo = [0] * 700000

for i in range(n):
    a = int(input())
    v = seg.query(max(a-k,0), a+k+1)
    if memo[a] < v + 1:
        memo[a] = v + 1
        seg.update(a, v + 1)
    
print(max(memo))

Measured memory_bytes: 92404
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#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 all(x) (x).begin(),(x).end()
int main(){
    int n;
    cin>>n;
    map<int,int> ma;
    REP(i,n){
        int a;
        cin>>a;
        ma[a]++;
    }
    int ans=INF;
    FOR(i,-100,101){
        int sum=0;
        for(auto itr:ma){
            sum+=itr.se*pow((double)itr.fi-i,2);
        }
        ans=min(sum,ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256