akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
 
int dice1[6],dice2[6];
int i,t,clear=0;
 
int ue=1;
int hid=4;
int mig=3;
int mae=2;
int usi=5;
int sit=6;
 
void Move2();
void eMove();
void nMove();
void sMove();
void wMove();
 
int main(){
    for(i=0;i<6;i++)scanf("%d",&dice1[i]);
    for(i=0;i<6;i++)scanf("%d",&dice2[i]);
     
    Move2();
     
    if(clear==1)printf("Yes\n");
    else printf("No\n");
     
    return 0;
}
 
void Move2(){
    for(i=0;i<5000;i++){
        int rnd=rand()%4;
         
        if(rnd==0)eMove();
        else if(rnd==1)nMove();
        else if(rnd==2)sMove();
        else wMove();
         
        if((dice1[0]==dice2[ue-1])&&(dice1[1]==dice2[mae-1])&&
            (dice1[2]==dice2[mig-1])&&(dice1[3]==dice2[hid-1])&&
            (dice1[4]==dice2[usi-1])&&(dice1[5]==dice2[sit-1])){
            clear=1;
            break;
        }
    }
    return;
}
 
void eMove(){
    t=ue;
    ue=hid;
    hid=sit;
    sit=mig;
    mig=t;
    return;
}
 
void nMove(){
    t=ue;
    ue=mae;
    mae=sit;
    sit=usi;
    usi=t;
    return;
}
 
void sMove(){
    t=ue;
    ue=usi;
    usi=sit;
    sit=mae;
    mae=t;
    return;
}
 
void wMove(){
    t=ue;
    ue=mig;
    mig=sit;
    sit=hid;
    hid=t;
    return;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h> 
using namespace std; 
const int dx[]={1,0,-1,0,1,-1,-1,1}; 
const int dy[]={0,1,0,-1,1,1,-1,-1}; 
const int INF = 1e9; 
const long long LINF = 1e18; 
const double EPS = 1e-8; 
#define pb emplace_back 
#define mk make_pair 
#define fr first 
#define sc second 
#define ll long long 
#define reps(i,j,k) for(int i = (j); i < (k); ++i) 
#define rep(i,j) reps(i,0,j) 
#define all(a) (a).begin(),(a).end() 
#define MOD 1000000007 
typedef pair<int,int> Pii; 
typedef vector<int> vi; 
typedef pair<string, int> Psi; 
typedef pair<ll, ll> Pll;

int main(){
	int sum = 0;
	vi a(4);
	rep(i,4){
		cin >> a[i];
		sum += a[i];
	}
	sort(a.begin(),a.end());

	vi b(2);
	rep(i,2){
		cin >> b[i];
		sum += b[i];
	}
	sort(b.begin(),b.end());

	cout << sum - a[0] - b[0] << endl;

	return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>

using namespace std;

int main()
{
    char s[101], t[101];
    cin >> s >> t;
    int lens=strlen(s), lent=strlen(t);
    sort(s, s+lens);
    sort(t, t+lent, greater<int>());
    if(lens<lent){
        for(int i=0; i<lens; i++){
            if(s[i]<t[i]){
                cout << "Yes";
                break;
            }else if(s[i]>t[i]){
                cout << "No";
                break;
            }
            if(i==lens-1){
                cout << "Yes";
            }
        }
    }else{
        for(int i=0; i<lens; i++){
            if(s[i]<t[i]){
                cout << "Yes";
                break;
            }else if(s[i]>t[i]){
                cout << "No";
                break;
            }
            if(i==lens-1){
                cout << "No";
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 384
n=int(input())
a,b=map(int, input().split())
l=list(map(int, input().split()))
ul=[]
ml=[]
ol=[]
sorted(l)
for i in range(n):
	if l[i]<=a:
		ul.append(l[i])
	elif (a+1)<=l[i]<=b:
		ml.append(l[i])
	elif l[i]>=(b+1):
		ol.append(l[i])
print(min(len(ul),len(ml),len(ol)))

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


int main() {
  int A,B;
  cin>>A>>B;
  cout<<A*B<<endl;
}

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

int parse_int(string s){
	int reg = 1, res = 0;
	for(int i = 0;i < s.length();++i){
		if('2' <= s[i] && s[i] <= '9'){
			reg = s[i] - '0';
		}
		else{
			if(s[i] == 'm'){
				res += reg * 1000;
			}
			else if(s[i] == 'c'){
				res += reg * 100;
			}
			else if(s[i] == 'x'){
				res += reg * 10;
			}
			else {
				res += reg;
			}
			reg = 1;
		}
	}
	return res;
}

string parse_str(int a){
	string res = "";
	int divisor[] = {1000, 100, 10, 1};
	char symbol[] = {'m', 'c', 'x', 'i'};
	for(int i = 0;i < 4;++i){
		int c = a / divisor[i];
		if(c == 1){
			res += symbol[i];
		}
		else if(1 < c && c < 10){
			res += (c + '0');
			res += symbol[i];
		}
		a -= c * divisor[i];
	}
	return res;
}

int main(){
	int n;
	string a, b;
	cin >> n;
	for(int i = 0;i < n;++i){
		cin >> a >> b;
		cout << parse_str(parse_int(a) + parse_int(b)) << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#include<stdio.h>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;
int main()
{

    int t,n,i,arra[1000],m,sum=0;
    string s;
        cin>>n>>m;
        for(i=0;i<n;i++)
        {
            cin>>arra[i];
        }
        sort(arra,arra+n);
        for(i=0;i<m;i++)
            sum+=arra[i];
        cout<<sum<<endl;

    return 0;
}



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

int main(){
    int a , b , c;
    cin >> a >> b >> c;
    if(a<c && c<b) cout << "Yes" << endl;
    else if (c<a && c>b) cout << "Yes" << endl;
    else cout << "No" << endl;    
}

Measured memory_bytes: 256
//#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>

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<int, double> pid;
typedef pair<double, int> pdi;
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 A[2], B[2];
	rep(i, 0, 2)
	{
		cin >> A[i];
	}
	rep(i, 0, 2)
	{
		cin >> B[i];
	}
	sort(A, A + 2);
	sort(B, B + 2);
	cout << A[0] + B[0] << endl;

	return 0;
}

Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int a, b;
    for(;sc.hasNext();){
      out.print(sc.next() + " ");
      a = sc.nextInt(); b = sc.nextInt();
      out.println((a + b) + " " + (200 * a + 300 * b));
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 25856
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};



int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n; ll d, a;
    cin >> n >> d >> a;
    vector<Pll> monsters(n);
    for(int i=0;i<n;++i) {
        // cin >> x[i] >> h[i];
        cin >> monsters[i].first >> monsters[i].second;
    }
    sort(monsters.begin(), monsters.end());

    vector<ll> s(n+1, 0);
    ll ans = 0LL;
    for(int i=0;i<n;++i) {
        monsters[i].second -= s[i] * a;
        if(monsters[i].second > 0) {
            ll m = (monsters[i].second + a - 1) / a;
            ans += m;
            s[i] += m;
            auto itr = lower_bound(monsters.begin(), monsters.end(), Pll(monsters[i].first+2*d+1, 0LL));
            s[itr-monsters.begin()] -= m;
        }
        s[i+1] += s[i];;
        // for(int j=0;j<=n;++j) cerr << s[j] << " ";
        // cerr << endl;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4992
s = input()

flag = 1

for i in range(len(s)):
    if (i+1)%2 == 1:
        if s[i] != 'R' and s[i] != 'U' and s[i] != 'D' :
            flag = 0
            break
    
    else:
        if s[i] != 'L' and s[i] != 'U' and s[i] != 'D':
            flag = 0
            break

print("Yes" if flag == 1 else "No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
const int N = 4000;
int opt[N][N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    while(cin >> s >> t) {
        int ans = 0;
        for(int i = 0; i < s.size(); i++) {
            for(int j = 0; j < t.size(); j++) {
                ans = max(ans, opt[i][j] = s[i] == t[j] ? 1 + (i and j ? opt[i-1][j-1] : 0) : 0);
            }
        }
        cout << ans << endl;
    }
    return 0;
}



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

int main(){
  while(1){
    int H, W;
    cin>>H>>W;
    if(H == 0 && W == 0) break;

    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cout<<"#";

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



Measured memory_bytes: 3076
using System;

namespace ABC103_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var ans = 0;
            foreach(var ch in a)
            {
                ans += ch - 1;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13232
#include<stdio.h>

int main(){
    while(true){
        int h,w;
        scanf("%d %d",&h,&w);
        if(h == 0 && w == 0) break;
        for(int i = 1;i <= h;i++){
            for(int j = 1;j <= w;j++){
                if(i == 1 || j == 1|| i == h || j == w) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2596
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S, A = "AKIHABARA", sub;
  string data[16] = {"AKIHABARA", "AKIHABAR", "AKIHABRA", "AKIHABR", "AKIHBARA", "AKIHBAR", "AKIHBRA", "AKIHBR", "KIHABARA", "KIHABAR", "KIHABRA", "KIHABR", "KIHBARA", "KIHBAR", "KIHBRA", "KIHBR"};
  cin >> S;
  for(int i = 0; i < 16; i++){
    if(S == data[i]){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e5+9;
map<string,int>m;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    string s;
    int mx=0;
    for (int i=0;i<x;i++){
        cin>>s;
        m[s]++;
        mx=max(mx,m[s]);
    }
    set<string>st;
    for (auto j:m){
        if (j.second==mx)
            st.insert(j.first);
    }
    for (auto j:st)
        cout<<j<<endl;
    return 0;
}


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

void mergesort(long y[], int p[], int a[], int i, int j);
void merge(long y[], int p[], int a[], int i, int j);

int main(void)
{
	int n, m, *p, *a;
	long *y, *no, *c;
	scanf("%d%d", &n, &m);
	p=(int *)malloc(sizeof(int)*m);
	y=(long *)malloc(sizeof(long)*m);
	a=(int *)malloc(sizeof(int)*m);
	no=(long *)malloc(sizeof(long)*m);
	c=(long *)malloc(sizeof(long)*(n+1));

	for (int i = 0; i < m; ++i)
	{
		scanf("%d%ld", &p[i], &y[i]);
	}
	for (int i = 0; i < m; ++i)
	{
		a[i] = i;
	}
	for (int i = 0; i <= n; ++i)
	{
		c[i] = 1;
	}

	mergesort(y, p, a, 0, m-1);

	for (int i = 0; i < m; ++i)
	{
		no[a[i]] = (long)p[i]*1000000+c[p[i]];
		c[p[i]]++;
	}

	for (int i = 0; i < m; ++i)
	{
		printf("%012ld\n", no[i]);
	}

	free(y);
	free(p);
	free(a);
	free(no);
	free(c);

	return 0;
}

void mergesort(long y[], int p[], int a[], int i, int j)
{
	if (i-j == 0)
	{
		return;
	}
	else
	{
		mergesort(y, p, a, i, (i+j)/2);
		mergesort(y, p, a, (i+j)/2+1, j);
		merge(y, p, a, i, j);
		return;
	}
}

void merge(long y[], int p[], int a[], int i, int j)
{
	int l, r;
	long y2[j];
	int p2[j];
	int a2[j];
	l=i;
	r=(i+j)/2+1;
	for (int k = i; k <= j; ++k)
	{
		if (l > (i+j)/2)
		{
			y2[k] = y[r];
			p2[k] = p[r];
			a2[k] = a[r];
			r++;
		} else if (r > j)
		{
			y2[k] = y[l];
			p2[k] = p[l];
			a2[k] = a[l];
			l++;
		} else if (y[l] <= y[r])
		{
			y2[k] = y[l];
			p2[k] = p[l];
			a2[k] = a[l];
			l++;
		} else
		{
			y2[k] = y[r];
			p2[k] = p[r];
			a2[k] = a[r];
			r++;
		}
	}
	for (int k = i; k <= j; ++k)
	{
		y[k]=y2[k];
		p[k]=p2[k];
		a[k]=a2[k];
	}
	return;
}

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

int main() {
  string s;
  cin >> s;
  if (s[0] == s[1] && s[1] == s[2])
    cout << "Yes" << endl;
  else if (s[1] == s[2] && s[2] == s[3])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,l,r) for (int i=l; i<=r; i++)
typedef long long ll;
using namespace std;

int a,b;

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

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

using namespace std;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  
  int cnt=0;
  for(int i=a; i<=b; i++){
	if(i%c == 0){
		cnt++;
    }
  }
  
  cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main(){
  string s;
  while(getline(cin,s)){
    for(int i=0; i<26; i++){
      for(int j=0; j<s.size(); j++){
	if(s[j] == 'z') s[j] = 'a';
	else if(s[j] >= 'a' && s[j] < 'z') s[j]++;
      }
      if(s.find("this") != string::npos ||
	 s.find("the") != string::npos||
	 s.find("that") != string::npos){
	cout <<s<<endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int
vector<bool> get(int n) {
  // [1,n] でprimeならtrue,compならfalseの配列を返す↵
  vector<bool> flags(n + 1, true);
  flags[0] = flags[1] = false;
  for (int i = 2; i <= n; i += 1) {
    if (flags[i]) {
      for (int j = 2 * i; j <= n; j += i) {
        flags[j] = false;
      }
    }
  }
  return flags;
}
vector<int> p_list(int n) {
  auto s = get(n);
  vector<int> v;
  for (int i = 2; i * i <= n; i++) {
    if (s[i])
      v.push_back(i);
  }
  return v;
}

void solve(long long N, std::vector<long long> A) {
  vector<int> primes = p_list(1e6);
  int sz = primes.size();
  auto B = A;
  map<int, int> t;
  rep(i, N) {
    for (auto s : primes) {
      if (A[i] % s == 0) {
        t[s]++;
        while (A[i] % s == 0)
          A[i] /= s;
      }
    }
    if (A[i] != 1)
      t[A[i]]++;
  }
  for (auto s : t) {
    if (s.second > 1) {
      int ret = B[0];
      for (auto ss : B)
        ret = __gcd(ss, ret);
      if (ret == 1) {
        cout << "setwise coprime" << endl;
        return;
      } else {
        cout << "not coprime" << endl;
        return;
      }
    }
  }
  cout << "pairwise coprime" << endl;
}

signed main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


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

int getgcd(int n, int m)
{
  int r;
  if (n > m)
  {
    int t = m;
    m = n;
    n = t;
  }
  while ((r = m % n) != 0)
  {
    m = n;
    n = r;
  }
  return n;
}

int main(void)
{
  int K;

  cin >> K;

  int a, b, c;

  int ans = 0;

  for (int i = 1; i <= K; i++)
  {
    for (int j = 1; j <= K; j++)
    {
      for (int k = 1; k <= K; k++)
      {
        ans += getgcd(getgcd(i, j), k);
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using Graph = vector<vector<ll>>;

int main(){
  int a;
  cin >> a;
  string s;
  cin >> s;
  if (a >= 3200)
  {
    cout << s << endl;
  }
  else
  {
    cout << "red" << endl;
  }
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C___Sqrt_Inequality
{
    class Program
    {
        static void Main(string[] args)
        {
            var a_b_c = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long a = a_b_c[0], b = a_b_c[1], c = a_b_c[2];

            long right = a_b_c[2] - a_b_c[0] - a_b_c[1];
            Console.WriteLine(right > 0 && right * right - 4 * a * b > 0 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13396
#include <stdio.h>
int main()
{
    int A[110];
    int n, i, j, v;
    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &A[i]);
    for(i = 0; i < n; i++)
    {
        if(i) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    for(i = 1; i < n; i++)
    {
        v = A[i];
        j = i - 1;
        while(A[j] > v && j >= 0)
        {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        for(j = 0; j < n; j++)
        {
            if(j) printf(" ");
            printf("%d", A[j]);
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2144
import qualified Data.List as L
import Control.Monad

main = interact (show . solve . read)

p_list = reverse $ L.sort
    [ 6
    , 36
    , 216
    , 1296
    , 7776
    , 46656
    , 9
    , 81
    , 729
    , 6561
    , 59049]

hoge :: (Int, Int) -> Int -> [(Int, Int)]
hoge (c, n) s =
    let
        p =  n `div` s
    in
        if p < 9 then map (\t -> (c + t, n - s * t)) [0..p] else []

solve :: Int -> Int
solve n = foldl min 100000 $ map (\(a, b) -> a + b) $ foldl (\xs p -> join $ map (\n' -> hoge n' p) xs) [(0, n)] p_list



Measured memory_bytes: 1020
#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, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using P = pair<int, int>;

signed main() {

    int k, a, b;
    cin >> k >> a >> b;

    REP(i, a, b+1){
        if(i % k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>

using namespace std;

void solve() {
    int n;
    cin >> n;
    int a[n];
    for (int i=0; i < n; ++i) {
        cin >> a[i];
    }
    int b[n];
    for (int i=0; 2*i+1 < n; i += 1) {
        b[i] = a[n-1-2*i];
        b[n-1-i] = a[n-1-2*i-1];
    }
    if (n&1) {
        b[n/2] = a[0];
    }
    for (int i=0; i < n; ++i) {
        cout << b[i] << " ";
    }

}

int main() {

	solve();
    return 0;
}


Measured memory_bytes: 4728
import sys
input=sys.stdin.readline

def main():
    r,g,b,n=map(int,input().split())
    ans=0
    for i in range(n+1):
        for j in range(n+1):
            B=i*r+j*g
            if B>n: continue
            if (n-B)%b==0:
                ans+=1
    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

bool is_mm(string s) {
  return s > "00" && s < "13";
}

int main()
{
  string s;
  cin >> s;
  string first, second;
  first += s[0];
  first += s[1];
  second += s[2];
  second += s[3];
  if (is_mm(first) && is_mm(second)) {
    cout << "AMBIGUOUS" << endl;
    return 0;
  } else {
    if (is_mm(first)) {
      cout << "MMYY" << endl;
      return 0;
    } else if (is_mm(second)) {
      cout << "YYMM" << endl;
      return 0;
    } else {
      cout << "NA" << endl;
      return 0;
    }

  }
  return 0;
}

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

//カード捨てる
void throw_away_card(char *card, int num)
{
	int i;
	for (i = 0; i < num; i++) {
		card[i] = card[i + 1];
	}
}

int main (void)
{
	char Sa[100 + 1];
	char Sb[100 + 1];
	char Sc[100 + 1];
	char who = 'a';
	int num;

	//Aの入力
	scanf("%s", Sa);

	//Bの入力
	scanf("%s", Sb);

	//Cの入力
	scanf("%s", Sc);
	
	//ゲームスタート
	while (1) {
		if (who == 'a') {
			num = strlen(Sa);
			if (num == 0) {
				printf("A\n");
				break;
			}
			who = Sa[0];
			throw_away_card(Sa, num);

		} else if (who == 'b') {
			num = strlen(Sb);
			if (num == 0) {
				printf("B\n");
				break;
			}
			who = Sb[0];
			throw_away_card(Sb, num);
		} else if (who == 'c') {
			num = strlen(Sc);
			if (num == 0) {
				printf("C\n");
				break;
			}
			who = Sc[0];
			throw_away_card(Sc, num);
		}
	}
	
	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*
    add utility Algorithm
*/



int main(int argc, char const* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, M;
    cin >> N >> M;

    int left = N / 2;
    int right = N / 2 + 1;

    if (N % 2 == 1) {
        for (int i = 1; i <= M; ++i) {
            cout << i << " " << M * 2 + 1 - i << endl;
        }
    }
    else {
        int m2 = M / 2;
        int m1 = M - m2;

        for (int i = 1; i <= m1; i++)
        {
            cout << i << " " << m1 * 2 + 1 - i << endl;
        }

        int m = m1 * 2;
        for (int i = 1; i <= m2; i++)
        {
            cout << m + i << " " << m + m2 * 2 + 2 - i << endl;
        }

    }


    return 0;
}


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

template<class T>
void print_vec(vector<T>& v) {
	for (T n: v) cout << n << " ";
	cout << "\n";
}

int solve(int N, int M) {
	int a = M / N;
	int b = M % N;
	if (b == 0) return a; 
	while (a > 1 && M % a != 0) a--;
	return a;
}

int main() {
	// freopen("./input.txt", "r", stdin);
	int N, M;
	cin >> N >> M;
	cout << solve(N, M) << "\n";	
	
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<ll> div;
  vector<ll> div_2;
  vector<ll> div_4;
  rep(i, N){
    ll a;
    cin >> a;
    if (a % 2 != 0) div.push_back(a);
    else if (a % 2 == 0 && a % 4 != 0) div_2.push_back(a);
    else div_4.push_back(a);
  }
  if (div_4.size() >= div.size()){
    cout << "Yes" << endl;
  }
  else if (div.size() == div_4.size() + 1) {
    if (div_2.size() == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else {
    cout << "No" << endl;
  }
    
  
}


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

int main() {
  int  w;
  cin >> w;
  int a[100];
  for(int i =0;i<w;i++)
    cin >>a[i];
 
  
  int c,d;
    c = a[0];
   d = a[0];
   for (int i = 0; i < w; i++){
    
       if(a[i] >c){
          c = a[i];
       }
     if(a[i] <d){
       d =a[i];
     }
   }
    cout << c-d <<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{

    string s, k;    cin >> s >> k;
    int num = 0;
    for (int i = 0; i < s.size(); i++){
        if (s[i] != k[i]){
            num++;
        }
    }

    cout << num << endl;

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> B(N);
  for(int i = 0; i < N; ++i){
    cin >> B[i];
  }
  vector<bool> used(N,false);
  vector<int> ans;
  for(int i = 0; i < N; ++i){
    int j = 0, t = -1;
    for(int k = 0; k < N; ++k){
      if(not used[k]) ++j;
      if(j == B[k] and (t < 0 or B[k] >= B[t])){
        t = k;
      }
    }
    if(t < 0) break;
    ans.push_back(B[t]);
    used[t] = true;
  }
  if(ans.size() != N) cout << -1 << endl;
  else{
    for(int i = N-1; i >= 0; --i) cout << ans[i] << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int A, B;
int main()
{
    cin >> A >> B;
    if(A%3==0 || B%3==0 || (A+B)%3==0)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include<algorithm>
#include<string>
 
using namespace std;
int n,a;
int main (){
cin>>n>>a;if(n%3==0||a%3==0||(n+a)%3==0)cout<<"Possible "<<endl;else  cout<<"Impossible "<<endl;
 
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdint>
#include <iostream>
#include <vector>
#include <algorithm>


void mondai_a() {
    // 入力
    uint64_t n, a, b;
    std::cin >> n >> a >> b;

    uint64_t c = 0;
    // a,bの差が偶数だったらお互いに近づけばOK.
    if ( ( b - a ) % 2 == 0 ) {
        std::cout << ( b - a ) / 2;
        return;
    }
    // a,bの差が奇数だったら、どちらか片方どちらかの端に寄せるしかない
    // 寄せるまで
    uint64_t yose = std::min( (a-1), (n-b) );
    // 差が 1 しかなければ 1回追加しておしまい
    if ( ( b - a ) == 1 ) {
        std::cout << (yose + 1);
        return;
    }
    // 差が 3 以上の奇数であれば、お互いの寄せ + 1 でOK
    std::cout << ( yose + ( b - a )/2 + 1);
    return;
}

int main() {

    mondai_a();

    return 0;
}


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

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pti;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; }
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }
template<typename X, typename Y> inline ostream& operator<< (ostream& out, const map<X, Y>& a) { return out << vector<pair<X, Y>>(all(a)); }
template<typename T> inline ostream& operator<< (ostream& out, const pair<T*, int>& a) { return out << vector<T>(a.x, a.x + a.y); }

inline ld gett() { return ld(clock()) / CLOCKS_PER_SEC; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

#ifdef SU1
//#define GEN
#ifndef GEN
#define LOG
#endif
#endif

const int N = 101, K = 10100;

int n, m, k;
int a[K];

bool read() {
  if (!(cin >> n >> m >> k)) return false;
  forn(i, k) assert(scanf("%d", &a[i]) == 1);
  return true;
}

int ans[N][N];

int dx[] = { 0, 1, 0, -1 };
int dy[] = { 1, 0, -1, 0 };

void print() {
  forn(i, n) {
    forn(j, m) {
      if (j > 0) putchar(' ');
      printf("%d", ans[i][j]);
    }
    puts("");
  }
}

void solve() {
  int cnt[] = { m, n - 1 };
  int x = 0, y = -1, dir = 0, cur = 0;

  forn(i, k) {
    forn(j, a[i]) {
      x += dx[dir];
      y += dy[dir];
      ans[x][y] = i + 1;
      if (++cur >= cnt[dir % 2]) {
        cur = 0;
        cnt[dir % 2]--;
        dir = (dir + 1) % 4;
      }
    }
    //print(); puts("");
    //clog << "cnt: " << mp(cnt, 2) << endl;
  }

  print();
}

int main() {
#ifdef SU1
  assert(freopen("input.txt", "rt", stdin));
  //assert(freopen("output.txt", "wt", stdout));
#endif

  cout << setprecision(10) << fixed;
  cerr << setprecision(5) << fixed;

  while (read()) {
    ld stime = gett();
    solve();
#ifdef SU1
    cerr << "Time: " << gett() - stime << endl;
#endif
    //break;
  }

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<tuple>
#include<queue>
#define LL long long
#define TT std::tuple<LL,LL,LL>
#define PP std::pair<LL,LL>
LL N, C;
std::vector<PP> S;
LL R[100010];
LL L[100010];
LL RS[100010];
LL LS[100010];
LL ans;
LL res;
int main() {
	std::cin >> N >> C;
	S.push_back(PP{ 0,0 });
	S.push_back(PP{ C,0 });
	for (int i = 0; i < N; i++) {
		LL x, v;
		std::cin >> x >> v;
		S.push_back(PP{ x,v });
	}
	std::sort(S.begin(), S.end());
	LL sum = 0;
	for (int i = 1; i <= N; i++) {
		RS[i] += RS[i - 1] + S[i].second;
		sum -= S[i].first - S[i-1].first;
		sum += S[i].second;
		ans = std::max(sum, ans);
		res = std::max(ans, res);
		R[i] = ans;
	}
	sum = 0;
	std::reverse(S.begin(), S.end());
	ans = 0;
	for (int i = 1; i <= N; i++) {
		LS[i] += LS[i - 1] + S[i].second;
		sum -= S[i - 1].first - S[i].first;
		sum += S[i].second;
		ans = std::max(sum, ans);
		res = std::max(ans, res);
		L[i] = ans;
	}
	std::reverse(S.begin(), S.end());
	for (int i = 1; i <= N; i++) {
		res = std::max(res, L[N - i] - S[i].first*2 + RS[i]);
	}
	std::reverse(S.begin(), S.end());
	for (int i = 1; i <= N; i++) {
		res = std::max(res, R[N - i] - (C - S[i].first)*2 + LS[i]);
	}
	std::cout << res << std::endl;
	return 0;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,m; cin>>n>>m;
    vector<int> a(m);
    vector<vector<int>> c(m);
    rep(i,m) {
        cin>>a[i];
        int b; cin>>b;
        c.reserve(b);
        rep(j,b) {
            int t; cin>>t;
            --t;
            c[i].push_back(t);
        }
    }

    vector<ll> dp(1<<n,LINF);
    dp[0] = 0;
    
    for (int bit = 0; bit < (1<<n); ++bit) {
        rep(i,m) {
            int nxt = bit;
            for (auto &&e: c[i]) {
                int tmp = (1<<e);
                nxt |= tmp;
            }
            chmin(dp[nxt], dp[bit]+a[i]);
        }
    }

    if (dp[(1<<n)-1] == LINF) cout << -1 << '\n';
    else cout << dp[(1<<n)-1] << '\n';
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void) {
	int a, b, x;

	scanf("%d %d", &a, &b);

	if (1 > a || a > 100 || 1 > b || b > 100)
		return 0;
	else if (a <= 2 * b)
		x = 0;
	else
		x = a - 2 * b;

	printf("%d", x);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define endl '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define floop(i,a,b) for(int i=a;i<=b;++i)
const ll mod=1e9+7;
const int maxn=1e7+2;
int a[maxn];
int32_t main(){
	IOS;	
	int ans=0;
	int n;
	cin>>n;
	floop(i,2,n){
		ans+=(a[i]+2)*i;
		for(int j=i+i;j<=n;j+=i) a[j]++;		
	}
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 81748
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();

    let ab: Vec<(i64, i64)> = (0..n)
        .map(|_| {
            (
                itr.next().unwrap().parse().unwrap(),
                itr.next().unwrap().parse().unwrap(),
            )
        })
        .collect();
    let cd: Vec<(i64, i64)> = (0..m)
        .map(|_| {
            (
                itr.next().unwrap().parse().unwrap(),
                itr.next().unwrap().parse().unwrap(),
            )
        })
        .collect();

    let mut out = Vec::new();
    for i in 0..n {
        let x = ab[i].0;
        let y = ab[i].1;

        let mut mn = 1 << 30;
        let mut midx = 0;
        for j in 0..m {
            let v = (x - cd[j].0).abs() + (y - cd[j].1).abs();
            if mn > v {
                mn = v;
                midx = j;
            }
        }
        writeln!(out, "{}", midx + 1).ok();
    }
    stdout().write_all(&out).unwrap();
}


Measured memory_bytes: 2132
def slove():
    import sys
    input = sys.stdin.readline
    r = int(input().rstrip('\n'))
    if r < 1200:
        print("ABC")
    elif 1200 <= r < 2800:
        print("ARC")
    else:
        print("AGC")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      String op = sc.next();
      int b = sc.nextInt();
      if(op.equals("-"))System.out.println(a-b);
      else System.out.println(a+b);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
    ll N;
    cin >> N;
    string S;
    ll cnt=0;
    map<string,ll> data;
    for(int i=0;i<N;i++){
        cin >> S;
        data[S]++;
        cnt=max(cnt,data[S]);
    }
    for(auto p:data) {
        auto k=p.first;
        auto v=p.second;
        if(v==cnt) {
            cout << k << endl;
        }
        
    }
    
    
}


Measured memory_bytes: 19140
#include <stdio.h>

int main(void)
{
  int n, a, b, i, t[1000], c = 0;

  scanf("%d %d %d", &n, &a, &b);
  for (i = 0; i < n; i++) {
    scanf("%d", &t[i]);
  }

  for (i = 0; i < n; i++) {
    if (t[i] < a || b <= t[i]) {
      c++;
    }
  }

  printf("%d\n", c);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
char a[4][4];
int main()
{
	for(int i=1;i<=3;i++)
	for(int j=1;j<=3;j++)
	cin>>a[i][j];
	cout<<a[1][1]<<a[2][2]<<a[3][3];
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll; 
#define pb push_back
#define mp make_pair
#define mod 998244353
#define vi vector <ll>
using namespace std ; 
ll power(ll x,ll y,ll m)
{            //power(x,y)=x^y  %m;
	ll res=1%m;
	while(y)
	{
	    if(y&1)
	    res=(res*x)%m;
	    x=(x*x)%m;
	    y=(y>>1)%m;
	}
	return res;
}
ll mod_inverse(ll x,ll m)
{
	return power(x,m-2,m);
}
//ll least_prime[10000005]; 

int main ()
{
    ios_base :: sync_with_stdio ( false );
    cin.tie( NULL );
    cout.tie( NULL );
ll t = 1 ;
//cin>>t;
while ( t--)  
{
  string s,t;
  cin>>s>>t;ll cnt=0;
  for(ll i=0;i<s.length();i++)
  {if(s[i]!=t[i])
  cnt++;
  }
  cout<<cnt<<"\n";
  
 
}

 return 0;
}

Measured memory_bytes: 3800
import sys

def solve():
    N = int(input())
    cx, cy = 0, 0
    nt = 0
    for _ in range(N):
        t, x, y = map(int, input().split())
        rem = t - nt - abs(x - cx) - abs(y - cy)
        if rem < 0 or rem % 2 > 0:
            print("No")
            break
        cx, cy = x, y
        nt = t
    else: print("Yes")
        
    return 0

if __name__ == "__main__":
    solve()

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

int main() {
    long x, y, a, b, c, ans = 0;
    cin >> x >> y >> a >> b >> c;
    vector<long> p(a), q(b), r(c);
    rep(i, a) cin >> p.at(i);
    rep(i, b) cin >> q.at(i);
    rep(i, c) cin >> r.at(i);
    sort(p.begin(), p.end(), greater<long>());
    sort(q.begin(), q.end(), greater<long>());
    sort(r.begin(), r.end(), greater<long>());
    priority_queue<long> pq;
    rep(i, x) pq.push(p.at(i));
    rep(i, y) pq.push(q.at(i));
    rep(i, c) pq.push(r.at(i));
    rep(i, x + y) {
        long temp = pq.top();
        pq.pop();
        ans += temp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8816
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int gcd(int a, int b) {
	while (b > 0) {
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	int g = 0;
	vector<int> L(N + 1);
	vector<int> R(N + 1);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	L[0] = 0;
	for (int i = 0; i < N; i++) {
		L[i + 1] = gcd(L[i], A[i]);
	}
	R[N] = 0;
	for (int i = N - 1; i >= 0; i--) {
		R[i] = gcd(R[i + 1], A[i]);
	}

	for (int i = 0; i < N; i++) {
		res = max(res, gcd(L[i], R[i + 1]));
	}



	cout << res << endl;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;

int main() {
	int inf = -100100100;
	int N;
	cin >> N;
	vector<long long>A(N);
	for (int n = 0; n < N; ++n) {
		cin >> A[n];
	}
	vector<long long> dp(N);
	dp[0] = 1000;
	for (int n = 0; n < N; ++n) {
		for (int m = 0;m<n;++m) {
			long long tmp = dp[m] + (dp[m]/A[m])*A[n]- (dp[m] / A[m])*A[m];
			//cout << tmp << "_"<<dp[m] << "_" << A[m] << "_" << A[n]<<endl;
			dp[n] = max(dp[n], max(dp[m],tmp));
		}
	}
	cout << dp[N - 1] << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int k[20],s[20][20],p[20];
  for(int i=0;i<m;i++){
       cin>>k[i];
    for(int j=0;j<k[i];j++){
       cin>>s[i][j];
    }
  }
  for(int i=0;i<m;i++) cin>>p[i];
  
  int ans=0;
  for(int bit=0;bit<(1<<n);bit++){
    int light=0;
    for(int i=0;i<m;i++){
      int cnt=0;
      for(int j=0;j<k[i];j++){
        if(bit&(1<<s[i][j]-1)) cnt++;
      }
      if(p[i]==0&&(cnt%2==0)) light++;
      if(p[i]==1&&(cnt%2!=0)) light++;
    }
    if(light==m) ans++;
  }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K; cin >> N >> K;
    int h[N];
    for(int i = 0; i < N; i++) cin >> h[i];
    sort(h, h + N);
    int ans = 1000000007;
    for (int i = 0; i < N-K+1; i++)
    {
        ans = min(ans, h[i+K-1] - h[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long ans = 0;
    if(N%2 == 0){
      N /= 2;
      while(N>0){
        ans += N/5;
        N /= 5;
      }
    }
    System.out.println(ans);
  }
}

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


#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 961748941;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 2e5  + 5;
ll fat[maxn], inv[maxn];

ll C(int n, int k)
{
  if(n < k) 
    return 0;
  if(n < 0 || k < 0) 
    return 0;
  return (((fat[n] * inv[k]) % mod) * inv[n - k]) % mod;
}

void initFactorials()
{
  fat[0] = 1;
  inv[0] = 1;
  for(int i = 1; i < maxn; i++)
  {
    fat[i] = (i * fat[i-1]) % mod;
    inv[i] = exp(fat[i], mod - 2);
  }
}

int l[maxn], r[maxn], pos[maxn];
int a[maxn];

int main()
{
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  for(int i = 1 ; i <= n ; i++)
  {
    cin >> a[i];
    pos[a[i]] = i;
  }
  multiset<ll>s;
  s.insert(0);
  s.insert(0);
  s.insert(n+1);
  s.insert(n+1);
  // a < b < pos[i] < c < d
  ll ans = 0;
  for(ll i = n; i >= 1; i--)
  {
    auto it = s.lower_bound(pos[i]);
    --it;
    --it;
    auto a = *it;
    it++;
    auto b = *it;
    it++;
    auto c = *it;
    it++;
    auto d = *it;
    s.insert(pos[i]);
    ans += ((b - a) * (c - pos[i]) + (d - c) * (pos[i] - b)) * i;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 9044
#include<bits/stdc++.h>
// use gp_hash_table<int,int,custom_hash> m;
// in place of map
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
// This custom_hash is for unordered_map 
// use map<int, int, custom_hash> mp;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
 //    	freopen("input.txt", "r", stdin);
 //    	freopen("output.txt", "w", stdout);
	// #endif
	string s;
	cin>>s;
	ll sum=0;
	int n = (int)s(s)+1;
	vi v(n);
	v[0]=0;
	int c=0;
	rep(i,n-1){
		if(s[i]=='<'){
			c++;
			v[i+1]=c;
		}
		else {
			c=0;
			v[i+1]=0;
		}
		v[i+1] = c;
	}
	// rep(i,n){
	// 	cout<<v[i]<<" ";
	// }
	// cout<<"\n";
	c=0;
	repr(i,n-1){
		if(s[i]=='>'){
			c++;
			v[i]=max(v[i],c);
		}
		else {
			c=0;
			continue;
		}
	}
	rep(i,n){
		// cout<<v[i]<<" ";
		sum += v[i];
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 2844
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        (n,a,b):(u32,u32,u32)
    }
    let mut v: Vec<u32> = Vec::new();
    for i in 1..n + 1 {
        let s = i.to_string();
        let mut _result = 0;
        for c in s.chars() {
            let a = c as u32 - 48;
            _result += a;
        }
        if _result >= a && b >= _result {
            v.push(i);
        }
    }
    let _sum: u32 = v.iter().sum();
    println!("{}", _sum);
}


Measured memory_bytes: 2208
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  if(a==3||a==5||a==7){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}
    
    
  


Measured memory_bytes: 3636
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int z;
		//??????????????????????????????
		//??´??° x, y(x >= y)??????????????? x ??¨ y ????????§??¬?´???°??? y ??¨ x % y ????????§??¬?´???°???????????????
		//????????§ x % y ??? x ??? y ??§?????£???????????§??????
		do{
			z = Math.max(x, y) % Math.min(x, y);
			if(z == 0){
				System.out.println(Math.min(x, y));
			}
			else{
				if(x > y){x = z;}
				else{y = z;}
			}
		}while(z != 0);
	}
}

Measured memory_bytes: 26148
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int x = 0;
		for (int i = 1;i < N+1; i++) {
			int sum = 0;
			int n;
			int a = i;
			while(a != 0) {
				n = a % 10;
				sum += n;
				a = (a-n)/10;
			}
			if(sum >= A && sum <= B) {
				x = x + i;
			}
		}
		System.out.println(x);
	}
}

Measured memory_bytes: 23764
N = gets.to_i
s = N.times.map{gets.to_i}
s = s.sort
sum = s.inject(:+)
if sum % 10 != 0
  puts sum
else
  s.each do |x|
    if x % 10 != 0
      sum -= x
      puts sum
      exit
    end
  end
  puts 0
end


Measured memory_bytes: 14340