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

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

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll dp[3][101010];
ll c[3][101010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    REP(i, 3)REP(j, 101010) dp[i][j] = -1;

    ll N;
    cin >> N;
    REP(i, N){
    	cin >> c[0][i] >> c[1][i] >> c[2][i];
    }
    REP(i, 3) dp[i][0] = c[i][0];

    REP(i, N-1){
	    REP(j, 3){
	    	REP(k, 3){
	    		if(j==k) continue;
	    		dp[k][i+1] = max(dp[j][i] + c[k][i+1], dp[k][i+1]);
	    	}
	    }
	}

	cout << max(dp[0][N-1], max(dp[1][N-1], dp[2][N-1])) << endl;
    return 0;
}

Measured memory_bytes: 4992
A,B,K=map(int,input().split())
for i in range(K):
  if i%2==0:
    if A%2!=0:
      B += (A-1)//2
      A = (A-1)//2
    else:
      B += A//2
      A //= 2
  else:
    if B%2!=0:
      A += (B-1)//2
      B = (B-1)//2
    else:
      A += B//2
      B //= 2
print(A,B)      

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

const int inf = 1e9;

int main(void){
    int n;
    while (cin>>n && n) {
        vector<vector<int> > a(n, vector<int>(n+1, 0));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n+1; j++) {
                cin >> a[i][j];
            }
        }
        
        vector<int> dp(1<<n, inf);
        dp[0] = 0;
        for (int bit = 0; bit < (1<<n); bit++) {
            for (int i = 0; i < n; i++) {
                if ((bit & (1<<i)) == 1) continue;
                
                int cost = a[i][0];
                for (int j = 0; j < n; j++) {
                    if ((bit & (1<<j)) == 0) continue;
                    cost = min(cost, a[i][j+1]);
                }
                dp[(bit|(1<<i))] = min(dp[(bit|(1<<i))], dp[bit]+cost);
            }
        }
        cout << dp[(1<<n)-1] << endl;
    }
}

Measured memory_bytes: 3376
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;
bool odd(string s) {
    bool flag = true;
    for(int i = 0; i < s.size(); i+=2) {
        if(s[i] == 'L') flag = false;
    }
    if(!flag) return false;
    return true;
}
bool even(string s) {
    bool flag = true;
    for(int i = 1; i < s.size(); i += 2){
        if(s[i] == 'R') flag = false;
    }
    if(!flag) return false;
    return true;
}
int main() {
    string s;
    cin >> s;
    if(odd(s) && even(s)) cout  << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
  int N;
  std::cin >> N;
  std::vector<std::string> S(N);
  std::vector<int> MARCH(5, 0);
  for(int i = 0; i < N; i++){
    std::cin >> S.at(i);
    if(S.at(i).at(0) == 'M') MARCH.at(0)++;
    else if(S.at(i).at(0) == 'A') MARCH.at(1)++;
    else if(S.at(i).at(0) == 'R') MARCH.at(2)++;
    else if(S.at(i).at(0) == 'C') MARCH.at(3)++;
    else if(S.at(i).at(0) == 'H') MARCH.at(4)++;
  }
  
  long long ans = 0;
  for(int i = 0; i < 3; i++){
    long long ti = 1;
    ti *= MARCH.at(i);
    if(ti == 0) continue;
    for(int j = i+1; j < 4; j++){
      long long tj = ti;
      tj *= MARCH.at(j);
      if(tj == 0) continue;
      for(int k = j+1; k < 5; k++){
        long long tk = tj;
        tk *= MARCH.at(k);
        ans += tk;
      }//k
    }//j
  }//i
  std::cout << ans << std::endl;
  
}

Measured memory_bytes: 6144
x = gets.chomp.to_i
nmax = 1000
nmin = 1
result = 0
(nmin..nmax).each{|elem|
  x1 = x-100*elem
  if (x1 >= 0) and (x1 <=5*elem) 
    result = 1
  else
  end
  }

puts result


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  ll x,y;
  cin >> x >> y;
  int count = 0;
  while(x<y){
    x*=2;
    count++;
  }
  if(x==y) count++;
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;    
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()   
#define trav(a, x) for(auto& a : x)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr<< *it << " = " << a << endl;
	err(++it, args...);
}
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main()
{
    sws
    char in;
    cin>>in;
    if(in>='A' and in<='Z')
        cout<<"A"<<endl;
    else 
        cout<<"a"<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int ans = 0;
  FOR(i,0,N) {
    int l, r; cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
  return 0;
}


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

int32_t main()
{
	int i,k,n,sum=0;
	cin>>n>>k;
	int a[n];
	for(i=0;i<n;i++)cin>>a[i];
	
	sort(a,a+n);
	for(i=0;i<n-k;i++)
	{
		sum+=a[i];
	}
	cout<<sum<<"\n";
	
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root=NIL;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL)root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u==NIL)return;
 
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){
  if(u==NIL)return;

  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 25152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;
  int p;
  cin>>N;
  rep(i,N+1){
    if((i+i*i)/2>=N){
      p=i;
      break;
    }
  }
  int x;
  x=(p+p*p)/2-N;
  rep(i,p+1){
    if(i==0||i==x){
      continue;
    }
    cout<<i<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

// a^n mod pを計算　O(log n)
long long int pow_p(long long int a, long long int n, long long int p) {
    if (n == 0) {
        return 1;
    } else {
        long long int temp = pow_p(a, n / 2, p);
        if (n % 2 == 0) {
            return (temp * temp) % p;
        } else {
            return (((temp * temp) % p) * a) % p;
        }
    }
}

int main() {
    lint mod = 998244353;
    int n;
    cin >> n;
    vector<lint> d(n, 0);
    int d0;
    cin >> d0;
    if (d0 != 0) {
        cout << 0 << endl;
        return 0;
    }
    int d_max = 0;
    for (int i = 0; i < n - 1; i++) {
        int temp;
        cin >> temp;
        if (temp == 0) {
            cout << 0 << endl;
            return 0;
        }
        d[temp]++;
        d_max = max(d_max, temp);
    }
    lint ans = 1;
    for (int i = 2; i <= d_max; i++) {
        ans *= pow_p(d[i - 1], d[i], mod);
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
A,B,K = map(int, input().split())

takahashi_cookie = A
aoki_cookie = B
iteration = K

if 0 <= takahashi_cookie - iteration:
  takahashi_cookie -= iteration
 
elif 0 <= aoki_cookie + takahashi_cookie - iteration:
  aoki_cookie = aoki_cookie + takahashi_cookie - iteration
  takahashi_cookie = 0

else:
  takahashi_cookie = 0
  aoki_cookie = 0

print(str(takahashi_cookie) + ' ' + str(aoki_cookie))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10;

void solve() {
    ll n; cin >> n;
    int ans = 0;
    ll j;

    for (int i = 2; i <= sqrt(n); ++i) {
        j = i;
        while (n % j == 0) {
            ++ans;
            n /= j;
            j *= i;
        }

        while (n % i == 0) {
            n /= i;
        }
    }

    if (n > 1) ++ans;
    cout << ans << endl;
}

int main(void) {
    int t; t = 1;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
using namespace std;
#define int long long
void fast(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int32_t main()
{
    fast();
    int n;
    cin >> n;
    vector<int>a(n,0);
    for(int i = 0; i < (n - 1); i++){
        int t;
        cin >> t;
        a[t-1]++;
    }
    for(auto x:a)
        cout << x << "\n";
    return 0;
}


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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
    	n:isize,
        m:isize
    }
    
    println!("{}", if m*2>=n { 0} else {n-m*2});
}

Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N,C;
typedef pair<int, int> P;
vector<P> G[31]; 
int video[31][200003];

int main() {
  INCANT;
  cin >> N >> C;
  int s,t,c;
  rep(i, N) {
    cin >> s >> t >> c;
    G[c-1].push_back(P(s,t));
  }
  
  rep(c, C) {
    int tmp[200003];
    fill(tmp, tmp+200003, 0);
    for (auto p: G[c]) {
      tmp[p.first*2]++;
      tmp[p.second*2]--;
    }
    rep(j, 200001) {
      if (tmp[j]==1) {
        tmp[j-1]=1;
        tmp[j]=0;
      }
    }
    video[c][0] = tmp[0];
    rep(j, 200003) video[c][j+1] = video[c][j]+tmp[j+1];
  }
  int mx=0;
  rep(i, 200003) {
    int tmp=0;
    rep(c, C) tmp+=video[c][i];
    mx=max(mx, tmp);
  }
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 28832
#!/usr/bin/env python3
import numpy as np

N, K = list(map(int, input().split()))
h_list = list(map(int, input().split()))
h_list = np.array(h_list)
dp_list = np.zeros(N)
dp_list[0] = 0

for i in range(1, N):
    # j番目の足場からi番目の足場に飛ぶ

    min_j = max(i - K, 0)
    cost_list = dp_list[min_j:i] + np.abs(h_list[i] - h_list[min_j:i])
    # 最適コストで更新
    dp_list[i] = np.min(cost_list)

ans = int(dp_list[-1])
print(ans)


Measured memory_bytes: 22748
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


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

  map<int,int> cnt;
  for (int i = 0; i < N; i++) {
    cnt[A[i]]++;
  }
  priority_queue<pii, vector<pii>, greater<pii>> Q;
  for(auto e: cnt) {
    Q.push(mp(e.second, e.first));
  }

  if (cnt.size() <= K){
    cout << 0 << endl;
  } else {
    ll ans = 0;
    for(int i = 0; i < cnt.size() - K; i++) {
      pii p = Q.top(); Q.pop();
      ans += p.first;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 12536
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n, a, b; cin >> n >> a >> b;
	string ans = "NG";
	for (int i=0;i<100000;i++)
		if ((a<=n*i)&&(n*i)<=b) { ans = "OK"; }
	cout << ans << endl;
}

Measured memory_bytes: 3592
import sys


def main():
    n = int(sys.stdin.readline().strip())
    a = [int(s) for s in sys.stdin.readline().strip().split()]

    seen = set()
    is_yes = True
    for ai in a:
        if ai in seen:
            is_yes = False
            break
        seen.add(ai)
    if is_yes:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()

Measured memory_bytes: 95092
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstdlib>
#include<algorithm>
#include<map>
using namespace std;
char s[510][510];
int dp[510][510];
int gcd(int a,int b) {
    return a%b?gcd(b,a%b):b;
}
int main(){
    int n,m;
    int t;
    char x[10];
    while (scanf("%s",x)!=EOF) {
        if (x[0]>='A'&&x[0]<='Z')
            printf("A\n");
        else
            printf("a\n");

    }

    return 0;
}


Measured memory_bytes: 3156
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define F first
#define S second
#define pb push_back
#define bit __builtin_popcount
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define mkp make_pair
#define ffs fflush(stdout)

using namespace std;
using namespace __gnu_pbds;

//order_of_key(k) : Number of items strictly smaller than k
//find_by_order(k) : K-th element in a set (counting from 0)

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef vector <int> lnum;
typedef pair <int, int> pii;

const int N = (int)1e6 + 5;
const int MOD = (int)1e9 + 7;
const int inf = (int)1e18;
const int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
const ld eps = 1e9 - 7;
const int pp[] = {29, 31, 53, 67, 71};
const double pi = acos(-1.0);

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

int u[N];
vector <int> g[N];

signed main() {
  ios_base :: sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].pb(v);
    g[v].pb(u);
  }
  queue <int> q;
  vector <int> d(n + 1);
  q.push(1);
  u[1] = 1;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (auto to : g[v]) {
      if (!u[to]) {
        q.push(to);
        d[to] = d[v] + 1;
        u[to] = 1;
      }
    }
  }
  int f = 1;
  for (int i = 1; i <= n; ++i) {
    if (d[i] > d[f])
      f = i;
  }
  for (int i = 1; i <= n; ++i)
    u[i] = 0;
  for (int i = 1; i <= n; ++i)
    d[i] = 0;
  q.push(f);
  u[f] = 1;
  while (!q.empty()) {
    int v=  q.front();
    q.pop();
    for (auto to : g[v]) {
      if (!u[to]) {
        q.push(to);
        d[to] = d[v] + 1;
        u[to] = 1;
      }
    }
  }
  int mx = 0;
  for (int i = 1; i <= n; ++i) {
    if (d[i] > mx)
      mx = d[i];
  }
  if (mx % 3 == 1)
    cout << "Second";
  else
    cout << "First";
  return 0;
}


Measured memory_bytes: 38000
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)998244353;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var Mod = 998244353L;
            var N = Sarray()[0];
            var Ai = Sarray();
            var dct = new Dictionary<long, long>();
            if (Ai[0] != 0)
            {
                WriteLine(0);
                return;
            }
            for (var i = 0; i < N; ++i)
            {
                if (!dct.ContainsKey(Ai[i])) dct[Ai[i]] = 0;
                ++dct[Ai[i]];
            }
            if (1 != dct[0])
            {
                WriteLine(0);
                return;
            }
            var max = Ai.Max();
            var ans = 1L;
            for (var i = 1; i <= max; ++i)
            {
                if (!dct.ContainsKey(i))
                {
                    WriteLine(0);
                    return;
                }
                var t = ModPow(dct[i - 1], dct[i], Mod);
                ans = (ans * t) % Mod;
            }
            WriteLine(ans);
            //Out.Flush();
        }
        static long ModPow(long a, long n, long mod)
        {
            var res = 1L;
            while (0 < n)
            {
                if (n % 2 != 0) res = res * a % mod;
                a = a * a % mod;
                n >>= 1;
            }
            return res;
        }
    }
}

Measured memory_bytes: 28512
import java.util.Scanner;
public class Main {
		
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		
		String[][] map = 
			{
				{".", ",", "!", "?", " "},
				{"a", "b", "c"},
				{"d", "e", "f"},
				{"g", "h", "i"},
				{"j", "k", "l"},
				{"m", "n", "o"},
				{"p", "q", "r", "s"},
				{"t", "u", "v"},
				{"w", "x", "y", "z"}
			};
		
		for(int i = 0; i < n; i++){
			for(String str : sc.next().split("0")){
				if(str.length() == 0){
					continue;
				}
				
				System.out.print(map[str.toCharArray()[0] - '1'][(str.length() - 1) % map[str.toCharArray()[0] - '1'].length]);
			}
			System.out.println();
		}
	}
}

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

ll const m=1e9+7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int H,W; cin>>H>>W;
    char grid[H+1][W+1];
    for (int i1=1;i1<=W;i1++)
        grid[0][i1]='#';
    for (int i2=1;i2<=H;i2++)
        grid[i2][0]='#';
    grid[0][0]='#';
    for (int i=1;i<=H;i++) {
        for (int j=1;j<=W;j++)
            cin>>grid[i][j];
    }
    ll dp[H+1][W+1]; //number of paths i j me 
    dp[1][1]=1;
    for (int i=1;i<=H;i++) {
        for (int j=1;j<=W;j++) {
            if (grid[i][j]=='#' || (i==1 && j==1))
                continue;
            dp[i][j]=0;
            if (grid[i-1][j]=='.')
                dp[i][j]= (dp[i][j]%m + dp[i-1][j]%m)%m;
            if (grid[i][j-1]=='.')
                dp[i][j]= (dp[i][j]%m +dp[i][j-1]%m)%m;
        }
    }
    cout<<dp[H][W]<<"\n";
    return 0;
}

Measured memory_bytes: 9088
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------


int main(){
  int MAX = 101010;
  vector<int> is_prime(MAX,1);
  is_prime[0] = 0;
  is_prime[1] = 0;
  for(int i=2; i<=MAX; i++){
    if(!is_prime[i]) continue;
    for(int j=i*2; j<MAX; j+=i){
      is_prime[j] = 0;
    }
  }
  vector<int> vec(MAX+1,0);
  for(int i=0; i<MAX; i++){
    if(i%2){
      if(is_prime[i] && is_prime[(i+1)/2]){
        vec[i] = 1;
      }
    }
  }
  vector<int> sum(MAX+1,0);
  for(int i=0; i<MAX; i++){
    sum[i+1] += sum[i] + vec[i];
  }
  int Q;
  cin >> Q;
  for(int i=0; i<Q; i++){
    int l,r;
    cin >> l >> r;
    cout << sum[r+1] - sum[l] << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
def solve(string):
    n, m, *a = map(int, string.split())
    ans = [0] * (n + 1)
    a = set(a)
    ans[0] = 1
    ans[1] = 0 if 1 in a else 1
    for i in range(2, n + 1):
        if i in a:
            continue
        ans[i] += (ans[i - 2] + ans[i - 1]) % 1000000007
    return str(ans[-1])


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(m)])))


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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  i32 n, a, b;
  cin >> n >> a >> b;

  cout << min(a * n, b) << endl;

  return 0;
}


Measured memory_bytes: 3568
<?php
fscanf(STDIN, "%d", $N);
$ans = PHP_INT_MAX;
$sqrtN = sqrt($N);
for ($i = 1; $i <= $sqrtN; $i++) {
    if ($N % $i === 0) {
        $j = intdiv($N, $i);
        $ans = min($ans, $i + $j - 2);
    }
}
printf("%d", $ans);


Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
int N,d[100000+10]={};
signed main(){
  cin >> N;
  rep(i,N) cin >> d[i];
  sort(d,d+N);
  cout << d[N/2]-d[N/2-1] << endl;
  return 0;
}


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


int main() {
  int n, Y;
  cin >> n >> Y;
  bool ok = false;
  for (int x = 0; x <= n; x++) {
    for (int y = 0; y <= n; y++) {
      if (10000*x + 5000*y + 1000*(n - x - y) == Y && n - x - y >= 0) {
        ok = true;
        cout << x << ' ' << y << ' ' << n - x - y << endl;
        break;
      }
    }
    if (ok) {
      break;
    }
  }
  if (!ok) {
    cout << "-1 -1 -1" << endl;
  }
}

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

using namespace std;

using ll = long long;

int main(){
    ll n; cin >> n;
    vector<ll> v;
    ll i = 1;
    while(i <= 6){
        v.push_back(pow(6, i));
        v.push_back(pow(9, i));
        ++i;
    }
    v.push_back(1);
    sort(v.begin(), v.end());
    ll dp[100001] = {0};
    dp[0] = 0;
    for(ll i = 1; i <= n; ++i){
        dp[i] = 1e9;
        for(auto x:v){
            if(i - x >= 0)
                dp[i] = min(dp[i], dp[i - x] + 1);
        }
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    CIN(int, M);
    vector<int> ship(N);

    string ans = "IMPOSSIBLE";

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if (min(a,b) == 0) { ship[max(a,b)]++; }
        if (max(a,b) == N-1) { ship[min(a,b)]++; }
    }

    for (int i = 0; i < N; i++) {
        if (ship[i]==2) {
            ans = "POSSIBLE";
            break;
        }
    }

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

Measured memory_bytes: 1024
N = int(input())
L = [input() for i in range(N)]
L = sorted(L)
D = {}

for i in L:
    if i in D:
        V = D.get(i) + 1
    else:
        V = 1
    D[i] = V

D = sorted(D.items(),key=lambda x:x[1],reverse=True)

Ans = []

Ans.append(D[0][0])

for i in range(len(D)-1):
    if D[i][1] == D[i+1][1]:
        Ans.append(D[i+1][0])
    else:
        break

Ans = sorted(Ans)

for i in Ans:
    print(i)

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

  
int main2() {
  ll N, M;
  cin >> N >> M;
  if (N > M) swap(N, M);
  if (N == 1 && M == 1) {
    cout << 1 << endl;
    return 0;
  }
  if (N == 1) {
    cout << M-2 << endl;
    return 0;
  }
  cout << (N-2) * (M-2) << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#solve function
def solve(dates):
    counter = 0;
    start_month = dates[1]
    start_day, end_day = dates[2], 0

    for year in range(dates[0], 1000):
        for month in range(start_month, 11):
            if year%3 == 0 or month%2 == 1:
                end_day = 21
            else:
                end_day = 20

            # count days
            counter += (end_day - start_day)

            start_day = 1
        else:
            start_month = 1

    return counter


#main function
if __name__ == '__main__':
    n = int(input())

    dates = [0 for i in range(3)]
    tmp_dates = []
    for i in range(n):
        tmp_dates = input().split()
        for j in range(len(tmp_dates)):
            dates[j] = int(tmp_dates[j])

        date_count = solve(dates)
        print(date_count)

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

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

    int n;
    cin >> n;

    int cnt = 0;
    rep(i, n){
        int a, b;
        cin >> a >> b;

        if(a == b) ++cnt;
        else cnt = 0;

        if(cnt == 3){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3656
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int N = S.length();
		char last_1 = '!';
		String last_2 = "";
		int dp[][] = new int[N+1][2];
		for (int i=0;i<N;i++) {
			if (S.charAt(i) != last_1) {
				dp[i+1][0] = Math.max(dp[i][0], dp[i][1]) + 1;
			} else {
				dp[i+1][0] = dp[i][1] + 1;
			}
			if (i==0) {
				last_1 = S.charAt(i);
				continue;
			}
			if (String.valueOf(S.charAt(i)) + String.valueOf(S.charAt(i)) != last_2 ) {
				dp[i+1][1] = Math.max(dp[i-1][0], dp[i-1][1]) + 1;
			} else {
				dp[i+1][1] = dp[i-1][0] + 1;
			}
			last_1 = S.charAt(i);
			last_2 = String.valueOf(S.charAt(i)) + String.valueOf(S.charAt(i));
		}
		System.out.println(Math.max(dp[N][0], dp[N][1]));
	}
}

Measured memory_bytes: 68600
using System;
using System.Collections.Generic;

namespace P0024_PhysicalExperiments
{
    class Program
    {
        static void Main(string[] args)
        {

            var lines = new List<string>();

            while(true)
            {
                var line = Console.ReadLine();
                if (line == null) break;
                lines.Add(line);
            }

            foreach (var line in lines)
            {
                decimal v = decimal.Parse(line);
                decimal t = v / decimal.Parse("9.8");
                decimal y = decimal.Parse("4.9") * (t * t);
                decimal k = Math.Ceiling((y + decimal.Parse("5")) / decimal.Parse("5"));
                Console.WriteLine(k.ToString());

            }
        }
    }
}

Measured memory_bytes: 5904
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int number = sc.nextInt();
        int answer = 0;
        int max = 0;
        int allsum =0;
        int[] a = new int[number];
        for(int i= 0; i < number;i++){
            a[i] = sc.nextInt();
            if(a[i] >max){
                max = a[i];
            }
            allsum +=a[i];
        }
        max--;
        for(int j = 0; j < number;j++){
            answer += a[j]%max;
        }
        //System.out.print(answer);
        System.out.print(allsum -number);
    }
    
}


Measured memory_bytes: 28388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;long long ans;
int main()
{
   	scanf("%d",&n);
   	for(int i=1;i<=n;++i)ans+=1ll*i*(n-i+1);
   	for(int i=1,x,y;i<n;++i)
   	{
   		scanf("%d%d",&x,&y);
   		if(x>y)swap(x,y);
   		ans-=1ll*x*(n-y+1);
	}
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3804
import math
n,k = map(int,input().split())
sum_prob = 0

for i in range(1, n+1):
    count = math.ceil(math.log2(k/i))
    if i <= k:
        sum_prob += (1/n) * (1/2)**count
    else:
        sum_prob += (1/n)
print(sum_prob)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int N;
long long a[100010][3]; 
// DP テーブル
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

  
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n=sc.nextInt();
		boolean app=true;
		for(int i=0;i<n;i++) {
			int x=sc.nextInt();
			if(x%2==0&&x%3!=0&&x%5!=0) {
				app=false;
				break;
			}
		}
		if(app)
			pw.println("APPROVED");
		else
			pw.println("DENIED");
		pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}

Measured memory_bytes: 21332
#include<stdio.h>

int main(){
	int a,b;
	while(scanf("%d %d",&a,&b)!=EOF){
		printf("%d\n",keta(a+b));
	}
	return 0;
}

int keta(int a){
	int d=a,c=0;
	while(d!=0){
		d/=10;
		c++;
	}
	return c;
}

Measured memory_bytes: 600
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-6;
const vi emp;

ll Pow_mod(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r*=n;
		n*=n;
	}
	return r;
}

ll n,k;

int main(){
	cin>>n>>k;
	cout<<k*Pow_mod(k-1,n-1)<<endl;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define Si size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define Em empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define Fi first
#define Se second
#define Pi acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>

void FAST();
LL big_mod(LL val,LL pow,LL mod);
LL mod_inverse(LL val,LL mod);









int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,a[7],ans=0,mark=0,check;
    for(i=0; i<5; i++)
    {
        cin >> a[i];
        if(a[i]%10 == 0)
        {
            ans+=a[i];
        }
        else
        {
            check=((a[i]+9)/10)*10;
            if(check-a[i] > mark)
            {
                mark=check-a[i];
            }
            ans+=check;
        }
    }
    cout << ans-mark;
    return 0;
}







void FAST()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

LL big_mod(LL val,LL pow,LL mod)
{
    LL res = 1;
    val = val % mod;
    while(pow > 0)
    {
        if(pow & 1)
        {
            res = (res*val) % mod;
        }
        pow = pow >> 1;
        val = (val*val) % mod;
    }
    return res;
}

LL mod_inverse(LL val,LL mod)
{
    LL mod1 = mod;
    if(mod == 1)
    {
        return 0;
    }
    LL y = 0;
    LL x = 1;
    LL quotient,temp;
    while(val > 1)
    {
        quotient = val / mod;
        temp = mod;
        mod = val % mod;
        val = temp;
        temp = y;
        y = x - quotient * y;
        x = temp;
    }
    if(x < 0)
    {
        x += mod1;
    }
    return x;
}


Measured memory_bytes: 256
<?php
$A=[];
for($i=97;$i<123;$i++) $A[$i]=0;

while(1){
  $S=trim(fgets(STDIN));
  if(!$S){break;}

  foreach(str_split($S) as $c){
    $n=ord($c);
    if(64<$n && $n<91) ++$A[$n+32];
    elseif(96<$n && $n<123) ++$A[$n];
  }
}

for($i=97;$i<123;$i++) echo chr($i),' : ',$A[$i],PHP_EOL;

Measured memory_bytes: 15592
#include <iostream>
using namespace std;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
int main() {
	int n, p; cin >> n;
	int* a = new int[n + 1];
	rep(i, 1, n + 1) {
		cin >> p;
		a[p] = i;
	}
	rep(i, 1, n + 1) cout << n * i << " \n"[i == n];
	rep(i, 1, n + 1) cout << n * (n - i) + a[i] << " \n"[i == n];
	delete[] a;
	return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
using namespace std;int main(void){int N,ans=0;cin>>N;vector<int>vec(N);rep(i,0,N)cin>>vec[i];for(int v:vec)ans^=v;for(int v:vec)cout<<(ans^v)<<" ";cout<<endl;}

Measured memory_bytes: 3964
#include <stdio.h>
int main(void){
	int a,b,ans=0;
	scanf("%d%d",&a,&b);
	for(int i=0;i<2;i++){
		if(a>b){
			ans+=a;
			a--;
		}else{
			ans+=b;
			b--;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int A[] = new int[n];
		String[] tmps = br.readLine().split(" ");
		for(int i = 0 ; i < n ; i++){
			A[i] = Integer.parseInt(tmps[i]);
		}
		int q = partition(A,0,n - 1);
		disp(A,n,q);
	}

	public static void disp(int[] A,int n,int q){
		StringBuffer sb = new StringBuffer();
		for(int i = 0 ; i < n ; i++ ){
			if(i == q){
				sb.append("[");
				sb.append(A[i]);
				sb.append("]");
				sb.append(" ");
			}else{
				sb.append(A[i]);
				sb.append(" ");
			}
		}
		System.out.println(sb.toString().trim());
	}

	public static int partition(int[] A,int p,int r){
		int x = A[r];
		int mI = -1;
		int tmp;
		for(int i = 0 ; i < r ; i++){
			if(A[i] <= x){
				tmp = A[i];
				A[i] = A[++mI];
				A[mI] = tmp;
			}
		}
		tmp = x;
		A[r] = A[++mI];
		A[mI] = tmp;
		return mI;
	}
}

Measured memory_bytes: 41232
#include<stdio.h>
#include<stdlib.h>

int linearSearch(int);

int n,*S;

int main()
{
  int q,i,x,c = 0;
  int *T;

  scanf("%d",&n);
  S = (int *)malloc(sizeof(int) * n);
  if(S == NULL) exit(1);
  for(i = 0;i < n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  T = (int *)malloc(sizeof(int) * q);
  if(T == NULL) exit(1);
  for(i = 0;i < q;i++){
    scanf("%d",&T[i]);
    }
  
  for(i = 0;i < q;i++){
    x = linearSearch(T[i]);
    if(x != -1) c ++;
  }
  printf("%d\n",c);
  return 0;
}

int linearSearch(int key)
{
  int i;
  
  i = 0;
  S[n] = key;

  while(S[i] != key){
    i++;
    if(i == n) return -1;
  }
  return i;
}
 

Measured memory_bytes: 636
a,b,k = input().split()
a = int(a)
b = int(b)
k = int(k)
list_yakusu = list()
if(a > b):
    tmp = a
    a = b
    b = tmp
for i in range(1, a+1):
    if(a % i == 0 and b % i == 0):
        list_yakusu.append(i)
list_yakusu.sort(reverse=True)
print(list_yakusu[k-1])


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define P pair<int, int>
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    vector<int>an(32);
    for(int i = 0; i < 32; i++){
        an.at(i) = 1;
    }
    an.at(3) = 2;
    an.at(5) = 2;
    an.at(7) = 5;
    an.at(8) = 2;
    an.at(9) = 2;
    an.at(11) = 5;
    an.at(13) = 2;
    an.at(15) = 14;
    an.at(17) = 5;
    an.at(19) = 5;
    an.at(20) = 2;
    an.at(21) = 2;
    an.at(23) = 15;
    an.at(24) = 2;
    an.at(25) = 2;
    an.at(26) = 5;
    an.at(27) = 4;
    an.at(29) = 4;
    an.at(31) = 51;
    int k;
    cin >> k;
    k--;
    cout << an.at(k) << endl;

    solve();
    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 ll long long int

int main()
{
  int n;
  cin >> n;
  ll a[n];
  map<ll, int> m;
  rep(i, n)
  {
    cin >> a[i];
    m[a[i]]++;
  }
  int ans = 0;
  for (auto i : m)
  {
    if (i.second % 2 == 1)
    {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n;
  std::cin >> n;

  std::vector<int> x(n);
  std::vector<int> y(n);
  for(int i = 0; i < n; ++i) {
    std::cin >> x[i];
  }
  for(int i = 0; i < n; ++i) {
    std::cin >> y[i];
  }

  double Manhattan = 0.0;
  for(int i = 0; i < n; ++i) {
    Manhattan += std::abs(x[i] - y[i]);
  }

  double Euclidean = 0.0;
  for(int i = 0; i < n; ++i) {
    Euclidean += std::abs(x[i] - y[i]) * std::abs(x[i] - y[i]);
  }
  Euclidean = sqrt(Euclidean);

  double Euclidean_p3 = 0.0;
  for(int i = 0; i < n; ++i) {
    Euclidean_p3 += std::abs(x[i] - y[i]) * std::abs(x[i] - y[i]) * std::abs(x[i] - y[i]);
  }
  Euclidean_p3 = pow(Euclidean_p3, double(1.0/3.0));

  double Chebyshev = std::abs(x[0] - y[0]);
  for(int i = 1; i < n; ++i) {
    double tmp = std::abs(x[i] - y[i]);
    if(Chebyshev < tmp) {
      Chebyshev = tmp;
    }
  }

  printf("%.5f\n", Manhattan);
  printf("%.5f\n", Euclidean);
  printf("%.5f\n", Euclidean_p3);
  printf("%.5f\n", Chebyshev);

  return 0;
}

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

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

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define sp << ' ' << 
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353

int main()
{
    boost;
    ll tt = 1, n, k = 0, i, j;
    ll q, l = 0, r = 0, x, y, z, h, d;

    bool poss = true;
    string m;

    // cin >> tt;
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> k >> x >> y;

        ll ans = ceil(1.0*x/k)*k;
        if(ans <= y){
            cout << "OK" << nl;
        }
        else cout << "NG" << nl;
    }   
    return 0;
}

Measured memory_bytes: 3652
s = input()
t = []
r = 0

for i in range(len(s)):
    if s[i] == '0':
        t.append('0')
        r += 1
    elif s[i] == '1':
        t.append('1')
        r += 1    
    else:
        if r != 0:
            t.pop(r-1)
            r -= 1

print(''.join(t))

Measured memory_bytes: 9064