akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std ;
#define maxi 500000+10
#define lm 1000000+10
pair<int , pair<int , int>>  pr[maxi] ;
int tree[maxi] ;
int p[lm] ;
int ans[maxi] ;
void update(int idx, int val)
{
while(idx < maxi)
{
tree[idx] += val;
idx += (idx & -idx);
}
}

int read(int idx)
{
int sum = 0;
while(idx > 0)
{
sum += tree[idx];
idx -= (idx & -idx);
}
return sum;
}

int main()
{
   int n ;
   scanf("%d" , &n) ;
   int q ;
   cin>>q ;
   int a[n+1] ;
   for(int i=1 ; i<=n ; i++)
   scanf("%d", &a[i]) ;
   
   int x =1;

   for(int i=1 ; i<=q ; i++)
   {
       scanf("%d %d" , &pr[i].second.first , &pr[i].first) ;
       pr[i].second.second = i ;
   }
   sort(pr+1 , pr+q+1)  ;
   memset(tree , 0 , sizeof(tree)) ;
   memset(p , -1 , sizeof(p)) ;
   for(int i=1 ; i<=n ; i++)
   {
       if(p[a[i]]!= -1)
       update(p[a[i]] , -1)  ;
       p[a[i]] = i ;
       update(i , 1) ;


   while(x<=q && pr[x].first == i)
   {
       ans[pr[x].second.second] = read(pr[x].first) - read(pr[x].second.first-1);

       x++;

   }
   }
   for(int i=1 ;i<=q ; i++)
   printf("%d\n", ans[i]) ;




}

Measured memory_bytes: 19408
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

class Main{
    public static void main(String[] args){

        Scanner scan = new Scanner(System.in);
        int N,count = 0,color;
        String S;
        S = scan.next();
        N = String.valueOf(S).length();
        color = Integer.parseInt(S.substring(0,1));

        for(int i= 1;i < N; i++){
            if(Integer.parseInt(S.substring(i,i+1)) == color){
                count++;
            }
            if(color == 0){
                color = 1;
            }else{
                color = 0;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 32240
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  long int n;
  vector<int> s(1000);
  int len;
  cin>>n;

  vector<long int> a(40);
  a.at(0)=1;
  for(int i=1;i<40;i++)
  {
    a.at(i)=(-2)*a.at(i-1);
  }

  for(int i=0;i<40;i++)
  {
    if(n%abs(a.at(i+1))==0) s.at(i)=0;
    else {
      s.at(i)=1;
      n-=a.at(i);
    }

    if(n==0)
    {
      len=i+1;
      break;
    }
  }

  for(int i=1;i<=len;i++)
  {
    cout<<s.at(len-i);
  }
    cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<utility>
using namespace std;

int main(){
    int n;cin >> n;
    int d[n];
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N;
    cin>>N;
    double ans=0;
    for(int i=0;i<N;i++){
        double x;
        cin>>x;
        string u;
        cin>>u;
        if(u=="JPY")ans+=x;
        else ans+=x*380000;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let list = input
        .split_whitespace()
        .skip(1)
        .map(|x| x.parse::<i32>().unwrap())
        .fold((0, 0, 0), |(a, b, c), x| {
            if x % 4 == 0 {
                (a + 1, b, c)
            } else if x % 2 == 0 {
                (a, b + 1, c)
            } else {
                (a, b, c + 1)
            }
        });
    let (a, b) = (list.0, list.2 + if list.1 % 2 == 0 { 0 } else { 1 });
    if a >= b - 1 { "Yes" } else { "No" }.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!(super::run($input.to_string()), $output.to_string());
                }
            )*
        }
    }
}

tests! {
    test1: "3
1 10 100" => "Yes",
    test2: "4
1 2 3 4" => "No",
    test3:"3
1 4 1"=>"Yes",
    test4:"2
1 1"=>"No",
test5:"6
2 7 1 8 2 8"=>"Yes",
}


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

int main() {
	int n, A; cin >> n >> A;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] -= A;
	}
	int now = 0;
	const int M = 25*102;
	long long dp[2][M*2] = {0};
	dp[0][M] = 1;
	int lsum = 0, rsum = 0;
	for (int i = 0; i < n; i++) {
		now ^= 1;
		memcpy(dp[now], dp[!now], sizeof dp[now]);
		for (int j = lsum; j <= rsum; j++) {
			if (dp[!now][j + M]) {
				dp[now][j + a[i] + M] += dp[!now][j + M];
			}
		}
		if (a[i] >= 0) {
			rsum += a[i];
		} else {
			lsum += a[i];
		}
	}
	cout << dp[now][M] - 1 << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner s = new Scanner(System.in);
        int a, b, c;
        a = s.nextInt();
        b = s.nextInt();
        c = s.nextInt();

        if (b - a == c - b) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


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

int main(){
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for(int i=0; i<M; i++) cin >> B[i];

    int ans = 0;
    for(int i=0; i<N; i++){
        int sum = C;
        for(int j=0; j<M; j++){
            int a;  cin >> a;
            sum += B[j]*a;
        }
        if(sum>0) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

int main(){
	int mod = 0;
	string s;
	cin >> s;
	int lim = s.size();
	int m = 0;
	for (int i = 0; i < lim; i++)
	{
		m += s[i] - '0';
		m %= 9;
	}
	cout << (m % 9 == 0 ? "Yes": "No") << endl;
}

Measured memory_bytes: 3720
import sys

n = int(sys.stdin.readline().rstrip("\n"))
count = 0
for num in range(27, n+1, 2):
    divisor = 1
    for p in range(1, num, 2):
        if num % p == 0:
            divisor += 1
    if divisor == 8:
        count += 1
print(count)


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

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

using ll = long long;

int main(){
  int k;
  cin>>k;
  if(k <= 9){
    cout << k << endl;
    return 0;
  }
  set<ll> S;
  REP(i,9)S.insert(i+1);
  k -= 9;
  while(true){
    set<ll> T;
    for(ll x : S){
      int d = x % 10;
      for(int c = max(0,d-1); c <= min(9,d+1); c++){
        ll nx = 10ll * x + c;
        k--;
        if(k==0){
          cout << nx << endl;
          return 0;
        }
        T.insert(nx);
      }
    }
    S.swap(T);
  }
  return 0;
}



Measured memory_bytes: 3840
#include<cstdio>
using namespace std;
typedef long long ll;
ll MAX, K, base, cnt;
int main(){
  	scanf("%lld", &K);
    if(!(K & 1)){
        puts("-1");
        return 0;
    }
  	bool mk = 0;
  	while(cnt <= K){
        ++ cnt;
    	base = base * 10 + 7;
        //printf("%lld\n", base);
        base %= K;
        if(!base){
            printf("%lld", cnt);
            mk = 1; break;
        }
    }
    if(!mk) 
        puts("-1");
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
int p[MAXN], pp[MAXN];
int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &p[i]);
        p[i] += 1;
        if(i > 0 && p[i] > p[i - 1]) pp[i - 1] = 1;
    }
    for(int i = 1; i <= n; i++) {
        pp[i] += pp[i - 1];
    }
    int real_neut = 0;
    bool ex_neut = false;
    for(int i = 1; i + k - 1 <= n; i++) {
        bool neutral = (pp[i + k - 2] - pp[i - 1]) == (k - 1);
        if(neutral && !ex_neut) real_neut += 1;
        ex_neut = neutral; 
    }
    set<int> inside;
    int same = 0;
    for(int i = 1; i <= k; i++) {
        inside.insert(p[i]);
    }
    for(int i = 2; i + k - 1 <= n; i++) {
        if(p[i - 1] == *inside.begin() && p[i + k - 1] > *inside.rbegin()) same += 1;
        inside.erase(p[i - 1]);
        inside.insert(p[i + k - 1]);
    }
    real_neut = max(real_neut - 1, 0);
    printf("%d\n", n - k + 1 - same - real_neut);
    return 0;
}

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


using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  srand((unsigned)time(NULL));
  int d;
  int res = 0;
  cin >> d;
  vector<int> c(26);
  rep(i,26)cin >> c[i];
  vector<vector<int>> v(d,vector<int>(26));
  vector<int> contest(d,0);
  vector<int> last(26,0);
  vector<int> satisfy(26,0);
  rep(i,d)rep(j,26){
    int x;cin >> x;
    v[i][j] = x;
  }
  {
    int j = d;
    for(int i = 0;j;i++){
      contest[d-j] = (i%26);
      j--;
    }
  }
  for(int i = 1;i <= d;i++){
    //rep(j,26)if(v[i-1][contest[i-1]] < v[i-1][j])contest[i-1] = j;
    last[contest[i-1]] = i;
    res += v[i-1][contest[i-1]];
    rep(j,26)res -= c[j]*(i-last[j]),satisfy[j] += c[j]*(i-last[j]);
  }
  while(1.0*clock()/CLOCKS_PER_SEC <= 1.7){
    //int now_time = clock();
    //if(1.0*now_time/CLOCKS_PER_SEC > 1.7)break;
    int day = rand()%d,pos = rand()%26;
    vector<int> new_contest = contest;
    int res_ = res;
    int pre = new_contest[day];
    res_ += satisfy[pos];
    res_ += satisfy[pre];
    res_ -= v[day][pre];
    res_ += v[day][pos];
    int pos_satisfy = 0,pre_satisfy = 0;
    last[pos] = last[pre] = 0;
    new_contest[day] = pos;
    for(int i = 1;i <= d;i++)last[pos] = (new_contest[i-1] == pos ? last[pos] = i : last[pos]),pos_satisfy += c[pos]*(i-last[pos]);
    for(int i = 1;i <= d;i++)last[pre] = (new_contest[i-1] == pre ? last[pre] = i : last[pre]),pre_satisfy += c[pre]*(i-last[pre]);
    res_ -= (pos_satisfy+pre_satisfy);
    if(res < res_){
      res = res_;
      contest = new_contest;
      satisfy[pre] = pre_satisfy;
      satisfy[pos] = pos_satisfy;
    }
  }
  rep(i,d)cout << contest[i]+1 << endl;
  


  return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int ctoi (const char c){
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}

int main() {
    string N;
    cin >> N;
    ll ans = 0;
    REP(k,N.length()){
        ll num = ctoi(N[k]);
        ans += num;
    }
    if (ans % 9 == 0) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 3752
module.exports=function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=0)}([function(r,e,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(r,e,t){"use strict";function n(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=[],n=!0,o=!1,u=void 0;try{for(var i,f=r[Symbol.iterator]();!(n=(i=f.next()).done)&&(t.push(i.value),!e||t.length!==e);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return t}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){for(var e=n(r[0].split(" ").map(function(r){return Number(r)}),2),t=e[0],o=e[1],u=r[1].split(" ").map(function(r){return Number(r)}),i=0,f=0;f<t;f++)u[f]>o&&(i+=u[f]-o,u[f]=o);for(var l=0;l<t-1;l++)if(u[l]+u[l+1]>o){var a=u[l]+u[l+1]-o;a<=u[l+1]?(u[l+1]-=a,i+=a):(u[l+1]=0,i+=a)}console.log(i)}},function(r,e){r.exports=require("fs")}]);

Measured memory_bytes: 29592
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;





// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

ll gcd(ll a, ll b)
{
    if (a == 0)
        return (ll)b;
    return gcd(b % a, a);
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    
    rep(i,n) cin >> a[i];
    int now = 1;
    bool found = false;
    rep(i,n){
        if (a[i]==now){
            now++;
            found = true;
        }
    }
    if (found) cout << n-now+1;
    else cout << -1;
    rn 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
using namespace std;

const ll inf = 1e17;
const ll N = 1e6+10;
const ll bits = 62;
const ll mod = 1e9+7;

int main(){

   string s;

   cin>>s;

   for(int i=0;i<s.size();i++){
      if(i%2){
         if(s[i]=='R'){
            cout<<"No\n";
            return 0;
         }
      }else{
         if(s[i]=='L'){
            cout<<"No\n";
            return 0;
         }
      }
   }

   cout<<"Yes\n";
   return 0;
   
}

Measured memory_bytes: 256
x = int(input())
if x < 105:
	if x == 100 or x == 101 or x == 102 or x == 103 or x == 104:
		print(1)
	else:
		print(0)
	exit(0)

dp = [False]*(x+1)
dp[0] = True
dp[100] = True
dp[101] = True
dp[102] = True
dp[103] = True
dp[104] = True
dp[105] = True
for i in range(106,x+1):
	dp[i] =  dp[i-100] or dp[i-101] or dp[i-102] or dp[i-103] or dp[i-104] or dp[i-105]
if dp[x]:
	print(1)
else:
	print(0)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(a, n) rep(hoge, n) printf("%d%c", a[hoge], hoge == n - 1? '\n' : ' ');
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ln(a) cout << (a) << endl
#define INF 1000000000

using namespace std;
using ll = long long;
using P = pair<int, int>;

struct segtree {
    int n;
    int* dat;

    segtree(int _n) {
        n = 1;
        while(n < _n) n *= 2;
        dat = new int[n * 2 - 1];
        fill(dat, dat + n * 2 - 1, INT_MAX);
    }

    void update(int i, int x) {
        i += n - 1;
        dat[i] = x;
        while(i > 0) {
            i = (i - 1) / 2;
            dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }

    int find(int s, int t, int i, int l, int r) {
        if(t <= l || r <= s) return INT_MAX;
        if(s <= l && r <= t) return dat[i];
        int lv = find(s, t, i * 2 + 1, l, (l + r) / 2);
        int rv = find(s, t, i * 2 + 2, (l + r) / 2, r);
        return min(lv, rv);
    }
};

signed main() {
    ll a, b, k;
    cin >> a >> b >> k;
    if(k <= a) a -= k;
    else if(k <= a + b) {
        b -= k - a;
        a = 0;
    }else {
        a = 0;
        b = 0;
    }
    printf("%lld %lld\n", a, b);
}


Measured memory_bytes: 256
#include <iostream>

#include <stdio.h>
using namespace std;

int paitition(int A[],int p,int r)
{
    int x = A[r];
    int i = p-1,j,temp;
    for(j = p;j < r;j++){
        if(A[j]<=x){
            i++;
            temp = A[j];
            A[j] = A[i];
            A[i] = temp;
        }
    }
    temp = A[i+1];
    A[i+1] = A[r];
    A[r] = temp;
    return i+1;
}
int main()
{
    int n,A[100000],i;
    cin >> n;
    for( i = 0;i < n;i++){
        cin >> A[i];
    }
    int m = paitition(A,0,n-1);
    for( i = 0;i < n;i++)
    {
        if(i)cout << " ";
        if(i!=m){
             cout << A[i];
        }
        else{
            cout <<"["<<A[i]<<"]";
        }

    }
    cout << endl;
}



Measured memory_bytes: 3468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const  ll INF = 1e18;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define repb(bit,n,init) for(ll bit=init;bit<(1<<n);++bit)

int main()
{
    ll n;
    cin >> n;
    vector<ll> A(n);
    repd(i,n-1,0){
        cin >> A[i];
    }
    repi(i,n,0){
        cout << A.at(i) << ((i+1)%n == 0?"\n":" ");
    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
int to_int(string s){
	int k=1,res=0;
	for(int i=s.size()-1;i>=0;i--){
		if('0'<=s[i]&&s[i]<='9'){
			res+=k*(s[i]-'0');
		}else{
			res+=k*(s[i]-'a'+10);
		}
		k*=16;
	}
	return res;
}

int main(){
	string ans[2][2][2];
	ans[0][0][0]="black";
	ans[0][0][1]="blue";
	ans[0][1][0]="lime";
	ans[0][1][1]="aqua";
	ans[1][0][0]="red";
	ans[1][0][1]="fuchsia";
	ans[1][1][0]="yellow";
	ans[1][1][1]="white";
	string s;
	while(cin>>s&&s[0]!='0'){
		int a,b,c,dat[3];
		for(int i=1;i<6;i+=2){
			string tmp;int ans[3];
			tmp.assign(s,i,2);
			int d=to_int(tmp);
			if(d<=(to_int("ff")-d))dat[i/2]=0;
			else dat[i/2]=1;
		}
		cout<<ans[dat[0]][dat[1]][dat[2]]<<endl;
	}
}

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


int a[12][12];
const int INF = 1001001001;

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);

    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }
    
    //全探索するしかないらしい
    //ビット全探索 1<<nは2^n
    int ans=INF;
    rep(s, 1<<n){
        int cost=0;
        vector<int> d(m); //理解度
        rep(i,n){
            //sをi回右シフトするとsのiビット目が1の位にくる
            //&1とすることでsのiビット目が立っている時だけ実行できる
            if(s>>i & 1){
                cost += c[i];
                rep(j,m) d[j] += a[i][j];
            }
            bool ok = true;
            rep(j,m) if(d[j] < x) ok = false;
            if(ok) ans = min(ans, cost);
        }

    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;

}

Measured memory_bytes: 3608
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
S = input()
T = input()
Slis = sorted(list(S))
Tlis = sorted(list(T))[::-1]
SS = "".join(Slis)
TT = "".join(Tlis)
ans = "No"
if SS<TT:
    ans = "Yes"

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
double distance(vector<double>A,vector<double>B){
  if(A.size()==B.size()){
    double sum=0;
    for(int i=0;i<A.size();i++){
      sum=sum+(A.at(i)-B.at(i))*(A.at(i)-B.at(i));
    }
    return sqrt(sum);
  }
  else{
    return 0;
  }
}

bool is_integer_modf( double x ){
  double r;
  return 0==std::modf(x, &r);
}
      
int main(){
  int N,D;
  cin>>N>>D;
  vector<vector<double>>X(N,vector<double>(D));
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin>>X.at(i).at(j);
    }
  }
  int count=0;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      if(is_integer_modf(distance(X.at(i),X.at(j)))){
        count=count+1;
      }
    }
  }
  cout<<count<<endl;
}
  
  


Measured memory_bytes: 256
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
from fractions import gcd

NN = 202020
MOD = 10**9+7
INF = float("inf")

n = int(input())
A = list(map(int, input().split()))

init_pos = 0
psum = 0
for i in range(n):
    psum += A[i]
    if i%2 == 0 and psum <= 0:
        init_pos += 1-psum
        psum = 1
    elif i%2 == 1 and psum >= 0:
        init_pos += psum + 1
        psum = -1

init_neg = 0
psum = 0
for i in range(n):
    psum += A[i]
    if i%2 == 1 and psum <= 0:
        init_neg += 1-psum
        psum = 1
    elif i%2 == 0 and psum >= 0:
        init_neg += psum + 1
        psum = -1

print(min(init_pos, init_neg))


Measured memory_bytes: 88940
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		int n, a, b, c, x;
		while (true) {
			n = sc.nextInt(); a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt(); x = sc.nextInt();
			if (n == 0) break;
			int[] y = new int[n];
			for (int i = 0; i < n; i++)
				y[i] = sc.nextInt();
			int ans = 0, index = 0;
			while (ans <= 10001) {
				if (y[index] == x) {
					if (index == n-1) break;
					index++;
				}
				ans++;
				x = (a*x+b)%c;
			}
			if (ans <= 10000)
				out.println(ans);
			else
				out.println(-1);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

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

int main(){
  map<string, int> mp {
    {"SUN", 0},
    {"MON", 1},
    {"TUE", 2},
    {"WED", 3},
    {"THU", 4},
    {"FRI", 5},
    {"SAT", 6}
  };
  string s;
  cin >> s;
  cout << 7 - mp[s] << endl;
  return 0;
}


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

int main() {
  string s;
  string res;
  cin >> s;
  if (s[0] == s[1] or s[1] == s[2] or s[2] == s[3]) {
    res = "Bad";
  } else {
    res = "Good";
  }
  
  cout << res << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cmath>
#include <iostream>

using namespace std;

int main(){
  double a,b,c,d,e,f;
  vector<double> out;
  while (cin>>a>>b>>c>>d>>e>>f){
    out.push_back((c*e-b*f)/(a*e-b*d));
    out.push_back((c*d-a*f)/(b*d-a*e));
  }
  for (int i=0;i<out.size();i+=2){
    if (out[i]==0) out[i]=0;
    if (out[i+1]==0) out[i+1]=0;
    printf("%.3f %.3f\n",round(out[i]*1000)/1000.0,round(out[i+1]*1000)/1000.0);
  }
  return 0;
}

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

int main()
{
  int r, a;

  while (cin >> r >> a, r || a){
    int hit = 0, blow = 0;
    int n1[4], n2[4];
    for (int i = 0; i < 4; i++){
      n1[i] = r % 10;
      n2[i] = a % 10;
      r /= 10;
      a /= 10;
    }
    for (int i = 0; i < 4; i++){
      for (int j = 0; j < 4; j++){
        if (n1[i] == n2[j]){
          if (i == j) hit++;
          else  blow++;
        }
      }
    }
    cout << hit << ' ' << blow << endl;
  }
  return (0);
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  string s, t;
  std::cin >> s >> t;
  sort(ALL(s));
  sort(ALL(t), greater<char>());
  int ssize = s.size(), tsize = t.size();
  t = t.substr(0, s.size());
  if (s < t || (s == t && ssize < tsize))
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
}


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

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

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

using namespace std;

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

  int wl, wr, wt, wb;
  wl = wr = wt = wb = -1;

  rep(i, n) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) wl = max(wl, x);
    if (a == 2) {
      if (wr == -1)
        wr = x;
      else
        wr = min(wr, x);
    }

    if (a == 3) wb = max(wb, y);
    if (a == 4) {
      if (wt == -1)
        wt = y;
      else
        wt = min(wt, y);
    }
  }

  if (wl == -1) wl = 0;
  if (wr == -1) wr = w;
  if (wt == -1) wt = h;
  if (wb == -1) wb = 0;

  if (wr < wl || wb > wt) {
    cout << 0 << endl;
  } else {
    // cout << "debug: " << wl << ":" << wr << ":" << wt << ":" << wb << endl;
    int white = (wr - wl) * (wt - wb);
    cout << white << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	string s; cin >> s;
    int n = (int)s.size();
    rep(i, n) {
        cout << "x";
    }
    cout << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const [x, y] = spi[0].split(' ').map(e => parseInt(e));

    for (let i = 0; i < x + 1; i++) {
        const turu = i * 2;
        const kame = (x - i) * 4;

        if (turu + kame === y) {
            console.log("Yes");
            return;
        }
    }

    console.log("No");
};

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


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

signed main(){
	int q;
	set<int>s;
	cin>>q;
	while(q--){
		int x,y;
		cin>>x>>y;
		if(x)cout<<s.count(y)<<endl;
		else{
			s.insert(y);
			cout<<s.size()<<endl;
		}
	}
}


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

using namespace std;


int main() {
  int N;
  cin >> N;
  long long mod = (long long)1e9 + 7LL;
  long long ans = 1;
  for (int i = 1; i <= N; ++i) {
    ans = (ans * i) % mod;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using ll = long long;
using p = pair<int,int>;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int k;
    cin >> k;
    vector<ll> a;
    for (int i = 1; i <= 9; i++) a.push_back(i);
    while(1){
        if(k <= a.size()){
            cout << a[k-1] << endl;
            return 0;
        }
        k -= a.size();
        vector<ll> old;
        swap(old,a);
        for(ll x : old){
            for(int i = -1;i<=1;++i){
                int d = x%10 + i;
                if(d<0 || d > 9)continue;
                ll nx = x*10 + d;
                a.push_back(nx);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1712
char s[2<<17];
dp[2<<17][256];
i,j,L;
main(m){
	gets(s);
	for(i=L=strlen(s);i--;dp[i][s[i]]=m+1)
		for(m=1e9,j=97;j<123;j++)m=fmin(m,dp[i][j]=dp[i+1][j]);
	for(;++i<L;){
		for(m=j=97;j<123;j++)m=dp[i][j]<dp[i][m]?j:m;
		for(putchar(m);i<L&&s[i]-m;i++);
	}
}

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

int main(){
	int A, B;
	cin >> A >> B;
	
	int max=-100000;
	if((A+B) > max)	max = A+B;
	if((A-B) > max)	max = A-B;
	if((A*B) > max)	max = A*B;

	cout << max << endl;

	return 0;
}



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


int main(){
    int n;cin>>n;
    ll x;
    long double zbr=1;
    for(int i=0;i<n;i++){
        cin >>x;
        if(zbr!=-1)
            zbr*=x;
        if(zbr>1000000000000000000  || zbr<0){
            zbr=-1;
        }
        if(x==0){
            zbr=0;
        }
    }
    cout << (ll)zbr<<endl;

}


Measured memory_bytes: 3584
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

ab = [LIST() for _ in range(N-1)]

color = list(range(K))

graph = defaultdict(list)
for a, b in ab:
	graph[a-1].append(b-1)
	graph[b-1].append(a-1)

ans = 1
q = deque()
q.append((None, 0))
color = [K]*N

while q:
	from_node, to_node = q.popleft()
	if from_node == None:
		ans *= K
		# print(from_node, to_node, K)
	else:
		ans = (ans * color[from_node])%mod
		# print(from_node, to_node, color[from_node])
	if from_node != None:
		color[to_node] = color[from_node]
		color[from_node] -= 1
	if color[to_node] >= K-1:
		color[to_node] -= 1
	else:
		color[to_node] = K-2
	for node in graph[to_node]:
		if from_node == None:
			q.append((to_node, node))
		else:
			if node != from_node:
				q.append((to_node, node))
	
print(ans)


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

int main(){
	vector<int> train;
	int n;
	while(cin >> n){
		if(n!=0){
			train.push_back(n);
		}
		else{
			cout << train.back() << endl;;
			train.pop_back();
		}
	}
	return 0;
}

Measured memory_bytes: 0
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
vector<int> vertexs[3000];
int visited[3000];
vector<int> backing;
int final_tracking[10000];
int ok = 0;
int dfs(int now) {
	visited[now] = 1;
	REP(q, vertexs[now].size()) {
		int next = vertexs[now][q];
		if (visited[next] == 1) {
			final_tracking[next] = -1;
			final_tracking[now] = -2;
			backing.push_back(next);
			backing.push_back(now);
			ok = 1;
			return 1;
		}
		if (visited[next] == 2) continue;
		int nya = dfs(next);
		if (nya == 1) {
			if (final_tracking[now] == -1) {
				nya = 2;
			}
			else {
				final_tracking[now] = final_tracking[next] - 1;
				backing.push_back(now);
			}
		}
		if (nya >= 1) {
			return nya;
		}
	}
	visited[now] = 2;
	return 0;
}
int ok_visit[2000];
int second_dfs(int now) {
	visited[now] = 1;
	REP(q, vertexs[now].size()) {
		int next = vertexs[now][q];
		if (visited[next] == 1) {
			ok = 1;
			return 1;
		}
		if (visited[next] == 2) continue;
		int nya = second_dfs(next);
		if (nya == 1) {
			return nya;
		}
	}
	visited[now] = 2;
	return 0;
}
int main(){
	int n, m;
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		vertexs[a].push_back(b);
	}
	for (int i = 0; i < n; ++i) {
		if (visited[i] == 0) {
			dfs(i);
			if (ok == 1) {
				break;
			}
		}
	}
	if (ok == 0) {
		cout << -1 << endl;
		return 0;
	}
	REP(i, backing.size()){
		ok_visit[backing[i]] = 1;
	}
	vector<int> ans;
	REP(i, n) {
		if (ok_visit[i] == 1) {
			ok_visit[i] = 0;
			ok = 0;
			REP(q, n) {
				visited[q] = 0;
				if (ok_visit[q] != 1) {
					visited[q] = 2;
				}
			}
			REP(q, n) {
				if (visited[q] == 0) {
					second_dfs(q);
					if (ok == 1) break;
				}
			}
			if (ok == 0) {
				ok_visit[i] = 1;
				ans.push_back(i);
			}
		}
	}
	cout << ans.size() << endl;
	REP(i, ans.size()) {
		cout << ans[i]+1 << endl;
	}
}

Measured memory_bytes: 1016
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "bitset"

using namespace std;

//const long long int MOD = 998244353;
const long long int MOD = 1000000007;
const long double EPS = 1e-7;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> K;
	string s;
	cin >> s;
	if (s[0] == 'A') {
		s[0] = 'B';
		K--;
	}
	for (int i = 1; i < N; i++) {
		if (K < 100) {
			while (K) {
				if (s[0] == 'A') {
					s[0] = 'B';
					K--;
				}
				else {
					K--;
					for (int j = 0; j < N - 1; j++) {
						s[j] = 'A' + 'B' - s[j + 1];
					}
					s[N - 1] = 'A';
				}
			}
			cout << s << endl;
			return 0;
		}
		if (i % 2) {
			if (s[i] == 'B')K -= 2;
			else K--;
		}
		else {
			if (s[i] == 'A')K -= 2;
			else K--;
		}
		if (K < 100) {
			for (int j = 0; j + i < N; j++) {
				if (i % 2) {
					s[j] = 'A' + 'B' - s[i + j];
				}
				else {
					s[j] = s[i + j];
				}
			}
			for (int j = N - i; j < N; j++) {
				if ((N - 1 - j) % 2)s[j] = 'B';
				else s[j] = 'A';
			}
			s[0] = 'B';
		}
	}
	for (int j = 0; j < N; j++) {
		if ((N - 1 - j) % 2)s[j] = 'B';
		else s[j] = 'A';
	}
	s[0] = 'B';
	if (N % 2 == 0) {
		cout << s << endl;
		return 0;
	}
	K %= 2;
	if (K) {
		s[0] = 'A';
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 792
#include<stdio.h>

int main(void){
  long long int N,A,B;
  long long int i;
  long long int h[100000];
  long long int K;
  long long int left,right;
  long long int sum;

  scanf("%d %d %d",&N,&A,&B);
  //printf("%d\n", N);

  for(i=0;i<N;++i){
    scanf("%lld",&h[i]);
    //printf("h[%lld]=%lld\n", i,h[i]);
  }

  left=0;
  right=1000000000;
  //K=(right+left)/2;

  //printf("%d\n", K);

  while(left!=right-1){
    K=(right+left)/2;
    sum=0;
    for(i=0;i<N;i++){
      if(h[i]-K*B > 0){
        sum += (h[i]-K*B)%(A-B) ? (h[i]-B*K)/(A-B)+1 : (h[i]-B*K)/(A-B);
      }
    }
    if(sum <= K){
      right=(right+left)/2;
    }else{
      left=(right+left)/2;
    }
    //printf("%lld,%lld\n", left,right);

    /*if(left==right-1){
      break;
    }*/
  }

  printf("%lld\n", right);

  return 0;
}


Measured memory_bytes: 896
#include <cstdio>
using namespace std;
int main(){
    int a, b;
    scanf("%d%d", &a, &b);
    printf(a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0 ? "Possible" : "Impossible");
    return 0;
}


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

using namespace std;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int T = a / d + (a%d > 0);
    int A = c/ b + (c%b > 0);
    if (T >= A)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
}

Measured memory_bytes: 3496
m,k = gets.split.map(&:to_i)
if k >= 2**m || (m == 1 && k == 1)
    puts "-1"
else
    ans = [] 
    ans << k if k != 0
    (2**m).times do |i|
        if i != k
            ans << i
        end
    end
    ans << k
    ans << k if k == 0
    (2**m).times do |i|
        if 2**m-1-i != k
            ans << 2**m-1-i
        end
    end
    puts ans.join(" ")
end

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

int main() {
  LL k; cin >> k;

  cout << 50 << endl;
  for (int i = 0; i < 50; i ++) {
    if (i) cout << " ";
    cout << 49 - i + (k + 49 - i) / 50;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int h, w, k;
vector< vector<long long int> > pat(8, vector<long long int>(101, 0));

void func(int piv, int cont) {
    if (piv >= w) {
        for (int i=0; i<w; i++) {
            pat[i][cont+1] += pat[i][cont];
            pat[i][cont+1] %= 1000000007;
        }
        return;
    }
    
    swap(pat[piv][cont], pat[piv-1][cont]);
    func(piv+2, cont);
    swap(pat[piv][cont], pat[piv-1][cont]);
    func(piv+1, cont);

    return;
}

int main() {
    pat[0][0] = 1;
    cin >> h >> w >> k;

    for (int i=0; i<h; i++) {
        func(1, i);
    }

    cout << pat[k-1][h] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#include "bits/stdc++.h"

namespace adaptor = boost::adaptors;

const int64_t max = 200000;
const int64_t sentinel = 10000000000;

int64_t L[max / 2 + 2], R[max / 2 + 2];

int64_t merge(int64_t A[], int64_t n, int64_t left, int64_t mid, int64_t right) {
    int64_t cnt = 0;
    int64_t n1 = mid - left;
    int64_t n2 = right - mid;
    for (int64_t i = 0; i < n1; i++) {
        L[i] = A[left + i];
    }
    for (int64_t i = 0; i < n2; i++) {
        R[i] = A[mid + i];
    }
    L[n1] = R[n2] = sentinel;

    int64_t i = 0, j = 0;
    for (int64_t k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
            cnt += n1 - i;
        }
    }
    return cnt;
}

int64_t mergeSort(int64_t A[], int64_t n, int64_t left, int64_t right) {
    int64_t mid;
    int64_t v1, v2, v3;
    if (left + 1 < right) {
        mid = (left + right) / 2;
        v1 = mergeSort(A, n, left, mid);
        v2 = mergeSort(A, n, mid, right);
        v3 = merge(A, n, left, mid, right);
        return v1 + v2 + v3;
    } else {
        return 0;
    }
}

void solve() {
    int64_t A[max], n;
    std::cin >> n;
    for (int64_t i = 0; i < n; i++) {
        std::cin >> A[i];
    }
    int64_t ans = mergeSort(A, n, 0, n);
    std::cout << ans << std::endl;

    return;
}

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



Measured memory_bytes: 6292
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

h = int(arr_data[0][0])
w = int(arr_data[0][1])


s=""
s += (w+2)*"#"
s +="\n"

for i in range(1,1+h):
    
    s +="#"
    s += "".join(arr_data[i])
    s +="#\n"


s += (w+2)*"#"

print(s)

Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

LL dp[1005][1005];
const int MAX = 1005;
LL fac[MAX], finv[MAX], inv[MAX];

void init() {
	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;
	}
}

LL  ncr(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;
}

LL mod_pow(LL a, LL p) {
	LL ret = 1;
	LL tmp = a;
	while (p) {
		if (p & 1)ret = (ret * tmp) % MOD;
		p >>= 1;
		tmp = (tmp * tmp) % MOD;
	}
	return ret;
}

int main() {
	int n, a, b, c, d;
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	dp[a][0] = 1;
	init();
	FOR(i, a, b + 1) {
		REP(j, n+1) {
			if (dp[i][j] == 0)continue;
			dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
			if (j + c * i > n)continue;
			FOR(k, c, d + 1) {
				if (j + k * i > n)break;
				LL tmp = (fac[n - j] * finv[n - j - k * i]) % MOD;
				tmp = (tmp * mod_pow(finv[i], k)) % MOD;
				tmp = (tmp * finv[k]) % MOD;
				dp[i + 1][j + k * i] = (dp[i + 1][j + k * i] + dp[i][j]*tmp) % MOD;
			}
		}
	}
	cout << dp[b + 1][n] << endl;
	return 0;
}

Measured memory_bytes: 8064