akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
int n=0;
int x=0;

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

cout<<a[0];
for(int i=1;i<n;i++){
cout<<" "<<a[i];
}
return 0;

}




Measured memory_bytes: 4312
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
vector<vector<ll>>adj(500000);
ll visited[500000]{0};
int main()
{
    ll x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z;
}

Measured memory_bytes: 11904
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s = iterator.next().unwrap();
    return format!("{} {}", &s[0..4], &s[4..12]);
}


Measured memory_bytes: 2076
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var line = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
			WriteLine(line[2] * 60 + line[3] - (line[0] * 60 + line[1]) - line[4]);
		}
	}
}


Measured memory_bytes: 19032
class WhiteCellsAnswer
  def self.white_cells(h1, w1, h2, w2)
    (h1 - h2) * (w1 - w2)
  end
end

h1, w1, h2, w2 = STDIN.read.split(/\s+/).map(&:to_i)
puts WhiteCellsAnswer.white_cells(h1, w1, h2, w2)

Measured memory_bytes: 1788
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}
 
 
 
 
int main(){
 
    ios_base::sync_with_stdio(0);
 
    string str;
    cin>>str;
 
    for(int i=0;i<4;i++)
        cout<<str[i];
    cout<<" ";
    for(int i=4;i<str.length();i++)
        cout<<str[i];
 cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
constexpr int MOD = 1e9 + 7;
int dp[5005][5005];
char str[5005];
int main()
{
	// freopen("ARC059-F.in", "r", stdin);
	int n;
	scanf("%d%s", &n, str);
	int m = strlen(str);
	dp[0][0] = 1;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j <= n; j++)
		{
			(dp[i + 1][j + 1] += dp[i][j]) %= MOD;
			(dp[i + 1][j + 1] += dp[i][j]) %= MOD;
			(dp[i + 1][j ? j - 1 : 0] += dp[i][j]) %= MOD;
		}
	}
	long long ans = dp[n][m];
	for (int i = 0; i < m; i++)
		ans = ans * (MOD + 1) / 2 % MOD;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 97920
#include <bits/stdc++.h>
#define rep0(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;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

int main()
{
    int N,K;
    cin >> N >> K;
    ll input[N] = {};
    rep0(i,N){
        cin >> input[i];
    }
    sort(input,input+N);
    ll res = pow(10,9)+1;
    rep0(i,N-K+1){
        if(res > input[i+K-1]-input[i]){
            res = input[i+K-1]-input[i];
        }
    }
    cout <<res << endl;
}


Measured memory_bytes: 4364
N=gets.to_i
F=(1..N).map{gets.split.map(&:to_i)}
P=(1..N).map{gets.split.map(&:to_i)}
p (1..1023).map{|b|
    (0...N).map{|k|
        s=b.to_s(2).rjust(10,"0")
        P[k][10.times.map{|i|s[i].to_i*F[k][i]}.inject(:+)]
    }.inject(:+)
}.max

Measured memory_bytes: 3964
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);
            Arrays.sort(a);
            out.println(a[n - 1] - a[0]);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

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

    }
}



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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  sort(a, a + N);
  ll ans = a[N-1];
  int idx = N - 2;
  for (int i = 0; i < (N - 2) / 2; i++) {
    ans += a[idx] * 2;
    idx--;
  }
  if (N & 1) ans += a[idx];

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5200
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> A(N+1,0);
    long long ans=0;
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    if(A[0]!=0){
        cout << -1 << endl;
        return 0;
    }
    for(int i=N-1; i>=0; i--){
        cin >> A[i];
        if(A[i]<A[i+1]-1){
            cout << -1 << endl;
            return 0;
        }
        if(A[i]==A[i-1]+1){
            ans++;
        }else if(A[i]<=i){
            ans+=A[i];
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
N, M = [int(x) for x in input().split()]
T = [tuple(int(x) for x in input().split()) for i in range(N)]

res = 0
for value, num in sorted(T):
  if M >= num:
    res += value*num
    M -= num
  else:
    res += value * M
    break

print(res)

Measured memory_bytes: 17768
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  u64 n;
  cin >> n;
  u64 a[n];
  cin >> a[0];
  for (u64 i = 1; i < n; ++i) {
    cin >> a[i];
    if (a[i] == a[i-1]) {
      n--;
      i--;
    }
  }
  if (n==1) {cout << 1 << endl; return 0;}
  bool isup = (a[0] <= a[1] ? true : false);
  u64 cnt = 1;
  for (u64 i = 2; i < n; ++i) {
    if ((isup && a[i-1]>a[i]) || (!isup && a[i-1]<a[i])) {
      cnt++;
      if (i==n) break;
      isup = (a[i] <= a[i+1] ? true : false);
      i++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1024
//Work should be challenging and challange should be fun

#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll m=1e9+7;
ll fpow(ll a,ll p){
    if(p==0) return(1);
    ll b=fpow(a,p/2);
    if(p%2==0) return((b*b)%m);
    else return((((b*b)%m)*a)%m);
}

int main(){
    ll n;
    cin>>n;
    ll ans=(fpow(10,n)-2*fpow(9,n)+fpow(8,n)+5*m)%m;
    cout<<ans;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    ll r, D, x;
    cin >> r >> D >> x;
    REP(i, 10) {
        x = r * x - D;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = [[a[i], i] for i in range(n)]
b.sort(reverse = True)
dp = [[0] * (n + 1) for _ in range(n + 1)]
for i in range(n + 1):
    for j in range(n - i + 1):
        k = i + j - 1
        if k == -1:
            continue
        if i == 0:
            dp[i][j] = dp[i][j - 1] + abs(b[k][1] - (n - j)) * b[k][0]
        elif j == 0:
            dp[i][j] = dp[i - 1][j] + abs(b[k][1] - (i - 1)) * b[k][0]
        else:
            dp[i][j] = max(dp[i][j - 1] + abs(b[k][1] - (n - j)) * b[k][0], dp[i - 1][j] + abs(b[k][1] - (i - 1)) * b[k][0])
ans = 0
for i in range(n + 1):
    ans = max(ans, dp[i][n - i])
print(ans)

Measured memory_bytes: 100456
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int cnt[105];
signed main(){
	ios_base::sync_with_stdio(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ans=0;
	for(int i=a+1;i<=b;i++) cnt[i]++;
	for(int i=c+1;i<=d;i++) cnt[i]++;
	for(int i=1;i<=100;i++) if(cnt[i]==2) ans++;
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3588
N = int(input())
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(N)]
dp[0] = 0
for i in range(1, N):
	dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
	if i > 1:
		dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[N - 1])


Measured memory_bytes: 13928
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,i,j,a[110][110],b[10001][2];
int main(){
	scanf("%d",&n);
	if(n%2){
		for(i=1;i<n-1;i++)if(i<n-i)a[i][n-i]=1;
	}
	 else{
	 	for(i=1;i<n;i++)if(i<n-i+1)a[i][n-i+1]=1;
	 }
	for(i=1;i<n;i++)
	 for(j=i+1;j<=n;j++)if(!a[i][j])b[++m][0]=i,b[m][1]=j;
	printf("%d\n",m);
	for(i=1;i<=m;i++)printf("%d %d\n",b[i][0],b[i][1]);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n,k;
	cin>>n>>k;
	int ma = (n-1)*(n-2)/2;
	if( ma < k ) {
		cout<< -1<<endl;
		return 0;
	}
	int ans=0;
	vector< pair<int,int> > v;
	for(int i=2;i<=n;i++){
		ans ++ ;
		v.pb( mp ( 1, i ));
	}
	vector< pair<int,int> > cnd;
	for(int i=2;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			cnd.pb( mp (i,j) );
		}
	}
	for(int i=0;i<ma-k;i++){
		v.pb( cnd[i] );
		ans++;
	}
	cout<<ans<<endl;
	for(int i=0;i<v.size();i++){
		cout<<v[i].first<<" "<<v[i].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,Q;
  string S;
  cin>>N>>S>>Q;
  while(Q--){
    int k,ans=0,D=0,M=0,DM=0;
    cin>>k;
    for(int i=0;i<N;i++){
      if(i>=k){
        if(S[i-k]=='D')D--,DM-=M;
        else if(S[i-k]=='M')M--;
      }
      if(S[i]=='D')D++;
      else if(S[i]=='M')M++,DM+=D;
      else if(S[i]=='C') ans+=DM;
    }
    cout<<ans<<endl;
  }
}

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

struct Data{
  
  int t,s,d;

  bool operator<(const Data& data)const{
    if(data.t != t)return t < data.t;  
    if(data.s != s)return s < data.s;
    return d < data.d;
  }
  
};
int main(){

  int N,M;
  
  while(1){

    cin >>N>>M;
    if(N==0 && M==0)break;
    
    Data data[M];
    for(int i=0 ; i < M ; i++){
      cin >>data[i].t>>data[i].s>>data[i].d;
    }
    
    sort(data,data+M);
    
    bool isinfected[N+1];
    for(int i=1 ; i <= N ; i++)isinfected[i]=false;
    isinfected[1]=true;
    
    int cnt=1;
    for(int i=0 ; i < M ; i++){
      if(isinfected[data[i].s] && !isinfected[data[i].d]){
	isinfected[data[i].d]=true;
	cnt++;
      }
    }
    
    cout <<cnt<<endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 1432
#include <stdio.h>
#include <string.h>

int main(void) {
    char pattern[8][8];
    int r, c;
    int count = 0;
    
    for(r = 0 ; r < 8; r++) {
        scanf("%s", pattern[r]);
    }
    
    while(count++ < 3) {
        printf("%d\n", count * 90);
        
        for(c = 0; c < 8; c++) {
            for(r = 0; r < 8; r++) {
                switch(count) {
                    case 1: printf("%c", pattern[7 - r][c]);    break;
                    case 2: printf("%c", pattern[7 - c][7 - r]);break;
                    case 3: printf("%c", pattern[r][7 - c]);    break;
                }
            }
            putchar('\n');
        }
    }
    
    return(0);
}

Measured memory_bytes: 544
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n, m, q;
    scanf("%d %d", &n, &m);
    vector<vector<int> > a(n, vector<int>(0));
    for (int i = 0, j, k; i < m; i++)
    {
        scanf("%d %d", &j, &k);
        a[j].push_back(k);
        a[k].push_back(j);
    }
    vector<int> vis(n, -1);
    for (int i = 0; i < n; i++)
    {
        
        if (vis[i] == -1)
        {
            stack<int> b;
            b.push(i);
            vis[i] = i;
            for (int t; !b.empty(); )
            {
                t = b.top();
                b.pop();
                for (int j = 0; j < a[t].size(); j++)
                {
                    
                    if (vis[a[t][j]] == -1)
                    {
                        vis[a[t][j]] = i;
                        b.push(a[t][j]);
                    }
                }
            }
        }
    }
    
    scanf("%d", &q);
    for (int i = 0, j, k; i < q; i++)
    {
        scanf("%d %d", &j, &k);
        printf(vis[j] == vis[k] ? "yes\n" : "no\n");
    }
}


Measured memory_bytes: 8664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll comb[100][100];
ll N = 40;

void initialize() {
    for(int i = 0; i < 100; i++) {
        comb[i][0] = 1;
        for(int j = 1; j < i; j++) {
            comb[i][j] = comb[i-1][j] + comb[i-1][j-1];
        }
        comb[i][i] = 1;
    }
}

ll beki(ll a, ll b) {
    if(b == 0) return 1;
    ll ret = beki(a, b / 2);
    ret = ret * ret;
    if(b & 1) ret *= a;
    return ret;
}

ll f(ll num, ll x, ll y) {
    ll ret = 0;
    for(int j = 1; j <= x; j++) {
        ret += comb[x][j] * comb[num-x][j];
    }
    ret *= y;
    ret += beki(2, y) - 1;
    return ret;
}

ll before[205];
ll afternum[205];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    initialize();
    /*
    for(int i = 0; i <= N / 2; i++) {
        cerr << i << " " << f(i) << endl;
    }
    */
    ll num = 1;
    ll N;
    cin >> N;
    while(beki(2, num) - 1 <= N) num++;
    N -= beki(2, num - 1) - 1;
    int index = 0;
    while(N > 0) {
        index++;
        int now = 0;
        while((now + 1) * 2 <= num && f(num, now + 1, 1) <= N) {
            now++;
        }
        int now2 = 1;
        while(f(num, now, now2 + 1) <= N) now2++;
        N -= f(num, now, now2);
        //cerr << f(num, now, now2) << endl;
        before[index] = now;
        afternum[index] = now2;
    }
    //cerr << "num:" << num << endl;
    //for(int i = 1; i <= index; i++) cerr << i << " " << before[i] << " " << afternum[i] << endl;
    vector<int> ans;
    for(int i = index; i >= 1; i--) {
        for(int j = before[i+1]; j < before[i]; j++) ans.push_back(100);
        ans.push_back(i);
    }
    for(int j = before[1]; j < num; j++) ans.push_back(100);
    for(int i = 1; i <= index; i++) {
        for(int j = 0; j < afternum[i]; j++) ans.push_back(i);
    }
    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
const int mod=998244353;
const int M=14;
int n,m,ans,f[8010],F[8010];
int r[1<<M],A[1<<M],B[1<<M],a[1<<M],b[1<<M];
void inc(int &a,int b){
	(a+=b)%=mod;
}
int C(int n,int m){
	if(n<m||n<0||m<0)return 0;
	return 1LL*f[n]*F[m]%mod*F[n-m]%mod;
}
int mi(int a,int b){
	int s=1;
	for(;b;b>>=1,a=1LL*a*a%mod)
		if(b&1)s=1LL*s*a%mod;
	return s;
}
void NTT(int*a,int tp){
	ref(i,0,(1<<M)-1)if(r[i]<i)swap(a[i],a[r[i]]);
	for(int i=2;i<=(1<<M);i<<=1){
		int I=i>>1,w=mi(3,(mod-1)/i);
		if(tp<0)w=mi(w,mod-2);
		for(int j=0;j<(1<<M);j+=i)
			for(int k=j,W=1;k<j+I;++k,W=1LL*W*w%mod){
				int A=a[k],B=1LL*a[k+I]*W%mod;
				a[k]=(A+B)%mod;a[k+I]=(mod+A-B)%mod;
			}
	}
	int ni=mi(1<<M,mod-2);
	if(tp<0)ref(i,0,(1<<M)-1)a[i]=1LL*a[i]*ni%mod;
}
int main(){
	cin>>n>>m;
	f[0] = 1;
	ref(i,1,n)f[i] = 1LL*f[i-1]*i%mod;
	F[n] = mi(f[n], mod-2);
	def(i,n,1)F[i-1] = 1LL*F[i]*i%mod;
	ref(i,1,(1<<M)-1)r[i]=(r[i>>1]>>1)|((i&1)<<M-1);
	A[0] = 1;
	ref(i,1,m){
		memset(a,0,sizeof a);
		memset(b,0,sizeof b);
		ref(j,0,n)a[j]=1LL*A[j]*F[j]%mod;
		ref(j,0,n)b[j]=F[j];
		NTT(a,1); NTT(b,1);
		ref(j,0,(1<<M)-1)b[j]=1LL*a[j]*b[j]%mod;
		NTT(b,-1);
		ref(j,0,n)inc(B[j],b[j]);
		memset(a,0,sizeof a);
		memset(b,0,sizeof b);
		ref(j,1,n)a[j]=1LL*A[j]*F[j-1]%mod;
		ref(j,1,n)b[j]=F[j+1]*2%mod; b[0]=F[1];
		NTT(a,1); NTT(b,1);
		ref(j,0,(1<<M)-1)b[j]=1LL*a[j]*b[j]%mod;
		NTT(b,-1);
		ref(j,0,n)inc(B[j],b[j]);
		memset(a,0,sizeof a);
		memset(b,0,sizeof b);
		ref(j,2,n)a[j]=1LL*A[j]*F[j-2]%mod;
		ref(j,0,n)b[j]=F[j+2];
		NTT(a,1); NTT(b,1);
		ref(j,0,(1<<M)-1)b[j]=1LL*a[j]*b[j]%mod;
		NTT(b,-1);
		ref(j,0,n)inc(B[j],b[j]);
		
		ref(j,0,n)A[j]=1LL*B[j]*f[j]%mod,B[j]=0;
	}
	ref(i,0,n)inc(ans,1LL*C(n,i)*A[i]%mod);
	cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
  
int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s.at(i);

  int m;
  cin >> m;
  vector<string> t(m);
  rep(i,m) cin >> t.at(i);
  
  int ans=0;
  rep(i,n) {
    int point=0;
    rep(j,n) if(s.at(j)==s.at(i)) point++;
    rep(j,m) if(t.at(j)==s.at(i)) point--;
    ans=max(ans,point);
  }
  cout << ans << endl;
}

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

int m, n;

bool nImage[50][50];
bool mImage[50][50];

int main() {
	cin >> n >> m;
	
	char c;
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) {
		cin >> c;
		nImage[i][j] = (c == '#');
	}
	for(int i = 0; i < m; i++) for(int j = 0; j < m; j++) {
		cin >> c;
		mImage[i][j] = (c == '#');
	}
	bool ans = false;
	for(int i = 0; i <= n-m; i++) for(int j = 0; j <= n-m; j++) {
		bool valid = true;
		for(int mi = i; mi < i+m; mi++) for(int mj = j; mj < j+m; mj++) {
			valid = (valid && (nImage[mi][mj] == mImage[mi-i][mj-j]));
		}
		ans = (ans || valid);
	}

	cout << (ans? "Yes":"No") << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    String S = sc.next();
    char[] str = S.toCharArray();
    
    int countC = 0;
    int countBig = 0;
      if(str[0] == 'A'){
        for(int i = 2 ; i <= str.length-2 ; i++){
          if(str[i] == 'C'){
            countC++;
          }
        }
        if(countC == 1){
          for(int j = 0 ; j < str.length ; j++){
            char h = str[j];
            if(Character.isUpperCase(h)){
              countBig++;
            }
          }
          if(countBig == 2){
            System.out.println("AC");
          }else{
            System.out.println("WA");
          }         
        }else{
          System.out.println("WA");
        }       
      }else{
        System.out.println("WA");
      }   
  }
}

Measured memory_bytes: 35512
#include<bits/stdc++.h>
#define il inline
#define vd void
#define mod 1000000007
typedef long long ll;
il int gi(){
	int x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int f[2010][2010];
int inv[4001000],C[4001000];
int main(){
	int n=gi(),k=gi();
	if(k==1)return puts("1"),0;
	inv[1]=1;for(int i=2;i<=n*k;++i)inv[i]=mod-1ll*(mod/i)*inv[mod%i]%mod;
	C[k-2]=1;
	for(int i=k-1;i<=n*k;++i)C[i]=1ll*C[i-1]*inv[i-k+2]%mod*i%mod;
	f[0][0]=1;
	for(int i=1;i<=n;++i)
		for(int j=0;j<=std::min(i,n);++j){
			f[i][j]=f[i-1][j];
			if(j)f[i][j]=(f[i][j]+1ll*C[(n-i)+(n-j+1)*(k-1)-1]*f[i][j-1]%mod*(n-j+1)%mod)%mod;
		}
	printf("%d\n",f[n][n]);
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
constexpr ll mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
using namespace std;
int n;
vector<int> E[200000];
vector<double> ret(200000);
void dfs(int u,int pre){
    double r = 0.0;
    int ch = 0;
    for(auto v : E[u])if(pre != v){
        dfs(v,u);
        r += ret[v] + 1.0;
        ch++;
    }
    if(ch >= 1) ret[u] = r/ch;
}
void dfs2(int u,double pv,int pre){
    double r = 0.0;
    for(auto v : E[u]){
        if(pre == v) r += pv + 1.0;
        else r += ret[v] + 1.0;
    }
    ret[u] =r / E[u].size();
    for(auto v :E[u])if(pre != v){
        dfs2(v,(r-ret[v]-1.0)/max(1,(int)(E[u].size() - 1)),u);
    }
}
int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    cin>>n;
    for(int i=0;i<n-1;++i){
        int u,v;
        cin>>u>>v;
        u--;v--;
        E[u].push_back(v);
        E[v].push_back(u);
    }
    dfs(0,-1);
    dfs2(0,0,-1);
    
    for(int i=0;i<n;++i)cout << fixed << std::setprecision(10) << ret[i] << endl;
    return 0;
}

Measured memory_bytes: 20012
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
A,B = list(map(int,input().split()))

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if gcd(A,B) == 1:
  print(1)
else:
  print(len(factorization(gcd(A,B)))+1)

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

using namespace std; 

int main() {
    int N, K;
    cin >> N >> K;
    int digit = 0;

    while(N > 0) {
        N /= K;
        digit++;
    }

    cout << digit << endl;
}

Measured memory_bytes: 256
import numpy as np

c = np.zeros(int(2e5))
c_1 = np.ones(int(2e5))

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

for i in range(n):
    c[a[i] - 1] += 1

ans = int(sum(c * (c - c_1) / 2))

for i in range(n):
    print(ans - int(c[a[i]-1]-1))

Measured memory_bytes: 35668
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    if(a+b-1 > n || n > (ll)a*b){
        cout << "-1\n";
        return 0;
    }
    int kp = n;
    vvi ans(a);
    n -= a;
    int st = 1;
    rep(i,a){
        if(n >= b-1){
            ans[i].resize(b);
            rep(j,b-1){
                ans[i][j+1] = b-2+st-j;
            }
            n -= b-1;
            st += b-1;
        }else if(n == 0){
            ans[i].resize(1);
        }else{
            ans[i].resize(n+1);
            rep(j,n){
                ans[i][j+1] = n-1+st-j;
            }
            st += n;
            n = 0;
        }
        ans[i][0] = kp-a+1+i;
    }
    rep(i,a){
        rep(j,len(ans[i])){
            cout << ans[i][j] << " ";
        }
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 16640
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

graph = [[] for _ in range(n)]
for i in range(m):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    graph[x].append(y)
    graph[y].append(x)

memo = [-1] * n

def dfs(v, memo):
    memo[v] = 1
    for nv in graph[v]:
        if memo[nv] != -1:
            continue
        dfs(nv, memo)

ans = 0

for i in range(n):
    if memo[i] != -1:
        continue
    dfs(i, memo)
    ans += 1

print(ans)

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

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

	std::string s;
	std::cin>>s;

	int numW=0;

	for(int i=0; i< n; i++)
		if(s[i]=='W')
			numW++;


	int numChange=0;

	for(int i=0; i< n-numW; i++){
		if(s[i]=='W')
			numChange++;
	}

	if(numW==n){
		std::cout<<0<<std::endl;
	}
	else{
		std::cout<<numChange<<std::endl;

	}

	return 0;	
}

Measured memory_bytes: 3752
def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    print(solve(a))

def solve(a):
    c = dict()
    for i in a:
        c[i] = c.get(i, 0) + 1
    
    return count(i for i in c.values() if i % 2 != 0)

def count(it):
    c = 0
    for _ in it:
        c += 1
    return c

main()


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

using namespace std;

void Q1() {

	double r;
	double PI = 3.141592653589;
	cin >> r;

	printf("%lf %lf\n", PI*r*r, 2 * r*PI);

}

void Q2() {
	int a, b;
	string op;

	while (true)
	{
		cin >> a >> op >> b;
		if (op == "?") { break; }
		else if (op == "+") {
			cout << a + b << endl;
		}
		else if (op == "-") {
			cout << a - b << endl;
		}
		else if (op == "*") {
			cout << a * b << endl;
		}
		else if (op == "/"){
			cout << a / b << endl;
		}
	}
	
}

void Q3() {
	int x; cin >> x;
	long long sum = 0;
	vector<int> a;
	a.resize(x);

	for (int i = 0; i < x; i++) {
		cin >> a[i];
		sum += a[i];

	}

	sort(a.begin(), a.end());

	cout << a[0] << " " << a[x - 1] << " " << sum << endl;
}

void Q4() {

	while (true)
	{
		int a, b;
		cin >> a >> b;

		if (a == 0 && b == 0)break;

		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				cout << "#";
				if (j == b - 1) {
					cout << "\n";
					break;
				}
			}
		}

		cout << "\n";
	}
}

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

Measured memory_bytes: 1252
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val listOfNumbers = readLine()!!.split(" ").map(String::toInt)
    var deletionCount = 0
    var currentIndex = 1
    var found = false
    for (x in listOfNumbers) {
        if (x == currentIndex) {currentIndex++; found = true}
        else deletionCount++
    }
    if (found) println(deletionCount)
    else println(-1)
}

Measured memory_bytes: 83060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N;
	string S, T;

	cin >> N >> S >> T;

	rep(i, N) {
		cout << S[i] << T[i];
	}
	cout << endl;

	return 0;
}

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

using namespace std;

#define DIM 27
#define INF 10000000007
#define X 40000
#define epc 0.0000000000000000000001
#define pi 3.14159265358979323846
#define MAX 25

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<ll,ll> pllll;
typedef pair<I,I> pII;

typedef queue<ll> qll;
typedef queue<I> qI;
typedef priority_queue<long long> pqllmin;
typedef priority_queue<pllll,vector<pllll>,greater<pllll> > pqpllllmax;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef set<I> sI;
typedef set<ll> sll;

typedef stack<I> stI;
typedef stack<ll> stll;

typedef char cr;
typedef string str;

ll n,c0,c1;

int main()
{
    //freopen("input.txt","r",stdin);
    //cout<<"ops"<<endl;

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1;i<=n;i++){
     if(i%2==1)c1++;
     else c0++;
    }
    cout<<c0*c1<<endl;
}


Measured memory_bytes: 256
<?php
$n = intval(fgets(STDIN));
for($i = 0; $i < $n; $i++){
  $a[$i] = intval(fgets(STDIN));
  for($j = 0; $j < $a[$i]; $j++){
    fscanf(STDIN, '%d%d', $b, $c);
    $map[$i][$b-1] = $c; 
  }
}
$max = 0;
for($i = 0, $I = 2**$n; $i < $I; $i++){
  $bits = sprintf('%0'.$n.'b', $i);
  foreach($map as $from => $row){
    if($bits[$from] === '1'){ 
      foreach($row as $to => $v){
        if($bits[$to] != $v){ 
          continue 3;
        }
      }
    }
  }
  $sum = 0;
  for($j = 0; $j < $n; $j++){
    $sum+=$bits[$j];
  }
  $max = max($max, $sum);
}
echo $max;


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

char S[10];

ll i, j, k;
int main(){
    scanf("%s", S);
    if(S[2]==S[3]&&S[4]==S[5]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
////=====BIsmillahir Rahmanir Rahim =====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
         Comilla University

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define fi 2*acos(0.0)
#define ll  long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl printf("\n")
#define infinity 1e16
#define mod 1000000007
#define cn continue
#define csprint1 printf("Case %lld: ", cs++)
#define csprint2 printf("Case %lld:\n", cs++)
#define sf(a) scanf("%lld", &a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define all(v) v.begin(),v.end()
#define pfn(a) printf("%lld\n",a)
#define pfs(a) printf("%lld ",a)

using namespace __gnu_pbds;
using namespace std;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<pl> vpi;
typedef vector<pl> vpl;
typedef tree<pair<ll, int> , null_type, less<pair<ll, int> >, rb_tree_tag, tree_order_statistics_node_update> ost;
#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 <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(int mask,int bit){return mask & (1<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

/*----------------------Graph Moves----------------*/
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

///=====================================///

const int  maX=1e5+10;
int a[2005];
int main()
{
    ll n;
    sf(n);
    ll ara[n];
    ll dp[maX];
    for(ll i=0;i<n;i++)dp[i]=infinity;
    dp[0]=0;
    for(ll i=0;i<n;i++){
        sf(ara[i]);
        if(i-1>=0){
            dp[i]=min(dp[i],dp[i-1]+abs(ara[i]-ara[i-1]));
        }
        if(i-2>=0){
            dp[i]=min(dp[i],dp[i-2]+abs(ara[i]-ara[i-2]));
        }
    }
    pfn(dp[n-1]);

return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	ll x; cin>>x;
	ll ret = 2*(x/11);
	x %= 11;
	if(x > 0)ret++;
	if(x > 6)ret++;
	cout<<ret<<endl;

	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		TreeMap<String, Integer> map = new TreeMap<String, Integer>();
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int max = 0;
		for(int i = 0; i < n; i++) {
			String s = scan.next();
			if(map.containsKey(s)) {
				int num = map.get(s) + 1;
				map.put(s, num);
				if(max < num) max = num;
			} else {
				map.put(s, 1);
				if(max < 1) max = 1;
			}
		}
		for(String val: map.keySet()) {
			if(map.get(val) == max)	System.out.println(val);
		}
		scan.close();
	}

}


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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        pair sp = new pair();
        int x = 0, y = 0, h = 0;
        pair[] p = new pair[n];
        boolean start = true;
        for (int i = 0; i < n; i++) {
            x = in.ni(); y = in.ni(); h = in.ni();
            if(start&&h!=0){
                sp.x = x; sp.y = y; sp.h = h;
                start  = false;
            }
            p[i] = new pair();
            p[i].x = x; p[i].y = y; p[i].h = h;
        }
        out:for (int i = 0; i <= 100; i++) {
            for (int j = 0; j <= 100; j++) {
                h = sp.h + Math.abs(sp.x-i)+Math.abs(sp.y-j);
                boolean flag = true;
                for(pair a: p){
                    if(h-Math.abs(a.x-i)-Math.abs(a.y-j)>0&&h-Math.abs(a.x-i)-Math.abs(a.y-j)!=a.h||h-Math.abs(a.x-i)-Math.abs(a.y-j)<=0&&a.h!=0){
                        flag = false;
                        break;
                    }
                }
                if(flag){
                    out.printf("%d %d %d", i, j, h);
                    break out;
                }
            }
        }
    }
    public static class pair{
        int x, y, h;
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 21588
#include <iostream>
#define L 100005
using namespace std;

struct Robin { char name[100]; int time;};

//queue
int head, tail;

Robin Q[L];

void enqueue(struct Robin x) {
  Q[tail] = x;
  tail = (tail+1) % L;
}

Robin dequeue() {
  Robin x = Q[head];
  head = (head+1) % L;
  return x;
}

int min(int a, int b) { return a < b ? a : b; }

int main() {

  int elapsed = 0;
  int n, q, c;
  cin >> n >> q;

  head = 0;
  Robin u;

  for (int i=0; i < n; i++) {
    cin >> Q[i].name >> Q[i].time;
  }

  tail = n;
  
  while (head != tail) {
	
    u = dequeue();
    c = min(q, u.time);
    u.time -= c;
    elapsed += c;
    if ( u.time > 0 ) enqueue(u);
    else  {
      cout << u.name << " " << elapsed << endl;
    }   
  }

  return 0;
}

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

typedef long long ll;

typedef pair<int, pair<int, int> > p;

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

    ll K;
    cin >> K;

    if(K == 0) {
        cout << 2 << endl << 1 << " " << 1 << endl;
    } else if(K == 1) {
        cout << 3 << endl << 1 << " " << 1 << " " << 3 << endl;
    } else if(K <= 50) {
        cout << K << endl;
        for(int i = 0; i < K; i++) {
            cout << K << " ";
        }
        cout << endl;
    } else {
        ll x = K / 50LL;
        vector<ll> ans(50, 49LL + x);
        ll y = K % 50LL;
        for(int i = 0; i < y; i++) {
            ans[i] += 51LL - y;
        }
        for(int i = y; i < 50; i++) {
            ans[i] -= y;
        }
        cout << 50 << endl;
        for(int i = 0; i < 50; i++) {
            cout << ans[i] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a1,a2,a3,a4,b1,b2,b3,b4,c,d;
	scanf("%d %d %d %d",&a1,&a2,&a3,&a4);
	scanf("%d %d %d %d",&b1,&b2,&b3,&b4);
	c=a1+a2+a3+a4;
	d=b1+b2+b3+b4;
	if(c<d){
			printf("%d\n",d);
	}
	else if(c==d){
					printf("%d\n",c);
	}
	else{
		printf("%d\n",c);
	}
	return 0;
}

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



int main() {
    long int n;
    cin >> n;
    
    long int ts = 1;
    int cnt = 1;
    while(1) {
        if(n - ts * 26 <= 0)
            break;
        else {
            ts *= 26;
            n -= ts;
            cnt++;
        }
    }
    
    n--;
    vector<int> name(0);
    rep(i,cnt) {
        name.push_back(n%26);
        n /= 26;
    }
    
    
    for(int i = (int)name.size()-1; i >= 0; i--) {
        cout << (char)('a' + name[i]);
    }
    cout << endl;
    
    return 0;
}




Measured memory_bytes: 3632
import java.io.BufferedReader

fun main() {
    val br = System.`in`.bufferedReader()
    val n = br.readInt()
    val q = br.readInt()
    val colors = IntArray(n) { br.readInt() - 1 }
    val lefts = IntArray(q)
    val rights = IntArray(q) {
        lefts[it] = br.readInt()
        br.readInt()
    }
    val order = IntArray(q) { it }.sortedWith(Comparator { a, b -> rights[a].compareTo(rights[b]) })
    var idx = 0
    val fenwick = Fenwick(n)
    val answers = IntArray(q)
    val lastOccurrence = IntArray(n)
    for (x in 0 until n) {
        val c = colors[x]
        if (lastOccurrence[c] != 0) {
            fenwick.add(lastOccurrence[c], -1)
        }
        lastOccurrence[c] = x + 1
        fenwick.add(x + 1, 1)
        while (idx < q && rights[order[idx]] == x + 1) {
            answers[order[idx]] = fenwick.get(lefts[order[idx]], rights[order[idx]])
            idx++
        }
    }
    print(answers.joinToString("\n"))
}

private class Fenwick(val size: Int) {
    private val ary = IntArray(size)

    fun add(idx: Int, v: Int) {
        var k = idx
        while (k <= size) {
            ary[k - 1] += v
            k += k and -k
        }
    }

    fun set(idx: Int, v: Int) {
        add(idx, v - get(idx, idx))
    }

    fun get(idx: Int): Int {
        var k = idx
        var r = 0
        while (k > 0) {
            r += ary[k - 1]
            k -= k and -k
        }
        return r
    }

    fun get(a: Int, b: Int): Int {
        return get(b) - get(a - 1)
    }
}

private const val SPACE_INT = ' '.toInt()
private const val ZERO_INT = '0'.toInt()
private const val NL_INT = '\n'.toInt()

private fun BufferedReader.readInt(): Int {
    var ret = read()
    while (ret <= SPACE_INT) {
        ret = read()
    }
    val neg = ret == '-'.toInt()
    if (neg) {
        ret = read()
    }
    ret -= ZERO_INT
    var read = read()
    while (read >= ZERO_INT) {
        ret *= 10
        ret += read - ZERO_INT
        read = read()
    }

    while (read <= SPACE_INT && read != -1 && read != NL_INT) {
        mark(1)
        read = read()
    }
    if (read > SPACE_INT) {
        reset()
    }
    return if (neg) -ret else ret
}

Measured memory_bytes: 91960
num = int(input())

from collections import defaultdict
dic = defaultdict(int)

for i in range(num):
  s = input()
  if s in dic:
      dic[s] += 1
  else:
      dic[s] = 1

k = {}
k = [key for m in [max(dic.values())] for key,val in dic.items() if val == m]
k.sort()
for i in k:
  print(i)

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

using namespace std;

int main()
{
    int n ;
    string str;
    cin >> n;
    cin >> str;
    if(n%2==1)
    {
        cout << "No" ;
        return 0;
    }
    string s =str.substr(0,n/2);
    string f = str.substr((n/2) , n-1);
    if(s!=f)
    {
        cout << "No";
        return 0;
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int,int> pii;
typedef priority_queue<int,vector<int>,greater<int> > small_heap;
typedef priority_queue<int> big_heap;

int main()
{
    double n;cin>>n;
    double kk=n/3;
    printf("%.12f\n",kk*kk*kk);
    return 0;
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int x, a, b;
    cin >> x >> a >> b;
    
    if(b-a <= 0){
        cout << "delicious" << endl;
    }else if(b-a <= x){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }
}

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

int main()
{
	string s;
    int A , B;
	cin  >>A >> B>>s;
	

	for (int i = 0; i < A; ++i) {
      if(s[i]== '0' || s[i]== '1' || s[i]== '2' || s[i]== '3' || s[i]== '4' ||
         s[i]== '5' || s[i]== '6' || s[i]== '7' || s[i]== '8' || s[i]== '9' ){
         continue;
        }
      else {  cout << "No" << endl ;
      return 0 ;
            }
      }
  if ( s[A] != '-' ){
     cout << "No" << endl ;
     return 0 ;    }
  for ( int i = A + 1 ; i < B + A +1 ; ++i ){
     if(s[i]== '0' || s[i]== '1' || s[i]== '2' || s[i]== '3' || s[i]== '4' ||
        s[i]== '5' || s[i]== '6' || s[i]== '7' || s[i]== '8' || s[i]== '9' ){
          continue;
        }
      else { 
       cout << "No" << endl ;
       return 0 ;     
    }
    }
  cout << "Yes" << endl ;
  return 0 ;
  }


Measured memory_bytes: 256