akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int N = Integer.parseInt(sc.next());
		HashSet<String> set = new HashSet<>();
		int red = 0;
		for(int i= 0; i<N; i++){
			int a = Integer.parseInt(sc.next());
			if(a<400){
				set.add("gray");
			}
			else if(a<800){
				set.add("brown");
			}
			else if(a<1200){
				set.add("g");
			}
			else if(a<1600){
				set.add("a");
			}
			else if(a<2000){
				set.add("b");
			}
			else if(a<2400){
				set.add("y");
			}
			else if(a<2800){
				set.add("o");
			}
			else if(a<3200){
				set.add("red");
			}
			else{
				red++;
			}
		}
		int min = Math.max(set.size(),1);
		int max = min + red;
		if(set.size() == 0){
			max = red;
		}
		out.println(min + " " + max);
		
		sc.close();
		out.flush();
	}
}

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

int main() {
    std::size_t n{};
    std::cin >> n;
    std::vector<std::pair<int, int>> ts;
    ts.reserve(n);
    for (std::size_t i = 0; i < n; ++i) {
        int a{}, b{};
        std::cin >> a >> b;
        ts.emplace_back(a, b);
    }
    std::sort(std::begin(ts), std::end(ts), [](const auto& l, const auto& r){ return l.second < r.second; });
    int t = 0;
    for (const auto& e : ts) {
        const auto a = e.first;
        const auto b = e.second;
        t += a;
        if (t > b) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second
 
typedef pair<int, int> PII;
typedef long long ll;
 
const int MOD = 1e9+7;
 
int a[1005][1005],d[1005][1005];
int h,w,sx,sy,ex,ey;
int dx[4]= {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int main() {
 
	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(d,0x3f3f3f3f,sizeof(d));
	cin >> h >> w >> sx >> sy >> ex >> ey;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char c;
			cin >> c;
			if (c=='#') a[i][j]=1;
		}
	}
	sx--,sy--,ex--,ey--;
	deque<PII> q;
	q.push_back(mp(sx,sy));
	d[sx][sy]=0;
	while (!q.empty()) {
		PII cur = q.front();
		q.pop_front();
		for (int i = 0; i < 4; i++) {
			int nx = cur.fi+dx[i];
			int ny = cur.se+dy[i];
			if (nx<0||ny<0||nx>=h||ny>=w||a[nx][ny]) continue;
			if (d[nx][ny]>d[cur.fi][cur.se]) {
				d[nx][ny]=d[cur.fi][cur.se];
				q.push_front(mp(nx,ny));
			}
		}
		for (int i = cur.fi-2; i<= cur.fi+2; ++i) {
			for (int j = cur.se-2; j<=cur.se+2; ++j) {
				if (i<0||j<0||i>=h||j>=w||a[i][j]) continue;
				if (d[i][j]>d[cur.fi][cur.se]+1) {
					d[i][j]=d[cur.fi][cur.se]+1;
					q.push_back(mp(i,j));
				}
			}
		}
	}
 
	cout << (d[ex][ey]>1e7?-1:d[ex][ey]) << "\n";
}

Measured memory_bytes: 11556
fun main(args: Array<String>) {
    val s = readString()

    val r = listOf(
        Regex(".*keyence"),
        Regex("k.*eyence"),
        Regex("ke.*yence"),
        Regex("key.*ence"),
        Regex("keye.*nce"),
        Regex("keyen.*ce"),
        Regex("keyenc.*e"),
        Regex("keyence.*")
    )

    var ans = false
    r.forEach {
        if (it.matches(s)) {
            ans = true
        }
    }
    if (ans) {
        println("YES")
    } else {
        println("NO")
    }
}

// Tools
fun readString() = readLine()!!

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007)
#define IINF (1<<28)
#define LINF (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"

namespace solver {
  using namespace std;
  typedef long long ll;

  int N, R;
  

  void init() {
    cin >> N >> R;
  }

  void solve() {
    if(N<10) cout << R+(100*(10-N));
    else cout << R;
    cout << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

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

typedef long long ll;

int main(){

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

    int x, y;
    cin >> x >> y;

    bool flag = false;
    for(int i=1; i<=x; i++){
        if(i*2+(x-i)*4==y || (x-i)*2+i*4==y){
            flag=true;
        }
    }    

    if(!flag) cout <<"No\n";
    else cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<int>> x(n), y(n);
    REP(i, n) {
        cin >> a[i];
        REP(j, a[i]) {
            int s, t;
            cin >> s >> t;
            s--;
            x[i].push_back(s);
            y[i].push_back(t);
        }
    }

    // REP(i, n) 
    //     REP(j, x[i].size()){
    //         cout << x[i][j] << " " << y[i][j]<< endl;
    //     }

    int ans = 0;
    bool ok = true;
    for(int bit = 0; bit < (1<<n); bit++) {
        ok = true;
        for(int i = 0; i < n; i++) {
            if (bit & (1<<i)) {                
                for(int j = 0; j < x[i].size(); j++) {                    
                    if (bit & (1<<x[i][j]) && !y[i][j] || !(bit & (1<<x[i][j])) && y[i][j]) {
                        ok = false;
                        break;
                    }
                }
            }
        }
        // cout << bit << " " << ok << " " << __builtin_popcount(bit) << endl;
        if (ok) chmax(ans, __builtin_popcount(bit));
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		while(true) {
			int x = stdIn.nextInt();
			String y = stdIn.next();
			int z = stdIn.nextInt();
			if ("?".equals(y)) break;

			if ("+".equals(y)) {
				System.out.printf("%d%n", x + z);
			} else if ("-".equals(y)) {
				System.out.printf("%d%n", x - z);
			} else if ("*".equals(y)) {
				System.out.printf("%d%n", x * z);
			} else if ("/".equals(y)) {
				System.out.printf("%d%n", x / z);
			}
    	}
		stdIn.close();
	}
}



Measured memory_bytes: 26396
# Aさん:a Bさん:b Cさん:c
# 距離がd以内のとき会話可能

a, b, c, d = map(int, input().split())

if abs(a - c) <= d:
    ans = 'Yes'
elif (abs(a - b) <= d) and (abs(b - c) <= d):
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Measured memory_bytes: 9100
#include<stdio.h>
#define M 1000

int head=0, stack[M];

void push(int n){
  stack[++head]=n;
}

int pop(void){
  head--;
  return stack[head+1];
}

void calc(char op){
  int n1=pop(), n2=pop();
  if(op=='+') push(n1+n2);
  if(op=='-') push(n2-n1);
  if(op=='*') push(n2*n1);
}

int main(void){
  char a[1000];
  int t,s;
    while(scanf("%s",a)!=EOF){
      if(a[0]=='+' || a[0]=='-' || a[0]=='*') calc(a[0]);
      else push(atoi(a));
    }
  printf("%d\n",pop());
  return 0;
}

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

int N;
vector<long long> a;

void solve() {
    map<long long, long long> ma;
    for (int i = 0; i < N; ++i) ma[a[i]]++;
    long long res = 0;
    for (auto it : ma) res += it.second * (it.second - 1) / 2;
    for (int i = 0; i < N; ++i) {
        long long val = ma[a[i]];
        long long before = val * (val - 1) / 2;
        long long after = (val - 1) * (val - 2) / 2;
        cout << res + after - before << endl;
    }
}

int main() {
    cin >> N;
    a.resize(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    solve();
}

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

#define dbg(help) cerr << #help << " = " << (help) << endl;
#define int  long long
#define endl "\n"

using namespace std;

void boot_up() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef LOCAL 
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
#endif
    cout.setf(ios::fixed); cout.precision(4);
}

const int INF = 1e18, maxn = 3e5 + 1;

signed main() {
    boot_up();

    int n, l, sum = 0;
    cin >> n >> l;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; ++i) {
        a[i] = l + i - 1;
        sum += a[i];
    }

    int ans = INF;
    for (int i = 1; i <= n; ++i) {
        int currs = sum - a[i];
        if (abs(ans - sum) > abs(currs - sum)) {
            ans = currs;
        }
    }

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


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

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

    int cnt=0;
    for(int i=0;i<=N-2;i++){
        int mn=a[i],idx=i;
        for(int j=i+1;j<N;j++) if(a[j]<mn){
            mn=a[j]; idx=j;
        }
        if(idx!=i) swap(a[i],a[idx]),cnt++;
    }
    for(int i=0;i<N;i++) cout<<a[i]<<(i==N-1? '\n':' ');
    cout<<cnt<<endl;
    return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	vector<int> A(N);
	rep(i, 0, N)cin >> A[i];

	vector<int> CNT(32, 0);
	int ans = 0;
	int l = 0;
	rep(r, 0, N)
	{
		rep(j, 0, 32)
		{
			CNT[j] += (A[r] >> j) & 1;
		}
		while (true)
		{
			bool ok = true;
			rep(j, 0, 32)
			{
				if (CNT[j] > 1)ok = false;
			}
			if (ok)break;
			rep(j, 0, 32)
			{
				CNT[j] -= (A[l] >> j) & 1;
			}
			l++;
		}
		ans += r - l + 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4776
#include <iostream>
#include <vector>
#include <math.h>


double dist2(const std::vector<double> &y, const std::vector<double> &z) {
    double s = 0;
    for (int i = 0; i < y.size(); ++i) {
        s += (y[i] - z[i]) * (y[i] - z[i]);
    }
    return s;
}

bool is_good_dist(double d) {
    long long l = d;
    long long s = sqrt(double(l));
    return s * s == l;
}

int main() {
    long long n, d;
    std::cin >> n >> d;
    std::vector<std::vector<double>> xs(n);
    for (int i = 0; i < n; ++i) {
        std::vector<double> x(d);
        for (int j = 0; j < d; ++j) {
            double v;
            std::cin >> v;
            x[j] = v;
        }
        xs[i] = x;
    }

    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            auto d = dist2(xs[i], xs[j]);
            if (is_good_dist(d)) {
                ++ans;
            }
        }
    }

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


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int A = in.nextInt();
		int B = in.nextInt();
		String S = in.next();
		
		if (S.length() != N) throw new IllegalArgumentException();
		int AB = A + B;
		
		for(int i=0; i<N; i++) {
			char c = S.charAt(i);
			
			if (c == 'a' && AB > 0) {
				System.out.println("Yes");
				AB--;
			} else if (c == 'b' && AB > 0 && B>0) {
				System.out.println("Yes");
				AB--; B--;
			} else {
				System.out.println("No");
			}
		}
 
	}
 
}

Measured memory_bytes: 23500
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    vector<pair<ll,ll> > z;
    int i;
    for(i=0; i<n; i++) {
        ll a,b;
        scanf("%lld%lld", &a, &b);
        z.push_back(make_pair(a+b,a-b));
    }
    sort(z.begin(),z.end());

    int cnt=1;
    int prev=0;
    ll curr=z[0].first;
    for(i=1; i<n; i++) {
        if(z[i].second<curr) {
            continue;
        }
        cnt++;
        prev=i;
        curr=z[i].first;
    }
    printf("%d\n",cnt);

    return 0;
}


Measured memory_bytes: 2420
#include<stdio.h>

int main(){

    int i,j;
    int x,y,z;
    int tmp;

    //----input----
    scanf("%d %d %d", &x, &y, &z);

    //----mainFunction----
    tmp = x;
    x = y;
    y = tmp;

    tmp = x;
    x = z;
    z = tmp;

    //----output----
    
    printf("%d %d %d\n", x, y, z);

    return 0;

}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
    int N; cin >> N;
    int ans=0;
    for(int i=1;i<=N;i+=2){
        int cnt=0;
        cerr << i << " ";
        for(int j=1;j<=200;j++){
            if(i%j == 0){
                cerr << j << " ";
                cnt++;
            }
        }
        cerr << cnt << endl;
        if(cnt==8) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	ll n,a[mx],i,j,g[mx], g2[mx];
    
    cin>>n>>a[0];
    g[0]=a[0];
    
    for(i=1;i<n;i++)
    {
        cin>>a[i];
        g[i]= gcd(g[i-1], a[i]);
    }
    
    g2[n-1]= a[n-1];
    for(i=n-2; i>-1;i--){
        g2[i]= gcd(g2[i+1], a[i]);
    }
   
   ll ans= g2[1], tmp;
   
    for(i=1;i<n-1;i++)
    {
        tmp= gcd(g[i-1], g2[i+1]);
        if(tmp> ans)
        ans= tmp;
    }
    if(ans< g[n-2])
    ans= g[n-2];
    
    cout<<ans;
    return 0;
}























Measured memory_bytes: 4608
def main():
    from collections import Counter
    import itertools
    from math import factorial as f
    
    n, *s = open(0).read().split()
    i = [x[0] for x in s]
    d = Counter(i)
    c = [d.get(i) for i in 'MARCH' if d.get(i) != None]
    
    if len(c) < 3:
        ans = 0
    else:
        ans = 0
        for a,b,c in itertools.combinations(c,3):
          ans += a*b*c
    
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 11504
import java.util.Scanner;
import java.util.Queue;
import java.util.ArrayDeque;
import java.util.Arrays;
 
public class Main {
	static int cnt = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long a = sc.nextInt();
		long b = sc.nextInt();
		long c = sc.nextInt();
		long d = sc.nextInt();
		long max = -1000000000000000000l;
		long ac = a*c;
		long bc = b*c;
		long cd = b*d;
		long da =d* a;
		System.out.println(Math.max(Math.max(ac, bc), Math.max(cd, da)));
		
	}

}

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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<ll> A(N);

    rep(i, N)
    {
        cin >> A[i];
    }

    ll cnt=0;
    ll zero=0;
    ll sum = 0;
    ll min=1e10;
    rep(i, N)
    {
        sum+=abs(A[i]);
        if(abs(A[i])<min)
        {
            min=abs(A[i]);
        }
        if(A[i]<0)
        {
            cnt++;
        }
    }

    

    if(cnt%2==0)
    {
        cout << sum << endl;
    }
    else
    {
        cout << sum-min*2 << endl;
    }
    


    

    return 0;
}



Measured memory_bytes: 1024
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto n = lread();
    auto p = aryread();
    // writeln(p);
    auto min_x = new long[](n); //i番目にiまでの最小値
    min_x[0] = p[0];
    foreach (i; 1 .. n)
    {
        min_x[i] = min(min_x[i - 1], p[i]);
    }
    // writeln(min_x);
    long cnt;
    foreach (i; 0 .. n)
    {
        if (p[i] <= min_x[i])
        {
            cnt += 1;
        }
    }
    writeln(cnt);

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


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

int yu[12];
int biao[12]={-100,8,5,2,10,7,4,1,9,6,3,0};
int main()
{
    int n,k;
    while (scanf("%d%d",&n,&k)!=EOF)
    {
        int i,j;

        int x=(n-2)/11;//算出有多少
        int y=(n-2)%11;

        for (i=1;i<=11;i++)
            yu[i]=x;
        for (i=1;i<=y;i++)
            yu[i]++;

        int num=0;
        for (i=1;i<=11;i++)
        {
            for (j=1;j<=5;j++)
            {
                if ((biao[i]+j*9+9)%11==k)
                {
                    num+=yu[i];
                }
            }
        }

/*
        int num=0;
        for (int i=1;i<=n-2;i++)
        {
            for (int j=1;j<=5;j++)
            {
                if ((63*i+j*9+9)%11==k)
                    num++;
            }
        }
*/

        printf("%d\n",num);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long gcd(long a,long b)
{
 long r;
 if(a<b)
	swap(a,b);
  r = a % b;
  while(r!=0){
	a = b; b = r;
	r = a % b;
  }
  return b;
}
int main(){
	int n;
  	long c = 1;
  	cin >> n;
  	vector<long> a(n);
  	for(int i = 0 ; i < n;i++)
      	cin >> a[i];
  	c = a[0];
  	for(int i = 1; i < n; i++) {
    	c =  a[i] / gcd(c,a[i]) * c; 
    }
  	cout << c << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int b[6];
int tln,uln;
string t,u;
int fn(int p,int n,int m){
  int h,i,j;
  if(p==m){
    j=-1;
    for(i=0;i<m;i++){
      for(j++;j<uln;j++){
	h=0;
	switch(t[b[i]]){
	case '(':
	  if(u[uln-j-1]==')')
	    h=1;
	  break;
	case ')':
	  if(u[uln-j-1]=='(')
	    h=1;
	  break;
	case '{':
	  if(u[uln-j-1]=='}')
	    h=1;
	  break;
	case '}':
	  if(u[uln-j-1]=='{')
	    h=1;
	  break;
	case '[':
	  if(u[uln-j-1]==']')
	    h=1;
	  break;
	case ']':
	  if(u[uln-j-1]=='[')
	    h=1;
	  break;
	}
	if(h)
	  break;
      }
      if(j==uln)
	break;
    }
    if(i==m)
      return 1;
  }else{
    for(i=(p?b[p-1]+1:0);i<n;i++){
      b[p]=i;
      if(fn(p+1,n,m))
	return 1;
    }
  }
  return 0;
}
int main(){
  int i;
  string s;
  cin>>s;
  t=s.substr(0,s.find("iwi"));
  u=s.substr(s.find("iwi")+3);
  tln=t.length();
  uln=u.length();
  for(i=min(tln,uln);i>0;i--){
    if(fn(0,tln,i))
      break;
  }
  cout<<3+2*i<<endl;
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define f q.front()
#define SIZE (ll)(1e3)
#define mod (ll)(1e9+7)
using namespace std;
typedef long long int ll;
int main(){
	int a,i,b;cin>>a>>b;
	int ar[b];for(i=0;i<b;i++)cin>>ar[i];
	vector<int>diff;
	for(i=1;i<b;i++){
		int dif=ar[i]-ar[i-1];
		diff.pb(dif);
	}
	int dif=(a-ar[b-1])+ar[0];
	diff.pb(dif);
	sort(diff.begin(),diff.end());
	cout<<a-(diff[diff.size()-1]);
	return 0;

}

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

int main(){
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> l(q),r(q);
    for(int i=0; i<q; i++){
        cin >> l.at(i) >> r.at(i);
        l.at(i)-=2;
        r.at(i)--;
    }
    vector<int> count(n,0);
    for(int i=0; i<n-1; i++){
        count.at(i+1) = count.at(i);
        if(s.at(i) == 'A' && s.at(i+1) == 'C') count.at(i+1)++; 
    }
    for(int i=0; i<q; i++){
        if(l.at(i) == -1) cout << count.at(r.at(i)) << endl;
        else{
            if(s.at(l.at(i)) == 'A' && s.at(l.at(i)+1) == 'C'){
                cout << count.at(r.at(i)) - count.at(l.at(i)) -1<< endl;
            }
            else{
                cout << count.at(r.at(i)) - count.at(l.at(i)) << endl;
            }
        }
    }
    cout << endl;

}

Measured memory_bytes: 4508
import sys

S = input()

Q = int(input())
flag=0
mae = ''
matsu = ''

for i in range(Q):
    r = sys.stdin.readline().rstrip('\n')
    if r == '1':
        flag = 1 - flag
    else:
        ni, f, c = r.split()
        if f=='1':
            if flag == 0:
                mae += c
            else:
                matsu += c
        else:
            if flag == 0:
                matsu += c
            else:
                mae += c


if flag ==0:
    print(mae[::-1]+S+matsu)
else:
    print(matsu[::-1]+S[::-1]+mae)

Measured memory_bytes: 4468
N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

for cxi in range(101):
    for cyi in range(101):
        for k in range(N):
            if params[k][2] > 0:
                hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

        for k in range(N):
            if params[k][2] != max((hight - abs(params[k][0] - cxi) - abs(params[k][1] - cyi)), 0):
                break
        
        else:
            print(cxi, cyi, hight)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
    int a,b,c,N,box,sum,powerA,powerB,powerC;
    scanf("%d",&N);
    while(N--)
    {
        scanf("%d%d%d",&a,&b,&c);
        if(b>c)
        {
            box=c;
            c=b;
            b=box;
        }
        if(a>b)
        {
            box=b;
            b=a;
            a=box;
        }
        if(b>c)
        {
            box=c;
            c=b;
            b=box;
        }
        powerA=a*a;
        powerB=b*b;
        powerC=c*c;
        sum=powerA+powerB;
        if(sum==powerC)
        {
            printf("YES\n");
        }
        else if(sum!=powerC)
        {
            printf("NO\n");
        }
    }
    return 0;
}

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

int main(){
  int A,B;
  cin>>A>>B;
  if(A==B)cout<<"Draw"<<endl;
  else if(A==1)cout<<"Alice"<<endl;
  else if(B==1)cout<<"Bob"<<endl;
  else if(A>B)cout<<"Alice"<<endl;
  else cout<<"Bob"<<endl;
  return 0;
    }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

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

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

    int r = 1;
    for (int i = 1; i < n; i++) {
        if (s[i] != s[i - 1]) r++;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 9540
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8[:], ), cache=True)
def main(A):
    counts = np.zeros((19, 19), np.int64)
    for x in A:
        e = 0
        while x % 2 == 0:
            x, e = x // 2, e + 1
        f = 0
        while x % 5 == 0:
            x, f = x // 5, f + 1
        e = min(e, 18)
        f = min(f, 18)
        counts[e, f] += 1
    # 任意の順序対
    x = 0
    for a in range(361):
        for b in range(361):
            i, j = divmod(a, 19)
            k, l = divmod(b, 19)
            if i + k >= 18 and j + l >= 18:
                x += counts[i, j] * counts[k, l]
    # 自分どうし
    for a in range(361):
        i, j = divmod(a, 19)
        if i + i >= 18 and j + j >= 18:
            x -= counts[i, j]
    return x // 2

N = int(readline())
A = np.array(read().split(), np.float64)

A = np.rint(10**9 * A).astype(np.int64)

print(main(A))

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll a,b,c,d;cin>>a>>b>>c>>d;
  vector<ll>e(101);
  e[a]++;e[b]--;e[c]++;e[d]--;
  for(i=0;i<100;i++){
    if(e[i]>=2)res++;
    e[i+1]+=e[i];
  }
  cout<<res<<endl;

  return 0;
}

Measured memory_bytes: 256
d, n = map(int, input().split())
if d == 0:
    if n != 100:
        print(n)
    else:
        print(n+1)
elif d == 1:
    if n != 100:
        print(100 * n)
    else:
        print(100 * (n+1))
else:
    if n != 100:
        print(10000 * n)
    else:
        print(10000 * (n+1))

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 2e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int n;
int a[N];
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);
	for(int i=1; i<n; i++) {
		if (a[i] == a[i-1]) return 0*puts("NO");
	}
	puts("YES");
	return 0;
}


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

Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    int a,c=0,d=0;
    string b;
    cin >>a>>b;
    for(int i=0;i<b.size();i++){
        if(b[i]=='I'){
            c++;
        }else{
            c--;
        }
        d=max(d,c);
    }
    cout << d;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100000000
int m[101][101];
  
void matrixChainMultiplication(int n, int *p){
  int i,j,k,l;
    
  for(i=1; i<n+1; i++){
    m[i][i]=0;
  }
  for(l=2; l<n+1; l++){
    for(i=1; i<n-l+2; i++){
      j=i+l-1;
      m[i][j]=N;
      for(k=i; k<j; k++){
    if(m[i][j]>m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]){
      m[i][j]=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
    }
      }
    }
  }
}
  
int main(){
  int i,p[101],n;
  scanf("%d", &n);
  for(i=1; i<n+1; i++){
    scanf("%d%d", &p[i-1], &p[i]);
  }
  matrixChainMultiplication(n,p);
  printf("%d\n", m[1][n]);
    
  return 0;
}

Measured memory_bytes: 632
const [_, inp] = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");

const a: bigint[] = inp.split(" ").map((s: string) => BigInt(s));
if (a.includes(BigInt(0))) {
    console.log(0);
    process.exit(0);
}

let ans: bigint = BigInt(1);
a.forEach((n: bigint) => {
    ans = BigInt(ans) * BigInt(n);
    if (ans > Math.pow(10, 18)) {
        console.log(-1);
        process.exit(0);
    }
});

console.log(ans.toString());


Measured memory_bytes: 45560
import sys
import math
Input = sys.stdin.readline
 
N, M = map(int, Input().split())
D = []
 
for i in range(int(math.sqrt(M)), 0, -1):
    if M % i == 0:
      D.append(i)
      D.append(M // i)

D.sort(reverse=True)
for d in D:
    if M >= N*d:
        print(d)
        break

Measured memory_bytes: 3064
import sys
s=list(input())
t=list(input())
c=[chr(i) for i in range(97, 97+26)]
l=[[] for i in range(26)]
l2=[[] for i in range(26)]
for i in range(len(s)):
  l[c.index(s[i])].append(t[i])
  l2[c.index(t[i])].append(s[i])
for i in range(26):
  l[i]=list(set(l[i]))
  l2[i]=list(set(l2[i]))
for i in range(26):
  if len(l[i])>=2:
    print('No')
    sys.exit()
  if len(l2[i])>=2:
    print('No')
    sys.exit()
print('Yes')

Measured memory_bytes: 81484
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<iostream>
using namespace std;


int main()
{
	int i, j, k, l, A, B, C, D, X, Y,N;
	long long int sum, flag;
	sum = 0;
	flag = 0;
	cin >> N;
	char S[300001];
	cin >> S;
	pair<int, int> P[300001] = {};
	P[0].first = P[0].second = 0;
	for (i = 1; i <= N; i++) {
		if (S[i-1] == 'E') {
			P[i].first=P[i-1].first+1;
          P[i].second=P[i-1].second;

		}
		else {
			P[i].first=P[i-1].first;
          P[i].second=P[i-1].second+1;
		}
	}
	int ans[300000] = {};
	for (i = 0; i < N; i++) {
		ans[i] = (P[N].first - P[i+1].first) + P[i].second;
	}
	sort(ans, ans + N);
	cout << ans[0] << endl;
    return 0;
}



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

int main(){
    int N, K, ans=0;
    cin >> N ;
    vector<int> a(N);
    for(int i=0; i<N; i++)
	cin >> a[i];
    for(int i=0; i<N; i++){
	while(true){
	    if(a[i]%2==0){
		a[i]/=2;
		ans++;
	    }
	    else
		break;
	}
    }
    
    cout << ans << endl;
    
}



Measured memory_bytes: 256
n,k=map(int,input().split())	
x=[list(map(int, input().split())) for i in range(2*k)]
ans=[range(1,n+1)]
num=[]
many=x[0:2*k:2]
cookie=x[1:2*k:2]
for y in range(len(cookie)):
    for z in range(len(cookie[y])):
        num.append(cookie[y][z])
Q=set(num)
W=list(Q)
print(n-len(W))

Measured memory_bytes: 9236
<?php
list($n,$k,$q)=explode(" ",trim(fgets(STDIN)));
if($q < $k){
  echo join("\n",array_fill(0,$n,'Yes'));
}else{
$i=0;
while($i<$q){
  $a[]=trim(fgets(STDIN));
  ++$i;
}
$a=array_count_values($a);
$ans=array_fill(0,$n,'No');
foreach( $a as $key => $val){
  if($k-$q+$val > 0){
    $ans[$key-1] = 'Yes';
  }
}
echo join("\n",$ans);
}

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

int main() {
  int n, x = 0, a = 0;
  string s;
  cin >> n >> s;
  
  for (int i = 0; i < s.size(); i++) {
    s[i] == 'I' ? x += 1 : x -= 1;
    a = max(a, x);
  } 
  
  cout << a << endl;
} 


Measured memory_bytes: 256
#include<cstdio>
#define ll long long
const int N=2e5+5,mo=1e9+7;
int n,nx,ny,mx1,mx2,a[N],b[N],mx[N],inv[N],i,j;
int read(){
	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;
}
int Min(int x,int y){return b[x]<b[y]?x:y;}
int et,he[N];
struct edge{int l,to;}e[4*N];
void line(int x,int y){
	e[++et].l=he[x];he[x]=et;e[et].to=y;
	e[++et].l=he[y];he[y]=et;e[et].to=x;
}
int cnt,qn,q[N],g[N],ans;
void dfs(int x){
	cnt++;ans=(ll)ans*cnt%mo;
	if (!(g[a[x]]++)) q[++qn]=a[x];
	a[x]=0;
	for (int i=he[x];i;i=e[i].l)
		if (a[e[i].to]) dfs(e[i].to);
}
int main(){
	n=read();nx=read();ny=read();b[0]=1e9+1;
	for (i=1;i<=n;i++){
		a[i]=read();b[i]=read();
		mx[a[i]]=Min(mx[a[i]],i);
	}
	for (i=1;i<=n;i++)
		if (b[mx[i]]<b[mx1]) mx2=mx1,mx1=mx[i];
		else if (b[mx[i]]<b[mx2]) mx2=mx[i];
	for (i=1;i<=n;i++){
		if (i!=mx[i]&&b[i]+b[mx[a[i]]]<=nx) line(i,mx[a[i]]);
		if (a[i]==a[mx1]){
			if (b[i]+b[mx2]<=ny) line(i,mx2);
		}
		else if (b[i]+b[mx1]<=ny) line(i,mx1);
	}
	for (inv[1]=1,i=2;i<=n;i++)
		inv[i]=(ll)inv[mo%i]*(mo-mo/i)%mo;
	for (i=2;i<=n;i++) inv[i]=(ll)inv[i]*inv[i-1]%mo;
	for (ans=1,i=1;i<=n;i++) if (a[i]){
		qn=0;cnt=0;dfs(i);
		for (j=1;j<=qn;j++)
			ans=(ll)ans*inv[g[q[j]]]%mo,g[q[j]]=0;
	}
	printf("%d",ans);
}

Measured memory_bytes: 11520
#include<iostream>
using namespace std;
int main(){
long n,x[32],i,j;
while(cin>>n,n){
i=0;
for(;;){
if(n<0)x[i]=9-(-n-1)%10;else x[i]=n%10;
n=(x[i]-n)/10;
if(n==0)break;i++;
}
for(j=i;j>=0;j--)cout<<x[j];cout<<endl;
}
return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<string>
#include<cstring>
#include<vector>

using namespace std;
const int M=1046527;
const int L=14;
const int NIL=-1;
string H[M];

int h1(int key){
	return key % M;
}
int h2(int key){
	return 1+(key % (M-1));
}
int getChar(char ch){
	switch(ch){
		case 'A':return 1;
		case 'C':return 2;
		case 'G':return 3;
		case 'T':return 4;
		default:return 0;
	}
}
long long getKey(string str){
	int len=str.size();
	long long sum=0,p=1;
	for(int i=0;i<len;++i){
         sum+=p*getChar(str[i]);
         p*=5;
	}
	return sum;
}
void insert(string &word){
     long long key=getKey(word);
     int i=0,j;
     while(true){
        j=(h1(key)+i*h2(key)) % M;
        if(H[j]=="") {
           H[j]=word;
           return;
        }
        else i++;
        
     }
}
bool find(string &word){
      
        long long key=getKey(word);
        long long h,i;
        for(i=0;;i++){
        	h=(h1(key)+i*h2(key)) % M;
        	if(H[h]==word) return true;
        	else if(H[h].size()==0) return false;
        }

}

int main(){
	int n ;
	string com,word;
	
	cin>>n;
	while(cin>>com>>word){
		if(com[0]=='i'){
             insert(word);
		}
		else if(com[0]=='f'){
           if( find(word) )
           	cout<<"yes"<<endl;
           else
           	cout<<"no"<<endl;
		}
	}

}


Measured memory_bytes: 42924
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

string b;

int main()
{
	cin >> b;
	if (b[0] == 'A')
	{
		cout << "T" << endl;
		return 0;
	}
	if (b[0] == 'T')
	{
		cout << "A" << endl;
		return 0;
	}
	if (b[0] == 'G')
	{
		cout << "C" << endl;
		return 0;
	}
	if (b[0] == 'C')
	{
		cout << "G" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

const int m = 2019;

int main()
{

    int a, b;
    cin >> a >> b;
    string x;
    if (a > b)
    {
        x = ">";
    }
    else if (a < b)
    {
        x = "<";
    }
    else
    {
        x = "==";
    }

    cout << "a " + x + " b" << endl;

    return 0;
}


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

#define int long long

using namespace std;

char a[701][701];

 main () {   
 	int n;
 	cin >> n;
 	for (int i = 1;i <= n;i ++) {
 		for (int j = 1;j <= n;j ++) {
 			cin >> a[i][j];
 			a[i + n][j] = a[i][j];
 			a[i][j + n] = a[i][j];
 			a[i + n][j + n] = a[i][j];
 		}
 	}
 	int ans = 0;
 	for (int st = 1;st <= n;st ++) {
 		int ok = 0;   
 		for (int i = st;i < n + st;i ++) {
 			for (int j = 1;j <= n;j ++) {
 			    int pos1 = j;
 			    int pos = i - st + 1;
 				char x = a[i][j];
 				char y = a[pos1 + st - 1][pos];
 				if (x != y) ok = 1;
 			}   	
 		}
 		ans += 1 - ok;
 	}
 	cout << ans * n;
    return 0;           		
}

Measured memory_bytes: 768
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll gcd(ll x,ll y){
    if(!y)
        return x;
    return gcd(y,x%y);
}
ll n,m;
int main()
{
    //freopen("light.in","r",stdin);
    //freopen("light.out","w",stdout);
    scanf("%lld%lld",&n,&m);
    m=min(m,n-m);
    ll k=max(gcd(n,m),n-gcd(n,m));
    printf("%lld\n",k*3);
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void){
	int a[20],b[20],i,t,n,nn,y;
	a[0] = 1;
	for(t = 1;t<20;t++){
		a[t] = 0;
	}

	scanf("%d",&n);

	for(t=1;t<n+1;t++){
		for(i=0;i<20;i++){
			b[i] = 0;
		}

		for(i=0;i<20;i++){
			b[i] = a[i]*t;
		}

		for(i=0;i<20;i++){
			y = b[i]/10;
			b[i+1] += y;
			b[i] -= y*10;
		}

		for(i=0;i<20;i++){
			a[i] = b[i];
		}



	}

	if(n<4){
		nn = 1;
	}
	else if(n<6){
		nn = n - 2;
	}
	else if(n<14){
		nn =n - 3;
	}
	else if(n<19){
		nn =n -2;
	}
	else{
		nn = n -1;
	}

	for(i=0;i<nn;i++){
		printf("%d",a[nn-i-1]);
	}
		printf("\n");

	


return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath> 
#include <queue>
#include <functional>

using namespace std;
//typedef long long ll;
//typedef pair<int, int> P;
//static const int dx[4] = {1, -1, 0, 0};
//static const int dy[4] = {0, 0, 1, -1};


int main() {

    int N, M; cin >> N >> M;
    vector<int> num(100001, 1);
    vector<int> red(100001, 0);
    red[1] = 1;
    int x, y;
    for (int i = 0; i < M; i++) {
        cin >> x >> y;
        num[x]--; num[y]++;
        if (red[x] == 1) red[y] = 1;
        if (num[x] == 0) red[x] = 0;
    }

    int cnt = accumulate(red.begin(), red.end(), 0);
    cout << cnt << '\n';

}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=2e5+10;

char s[maxn],ans[maxn];
string s2;
int n,nxt[maxn][30],cnt[maxn];
bool f[maxn];

int main(){
	cin>>s2;
	for(int i=0;i<s2.size();i++) s[i+1]=s2[i];
	n=(int)s2.size();
	for(int i=0;i<maxn;i++) for(int j=0;j<30;j++) nxt[i][j]=n+1;
	for(int i=0;i<26;i++){
		int lst=n+1;
		for(int j=n;j>=0;j--){
			nxt[j][i]=lst;
			if(j!=0&&s[j]=='a'+i) lst=j;
		}
	}
	for(int i=0;i<maxn;i++) cnt[i]=-1;
	int cs=0;
	for(int i=n;i>=0;i--){
		bool flag=1;
		for(int j=0;j<26;j++) if(f[j]==0) flag=0;
		if(flag){
			cs++;
			for(int j=0;j<26;j++) f[j]=0;
		}
		cnt[i]=cs;
		if(i!=0) f[s[i]-'a']=1;
	}
	int len=cnt[0]+1,pos=0;
	for(int i=0;i<len;i++){
	//	cout<<pos<<" ";
		for(int j=0;j<26;j++){
			int np=nxt[pos][j];
		//	cout<<cnt[np]<<" "<<len-i-1<<endl;
			if(cnt[np]<len-i-1){
				ans[i]='a'+j;
				pos=np;
				break;
			}
		}
	}
//	cout<<endl;
	string t=(string)ans;
	cout<<t<<endl;
	return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 100005;

int freq[N], v[N];

void solve(){
	int n, q;
	ll sum = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> v[i];
		freq[v[i]]++;
		sum += v[i];
	}
	cin >> q;
	while(q--){
		ll x,y;
		cin >> x >> y;
		sum -= ((ll)freq[x]*x);
		sum += ((ll)freq[x]*y);
		freq[y] += freq[x], freq[x] = 0LL;
		cout << sum << endl;
	}
}

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


Measured memory_bytes: 4320
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>

#define for0(i, n)    for (int i = 0  ; i <  (n); ++i)
#define for1n(i, n)   for (int i = 1  ; i <= (n); ++i)
#define for1(i, n)    for (int i = 1  ; i <  (n); ++i)
#define forn(i, n)    for (int i = 0  ; i <= (n); ++i)
#define forx(i, n, x) for (int i = (x); i <  (n); ++i)

using namespace std;

typedef long long ll;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll> ,greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;


int main(void){

    int a, b;

    cin >> a >> b;

    int c = (b - 1) / (a - 1);

    if ((b - 1) % (a - 1) != 0) {
        ++c;
    }
    
    cout << c;
    

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  cin >> N;
  map<char, ll> mp;
  REP(i, N) {
    string S;
    cin >> S;
    mp[S[0]]++;
  }
  ll ans = 0;
  ans += mp['M'] * mp['A'] * mp['R'];
  ans += mp['M'] * mp['A'] * mp['C'];
  ans += mp['M'] * mp['A'] * mp['H'];
  ans += mp['M'] * mp['R'] * mp['C'];
  ans += mp['M'] * mp['R'] * mp['H'];
  ans += mp['M'] * mp['C'] * mp['H'];
  ans += mp['A'] * mp['R'] * mp['C'];
  ans += mp['A'] * mp['R'] * mp['H'];
  ans += mp['A'] * mp['C'] * mp['H'];
  ans += mp['R'] * mp['C'] * mp['H'];
  cout << ans << endl;
  return 0;
}

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

#define MOD 1000000007
#define lli long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = n - 1; ~i; i--)
#define pb push_back
#define mkp make_pair
#define endl "\n"

using namespace std;

bool enable_test_case = false;
bool enable_google = false;

void solve()
{
    lli n;
    cin >> n;
    lli h[n];
    lli dp[n];
    rep(i, n)
    {
        cin >> h[i];
        dp[i] = INT64_MAX;
    }
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    dp[2] = min(abs(h[0] - h[2]), abs(h[0] - h[1]) + abs(h[1] - h[2]));
    //cout << dp[0] << "  " << dp[1] << " " << dp[2] << endl;
    for (int i = 3; i < n; i++)
    {
        for (int j = 1; j <= 2; j++)
        {
            //cout << dp[i] << " " << dp[i - j] << " " << abs(h[i - j] - h[i]) << endl;
            dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
        }
    }
    // rep(i, n)
    // {
    //     cout << dp[i] << " ";
    // }
    cout << dp[n - 1];
    cout << endl;
}

void google_contests(int t)
{
    cout << "Case #" << t + 1 << ": ";
}

void test_case()
{
    if (enable_test_case)
    {
        lli t;
        cin >> t;
        rep(i, t)
        {
            if (enable_google)
                google_contests(i);
            solve();
        }
    }
    else
    {
        solve();
    }
}

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

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    test_case();

    return 0;
}


Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define sort(a) sort(all(a))
using P = pair<int, int>;
using ll = long long;
using ld = long double;
int dx[4] = { 0, 1, 0,-1 };
int dy[4] = { 1, 0,-1, 0 };

const int INF = (1<<21);

signed main() {
  int K,N;
  cin >> K >> N;
  int A[2*N];
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A[i] = a;
    A[i+N] = a+K;
  }
  int ans = INF;
  for (int i = 0; i < N; i++) {
    ans = min(ans, A[i+N-1]-A[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
n, k = map(int, input().split())
s = input()

leftflag = 0
if s[0] == "L":
  leftflag = 1
  
rightflag = 0
if s[-1] == "R":
  rightflag = 1
    
rlnum = 0

for i in range(len(s)-1):
  if s[i] == "R" and s[i+1] == "L":
    rlnum += 1

rlnum_final = rlnum
rightflag_final = rightflag
leftflag_final = leftflag
    
if k <= rlnum - 1:
  rlnum_final = rlnum - k
  
if k == rlnum :
  rlnum_final = 0
  if rightflag == 0 and leftflag == 0:
    rightflag_final = 1
    
if k >= rlnum + 1:
  rlnum_final = 0
  rightflag_final = 1
  leftflag_final = 0

print(n - (2*rlnum_final + rightflag_final + leftflag_final))

Measured memory_bytes: 3316
#!/usr/bin/env python3
import collections

N = int(input().split()[0])
S = input()

ext_n_open, ext_n_close = 0, 0
sub_s = ""

for i, ch in enumerate(list(S)):
    if ch == "(":
        ext_n_open += 1
    else:
        if ext_n_open == 0:
            # 余分な)である
            ext_n_close += 1
        else:
            # 以前出た(と相殺
            ext_n_open -= 1

ans = "(" * ext_n_close + S + ")" * ext_n_open

print(ans)


Measured memory_bytes: 3316
/*
英小文字のみからなる文字列 s, t が与えられます。 
あなたは、s の文字を好きな順に並べ替え、文字列 s′ を作ります。 
また、t の文字を好きな順に並べ替え、文字列 t′ を作ります。 
このとき、辞書順で s′< t′ となるようにできるか判定してください。
*/
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end()); // 降順に
    if (s<t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int sum[2],T,a,b,c,d;
	for(int i=0;i<2;++i){
		cin>>a>>b>>c>>d;
		sum[i]=a+b+c+d;
	}
	cout<<max(sum[0],sum[1])<<endl;
	return 0;
}

Measured memory_bytes: 0