akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
using namespace std;

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

struct compare1 { 
    bool operator()(const pair<long, long>& value,  
                                const long& key) 
    { 
        return (value.first < key); 
    } 
    bool operator()(const long& key,  
                    const pair<long, long>& value) 
    { 
        return (key < value.first); 
    } 
};

struct UnionFind {
    vector<int> par;
    vector<int> rank;

    UnionFind(int n = 1){
        init(n);
    }

    void init(int n = 1){
        par.resize(n);
        rank.resize(n);
        REP(i, n) par[i] = i, rank[i] = 0; 
    }

    int root(int x){
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y){
        return root(x) == root(y);
    }

    bool merge(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(rank[x] < rank[y]) swap(x, y);
        if(rank[x] == rank[y]) rank[x]++;
        par[y] = x;
        return true;
    }
};

template<class Abel> struct weightedUnionFind{
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    weightedUnionFind(int n = 1, Abel SUM_UNITY = 0){
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0){
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        REP(i, n) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY; 
    }

    int root(int x){
        if(par[x] == x) return x;
        else{
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x){
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y){
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w){
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if(x == y) return false;
        if(rank[x] < rank[y]) swap(x, y), w = -w;
        if(rank[x] == rank[y]) rank[x]++;
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y){
        return weight(y) - weight(x);
    }
};

using Graph = vector<vector<Edge>>;
using P = pair<int, int>;

int main()
{
    long N; cin >> N;
    long A[200005];
    for(long i = 0; i < N; i++) cin >> A[i];
    
    long r = 0;
    long ans = 0;
    long temp = 0;
    for(long l = 0; l < N; l++){
        while(temp + A[r] == (temp ^ A[r]) && r < N){
            temp += A[r];
            r++;
        }
        ans += r-l;
        temp -= A[l];
        //cout << l << " " << r << endl;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S1,S2,S3;
  cin >> S1 >> S2 >> S3;
  char judge='a';
  string win;
  for(int i=0;i<10000;i++){
    if(judge=='a'&&S1.size()!=0){
      judge=S1.at(0);
      S1.erase(0,1);
    }
    if(judge=='b'&&S2.size()!=0){
      judge=S2.at(0);
      S2.erase(0,1);
    }
    if(judge=='c'&&S3.size()!=0){
      judge=S3.at(0);
      S3.erase(0,1);
    }
    if(judge=='a'&&S1.empty()){
      win="A";
      break;
    }
    if(judge=='b'&&S2.empty()){
      win="B";
      break;
    }
    if(judge=='c'&&S3.empty()){
      win="C";
      break;
    }
  }
  cout << win << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
// #define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}


unordered_map<int,int>mm;
int temp=0;

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    string a;
    cin>>a;
    int n=a.length();
    for(int i=0;i<n;i++)
    {
        temp^=(1<<(a[i]-'a'));  
        for(int j=0;j<26;j++)
        {
            int z=(temp^(1<<j));
            if(z==0)
                mm[temp]=1;
            else if(temp==0)
                mm[temp]=1;
            else if(mm[temp]!=0 && mm[z]!=0)
                mm[temp]=min(mm[temp],mm[z]+1);
            else if(mm[temp]==0&& mm[z]!=0)
                mm[temp]=mm[z]+1;
        }
        if(temp==0)
            mm[temp]=1;
    }
    if(temp==0)
        cout<<1;
    else
        cout<<mm[temp];
    
} 
    


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

using namespace std;


#define PI 3.14159265
#define int long long




main(){


	int n;

	cin >> n;

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

	int m = h[0], cnt = 1;
	for(int i = 1; i < n; i++){
		if(h[i] >= m) cnt++;

		m = max(m, h[i]);
	}


	cout << cnt << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,m,s,c,C;
    in>>n>>m;
    if(n==1){
        if(m==0) return cout<<0<<endl,0;
        in>>s>>c;
        fr(i,m-1){
            in>>s>>C;
            if(c!=C) return puts("-1"),0;
        }
        cout<<c<<endl;
        return 0;
    }
    vector<int> ans(n,-1);
    fr(i,m){
        in>>s>>c;
        --s;
        if(s==0&&c==0) return puts("-1"),0;
        if(ans[s]==-1) ans[s]=c;
        else if(ans[s]!=c) return puts("-1"),0;
    }
    Fr(i,n-1) if(ans[i]<0) ans[i]=0;
    if(ans[0]<0) ans[0]=1;
    fr(i,n) cout<<ans[i];
    cout<<endl;
}

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

int main() {
  string S ; cin >> S; // 入力文字列
  string Ans = "Yes";

  if ( S == "AAA" || S== "BBB") {
    Ans = "No";
  }

  cout << Ans << endl;
  
}



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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,ma=0,a=0,sum=0;
	cin>>n;
	cin>>ma;
	for(int i=0;i<n-1;i++){
		cin>>a;
		if(ma>a){
			sum+=ma-a;
		}
		ma=max(ma,a);
	}
	cout<<sum<<endl;
	return 0;
}


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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

//bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


int main() {
    string s;
    cin >> s;
    stack<char> stack;
    for (char c : s) {
        if (c == '0') stack.push('0');
        if (c == '1') stack.push('1');
        if (c == 'B' && !stack.empty()) stack.pop();
    }

    vector<char> ans;
    while (!stack.empty()) {
        ans.push_back(stack.top());
        stack.pop();
    }

    reverse(ans.begin(), ans.end());

    for (char c: ans) cout << c;
    cout << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const int INF=1000000007;

ll dp[100005][2];
const ll mod=1000000007;

int main(){
  string s; cin>>s;
  // a+b=XOR(a,b)⇔a+b=XOR(a,b)+AND(a,b) (AND(a,b)==0)
  dp[0][0]=1;
  rep(i,s.size()){
    //a+b==0
    if(s[i]=='0'){
      dp[i+1][0]=dp[i][0];
      dp[i+1][1]=dp[i][1];
    }else{
      dp[i+1][1]=(dp[i][0]+dp[i][1])%mod;
    }
    //a+b==1
    if(s[i]=='0'){
      dp[i+1][1]+=dp[i][1]*2;
      dp[i+1][1]%=mod;
    }else{
      dp[i+1][0]+=dp[i][0]*2%mod;
      dp[i+1][1]+=dp[i][1]*2%mod;
    }
  }

  ll ans=(dp[s.size()][0]+dp[s.size()][1])%mod;
  cout<<ans<<endl;

}


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

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int h = Integer.parseInt(br.readLine());
        int w = Integer.parseInt(br.readLine());
        int n = Integer.parseInt(br.readLine());
        int max = Math.max(h, w);
        int ans = (n + max - 1) / max;
        System.out.println(ans);
    }
}


Measured memory_bytes: 22484
process.stdin.resume();
process.stdin.setEncoding('utf8');

var input_lines = []; 
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  input_lines.push(line);
});
reader.on('close', () => {
  var height = Number(input_lines[0].split(' ')[0]);
  var width = Number(input_lines[0].split(' ')[1]);
  var count = 0;

  if(height === 1 || width === 1){
    console.log (1);
  }else{
    var odd = Math.ceil(height / 2);
    var even = height - odd;
    var movable_even = Math.floor(width / 2);
    var movable_odd = width % 2 === 1 ? movable_even + 1 : movable_even
    
    count = (even * movable_even) + (odd * movable_odd);
    
    console.log(count);
  }
});

Measured memory_bytes: 9676
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char str[2][60];

int main(){
	int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
	printf("%d\n",max(0,min(b,d)-max(a,c)));
}

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp::Ordering::{Equal, Greater, Less};
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;

// collatz-problem.rs --- Collatz Problem
// author: Seong Yong-ju <sei40kr@gmail.com>

// tanakah's input macro
// cf https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(x: u32) -> u32 {
    if x % 2 == 0 {
        x / 2
    } else {
        3 * x + 1
    }
}

fn main() {
    input! {
        s: u32,
    };

    let mut x = s;
    let mut ans = 1;
    while x != 4 && x != 2 && x != 1 {
        x = f(x);
        ans += 1;
    }

    println!("{}", ans + 3);
}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const ll mod = 1e9 + 7;


int main(){

  int n;cin>>n;
  vector<string>s[55];
  vector<int>v(26,50),h(26,0);

  map<char,int>mp;
  string str;

  rep(i,0,n){

    cin>>str;

    rep(j,0,str.size()){
      mp[str[j]-'a']++;
    }

    for(map<char,int>::iterator itr=mp.begin();itr!=mp.end();itr++){
      h[(int)itr->first]=itr->second;
    }
    rep(i,0,26){
      v[i]=min(v[i],h[i]);
      h[i]=0;
    }
    mp.clear();
  }

  rep(i,0,26){
    rep(j,0,v[i]){
      cout<<(char)('a'+i);
    }
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i=2LL; i * i <= n; ++i) {
        if(n % i != 0) continue;
        ll num = 0;
        while(n % i == 0) {
            n /= i;
            ++num;
        }
        for (ll j = 1; ; ++j) {
            if(num >= j) {
                num -= j;
                ++ans;
            }
            else {
                break;
            }
        }
    }
    if (n != 1) ++ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;

        static void Solve()
        {
            int n = ReadAndParseInt();
            var a = ReadAndParseLongArr();

            long cost0 = CalcCost(a, i => i % 2 == 0);
            long cost1 = CalcCost(a, i => i % 2 == 1);
            long ans = Math.Min(cost0, cost1);
            Console.WriteLine(ans);
        }
        private static long CalcCost(long[] a, System.Func<int, bool> plusCondition)
        {
            long cost = 0;
            long sum = 0;
            for (int i = 0; i < a.Length; ++i)
            {
                var val = a[i];
                sum += val;
                if (plusCondition(i))
                {
                    // +にする
                    if (sum <= 0)
                    {
                        long add = 1 - sum;
                        cost += add;
                        sum += add;
                    }
                }
                else
                {
                    // - にする
                    if (sum >= 0)
                    {
                        long sub = -sum - 1;
                        cost += Math.Abs(sub);
                        sum += sub;
                    }
                }
            }
            return cost;
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 25180
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

S = input()
y, m = int(S[:4]), int(S[5:7])
if y < 2019 or (y == 2019 and m <= 4):
    print('Heisei')
else:
    print('TBD')



Measured memory_bytes: 64364
n = int(input())
z = []
w = []
for i in range(n):
    x,y = map(int,input().split())
    z.append(x+y)
    w.append(x-y)
zmax = max(z)-min(z)
wmax = max(w)-min(w)
print(max(zmax,wmax))

Measured memory_bytes: 24820
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc177/abc177_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string S, T;
  cin >> S >> T;
  int N = S.size();
  int M = T.size();

  int ans = INF;
  rep(i, N - M + 1) {
    int tmp = 0;
    rep(j, M) {
      if (S[i + j] != T[j]) tmp++;
    }
    ans = min(ans, tmp);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3656
s = input()
K = int(input())
ab = 'abcdefghijklmnopqrstuvwxyz'
N = len(s)
substrings = set()
for i in ab:
    for l in range(N):
        if s[l] != i:
            continue
        for r in range(l,N):
            if r-l+1 > K:
                break
            substrings.add(s[l:r+1])
    if len(substrings) >= K:
        break
substrings = list(substrings)
substrings.sort()
print(substrings[K-1])


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

int main() {
    int K;
    cin >> K;
    string S_temp = "ACL";
    string ans = S_temp;
    for (int i=1; i<K; i++) {
        ans += S_temp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
import sys
from operator import mul
from functools import reduce
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

def com(n,r):
    r = min(n-r,r)
    if r == 0: return 1 
    return reduce(mul,range(n,n-r,-1))//reduce(mul,range(1,r+1))

n = int(readline())

if n < 3:
    print(0)
    sys.exit()

ans = 0
for i in range(1,n//3+1):
    num = n - i * 3
    ans += com(num+i-1,i-1)
    
print(ans%1000000007)

Measured memory_bytes: 9592
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll ans=0;
    while(true){
        bool ok=true;
        rep(i,n){
            if(a[i]%2==1){
                ok=false;
                break;
            }
        }
        if(!ok) break;
        rep(i,n){
            a[i]/=2;
        }
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include <iostream>
using namespace std;
    
int main(){
int x,y;
int a;
    
cin >> x >> y;
while(x != 0 || y != 0){
if( x>y){
a = x;
x = y;
y = a;
}
cout << x << " " << y << endl;
cin >> x >> y;
}
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
const int MAX = 2e5 + 1e4 + 10;
typedef long long i64;
using namespace std;

int deg[MAX];
int main() {

    #ifdef LOCAL_DEBUG
    freopen ("data.in", "r", stdin );
    freopen ("data.out", "w", stdout );
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    #define endl '\n'


    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
    	int a, b; cin >> a >> b ; a--; b--;
    	deg[a]++; deg[b]++;
    }
    bool ans = true;
    for(int i = 0; i < n; i++)
    	if(deg[i] & 1)
    		ans = false;
    cout << (ans ? "YES" : "NO") << endl;


}



Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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;
}

const int MAX_N = 100000;

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

    int count = 0;

    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        if (x % 2 == 1) count++;
    }

    if (count % 2 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
}


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

typedef std::pair<int, int> P;

std::vector<P> ps( 10000 );

int main()
{
	int n;
	while( std::cin >> n, n )
	{
		ps.clear();

		for( int i = 0; i != n; ++i )
		{
			int p, d1, d2;
			std::cin >> p >> d1 >> d2;
			ps.push_back( std::make_pair( d1 + d2, p ) );
		}

		std::sort( ps.rbegin(), ps.rend() );

		std::cout << ps[0].second << ' ' << ps[0].first << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
const int MAX = 1000005;
const ll MOD = 1000000007;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

vector<int> Zalgo(string s){
  int l = s.size();
  vector<int> a(l);
  int i=1,j=0;
  while(i < l){
    while(i+j<l && s[j]==s[i+j]) j++;
    a[i]=j;
    if(j==0){ i++; continue; }
    int k=1;
    while(i+k<l && k+a[k] < j){
      a[i+k] = a[k]; k++;
    }
    i+=k; j-=k;
  }
  a[0]=l;
  return a;
}
int main(){
  int n;
  string s;
  cin >> n >> s;
  int res=0;
  rep(i,n){
    string t = s.substr(i);
    auto lcp = Zalgo(t);
    rep(j,t.size()){
      int l = min(lcp[j],j);
      res = max(res,l);
    }
  }
  cout << res << endl;
}




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

int main() {
	int h, w;
	cin >> h >>w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			string x;
			cin >> x;
			if (x == "snuke") {
				char a = 'A' + j;
				cout << a << i + 1 << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
S = gets.chomp

ans = "Yes"
for i in 1..S.length do
  if i % 2 == 0 and S[i-1] == "R" then
    ans = "No"
  end
  if i % 2 == 1 and S[i-1] == "L" then
    ans = "No"
  end
end
    
puts ans

Measured memory_bytes: 1916
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())

    res = N % 1000
    res = 1000 - res
    res %= 1000

    print(res)



main()


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    for(int i = 0; i < s.size(); ++i) {
        s[i] += n;
        if(s[i] > 'Z') s[i] -= 'Z' - 'A' + 1;
    }
    cout << s << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(int i=0; i<v; i++)
#define forj(v) for(int j=0; j<v; j++)
#define fork(v) for(int k=0; k<v; k++)
#define forl(v) for(int l=0; l<v; l++)
#define fort(v) for(int t=0; t<v; t++)
#define forz(v) for(int z=0; z<v; z++)
#define forx(v) for(int x=0; x<v; x++)
#define ll long long
#define lll __int128
#define MAX (int)(4*pow(10,3) + 100)
#define pb(a) push_back(a)
#define ch (int)(4*pow(10,4) + 100)
#define ld long double
// #define cout out
// #define cin in
ll inf = pow(10,18);
ll modulo = pow(10,9)+7 ;
double eps = 1e-9;
ifstream in;
ofstream out;
 


 
void deal(){
	string a;
	cin>>a;
	sort(a.begin(), a.end());
	if(a[0] != a[2]){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
		
}
 
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
 
 
/* 
6 8 
1 2
2 3
3 4
4 1
2 5
3 5
1 6
4 6
*/

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int ab(int a,int b){
    if (a<b) {
        return b-a;
    }else{
        return a-b;
    }
}

int main() {
    for (; ;) {
        int n ,m;
        cin >>n >>m;
        if (n==0&&m==0) {
            break;
        }
        int taro[n],hanako[m];
        int sumt=0,sumh=0;
        for (int i=0; i<n;i++) {
            cin >> taro[i];
            sumt += taro[i];
        }
        for (int i=0; i<m; i++) {
            cin >> hanako[i];
            sumh+=hanako[i];
        }
        int dis = sumt-sumh;
        int ans=0;
        int wa=100000007;
        int I =0,J=0;
        for (int i=0; i<n; i++) {
            for (int j=0; j<m; j++) {
                if (2*(taro[i]-hanako[j])==dis) {
                    ans++;
                    if (wa>=taro[i]+hanako[j]) {
                        I=i;
                        J=j;
                    }
                    wa=min(wa,taro[i]+hanako[j]);
                    }
            }
        }
        if (ans==0) {
            cout << -1 <<endl;
        }else{
            cout << taro[I] << " "<< hanako[J] << endl;
        }
    }
}

Measured memory_bytes: 1164
#include<bits/stdc++.h> 
using namespace std; 
  
// Returns the longest repeating non-overlapping 
// substring in str 
int longestRepeatedSubstring(string str) 
{ 
    int n = str.length(); 
    int LCSRe[n+1][n+1]; 
  
    // Setting all to 0 
    memset(LCSRe, 0, sizeof(LCSRe)); 
  
    string res; // To store result 
    int res_length  = 0; // To store length of result 
  
    // building table in bottom-up manner 
    int i, index = 0; 
    for (i=1; i<=n; i++) 
    { 
        for (int j=i+1; j<=n; j++) 
        { 
            // (j-i) > LCSRe[i-1][j-1] to remove 
            // overlapping 
            if (str[i-1] == str[j-1] && 
                LCSRe[i-1][j-1] < (j - i)) 
            { 
                LCSRe[i][j] = LCSRe[i-1][j-1] + 1; 
  
                // updating maximum length of the 
                // substring and updating the finishing 
                // index of the suffix 
                if (LCSRe[i][j] > res_length) 
                { 
                    res_length = LCSRe[i][j]; 
                    index = max(i, index); 
                } 
            } 
            else
                LCSRe[i][j] = 0; 
        } 
    } 
  return res_length;
    // If we have non-empty result, then insert all 
    // characters from first character to last 
    // character of string 
  /*  if (res_length > 0) 
        for (i = index - res_length + 1; i <= index; i++) 
            res.push_back(str[i-1]); 
  
    return res;*/ 
} 
  
// Driver program to test the above function 
int main() 
{ 
int n;
cin>>n;
    string str;
    cin>>str;
    cout << longestRepeatedSubstring(str); 
    return 0; 
} 

Measured memory_bytes: 98048
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#define PII pair<int,int>
#define MP make_pair
#define fir first
#define sec second
#define PB push_back
#define db long double
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1010,inf=1e9;
inline int Abs(int x) { return x>0?x:-x; }
int S,T;
namespace Flow {
	const int N=5010;
	int head[N],cur[N],vis[N];
	ll dis[N];
	struct ed { int to,next,f; ll w; };
	vector<ed> e;
	void init() { e.clear(); memset(head,-1,sizeof(head)); }
	void ad(int x,int y,int f,ll w) {
		e.PB((ed){y,head[x],f,w}); head[x]=e.size()-1;
		e.PB((ed){x,head[y],0,-w}); head[y]=e.size()-1;
	}
	queue<int> q;
	bool bfs() {
		memset(dis,-0x3f,sizeof(dis));
		memcpy(cur,head,sizeof(cur));
		dis[S]=0,q.push(S),vis[S]=1;
		while(!q.empty()) {
			int u=q.front(); q.pop(),vis[u]=0;
			for(int k=head[u];~k;k=e[k].next) if(e[k].f) {
				int v=e[k].to;
				if(dis[v]<dis[u]+e[k].w) {
					dis[v]=dis[u]+e[k].w;
					if(!vis[v]) q.push(v),vis[v]=1;
				}
			}
		}
		return dis[T]>-1e16;
	}
	int dfs(int u,int f) {
		if(u==T||!f) return f; int ret=0,tmp;
		vis[u]=1;
		for(int &k=cur[u];~k;k=e[k].next) if(e[k].f) {
			int v=e[k].to;
			if(dis[v]==dis[u]+e[k].w&&!vis[v]&&(tmp=dfs(v,min(f,e[k].f)))) {
				f-=tmp,ret+=tmp;
				e[k].f-=tmp,e[k^1].f+=tmp;
				if(!f) break;
			}
		}
		vis[u]=0;
		return ret;
	}
	ll work() { ll ans=0; while(bfs()) ans+=dis[T]*dfs(S,1e9); return ans; }
}
int rx[N],ry[N],rc[N];
int bx[N],by[N],bc[N];
int n;
int main() {
	rd(n);
	for(int i=1;i<=n;++i) rd(rx[i]),rd(ry[i]),rd(rc[i]);
	for(int i=1;i<=n;++i) rd(bx[i]),rd(by[i]),rd(bc[i]);
	S=2*n+1,T=2*n+2;
	int p[4];
	for(int i=0;i<4;++i) p[i]=2*n+3+i;
	Flow::init();
	for(int i=1;i<=n;++i) {
		Flow::ad(S,i,rc[i],0);
		Flow::ad(i+n,T,bc[i],0);
	}
	for(int i=1;i<=n;++i) {
		Flow::ad(i,p[0],inf,rx[i]+ry[i]);
		Flow::ad(i,p[1],inf,rx[i]-ry[i]);
		Flow::ad(i,p[2],inf,-rx[i]+ry[i]);
		Flow::ad(i,p[3],inf,-rx[i]-ry[i]);
		
		Flow::ad(p[0],i+n,inf,-bx[i]-by[i]);
		Flow::ad(p[1],i+n,inf,-bx[i]+by[i]);
		Flow::ad(p[2],i+n,inf,bx[i]-by[i]);
		Flow::ad(p[3],i+n,inf,bx[i]+by[i]);
	}
	printf("%lld",Flow::work());
	return 0;
}


Measured memory_bytes: 1148
#include<stdio.h>
int main(void) {
	long long int a, b, c, d, ans;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	ans = a * c;
	if (a * d > ans) {
		ans = a * d;
	}
	if (b * c > ans) {
		ans = b * c;
	}
	if (b * d > ans) {
		ans = b * d;
	}
	printf("%lld",ans);
	return 0;
}

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

int main() {
  string s,t; cin >> s >> t;

  for(int i = 0;i < (int)s.size();i++) {
    if(s[i] != t[i]) { cout << "No\n"; return 0; }
  }

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

Measured memory_bytes: 3624
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;

int main() {
  int N, P;
  cin >> N >> P;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  bool even=true;
  rep(i, N) {
    if(A[i]%2) {
      even=false;
      break;
    }
  }
  ll ans;
  if(even)
    if(P)
      ans = 0;
    else
      ans = (ll)pow(2, N);
  else
    ans = (ll)pow(2, N-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  lint K;
  cin >> K;
  lint A[K];
  reprev(i,K) cin >> A[i];
  lint CMAX=2,CMIN=2;
  bool check=true;
  rep(i,K){
    if(CMIN%A[i]<=CMAX%A[i] && CMIN/A[i]==CMAX/A[i] && CMIN%A[i]!=0 && CMAX%A[i]!=0) check=false;
    if(CMAX>=A[i]){
      CMIN=((CMIN+A[i]-1)/A[i])*A[i];
      CMAX=(CMAX/A[i])*A[i]+A[i]-1;
    }
    else check=false;    
  }
  if(check) cout << CMIN << " " << CMAX << endl;
  else cout << -1 << endl;
}

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

int main(){

string s;
  cin>>s;
  bool x =true;
  
 
  if (s[0] == s[1]) 
    x = false;
   if (s[1] == s[2]) 
      x = false;
     if (s[2] == s[3]) 
   x = false;
  
  if(x){
  cout<<"Good"<<endl;
  }else{
    cout<<"Bad"<<endl;
  }
  
}

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

public class Main{
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}
        public FastReader(String fileName) throws FileNotFoundException{br = new BufferedReader(new FileReader(fileName));}
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();}
        int nextInt(){return Integer.parseInt(next());}
        long nextLong(){return Long.parseLong(next());}
        double nextDouble(){return Double.parseDouble(next());}
        char[][] readCharArray(int n,int m) {
            String str;
            char[][] arr = new char[n][m];
            for(int i=0;i<n;i++) {
                str=nextLine();
                for(int j=0;j<n;j++) {
                    arr[i][j]=str.charAt(j);
                }
            }
            return arr;
        }
        char[][] readCharArray(int n){
            return readCharArray(n,n);
        }
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}
    }
    static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        System.out.println();
    }
    static final Random random=new Random();
    static void ruffleSort(int[] a) {
        int n=a.length;//shuffle, then sort
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n), temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader st = new FastReader();
        String str = st.nextLine();
        if(str.charAt(str.length()-1)=='s') {
        	System.out.println(str+"es");
        }else {
        	System.out.println(str+"s");
        }
    }
}

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;





int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	si s{1, 2, 3};

	int A, B;

	cin >> A >> B;

	s.erase(A);
	s.erase(B);

	cout << *s.begin() << '\n';

	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
struct node
{
	int a[6010],l;
	string s;
	node()
	{
		l=0;
		memset(a,0,sizeof(a));
		s="";
	}
	void add(int i,int j)
	{
		int x=lower_bound(a,a+l,j)-a;
		string str="b"+s.substr(0,x)+"a"+s.substr(x,l-x);
		if (str<s)
		{
			return;
		}
		l++;
		for (int k=l;k>x;k--)
		{
			a[k]=a[k-1];
		}
		a[x]=j;
		l++;
		for (int k=l;k;k--)
		{
			a[k]=a[k-1];
		}
		a[0]=i;
		s=str;
	}
};
int n,a[6010],b[6010],c[6010];
char s[6010];
string work(int f,int l,int r)
{
	if (l>r)
	{
		return "";
	}
	int s0=0,s1=0;
	for (int i=l;i<=r;i++)
	{
		if ((s[i]-'a')==f)
		{
			s0++;
			a[s0]=i;
		}
		else
		{
			s1++;
			b[a[s1]]=i;
		}
	}
	string res="";
	if (!f)
	{
		int i=l;
		while (i<=r)
		{
			if ((s[i]-'a')!=f)
			{
				i++;
				continue;
			}
			res=res+"ab";
			i=b[i]+1;
		}
	}
	else
	{
		for (int i=l-1;i<=r;i++)
		{
			c[i]=0;
		}
		for (int i=l;i<=r;i++)
		{
			if ((s[i]-'a')==f)
			{
				c[i]=c[i-1]+1;
			}
			else
			{
				c[i]=c[i-1];
			}
		}
		vector<int> v;
		v.clear();
		int mx=l;
		v.push_back(l);
		for (int i=l+1;i<=r;i++)
		{
			if (c[b[i]]-c[i]>c[b[mx]]-c[mx])
			{
				v.clear();
				mx=i;
				v.push_back(i);
			}
			else if (c[b[i]]-c[i]==c[b[mx]]-c[mx])
			{
				v.push_back(i);
			}
		}
		for (int j=0;j<v.size();j++)
		{
			string now="";
			for (int i=v[j];i<=r;i++)
			{
				if ((s[i]-'a')==f)
				{
					now.push_back(s[i]);
				}
				else
				{
					if (i>=b[v[j]])
					{
						now.push_back(s[i]);
					}
				}
			}
			res=max(res,now);
		}
	}
	return res;
}
int main()
{
	scanf("%d",&n);
	scanf("%s",&s);
	int sa=0,sb=0,lst=2*n-1;
	string ans="";
	for (int i=2*n-1;i>=0;i--)
	{
		if (s[i]=='a')
		{
			sa++;
		}
		else
		{
			sb++;
		}
		if (sa!=sb)
		{
			continue;
		}
		if (s[i]=='a')
		{
			if (s[i-1]=='b')
			{
				continue;
			}
			if (lst==2*n-1)
			{
				ans=work(0,i,lst)+ans;
			}
			lst=i-1;
		}
		else
		{
			string str=work(1,i,lst);
			if ((str+ans)>ans)
			{
				ans=str+ans;
			}
			lst=i-1;
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <list>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
#include <ctime>
#include <assert.h>
using namespace std;

const unsigned long long MOD = (unsigned long long)(1e9 + 7);

#define FROM_0(i, n) for(int i = 0; i < (n); i++)
#define FROM_S(i, s, e) for(int i = (s); i < (e); i++)
#define ITER_BEGIN_END(iter, vec) for(auto iter = vec.begin(); iter != vec.end(); iter++)

int main()
{
    int n;
    cin >> n;
    unsigned long long count[] = { 0, 0, 0, 0, 0 };
    FROM_0(i, n)
    {
        string s;
        cin >> s;
        switch (s[0])
        {
        case 'M':
            count[0]++;
            break;
        case 'A':
            count[1]++;
            break;
        case 'R':
            count[2]++;
            break;
        case 'C':
            count[3]++;
            break;
        case 'H':
            count[4]++;
            break;
        default:
            break;
        }
    }
    unsigned long long sum = 0;
    FROM_0(i, 5)
    {
        FROM_S(j, i + 1, 5)
        {
            FROM_S(k, j + 1, 5)
            {
                sum += count[i] * count[j] * count[k];
            }
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3532
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


signed main(){
	int X;cin>>X;
	cout<<(X>=30?"Yes":"No")<<endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n, k;
  cin>>n>>k;
  int a[n];
  for(int i=0; i<n; i++)
    cin>>a[i];
  
  int dp[n];
  memset(dp, 0, sizeof(dp));
  
  for(int i=1; i<n; i++){
      int m = INT_MAX;
      for(int j=1; j<=k; j++){
          int pre = i-j;
          if(pre < 0){
              continue;
          }
          m = min(m, abs(a[i]-a[pre]) + dp[pre]);
      }
      dp[i] = m;
  }
  
  cout<<dp[n-1];
  
}

Measured memory_bytes: 4428
import java.util.*;

public class Main{
	static public void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int S=sc.nextInt();
		int h=0;
		int m=0;
		int s=0;
		while(true){
			if(S>=3600){
				h++;
				S-=3600;
			}else if(S>=60){
				m++;
				S-=60;
			}else{
				s=S;
				break;
			}
		}
		String msg=h+":"+m+":"+s;
		System.out.println(msg);
	}
}


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
    if (ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
    else return 0;
}

long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++){
        sum += p * (getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key) {return key % M; }
int h2(int key) {return 1 + (key % (M-1)); }

int find(char str[]){
    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++){
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]){
    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++){
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0){
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++) H[i][0] = '\0';
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%s %s", com, str);
        
        if (com[0] == 'i'){
            insert(str);
        }
        else {
            if (find(str)){
                printf("yes\n");
            }
            else {
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 16996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a>k) cout<<":("<<endl;
  else cout<<"Yay!"<<endl;
}

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[][] c = new char[3][];
		c[0] = sc.next().toCharArray();
		c[1] = sc.next().toCharArray();
		c[2] = sc.next().toCharArray();

		pr.print(c[0][0]);
		pr.print(c[1][1]);
		pr.print(c[2][2]);
		pr.println();
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 24020