akhauriyash/Code-Regression huggingface dataset:
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <ll , ll>;
void in(ll &x);
const ll N = 3050;
#define singleCase
// #define multipleCase
const ll M = 998244353;
ll n, s;
ll dp[N][N], a[N];

ll f(ll cur , ll rem) {
   if (cur > n) return rem == 0;
   ll &sol = dp[cur][rem];
   if (sol != -1) return sol;
   sol = 0;
   if (rem >= a[cur]) (sol += f(cur + 1 , rem - a[cur])) %= M;
   (sol += 2 * f(cur + 1 , rem)) %= M;
   return sol;
}

void work() {
   in(n); in(s);
   for (ll i = 1 ; i <= n ; i++) {
      in(a[i]);
   }
   memset (dp , -1 , sizeof dp);
   printf("%lld\n" , f(1 , s));
   return;
}

int main() {
   #ifdef multipleCase
      ll nQ; in(nQ);
      while (nQ--)
         work();
   #endif
   #ifdef singleCase
      work();
   #endif
   return 0;
}

void in(ll &x) {
	bool neg = false;
	register ll c;
	x = 0;
	c = getchar();
	if(c == '-') {
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	  x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 76564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  char a, b, c, d, e, f;
  in3(a, b, c);
  in3(d, e, f);
  if(a == f && b == e && c == d)
    out("YES");
  else
    out("NO");
  memi;
}

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

int main(){
    int n;
    while( true ){
        cin >> n;
        if( !n ) break;
        vector<int> taro, hanako;
        for(int i = 0; i < n; i++){
            int a;
            cin >> a;
            taro.push_back(a);
        }
        sort(taro.begin(), taro.end());
        for(int j = 1; j < taro[0]; j++){
            hanako.push_back(j);
        }
        for(int i = 0; i < n-1; i++){
            for(int j = taro[i]+1; j < taro[i+1]; j++){
                hanako.push_back(j);
            }
        }
        for(int j = taro[n-1]+1; j <= 2*n; j++){
            hanako.push_back(j);
        }
        int top = 0;
        vector<int>::iterator min;
        while( true ){
            min = lower_bound(taro.begin(), taro.end(), top);
            if( min == taro.end() ){
                top = 0;
            }else{
                top = *min;
                taro.erase(min);
            }
            if( taro.empty() ) break;
            min = lower_bound(hanako.begin(), hanako.end(), top);
            if( min == hanako.end() ){
                top = 0;
            }else{
                top = *min;
                hanako.erase(min);
            }
            if( hanako.empty() ) break;
        }
        cout << hanako.size() << '\n' << taro.size() << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;

int main(void) {
    int N, M;
    ll K;
    cin >> N >> M >> K;
    vector<ll> A(N);
    vector<ll> B(M);

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

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

    vector<ll> a_s(N+1);
    vector<ll> b_s(M+1);

    a_s[0] = 0;
    b_s[0] = 0;

    for(int i = 1 ; i < N+1; i++){
        a_s[i] = a_s[i-1] + A[i-1];
    }

    for(int i = 1; i < M+1; i++){
        b_s[i] = b_s[i-1] + B[i-1];
    }

    ll ans = 0;
    int j = M;

    for(int i = 0; i < N + 1; i++){
        if(a_s[i] > K) break;

        while( b_s[j] > K - a_s[i]){
            j--;
        }

        ans = (ans > i + j) ? ans : i + j;
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
    string s;
    getline(cin, s);

    string result = "";

    for(int i=0; i<s.size(); ++i) {
        char c = s[i];
        if (isalpha(c)) {
            if (islower(c)) {
                char c_upper = toupper(c);
                string c_upper_str = {c_upper};
                result += c_upper_str;
            } else if (isupper(c)) {
                char c_lower = tolower(c);
                string c_lower_str = {c_lower};
                result += c_lower_str;
            }
        } else {
            string c_str = {c};
            result += c_str;
        }
    }

    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3208
n,k=map(int, input().split())
a=list(map(int, input().split()))
ans=0
x=0
y=0
for i in range(n):
    for j in range(n):
        if a[i]>a[j] and i>j:
            x+=1
        if a[i]>a[j] and i<j:
            y+=1
ans+=(x*(k-1)*k//2+y*k*(k+1)//2)%(10**9+7)
print(ans)

Measured memory_bytes: 3188
class RMQ:
  def __init__(self,n,e):
    self.n = 2**((n-1).bit_length())
    self.e = e
    self.d = [e]*(self.n<<1)
  
  def update(self,k,x):
    k += self.n-1
    self.d[k] = x
    while k > 0:
      k = (k-1)>>1
      self.d[k] = min(self.d[(k<<1)+1],self.d[(k<<1)+2])
    
  def query(self,l,r):
    L = l+self.n; R = r+self.n
    s = self.e
    while L < R:
      if R & 1:
        R -= 1
        s = min(s,self.d[R-1])
      if L & 1:
        s = min(s,self.d[L-1])
        L += 1
      L >>= 1; R >>= 1
    return s

[n,q] = list(map(int,input().split()))
rmq = RMQ(n,(1<<31)-1)
for i in range(q):
	[com,x,y] = list(map(int,input().split()))
	if com == 0:
		rmq.update(x,y)
	else:
		print(rmq.query(x,y+1))



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

int maxtype(vector<int> C, vector<long> S, int day, map<int, int> Last) {
  int T = 26;
  long max = 0;
  long score = 0;
  int type = 1;
  int keep;
  for (int i = 1; i <= T; i++) {
    keep = Last[i];
    Last[i] = day;
    score += S.at(i);
    for (int j = 1; j <= T; j++) {
      if (j != i) {
        score -= C.at(j) * (day - Last[j]);
      }
    }
    if (score > max) {
      type = i;
      max = score;
    }
    score = 0;
    Last[i] = keep;
  }
  return type;
}

int main() {
  int D;
  cin >> D;
  const int T = 26;
  vector<int> c(T+1);
  vector<vector<long>> s(D+1, vector<long>(T+1));
  map<int, int> last;
  for (int i = 1; i <= D; i++) {
    last[i] = 0;
  }
  int t;
  
  // 入力
  for (int i = 1; i <= T; i++) {
    cin >> c.at(i);
  }
  for (int i = 1; i <= D; i++) {
    for (int j = 1; j <= T; j++) {
      cin >> s.at(i).at(j);
    }
  }
  
  // 処理
  for (int i = 1; i <= D; i++) {
    t = maxtype(c, s.at(i), i, last);
    // last更新
    last[t] = i;
    cout << t << endl;
  }
  return 0;
}

Measured memory_bytes: 3752
n=int(input())
lists=[]
import math
for i in range(n):
    a,t=map(int,input().split())
    lists.append([a,t])
x=1
y=1
for i in range(n):
    j=max((x-1)//lists[i][0]+1,(y-1)//lists[i][1]+1)
    x=lists[i][0]*j
    y=lists[i][1]*j
print(x+y)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);

ll n,a[100001],m,x,i,b[100001];

int main()
{
	ll n;
	cin>>n;
	ll a[n],i,s=0;
	map<ll,ll> mp;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		mp[a[i]]++;
	}
	for(i=1;i<=n;i++)
	{
		ll it=mp[i];
		ll p=it*(it-1)/2;
		if(p>0)
		s+=p;
	}
	for(i=0;i<n;i++)
		cout<<s-mp[a[i]]+1<<"\n";
} 

Measured memory_bytes: 16640
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <stack>
#include <set>
#include <vector>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;





int main() {
  for (int N; cin >> N, N != 0; ) {
    int W, H; cin >> W >> H;

    int grid[110][110] = {};
    rep(i, N) {
      int x, y; cin >> x >> y;
      grid[y - 1][x - 1] = 1;
    }

    int S, T; cin >> S >> T;

    int slide[110][110] = {};
    rep(i, H) rep(j, W) slide[i + 1][j + 1] = slide[i + 1][j] + grid[i][j];
    rep(j, W) rep(i, H) slide[i + 1][j + 1] += slide[i][j + 1];

    int ans = 0;
    for (int i = 0; i + T <= H; i++) for (int j = 0; j + S <= W; j++) {
      // [i, i + T) x [j, j + S)
      int t = slide[i + T][j + S] - slide[i][j + S] - slide[i + T][j] + slide[i][j];
      ans = max(ans, t);
    }

    cout << ans << endl;

  }

  
  
  return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define ll long long

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

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

    vector<int> min_p(n);
    min_p[0] = p[0];
    for(int i = 1;i < n;++i){
        min_p[i] = min(min_p[i-1], p[i]);
    }

    int ans = 1;
    for(int i = 1;i < n;++i){
        //cout << i  << " " << p[i] << " " << min_p[i+1] << endl;
        if(p[i] <= min_p[i-1]){
            ++ans;
            //cout << i  << " " << p[i] << " " << min_p[i+1] << endl;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
N = input().split()
N = [int(i) for i in N]
pi = [0 for i in range(N[0])]
ci = [0 for i in range(N[0])]
for i in range(N[0]):
    buf = input().split()
    pi[i] = int(buf[0])
    ci[i] = int(buf[1])

num_min = 10*100
G_new = N[1]

flag= [0 for i in range(N[0])]
for i in range(0, pow(2, N[0])):
    G_new = N[1]
    count = 0
    #print(bin(i))
    for j in range(N[0]):
        flag[j] = (i>>j & 1)
        if(flag[j]==1):
            G_new -= ci[j]
            G_new -= 100*(j+1)*pi[j]
            count += pi[j]
    #print(flag)

    if(G_new<=0):
        if(count < num_min):
            num_min = count
            #print(count)

    else:
        for j in range(N[0]):
            if((flag[N[0]-1-j])==0):
                if(G_new - 100*(N[0]-j)*pi[N[0]-1-j] <= 0):
                    count += -(-G_new//(100*(N[0]-j)))
                    if(count < num_min):
                        num_min = count
                break

    
print(num_min)


Measured memory_bytes: 3064
from itertools import *
from math import gcd

k = int(input())
if gcd(k, 10) == 1:
    i = 0
    r = 0
    while True:
        i += 1
        r = (10*r+7)%k
        if r == 0:
            print(i)
            break
else:
    print(-1)


Measured memory_bytes: 9112
import java.util.*;

public class Main {
    public static void main(String[] a) {
        // Your code here!
        Scanner sc = new Scanner(System.in);

        int[] mountainsHight = new int[10];

        for(int i = 0; i < 10; i++){
          mountainsHight[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(mountainsHight);

        for(int i = 9; i > 6; i--) {
          System.out.println (mountainsHight[i]);
        }
    }
}



Measured memory_bytes: 26004
package main

import (
  "fmt"
)

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

  var ans, max int
  for i := 0; i < N; i++ {
    var H int
    fmt.Scan(&H)
    if max <= H {
      ans++
      max = H
    }
  }
  fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if(n < 1000) cout << "ABC" << endl;
    else cout << "ABD" << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
void solve(){
	ll k;
	cin>>k;
	if(k%2==0||k%5==0){
		cout<<"-1";
		exit(0);
	}
	ll p=1,cur=0,res=1;
	while(1){
		cur+=(p*7)%k;
		cur%=k;
		if(!cur){
			cout<<res<<"\n";
			break;
		}
		p=(p*10)%k;
		res++;
	}
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

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

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

Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let x: i32 = sc.read();
    let y: i32 = sc.read();
    let z: i32 = sc.read();
    println!("{} {} {}", z, x, y);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int res=0;
  string S;
  cin >> S;
  for(int i=0;i<S.size();i++)
    res += (S[i] - '0');
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


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

int main() {
  int N;
  cin >> N;
  int dig = 0;
  for (int n = N; n != 0; n /= 10){
    dig += n % 10;
  }
  if (N % dig == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

using std::pair;
using std::make_pair;
typedef pair<int, int> Pair;

#define update_max(a, b) if ((a) < (b)) (a) = (b)
#define update_min(a, b) if ((a) > (b)) (a) = (b)

const int N = 200;
const int MOD = 1000000000 + 7;

int a[N], b[N];
long long dp[N][2][2][2];

long long get(int pivot, bool first, bool less, bool greater) {
  if (pivot == 0) {
    return 1;
  }
  if (dp[pivot][first][less][greater] != -1) {
    return dp[pivot][first][less][greater];
  }
  int lower_x = greater ? 0 : a[pivot];
  int lower_y = greater ? 0 : a[pivot];
  int upper_x = less ? 1 : b[pivot];
  int upper_y = less ? 1 : b[pivot];
  long long result = 0, temp = 0;
  for (int i = lower_y; i <= upper_y; ++ i) {
    if (first && i == 0) continue;
    for (int j = lower_x; j <= upper_x; ++ j) {
      if (first && j == 0) continue;
      if (i < j) continue;
      temp = get(pivot - 1, false, less || i < upper_y, greater || j > lower_x);
      result += temp;
      if (result >= MOD) result -= MOD;
    }
  }
  dp[pivot][first][less][greater] = result;
  return result;
}

long long solve(long long x, long long y) {
  int len_a = 0;
  while (x) {
    a[++ len_a] = x % 2;
    x /= 2;
  }

  int len_b = 0;
  while (y) {
    b[++ len_b] = y % 2;
    y /= 2;
  }

  long long result = 0;
  for (int len = len_b; len >= len_a; -- len) {
    result += get(len, true, len < len_b, len > len_a);
    if (result >= MOD) result -= MOD;
  }
  // std::cerr << y << " " << result << std::endl;
  return result;
}

void run(int case_id = 0) {
  memset(dp, -1, sizeof(dp));
  long long l, r;
  std::cin >> l >> r;
  long long answer = solve(l, r);
  std::cout << answer << "\n";
}

void multi_cases_main() {
  int num_tests;
  std::cin >> num_tests;
  for (int t = 1; t <= num_tests; ++ t) {
    run(t);
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  run();
  return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/07/07  Problem: ABC 133 D / Link: http://abc133.contest.atcoder.jp/tasks/abc133_d  ----- */


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

	int N; cin >> N;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	LL asum = accumulate(a.begin(), a.end(), 0LL);
	FOR(i, 0, N - 1) {
		if (i % 2 == 0) {
			asum -= 2 * a[i];
		}
	}
	LL xn = asum;
	vector<LL>ans(N); {
		ans.back() = xn;
		ans.front() = 2 * a.back() - xn;
		xn = ans.front();
	}
	FOR(i, 1, N) {
		ans[i] = 2 * a[i - 1] - xn;
		xn = ans[i];
	}
	FOR(i, 0, N) {
		cout << ans[i] << " \n"[i + 1 == N];
	}

	return 0;
}


Measured memory_bytes: 2944
A, B, C, X, Y = map(int, input().split())
result = []
if X >= Y:
    result.append(X * C * 2)
    result.append(Y * C * 2 + (X-Y)*A)
else:
    result.append(Y * C * 2)
    result.append(X * C * 2 + (Y-X)*B)
result.append(X*A+Y*B)
print(min(result))


Measured memory_bytes: 3060
import math
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


x = int(input())
c=0
for k in range(x,100004):

  if is_prime(k) == 1:
    print(k)
    break

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
	int n,s[101],i,j,x,sum;
	scanf("%d",&n);
	sum=0;
	for(i=0;i<n;i++){
		scanf("%d",&s[i]);
		sum+=s[i];
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(s[i]<s[j]){
				x=s[i];
				s[i]=s[j];
				s[j]=x;
			}
		}
	}
	if(sum%10==0){
		for(i=0;i<n;i++){
			// printf("s[%d]=%d\n",i,s[i]);
			if(s[i]%10!=0){
				sum-=s[i];
				break;
			}
		}
	}
	if(sum%10==0) sum=0;
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int n;
	scanf("%d", &n);
	bitset<10001> a(1);
	for(int i = 0, j; i < n; ++i)
	{
		scanf("%d", &j);
		a |= a << j;
	}
	for(int i = 10000; i >= 0; --i)
	{
		if(i % 10)
		{
			if(a.test(i))
			{
				printf("%d\n", i);
				return 0;
			}
		}
	}
	printf("0\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
const lint mod = 1e9 + 7;

int main(){
    int n;
    scanf("%d", &n);
    lint a[n];
    map<int, int> mp;
    rep(i, n){
        scanf("%lld", &a[i]);
        ++mp[a[i]];
    }
    sort(a, a+n, greater<lint>());
    int ans = 0;
    rep(i, n){
        if(!mp[a[i]]) continue;
        int k = 1;
        while(k <= a[i]) k *= 2;
        if(a[i] == k / 2 && mp[a[i]] == 1) continue;
        if(mp[k - a[i]]){
            --mp[a[i]];
            --mp[k - a[i]];
            ++ans;
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 20608
#include <iostream>
using namespace std;
static const int INFTY = (1<<29);

struct Item {
  int v, w;
};

int main() {
  int N, W;
  cin >> N >> W;
  Item items[N+1];
  for (int i = 1; i <= N; i++) {
    cin >> items[i].v >> items[i].w;
  }
  int C[N+1][W+1];
  for (int i = 0; i <= N; i++) {
    for (int w = 0; w <= W; w++) {
      if (!i || !w) C[i][w] = 0;
      else C[i][w] = INFTY;
    }
  }
  for (int i = 1; i <= N; i++) {
    for (int w = 1; w <= W; w++) {
      if (items[i].w <= w) {
        if (items[i].v + C[i-1][w-items[i].w] > C[i-1][w]) {
          C[i][w] = items[i].v + C[i-1][w-items[i].w];
        } else {
          C[i][w] = C[i-1][w];
        }
      } else {
        C[i][w] = C[i-1][w];
      }
    }
  }
  cout << C[N][W] << endl;
  return 0;
}



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

long int a,b;

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

int main(){
    while(cin){
        cin >> a >> b;
        if(!cin) break;
        long int ans = gcd(a,b);
        cout << ans << " " << (a*b)/ans << endl;
    }
}

Measured memory_bytes: 3024
n,m=map(int,input().split())
data=[]
for i in range(n):
    a,b=map(int,input().split())
    data.append([a,b])
data.sort()
buf=0
ans=0
for i in range(n):
    data_i=data[i]
    ans+=data_i[0]*data_i[1]
    buf+=data_i[1]
    if buf>=m:
        ans-=data_i[0]*(buf-m)
        break
print(ans)

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

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

main(){

  ll n;
  cin>>n;
  vector<pair<ll,ll>> a(n);
  rep(i,n)cin>>a[i].first>>a[i].second;

  auto cmp = [](auto a,auto b){
    return a.second==b.second?a.first<b.first:a.second<b.second;
  };
  sort(a.begin(),a.end(),cmp);

  ll now = 0;
  rep(i,n){
    now += a[i].first;
    if(now<=a[i].second)continue;
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;

}

Measured memory_bytes: 3456
#include <stdio.h>

void cut(int* cards,int n,int k) {
	int result[200];
	int i;
	for(i=0;i<k;i++) {
		result[2*n-k+i]=cards[i];
	}
	for(i=k;i<2*n;i++) {
		result[i-k]=cards[i];
	}
	for(i=0;i<n*2;i++) {
		cards[i]=result[i];
	}
}

void rshuffle(int* cards,int n) {
	int result[200];
	int i;
	for(i=0;i<n;i++) {
		result[i*2]=cards[i];
		result[i*2+1]=cards[i+n];
	}
	for(i=0;i<n*2;i++) {
		cards[i]=result[i];
	}
}

int main(void) {
	int cards[200];
	int i,n,m,k;
	scanf("%d",&n);
	scanf("%d",&m);
	for(i=0;i<n*2;i++)cards[i]=i+1;
	for(i=0;i<m;i++) {
		scanf("%d",&k);
		if(k==0)rshuffle(cards,n);
		else cut(cards,n,k);
	}
	for(i=0;i<n*2;i++)printf("%d\n",cards[i]);
	return 0;
}

Measured memory_bytes: 0
def check(ai, ratemax, d):
    if 3199 < ai:
        ratemax += 1
    else:
        d[ai // 400] = 1
    return ratemax


def main():
    N, *a = map(int, open(0).read().split())
    lst = [0] * 8
    ratemax = 0
    for ai in a:
        ratemax = check(ai, ratemax, lst)
    print(sum(lst) if sum(lst) else 1, sum(lst) + ratemax)
    return


main()


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

typedef long long ll;
const int MN = 5005;
ll A, B, N, arr[MN], dp[MN][MN], i, j;
ll solve(ll n,ll lim){
    if(n==0) return 0;
    else if(dp[n][lim]!=-1) return dp[n][lim];
    if(arr[n]>lim) dp[n][lim]=A+solve(n-1,lim);
    else dp[n][lim]=min(solve(n-1,arr[n]),solve(n-1,lim)+B);
    return dp[n][lim];
}
int main(){
    for(scanf("%lld%lld%lld",&N,&A,&B),i=1;i<=N;i++)
        scanf("%lld",&arr[i]);
    memset(dp,-1,sizeof(dp));
    printf("%lld\n",solve(N,N+1));
    return 0;
}


Measured memory_bytes: 196224
#include<stdio.h>
#include<string.h>
 
int main(){
  char inp[11];
  scanf("%s",inp);
 
  int j=0;
  char array[11]={'\0'};
  int len=strlen(inp);
  for(int i=0;i<len;i++){
    if(inp[i]=='0'){
      array[j]='0';
      j++;
    }else if(inp[i]=='1'){
      array[j]='1';
      j++;
    }else if(inp
	
	[i]=='B'){
      if(j!=0){
        j--;
        array[j]='\0';
      }
    }
  }
  printf("%s",array);
  return 0;
}

Measured memory_bytes: 1732
n = gets.to_i
ary = gets.split(' ').map(&:to_i)
res = []
(0...n).each{|i|
  if i.even?
    res.unshift(ary[i])
  else
    res.push(ary[i])
  end
}
if n.even?
  res.reverse!
end
puts res.join(' ')

Measured memory_bytes: 25696
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  ll N, K;
  cin >> N >> K;
  vector<int> A(N), F(N);
  FOR(i, N) cin >> A[i];
  FOR(i, N) cin >> F[i];
  if (accumulate(ALL(A), 0LL) <= K) {
    cout << 0 << endl;
    return 0;
  }
  sort(ALL(A));
  sort(ALL(F), greater<int>());
  ll l = 0, r = 0, m;
  FOR(i, N) r = max(r, (ll)A[i] * F[i]);
  m = l + (r - l) / 2;
  while (r - l > 1) {
    ll now = 0;
    FOR(i, N) { now += max(0LL, A[i] - (m) / F[i]); }
    if (now <= K) {
      r = m;
    } else {
      l = m;
    }
    m = l + (r - l) / 2;
  }
  cout << r << endl;
  return 0;
}

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

typedef long long ll;
typedef vector < int > vi;
typedef pair <int , int > pi;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fr(i,a,b) for(int i=a;i<b;i++)



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int arr[n-1];
    ll sum=0;
    int barr[n]={0};
    for(int i=0;i<n-1;i++)
    {
        cin>>arr[i];
        barr[arr[i]-1]++;
        
    }

    for(int i=0;i<n;i++)
    {
        cout<<barr[i]<<"\n";
        
        
    }
    

    return 0;
}


Measured memory_bytes: 5184
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		String str;
		int a[];
		int max;
		int min;

		n = sc.nextInt();
		a = new int[8];
		for (int i = 0; i < n; i++) {
			max = 0;
			min = 0;
			str = sc.next();
			for (int j = 0; j < 8; j++) {
				a[j] = str.charAt(j);
			}
			for (int j = 0; j < 8; j++) {
				int maxIndex = j;
				for (int k = j; k < 8; k++) {
					if (a[maxIndex] < a[k]) {
						maxIndex= k;
					}
				}
				int swap = a[maxIndex];
				a[maxIndex] = a[j];
				a[j] = swap;
			}
			for (int j = 0; j < 8; j++) {
				max *= 10;
				max += a[j];
			}
			for (int j = 7; 0 <= j; j--) {
				min *= 10;
				min += a[j];
			}
			System.out.println(max - min);
		}
	}
}

Measured memory_bytes: 12000
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include "bitset"
#include "cmath"
#include "list"
#include "complex"
#include <cassert>
#include "deque"

using namespace std;

#define f(i,n) for(int i=0; i<n;i++) 
#define rf(i, n) for(int i=n-1;i>=0;i--)
#define forn(i, j, n) for(int i=j; i<n; i++)
#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define mp make_pair
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'
#define all(a) a.begin(), a.end()
#define sqr(x) (x) * (x)
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
typedef long long ll;
typedef long double ld;
#define int ll
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

const int sze = 3e5 + 50, INF = 1e18 + 500, mod = 998244353;
const double eps = 5e-10, PI = 2 * acos(0.0);

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

vi vertices[sze];
vc visit(sze, false);
vi arr(sze, 0);
int n, m, k, t;
int d = 0;
int cnt = 0;
string s;
vi col(sze, 0);
vi sum(sze, INF);
int x, y;

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);*/
	
	cin >> s;

	if (s.size() == 2)
	{
		cout << s;
	}
	else
	{
		reverse(all(s));
		cout << s;
	}

	return 0;
}



Measured memory_bytes: 14592
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
#define int ll
using namespace std;
 
int a,b,c,d;
inline ll solve()
{
	--a,--b,--c,--d;
	int res=abs(a-c)+abs(b-d),t=1LL;
	for(rgi i=1;i<=33;++i) t*=3LL;
	for(rgi i=33;i>=0;--i)
	{
		for(rgi j=0;j<2;++j)
		{
			if(a/t==c/t&&(a/t)%3LL==1LL&&abs(b/t-d/t)!=1&&abs(b-d)>=t)
			{
				int mn=min(a,c),mx=max(a,c);
				return res+min(mn-mn/t*t+1LL,(mx/t+1LL)*t-mx)*2LL;
			}
			swap(a,b),swap(c,d);
		}
		t/=3LL;
	}
	return res;
}
 
signed main()
{
	rgi q;
	cin>>q;
	while(q--)
	{
		cin>>a>>b>>c>>d;
		cout<<solve()<<endl;
	}
	return 0;
}
// ----------------------------
// by imzzy


Measured memory_bytes: 384
def judge(s):
    n=len(s)
    if s[0]!="A":
        return False
    if s[2:n-1].count("C")!=1:
        return False
    ss=s[1:].replace("C","c")
    if ss.islower():
        return True
    return False


s=input()
if judge(s):
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int n;
  cin >> n;
  vector<int> primelist;
  for(int i=2;i <= 55555;i++){
    bool isprime = true;
    for(int j=2;j <= i-1;j++){
      if(i % j == 0){
        isprime = false;
        break;
      }
    }
    if(isprime && i % 10 == 1){
      primelist.push_back(i);
    }
  }
  rep(i,n){
    cout << primelist.at(i) << " ";
  }
        
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = 0;
        int b = 0;
        for (int i = 1 ; i <= k ;i++) {
            if (i % 2 == 0) {
                a++;
            }else {
                b++;
            }
        }
        System.out.println(a * b);
    }

}


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

int main() {
    int a,b;
	cin>>a>>b;
	if(a!=1 &&b!=1)
	    cout<<"1"<<endl;
	else if(a!=2 &&b!=2)
	    cout<<"2"<<endl;
	else
	    cout<<"3"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll k,cnt=0,i;
    queue<ll> q;
    cin >> k;
    for(i=1;i<10;i++) q.push(i);
    while(!q.empty()) {
    	ll p=q.front();
    	q.pop();
    	cnt++;
    	if(cnt==k) {
    		cout << p << "\n";
    		break;
    	}
    	ll rem=p%10;
    	if(rem != 0) q.push(10*p+rem-1);
    	q.push(10*p+rem);
    	if(rem != 9) q.push(10*p+rem+1);
    }
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;
  cin>>N;
  
  vector<char> S(N);
  for(int i=0;i<N;i++){
    cin>>S[i];
  }
  sort(S.begin(),S.end());
  
  if(S[N-1]=='Y'){
    cout<<"Four"<<endl;
  }
  else{
    cout<<"Three"<<endl;
  }
}

Measured memory_bytes: 3596
<?php

while (true) {
    
    fscanf(STDIN, "%d %d", $height, $width);
    
    if ($height == 0 && $width == 0){
        break;
    }
    
    $rectangle = new Rectangle($height, $width);
    $rectangles[] = $rectangle->drawChess();
}

echo implode(PHP_EOL, $rectangles),PHP_EOL;

class Rectangle {
    
    private $height;
    private $width;
    
    public function __construct($height, $width){
        $this->height = $height;
        $this->width = $width;
    }
    
    public function draw(){
        $rectangle = [];
        for($i = 0; $i < $this->height; $i++){
            $rectangle[] = str_repeat("#", $this->width);
        }
        return implode(PHP_EOL, $rectangle).PHP_EOL;
    }
    
    public function drawCheck(){
        $rectangle = [];
        for($i = 0; $i < $this->height; $i++){
            if($i == 0 || $i == $this->height -1 || $this->width <= 2){
                $rectangle[] = str_repeat("#", $this->width);
            }else{
                $rectangle[] = "#".str_repeat(".", $this->width - 2)."#";
            }
        }
        return implode(PHP_EOL, $rectangle).PHP_EOL;
    }
    
    public function drawChess(){
        $rectangle = [];
        for($i = 0; $i < $this->height; $i++){
            if($i % 2 == 0){
                $rectangle[] = $this->drawLine('#', '.');
            }else{
                $rectangle[] = $this->drawLine(".", "#");
            }
        }
        return implode(PHP_EOL, $rectangle).PHP_EOL;
    }
    
    public function drawLine($mark1, $mark2){
        $line = "";
        for($i = 0; $i < $this->width; $i++){
            if($i % 2 == 0){
                $line .= $mark1;
            }else{
                $line .= $mark2;
            }
        }
        return $line;
    }
    
}

Measured memory_bytes: 15148
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(style))]
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet, VecDeque};

//{{{
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[macro_export]
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)*}
    };
}

#[doc(hidden)]
#[macro_export]
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)*}
    };
}

#[doc(hidden)]
#[macro_export]
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! {
        n: usize,
        k: usize,
    }
    let mut cnt = 0;
    for i in 1..n + 1 {
        if i % 2 == 1 {
            cnt += 1;
        }
    }
    if cnt >= k {
        println!("YES");
    } else {
        println!("NO");
    }
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{

	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll ans=0;
	cin >>n;
	VI b(n), a(n);
	rep(i, n-1) cin >>b[i];
	if(n==2){cout<<b[0]*2<<"\n"; return 0;}
	a[0]=a[1]=b[0]; b.back()=99999999;
	rep2(i,1,n){
		a[i] = min(b[i-1], b[i]);
	}
	//for(auto x :a) printf("%d, ",x); puts("");
	cout << accumulate(all(a), 0LL) <<"\n";
}


Measured memory_bytes: 256
while true
    n = gets.to_i
    break if n == 0
    score = [0, 0]
    n.times{
        a, b = gets.chomp.split.map(&:to_i)
        if a == b
            score[0] += a
            score[1] += b
        elsif a > b
            score[0] += (a + b)
        else
            score[1] += (a + b)
        end
    }
    puts score.join(" ")
end


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



int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  vector<int> sect(n);
  for(int i=1; i<n; i++){
    sect[i] = a[i] - a[i-1];
  }
  sect[0] = a[0]+k-a[n-1];
  
  sort(sect.rbegin(), sect.rend());
  cout << k-sect[0] << endl;
  
  return 0;
}


Measured memory_bytes: 4796
#include<stdio.h>
int main(void)
{
	int n,x[100],a,m,i;
	scanf("%d", &n);
	m=n-1;
	for(i=0; i<n; i++)
	{
		scanf("%d", &a);
		x[m]=a;
		m--;
	}
	for(i=0; i<n; i++)
	{
		printf("%d", x[i]);
		if(i<n-1)
		printf(" ");
	}
	printf("\n");
	
	return 0;
}


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

string judge( int a, int b ){
	if( a == b )
		return "Draw";

	if( a != 1 && b != 1 && a > b )
		return "Alice";

	if( a != 1 && b != 1 && b > a )
		return "Bob";

	if( a == 1 && b != 1)
		return "Alice";

	if( b == 1 && a != 1)
		return "Bob";
}

int main( void ){
	int a,b;
	cin >> a >> b;
	
	cout << judge( a, b ) << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		System.out.println(gcd(Math.max(x, y), Math.min(x, y)));
		sc.close();
	}

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


Measured memory_bytes: 26216
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string>
#include <cmath>
#include <set>
#include <cmath>
using namespace std;


const long long mod = 1e+9 + 7;

vector<vector<long long>> multiply(const vector<vector<long long>>& a, const vector<vector<long long>>& b)
{
	int n = a.size();

	vector<vector<long long>> temp(n, vector<long long>(n, 0));

	for (int i = 0; i < n; i++)
	{
		for (int k = 0; k < n; k++)
		{
			for (int j = 0; j < n; j++)
			{
				temp[i][k] += a[i][j] * b[j][k];
				temp[i][k] %= mod;
			}
		}
	}

	return temp;
}

void binpow(long long m, vector<vector<long long>>& A)
{
	int n = (int)A.size();
	
	vector<vector<long long>> res(n, vector<long long>(n, 0));
	
	for (int i = 0; i < n; i++)
	{
		res[i][i] = 1;
	}

	while (m > 0)
	{
		if (m & 1)
		{
			res = multiply(res, A);
		}

		A = multiply(A, A);
		m >>= 1;
	}

	A = res;
}


void solve()
{
	vector<vector<long long>> A;

	int n;

	long long K;

	cin >> n >> K;
	
	A.assign(n, vector<long long>(n, 0));

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

	binpow(K, A);

	long long ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int k = 0; k < n; k++)
		{
			ans += A[i][k];
			ans %= mod;
		}
	}

	cout << ans;
}




int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        sc.close();
        Node[] nodes=new Node[k];
        for(int i=0;i<k;nodes[i]=new Node(i++));
        for(int i=1;i<k;i++){
            nodes[i].edges.add(new Edge((i*10)%k, 0));
            if((i*10)%k!=(i+1)%k) nodes[i].edges.add(new Edge((i+1)%k, 1));
        }
        System.out.println(_01bfs(nodes, 1)[0]+1);
    }

    public static int[] _01bfs(Node[] nodes, int s) {
        ArrayDeque<Integer> dq = new ArrayDeque<>();
        dq.add(s);
        int n = nodes.length;
        int[] d = new int[n];
        boolean[] visited=new boolean[n];
        for (int i = 0; i < n; d[i++] = Integer.MAX_VALUE) ;
        d[s] = 0;
        while (dq.size() > 0) {
            int now = dq.pollFirst();
            if(visited[now]) continue;
            visited[now]=true;
            for (Edge e : nodes[now].edges) {
                int next = e.id;
                int cost = e.cost;
                if (d[next] > d[now]) {
                    if (cost == 0) {
                        dq.addFirst(next);
                    } else {
                        dq.addLast(next);
                    }
                    d[next] = d[now] + cost;
                }
            }
        }
        return d;
    }

    static class Node {
        int id;
        int value;
        ArrayList<Edge> edges;

        public Node(int id) {
            this.id = id;
            this.value = Integer.MAX_VALUE;
            edges = new ArrayList<Edge>();
        }

        @Override
        public boolean equals(Object o) {
            if (!(o instanceof Node))
                return false;
            Node n = (Node) o;
            if (n.id == id)
                return true;
            else
                return false;
        }

        @Override
        public int hashCode() {
            return id;
        }
    }

    static class Edge {
        int id;
        int cost;
        public Edge(int id, int cost) {
            this.id = id;
            this.cost = cost;
        }
    }
}


Measured memory_bytes: 55348
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;


int main() {


	vector<string> v = { "SUN","MON","TUE","WED","THU","FRI","SAT" };

	string s;

	cin >> s;

	REP(i, 7) {
		if (s == v[i]) {
			cout << 7-i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256