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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;

ll ccw(pll a, pll b, pll c) {return a.x*b.y+b.x*c.y+c.x*a.y-a.y*b.x-b.y*c.x-c.y*a.x;}
pll operator * (pll a, pll b) {
	if (a.first<b.first) return pll(a.second-b.second,b.first-a.first);
	return pll(b.second-a.second,a.first-b.first);
}
bool operator <= (pll a, pll b) {
	return a.first*b.second<=b.first*a.second;
}
int n, m;
ll ans[300100];
struct CHT {
	vector<pll> vec;
	void init() {vec.clear();}
	void add(pll a) {
		while(vec.size()>=2&&ccw(vec[vec.size()-2],vec.back(),a)>=0) vec.pop_back();
		vec.push_back(a);
	}
	ll f(pll a, ll b) {return a.first*b+a.second;}
	void getvr(ll s, ll e) {
		ll i, j = 0;
		for (i=s;i<=e;i++) {
			while(j+1<vec.size()&&f(vec[j],i)<=f(vec[j+1],i)) j++;
			ans[i] = f(vec[j],i);
		}
	}
	ll getv(ll x) {
		ll s = 0, e = (int)vec.size()-2;
		while(s<=e) {
			ll m = (s+e)>>1;
			if(f(vec[m],x)<=f(vec[m+1],x)) s = m+1;
			else e = m-1;
		}
		return f(vec[s],x);
	}
} cht;
ll L[300100], R[300100], D[300100];
ll P[300100], Q[300100], T[300100], INF = 1LL<<50;

void dnc(int s, int e) {
	if (s==e) {
		D[s] = max(D[s],(s==1?0:L[s-2])+R[s+2]+1-T[s]);
		return;
	}
	int m = (s+e)>>1, i; ll res = -INF;
	cht.init();
    cht.add(pll(-1LL*(e+1),R[e+2]+Q[e+1]+1LL*(e+1)*(e+2)/2));
	for (i=e;i>m;i--) cht.add(pll(-i,R[i+1]+Q[i]+1LL*i*(i+1)/2));
	cht.getvr(s,m);
	for (i=s;i<=m;i++) {
		res = max(res,ans[i]+1LL*i*(i-1)/2-Q[i]+(i==1?0:L[i-2]));
		D[i] = max(D[i],res);
	}
	cht.init();
    cht.add(pll(-1LL*(n+1-s+1),(s==1?0:L[s-2])+P[s-1]+1LL*(n+1-s+1)*(n+2-s+1)/2));
    for (i=s;i<=m;i++) cht.add(pll(-(n+1-i),L[i-1]+P[i]+1LL*(n+1-i)*(n+2-i)/2));
    cht.getvr(n+1-e,n-m); res = -INF;
    for (i=e;i>m;i--) {
		res = max(res,ans[n+1-i]+1LL*(n+1-i)*(n-i)/2-P[i]+R[i+2]);
		D[i] = max(D[i],res);
    }
    dnc(s,m); dnc(m+1,e);
}

int main() {
    int i;
    scanf("%d",&n);
    for (i=1;i<=n;i++) scanf("%lld",&T[i]);
    for (i=1;i<=n;i++) P[i] = P[i-1]+T[i];
    for (i=n;i>=1;i--) Q[i] = Q[i+1]+T[i];
    for (i=1;i<=n;i++) D[i] = -INF;
    cht.init();
    cht.add(pll(-1LL*(n+1),1LL*(n+1)*(n+2)/2));
    for (i=n;i>=1;i--) {
		R[i] = max(cht.getv(i)+1LL*i*(i-1)/2-Q[i],R[i+1]);
		cht.add(pll(-i,R[i+1]+Q[i]+1LL*i*(i+1)/2));
    }
    cht.init();
    cht.add(pll(-1LL*(n+1),1LL*(n+1)*(n+2)/2));
    for (i=1;i<=n;i++) {
		L[i] = max(cht.getv(n+1-i)+1LL*(n+1-i)*(n-i)/2-P[i],L[i-1]);
		cht.add(pll(-(n+1-i),L[i-1]+P[i]+1LL*(n+1-i)*(n+2-i)/2));
    }
    dnc(1,n);
    scanf("%d",&m);
    for (i=0;i<m;i++) {
		int a; ll b;
		scanf("%d%lld",&a,&b);
		printf("%lld\n",max(L[a-1]+R[a+1],D[a]-b+T[a]));
    }

    return 0;
}


Measured memory_bytes: 18944
object Main extends App {

  import scala.io.StdIn._

  val n = readLine.trim.toInt
  val Array(t, a) = readLine.trim.split(' ').map(_.toInt)
  val heights = readLine.trim.split(' ').map(_.toInt)
  println(
    (0 until n).minBy{it ⇒ (t - heights(it) * 0.006 - a).abs} + 1
  )
  implicit class ScopeFunc[T](val value: T) {
    def let[A](func: T ⇒ A): A = func(value)
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}

/*
 */

Measured memory_bytes: 25416
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}

int mod = 1000000007;

class BIT
{
public:
    vector<int> bit;
    int M;

    BIT(int M):
        bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {
        if (!i) return 0;
        return (bit[i] + sum(i-(i&-i))) % mod;
    }

    void add(int i, int x) {
        if (i > M) return;
        bit[i] += x;
        bit[i] %= mod;
        add(i+(i&-i), x);
    }
};

signed main(){

    int N, A, B; cin >> N >> A >> B;
    vec S(N); readv(S);
    BIT X(N + 1), Y(N + 1);
    X.add(1, 1);
    Y.add(1, 1);
    int ix = 0, iy = 0;
    int now = S[0];
    FOR(i, 1, N){
        int tmpx = 0, tmpy = 0;

        int lx = Upper_bound(S, S[i] - A);
        if(ix <= lx) tmpy = X.sum(lx + 1) - X.sum(ix) + mod;
        int ly = Upper_bound(S, S[i] - B);
        if(iy <= ly) tmpx =  Y.sum(ly + 1) - Y.sum(iy) + mod;
        X.add(i + 1, tmpx);
        Y.add(i + 1, tmpy);
        if(S[i] - S[i - 1] < A) iy = i;
        if(S[i] - S[i - 1] < B) ix = i;
    }
    int ans = (X.sum(N) + Y.sum(N) - X.sum(ix) - Y.sum(iy) + 2 * mod) % mod;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 2560
import java.lang.Math
import scala.io.StdIn.{readLine,readInt}
import java.io._
import scala.collection.mutable.ArrayBuffer

object Main {
   def main(args: Array[String]) {
       val br = new BufferedReader(new InputStreamReader(System.in))
       val out = new PrintWriter(new OutputStreamWriter(System.out))
       val in = new StreamTokenizer(br)
       
       def nextInt:Int = {
           in.nextToken()
           in.nval.toInt
       }
       
       val a = nextInt
       val b = nextInt
       val g = 3
       if (a % g == 0 || b % g == 0 || (a+b) % g == 0) {
    		println("Possible");
    	} else {
    		println("Impossible");
    	}
       
       
	
   }
  
}

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

#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;

ll n, q;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    clock_t ck;
    ck = clock();
    cin >> n >> q;
    ll ans = (n-2)*(n-2);
    set<ii> r, c;
    r.insert({n,n}); c.insert({n,n});
    while (q--) {
        int t, x;
        cin >> t >> x;
        if (t == 1) { // masukin column
            auto ls = c.begin();
            if (ls->fi < x) {
                auto it = c.lower_bound({x+1,0});
                // cout << "here col " << (it->se) << '\n';
                ans -= (it->se)-2;
            }
            else {
                ans -= (ls->se)-2;
                r.insert({ls->se,x});
                c.insert({x,ls->se});
            } 
        }
        else { // masukin row
            auto ls = r.begin();
            if (ls->fi < x) {
                auto it = r.lower_bound({x+1,0});
                // cout << "here row " << (it->se) << '\n';
                ans -= (it->se)-2;
            }
            else {
                ans -= (ls->se)-2;
                r.insert({x,ls->se});
                c.insert({ls->se,x});
            }
        }
        // cout << ">> " << ans << '\n';
    }
    cout << ans << '\n';
    ck = clock()-ck;
    cerr << "It took " << 1.0*ck/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 22544
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    int num;
    cin >> num;
    
    vector<int> vec(num);
    for(int i=0; i<num; ++i) cin >> vec.at(i);
    
    int maxi = 1;
    int sum = 0;    
    for(int i=0; i<num; ++i){
        sum += vec.at(i);
        if(maxi<vec.at(i)) maxi=vec.at(i);
        
    }
    
    if(maxi < (sum-maxi)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

vi to[1000005];

int main() {
  int n; cin >> n;
  vector<queue<int>> a(n);
  rep(i,n) rep(j,n-1) {
    int foo; cin >> foo;
    foo--;
    a[i].push(foo);
  }
  set<ii> q;
  auto check = [&](int fi) {
    if (a[fi].size() == 0) return;
    int se = a[fi].front();
    if (a[se].size() == 0) return;
    if (a[se].front() == fi) {
      ii p(fi, se);
      if (p.first > p.second) swap(p.first, p.second);
      q.insert(p);
    } 
  };
  rep(i,n) {
    check(i);
  }
  int day = 0;
  while (q.size()) {
    day++;
    set<ii> next;
    swap(q, next);
    for (auto it=next.begin(); it != next.end(); it++) {
      ii p = *it;
      int fi = p.first, se = p.second;
      a[fi].pop();
      a[se].pop();
      check(fi);
      check(se);
    }
 }
 rep(i,n) {
   if (a[i].size()) {
     cout << -1 << endl; return 0;
   }
 }
  cout << day << endl;
  return 0;

}

Measured memory_bytes: 31388
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define seg_size 262144LL
#define MOD 998244353LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

#define int ll
int a, b, p;
int seg_tree[seg_size * 2];
int seg_find(int now, int n_l, int n_r, int w_l, int w_r) {
    if (w_l <= n_l && n_r <= w_r) return seg_tree[now];
    if (w_r <= n_l || n_r <= w_l) return 0;
    return seg_find(now * 2, n_l, (n_l + n_r) / 2, w_l, w_r)
        + seg_find(now * 2 + 1, (n_l + n_r) / 2, n_r, w_l, w_r);
}
void seg_set(int now) {
    seg_tree[now] = seg_tree[now * 2] + seg_tree[now * 2 + 1];
    if (now > 1)seg_set(now / 2);
}
void solve(){
    while (true) {
        REP(i, seg_size * 2) {
            seg_tree[i] = 0;
        }
        cin >> a >> b >> p;
        if (a == 0) return;
        vector<string> inputs;
        for (int i = a; i <= b; ++i) {
            inputs.push_back(to_string(i));
        }
        sort(ALL(inputs));
        seg_tree[(seg_size)] += 1;
        seg_set(seg_size / 2);
        int ans = 0;
        for (int i = 0; i < inputs.size(); ++i) {
            int hoge = stoll(inputs[i]) - a + 1LL;
            seg_tree[seg_size + hoge] = seg_find(1, 0, seg_size, 0, hoge) % p;
            ans += seg_tree[seg_size + hoge];
            seg_set((seg_size + hoge) / 2);
        }
        cout << ans % p << endl;
    }
}

#undef int
int main() {
    init();
    solve();
}


Measured memory_bytes: 12648
#include <stdio.h>

#define N 200000

int main()
{
  int i, num, maxnum, minnum, array[N];

  scanf("%d", &num);

  for( i=0; i<num; i++){
    scanf("%d", &array[i]);
  }

  maxnum = array[1] - array[0];
  minnum = array[0];
  
  for( i=1; i<num; i++){
    if( maxnum <= ( array[i] - minnum ) ){
      maxnum = array[i] - minnum;
    }

    if( minnum >= array[i] ){
      minnum = array[i];
    }
  }

  printf("%d\n", maxnum);

  return 0;
}

Measured memory_bytes: 1376
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <set>
using namespace std;
int main(){
    int t;
    cin >> t;
    set<int> s;
    s.insert(t);
    int temp = t;
    int now = 1;
    while(1){
        if(temp % 2 == 0) temp /= 2;
        else temp = temp * 3 + 1;
        if(s.count(temp)) break;
        s.insert(temp);
        now++;
    }
    cout << now + 1 << endl;
}

Measured memory_bytes: 3612
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
long long counter;
counter=1;
long long counter1;
counter1=1;
long long N,x;
cin>>N>>x;
counter1=COM(N,2)+COM(x,2);
cout<<counter1<<endl;}



Measured memory_bytes: 12160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //input
        int d = scanner.nextInt();
        int g = scanner.nextInt()/100;
        int[] p = new int[d + 1];
        int[] c = new int[d + 1];
        for (int i = 1; i <= d; i++) {
            p[i] = scanner.nextInt();
            c[i] = scanner.nextInt()/100;
        }

        //dp table
        int[][] dp = new int[d + 1][1001];//dp[i][j]//i問目までをトータルでj問解いたスコア

        for (int i = 1; i <= d; i++) {//10種類の問題
            for (int j = 1; j <= 1000; j++) {//トータルで解くべき問題数
                for (int k = 0; k <= p[i] && k <= j; k++) {//問題数
                    int score = i * k;//スコア計算
                    if (k == p[i]) score += c[i];

                    score += dp[i - 1][j - k];//前の問題達を解いた総合スコア
                    if (score > dp[i][j]) dp[i][j] = score;//max更新
                }
            }
        }

        for (int i = 1; i <= 1000; i++) {
            if (dp[d][i] >= g) {//d問目までをi回で解いたスコア
                System.out.println(i);
                return;
            }
        }
    }
}

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

typedef long long LL;
typedef std::valarray<LL> data;

const int N = 200005, M = 100;

std::string s, t;
LL l, r; int p;

void solve() {
	static int nxt[N], n = s.size();
	for (int i = 1, p = nxt[0] = -1; i <= n; nxt[i++] = ++p)
		while (p >= 0 && s[p] != s[i - 1]) p = nxt[p];
	int p = n; while (p << 1 > n) p = nxt[p];
	n -= p, s.resize(n), t = s.substr(0, n - nxt[n]);
}

LL len[M];
data sum[M];

data count(const std::string &s, int n = 0x3f3f3f3f) {
	data ret(26);
	for (int i = 0; i < n && i < s.size(); ++i) ++ret[s[i] - 'a'];
	return ret;
}

data dfs(int dep, LL n) {
	if (dep <= 1) return count(dep ? s : t, n);
	if (n <= len[dep - 1]) return dfs(dep - 1, n);
	else return sum[dep - 1] + dfs(dep - 2, n - len[dep - 1]);
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> s >> l >> r, solve();
	len[1] = s.size(), len[0] = t.size();
	sum[1] = count(s), sum[0] = count(t);
	for (p = 1; len[p] < 1e18; ++p)
		len[p + 1] = len[p] + len[p - 1], sum[p + 1].resize(26), sum[p + 1] = sum[p] + sum[p - 1];
	data ret = dfs(p, r) - dfs(p, l - 1);
	for (int i = 0; i < 26; ++i) std::cout << ret[i] << ' '; std::cout << '\n';
	return 0;
}

Measured memory_bytes: 1428
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    static int                      N;
    static int                      Q;
    static List<ArrayList<Integer>> adj = new ArrayList<>();
    static boolean[]                visited;
    static long[]                   counter;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = Integer.parseInt(sc.next());
        Q = Integer.parseInt(sc.next());
        visited = new boolean[N];
        counter = new long[N];

        for (int i = 0; i < N; i++) {
            ArrayList<Integer> ab = new ArrayList<>();
            adj.add(ab);
        }

        for (int i = 0; i < N - 1; i++) {
            int a = Integer.parseInt(sc.next()) - 1;
            int b = Integer.parseInt(sc.next()) - 1;

            adj.get(a).add(b);
            adj.get(b).add(a);
        }

        for (int i = 0; i < Q; i++) {
            int p = Integer.parseInt(sc.next()) - 1;
            int x = Integer.parseInt(sc.next());
            counter[p] += x;
        }

        dfs(0, -1);

        StringBuilder sb = new StringBuilder();
        for (long count : counter) {
            sb.append(count).append(" ");
        }

        System.out.println(sb.toString());
    }

    public static void dfs(int at, int prev) {
        visited[at] = true;

        if (prev != -1) {
            counter[at] += counter[prev];
        }

        for (int next : adj.get(at)) {
            if (!visited[next]) {
                dfs(next, at);
            }
        }
    }
}


Measured memory_bytes: 154452
const main = stdin => {
  const N = stdin.trim()
  for (let i = 0; i < N.length; i++) {
    if (N[i] === '7') {
      console.log('Yes')
      return
    }
  }
  console.log('No')
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,c(0);
  char ch;
  bool f1(0),f2(0);
  cin >> n;
  for(int i=0;i<n;++i){
    cin >> ch;
    if(ch == 'A') {
      f1 = true;
      f2 = false;
    }
    else if(ch == 'B') {
      if(f1){
        f2 = true;
        f1 = false;
      }else{
        f2 = false;
      }
    }
    else if(ch == 'C'){
      if(f2){
        c++;
   //     cout << i << ' ';
        f2 = false;
      }
      f1 = false;
    }
    else{
      f1 = false;
      f2 = false;
    }
  }
  cout << c;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		long[][] A = new long[N][2];
		for (int i = 0; i < N; i++) {
			A[i][0] = in.nextInt();
			A[i][1] = in.nextInt();
		}
		Arrays.sort(A, (a, b) -> Long.compare(a[0], b[0]));
		long ans = 0;
		int r = M;
		for (int i = 0; i < A.length; i++) {
			long n = Math.min(r, A[i][1]);
			ans += A[i][0] * n;
			r -= n;
			if (r == 0) {
				break;
			}
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 94984
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

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

int saiki(string str){
	//cout<<str<<endl;
	
	if(str[0]>='0' && str[0]<='2')return str[0]-'0';
	
	if(str[0]=='-'){
		int val = saiki(str.substr(1,str.size()-1));
		return (val-1)*-1+1;
	}
	
	if(str[0]=='('){
		int count = 0;
		rep(i,str.size()){
			if(str[i]=='(')count++;
			if(str[i]==')')count--;
			
			if(count==1 && str[i]=='*'){
				return min(saiki(str.substr(1,i-1)),saiki(str.substr(i+1,str.size()-i-2)));
			}
			if(count==1 && str[i]=='+'){
				return max(saiki(str.substr(1,i-1)),saiki(str.substr(i+1,str.size()-i-2)));
			}
		}
	}
}

int main(){
	B:;
	
	string str;
	cin>>str;
	if(str.size()==1 && str[0]=='.')return 0;
	
	int ans = 0;
	rep(i,3){
		rep(j,3){
			rep(k,3){
				string strcopy = str;
				rep(p,str.size()){
					if(str[p]=='P')str[p]='0'+i;
					if(str[p]=='Q')str[p]='0'+j;
					if(str[p]=='R')str[p]='0'+k;
				}
				int val = saiki(str);
				str = strcopy;
				
				if(val==2)ans++;
			}
		}
	}
	A:;
	
	printf("%d\n",ans);
	
	goto B;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c;cin >>a >> b >> c;
    if(a==b and b!=c)cout << "Yes";
    else if(b==c and a!=c)cout << "Yes";
    else if(a==c and a!=b)cout << "Yes";
    else cout << "No";
    }

Measured memory_bytes: 256
#define P(b,c)(x[b]*x[1+c]-x[1+b]*x[c])
float x[];main(i){for(;~scanf("%f,",x);i-9||memset(x,!puts(P(1,3)*P(3,5)>0&P(5,7)*P(7,1)>0?"YES":"NO",i=1),36))x[i]+=*x,x[++i%8+1]-=*x;}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<tuple>
#include<string>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef tuple<string,int,int> T;

bool myCompare(const T &l,const T &r)
{
    if(get<0>(l)!=get<0>(r)) return get<1>(l) > get<1>(r);
    return get<0>(l) > get<0>(r);
}

int main()
{
    int n;
    cin>>n;
    vector<T> a;
    rep(i,n)
    {
        string str;
        int y;
        cin>>str>>y;
        a.emplace_back(str,-y,i+1);
    }
    sort(a.begin(),a.end());

    rep(i,n)
    {
        cout<<(get<2>(a[i]))<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int r,g,b;
    scanf("%d%d%d",&r,&g,&b);
    if((r*100+g*10+b)%4==0)
        printf("YES\n");
    else
    {
        printf("NO\n");
    }
    return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
   int n;
   int main()
   {
   long long int a[30];
   while(~scanf("%d",&n))
      {
      for(int i=0;i<n;i++)
	     {
	     scanf("%lld",&a[i]);	
	     }
      int sum=0;
	  for(int i=1;i<n-1;i++)
	     {
	     if((a[i-1]>a[i]&&a[i]>a[i+1])||(a[i-1]<a[i]&&a[i]<a[i+1]))
		    {
		    sum++;
		    }	
	     }
	  printf("%d\n",sum); 	
      }	
   return 0;   
   } 
//

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

enum{
	A_in_B = -2,
	A_not_touch_B = 0,
	A_CROSS_B,
	B_in_A
};

int detectA_B(double *fs);
	

int main(void){
	int n;
	double fs[6];
	scanf("%d",&n);
	while(n--){
		scanf("%lf %lf %lf %lf %lf %lf", &fs[0], &fs[1], &fs[2], &fs[3], &fs[4], &fs[5]);
		printf("%d\n",detectA_B(fs));
	}
	return 0;
}

int detectA_B(double *fs){
	double xa = fs[0], ya = fs[1], ra = fs[2], xb = fs[3], yb = fs[4], rb = fs[5];
	double d =  sqrt( (xa - xb)*(xa - xb) + (ya-yb)*(ya-yb) );
	if( d > ra + rb) return A_not_touch_B;
	if( ra > d + rb) return B_in_A;
	if( rb > d + ra) return A_in_B;
	return A_CROSS_B;
}

Measured memory_bytes: 640
let f i = match i with
  (a, b, c) -> a + b + c

let char_to_int c1 c2 c3 = (int_of_string (String.make 1 c1),
                            int_of_string (String.make 1 c2),
                            int_of_string (String.make 1 c3))
let input = Scanf.bscanf Scanf.Scanning.stdin "%c%c%c" char_to_int

let () = print_int (f input)


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

#define ll long long
#define vec vector<ll>
#define sortv(a); sort(a.begin(), a.end());
#define rev(a); reverse(a.begin(), a.end());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)

ll MOD = 1000000007;
ll INF = 1LL << 60;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int l;cin>>l;
	double len = (double)l/3;
	cout<<fixed<<setprecision(12)<<(len*len*len);

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>
#include<atcoder/segtree>




using namespace std;
using namespace atcoder;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 998244353;


void solve() {
    int k;
    cin >> k;
    for (int i = 0; i < k; ++i) {
        cout << "ACL";
    }
    cout << endl;
}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 3640
n, k = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(k)]
mod = 998244353

dp = [0] * n
dp[0] = 1
acc = 0

for i in range(1, n):
    # 例4のi=13, lr=[[5, 8], [1, 3], [10, 15]]の場合を想像すると書きやすい
    for li, ri in lr:
        if i - li >= 0:
            acc += dp[i - li]
            acc %= mod
        if i - ri - 1 >= 0:
            acc -= dp[i - ri - 1]
            acc %= mod
    dp[i] = acc
print(dp[-1])

Measured memory_bytes: 16816
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
B = [i+a for i, a in enumerate(A)]
C = [j-a for j, a in enumerate(A)]

bc = Counter(B)
cc = Counter(C)

ans = 0
for k, v in bc.items():
    ans += v*cc[k]
print(ans)


Measured memory_bytes: 63660
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)

long long tmpmax(vector<long long>s, int n){
  long long tmpmax = -1e9;
  rep(i,n){
    tmpmax = max(tmpmax, s.at(i));
  }
  return tmpmax;
}

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> P(N), C(N);
  rep(i,N){
    cin >> P.at(i);
  }
  rep(i,N){
    cin >> C.at(i);
  }
  long long ans = -1e9;
  rep(i,N){
    vector<long long> s(N);
    long long score = 0;
    int oldi = i, x = N;
    rep(j,N){
      int newi = P.at(oldi) - 1;
      score += C.at(newi);
      s.at(j) = score;
      oldi = newi;
      if(newi==i){
        x = min(x, j+1);
        break;
      }
    }
    if(score>0){
      ans = max(ans, score*(K/x)+tmpmax(s, K%x));
      ans = max(ans, score*(K/x-1)+tmpmax(s, x));
    }else{
      ans = max(ans, tmpmax(s, x));
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3712
import sys
from itertools import product

def main():
    input = sys.stdin.readline
    N = int(input())
    F = []
    for _ in range(N):
        A = list(map(int, input().split()))
        F.append(A)

    P = []
    for _ in range(N):
        A = list(map(int, input().split()))
        P.append(A)

    ans = -10**9
    l = [0, 1]
    shop = list(product(l, repeat=10))
    for s in shop:
        if sum(s) == 0:
            continue

        cur = 0
        for i in range(N):
            f = F[i]
            n = sum([f[j] * s[j] for j in range(10)])
            cur += P[i][n]

        ans = max(ans, cur)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef vector<ii> vii;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////
int main()
{
    int a, b;
    cin >> a >> b;
    if (a > b)
    {
        a = a + b;
        b = a- b;
        a = a- b;
    }
    for (int i = 0; i < b; i++)
    {
        cout << a;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define reg register
using namespace std;
string s;
int n, k;
string intToA(int n,int radix)    //n是待转数字，radix是指定的进制
{
	string ans="";
	do{
		int t=n%radix;
		if(t>=0&&t<=9)	ans+=t+'0';
		else ans+=t-10+'a';
		n/=radix;
	}while(n!=0);	//使用do{}while（）以防止输入为0的情况
	reverse(ans.begin(),ans.end());
	return ans;	
}
int main() {
//  scanf("%s%d", s, &k);
//  char *ss;
//  int ans = strtol(s, &ss, k);
//  int ret = strlen(s);
//  printf("%d %d\n", ret, ans);
	cin >> n >> k;
//	_itoa(n, s, k);
//	char *ss;
//	int ans = strtol(s, &ss, k);
	string ss = intToA(n, k);
	int len = ss.length();
	cout << len << endl;
//	printf("%d\n", strlen(s));
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char line[100];
  int a, b, c;
  int tmp;
  fgets(line, sizeof(line), stdin);
  sscanf(line, "%d %d %d", &a, &b, &c);
  if(a>b){
	tmp=a;
	a=b;
	b=tmp;
  }
  if(a>c){
	tmp=a;
	a=c;
	c=b;
	b=tmp;
  }
  if(b>c){
	tmp=b;
	b=c;
	c=tmp;
  }
  printf("%d %d %d\n", a, b, c);
  return 0;
}



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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

int main()
{
  fastio;
  char c; cin >> c;
  int x = c - 'A';
  if (0 <= x && x <= 25) cout << 'A';
  else cout << 'a';
  return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) x-'0'
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

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

int main()
{
    weewoo;
    ll n,h;
    cin >> h >> n;
    vector<ll>a(h+5,1e9);
    a[0]=0;
    for(int i=0;i<n;i++){
        ll x,y;
        cin >> x >> y;
        for(int j=0;j<=h;j++){
            if(j<=x){
                a[j] = min(a[j],y);
            }
            else{
                a[j] = min(a[j-x]+y,a[j]);
            }
        }
        for(int j=0;j<h-1;j++){
            a[j]=min(a[j],a[j+1]);
        }
    }
    cout << a[h] << endl;
    return 0;
}


Measured memory_bytes: 384
N = int(input())
t_li = list(map(int, input().split()))
buf = t_li[:]
M = int(input())
drink = [list(map(int, input().split())) for i in range(M)]
for i in range(M) :
    buf[drink[i][0] - 1] = drink[i][1]
    print(sum(buf))
    buf = t_li[:]


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

int main() {
	string s;
	cin >> s;
	int N = (int)s.size();
	// 全部自分がグーを出したとき, 相手のパーの個数をPと置くと-P点に
	// 相手がグーのとき自分がパーだしたら+1点
	// 相手がパーのとき自分がパーだしたら+1点
	// どっちみちパーを出した回数だけ点数は上がる
	int P = 0;
	for(int i=0;i<N;i++) if(s[i] == 'p') P++;
	cout << N / 2 - P << endl;
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		long h = fs.nextLong();
		int cnt = 0;
		while(h>0) {
			h/=2;
			cnt++;
		}
		long ans = 0;
		long now = 1;
		for(int i=0;i<cnt;i++) {
			ans += now;
			now *= 2;
		}
		System.out.println(ans);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

const ll M = 1000000007;
const ll Max_n=1000001;

vector<ll> fac(Max_n);
vector<ll> ifac(Max_n);

ll mpow(ll x, ll n){ 
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll mcomb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main(){
    ll ans=0,x,y,n,m;
    cin >> x >> y;
    if((x+y)%3!=0){
    	cout << ans << endl;
    	return 0;
    }
    n=(2*x-y)/3;
    m=x-2*n;
    if(n<0 || m<0){
    	cout << ans << endl;
    	return 0;	
    }	
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<1000001; i++){
     	fac[i+1] = fac[i]*(i+1) % M;
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M;
    }
    ans = mcomb(n+m, m)%M;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;
//#define int long long
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>vec[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00 % jousu(10, y00)) / jousu(10, y00 - 1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}



int main() {
	int a;
	string s;
	cin >> a >> s;
	if (a < 3200)cout << "red" << endl;
	else cout << s << endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 10000000;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int, PP> PPP;
struct edge { int to; int to2; int cost; };

int used[2000];

signed main() {
	rep(i, 3) {
		int a, b; cin >> a >> b;
		used[a - 1]++; used[b - 1]++;
	}
	int cnt = 0;
	rep(i, 4)if (used[i] & 1)cnt++;
	if (cnt > 2)puts("NO");
	else puts("YES");
	}

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

using namespace std;

int main(){
   int n, b, f, r, v;
   int a[10] = { 0 };
   cin >> n;
   int college[4][3][10] = { 0 };
   for (int i = 1; i <= n; i++){
       cin >> b >> f >> r >> v;
       college[b - 1][f - 1][r - 1] += v;
   }
   for (int j = 0; j < 4; j++){
       for (int k = 0; k < 3; k++){
           for (int l = 0; l < 10; l++){
               if (college[j][k][l]>0||college[j][k][l]<0){
                   cout << " " <<0 + college[j][k][l];
               }
               else{
                   cout << " " << 0;
               }
           }
           cout << endl;
       }
       if (j < 3){
           cout << "####################" << endl;
       }
   }
   return 0;
   }


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,ans1,ans2;
    cin >> n >> m;
    ans1=m;
    ans2=n;
    for(int i=1;i<n;++i){
        ans1=ans1*10;
        ans1=ans1+m;
    }
    for(int i=1;i<m;++i){
        ans2=ans2*10;
        ans2=ans2+n;
    }
    if(ans1>=ans2){
        cout << ans1;
    }
    else{
        cout << ans2;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    rep(i, w + 2) cout << '#';
    cout << endl;
    rep(i, h) cout << '#' << s[i] << '#' << endl;
    rep(i, w + 2) cout << '#';
    cout << endl;
}

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

int main() {
  int r, D, x;
  cin >> r >> D >> x;
  int ans[11];
  ans[0] = x;
  for (int i = 1; i < 11; i++) {
    ans[i] = r * ans[i - 1] - D;
    cout << ans[i] << endl;
  }
};


Measured memory_bytes: 256
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let n: usize = read_line().trim().parse().unwrap();

    let mut ans: Vec<(usize,usize)> = Vec::new();

    if n %2 == 0 {
        for i in 0..n {
            for j in i+1..n {
                if i + j != n - 1 {
                    ans.push((i,j));
                }
            }
        }
    } else {
        for i in 0..n-1 {
            for j in i+1..n-1 {
                if i+j != n - 2 {
                    ans.push((i, j));
                }
            }
            ans.push((i, n-1));
        }
    }

    println!("{}", ans.len());
    for &(a, b) in ans.iter() {
        println!("{} {}", a+1, b+1);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

	int n;
	cin >> n;
	cout << n * n * n << endl;
	return 0;
}


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

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

    int N, K;
    cin >> N >> K;

    int ans = 0;

    for(int i = 0; i < N; i++) {
        int x;
        cin >> x;
        ans += min(x, abs(K - x)) * 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: i32,
        b: i32,
        t: i32,
    }
    println!("{}", t / a * b);
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	REP(i, 3500)REP(j, 3500){
		ll h = i+1;
		ll n = j+1;
		ll x = N*h*n;
		ll y = 4*h*n - N*n - N*h;
		if(y<=0||x<y||x<=0) continue;
		if(x%y==0){
			printf("%d %d %d\n", h, n, x/y);
			return 0;
		}
	}
    return 0;
}

Measured memory_bytes: 256
//C
//#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>


#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#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 <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Hang in there!

using namespace std;


int main() {
	string S;
	cin >> S;
	if (S.substr(0, 4) < "2019") {
		cout << "Heisei" << endl;
	}
	else if (S.substr(0, 4) > "2019") {
		cout << "TBD" << endl;
	}
	else {//2019
		if (S.substr(5, 2) < "05") {
			cout << "Heisei" << endl;
		}
		else {
			cout << "TBD" << endl;
		}
	}
}

	



Measured memory_bytes: 256
#define f(a) for(a=0;a++<n;)
d,a[101][101],b[101][101],u,v,c,t;main(n){n=atoi(gets(a));f(u)f(v)b[u][v]=1e8;for(;~scanf("%d%d%d",&u,&v,&c);a[u][v]=b[u][v]=b[v][u]=c);f(c)f(u)f(v)(t=b[u][c]+b[c][v])<b[u][v]?b[u][v]=t:0;f(u)f(v)d+=a[u][v]>b[u][v];printf("%d",d);}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<long long> h(n);
    long long maxh=0;
    for(int i=0;i<n;i++){
        cin >> h.at(i);
        maxh+=h.at(i);
    }
    sort(h.begin(),h.end(),std::greater<long long>());
    long long count=0;
    if(k<n){
        long long hidam=0;
        for(int i=0;i<k;i++){
            hidam+=h.at(i);
        }
        count = maxh-hidam;
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];
ll B[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N + 1) {
        cin >> A[i];
    }
    REP(i, N) {
        cin >> B[i];
    }

    ll s = 0;
    REP(i, N) {
        ll b = std::min(A[i], B[i]);
        B[i] -= b;
        s += b;
        A[i] -= b;
        ll b1 = std::min(A[i + 1], B[i]);
        s += b1;
        A[i + 1] -= b1;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <set>
#include <iterator>

using namespace std;

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

  // get substrings
  set<string> substrs;
  for(int i = 0; i < s.size(); ++i){
    for(int j = 1; j <= k; ++j){
      substrs.insert(s.substr(i, j));
    }
  }
  
  auto itr = substrs.begin();
  advance(itr, k-1);
  cout << *itr << endl;
}

Measured memory_bytes: 1664