akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

int n, m, A[300][300];
bool b[300];
vi vv;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, m) b[i] = true;
  FOR(i, 0, n)FOR(j, 0, m){
    cin >> A[i][j];
    A[i][j]--;
  }
  int ans = iinf, c = m;
  while(c > 0){
    vi v(m, 0);
    FOR(i, 0, n)FOR(j, 0, m)if(b[A[i][j]]){
      v[A[i][j]]++;
      break;
    }
    int ma = -1;
    FOR(i, 0, m){
      if(v[i] < ma) continue;
      if(v[i] > ma) {
        vv.resize(0);
        ma = v[i];
      }
      vv.pb(i);
    }
    mins(ans, ma);
    c -= sz(vv);
    for(int i: vv) b[i] = false;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
from itertools import count

N = 10 ** 5 + 10

is_prime = [True] * N
is_prime[0] = is_prime[1] = False

# ほぼO(N)
for i in range(N):
  if is_prime[i]:
    for j in count(2 * i, i):
      if j >= N:
        break
      is_prime[j] = False
      
is_2017_like_number = [0] * N

# O(N)
for i in range(N):
  if i % 2 != 0 and is_prime[i] and is_prime[(i + 1) // 2]:
    is_2017_like_number[i] = 1
    
cusum = [0] * (N + 1)

for i in range(N):
  cusum[i + 1] = cusum[i] + is_2017_like_number[i]
  
Q = int(input())

for _ in range(Q):
  l, r = map(int, input().split())
  r += 1  # 操作しやすいように [l, r) にする
  
  print(cusum[r] - cusum[l])
  

Measured memory_bytes: 52952
#include <cstdio>
#define ll long long

const int MAX = 2e5+10;
ll a[MAX];

int main(){
    int n, k; scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
    for (int i = 0, j = k; j < n; i++, j++){
        if (a[i] < a[j]) puts("Yes");
        else puts("No");
    }
    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, int> P;
int main(){
    long long N, M, K;
    cin >> N >> M >> K;
    vector<long long> A(N), B(M);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < M; i++) cin >> B[i];
    long long res = 0;
    long long ans = 0;
    int ind2 = -1;
    for(int i = 0; i < N; i++){
        if(res + A[i] > K) break;
        res += A[i];
        ind2 = i;
        ans++;
    }
    int ind = 0;
    for(int i = 0; i < M; i++){
        if(res + B[i] > K) break;
        res += B[i];
        ind = i + 1;
        ans++;
    }
    long long temp = ans;
    for(int i = 0; i <= ind2; i++){
        if(ind2 != -1) res -= A[ind2 - i];
        ans--;
        if(ind >= M) break;
        while(res + B[ind] <= K){
            res += B[ind];
            ans++;
            ind++;
            temp = max(temp, ans);
            if(ind >= M) break;
        }
    }
    cout << temp << endl;
}

Measured memory_bytes: 6360
import java.util.Arrays;
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[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        int color[] = {400, 800, 1200, 1600, 2000, 2400, 2800, 3200, Integer.MAX_VALUE};
        int count[] = new int[color.length];
        Arrays.fill(count, 0);

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < color.length; j++) {
                if (a[i] < color[j]) {
                    count[j]++;
                    break;
                }
            }
        }

        int c = 0;
        for (int i = 0; i < count.length - 1; i++) {
            if (count[i] != 0) {
                c++;
            }
        }

        int mn = Math.max(1, c);
        int mx = c + count[count.length - 1];

        System.out.println(mn + " " + mx);
        
    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <random>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, a, b;
lli x[100001];
int main() {
  cin >> n >> a >> b;
  read_n(x, n);

  lli ans = 0;
  for (lli i=1; i<n; ++i) {
    ans += min(a*(x[i]-x[i-1]), b);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
    int A,B,C;
    cin>>A>>B>>C;
    if(A==5&&B==5&&C==7||A==5&&B==7&&C==5||A==7&&B==5&&C==5)
    {
        cout<<"YES"<<endl;
    }
    else
        cout<<"NO"<<endl;
    return 0;

}


Measured memory_bytes: 3560
from fractions import gcd
a,b,c,d=map(int,input().split())

def notdiv(x,c,d):
    e=c*d//gcd(c,d)
    return x-((x//c)+(x//d)-(x//e))

print(notdiv(b,c,d)-notdiv(a-1,c,d))

Measured memory_bytes: 5048
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
using PII = pair<ll, ll>;
using PP = pair<ll, PII>;
#define FOR(i,a,n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i,n) FOR(i,0,n)
const ll INF = 1LL << 60;
template<typename T> void chmin(T &a, T b) { a = min(a, b); }
vector<PII> G[300000];
int cnt[300000];
int dist[300000];
struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<int> cnt;
	UnionFind(int n) {
		par.resize(n);
		for (int i = 0; i < n; i++) par[i] = i;
		rank.resize(n);
		cnt.resize(n);
	}
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (rank[x] < rank[y]) {
			par[x] = y;
			cnt[y] += cnt[x];
		}
		else {
			par[y] = x;
			cnt[x] += cnt[y];
			if (rank[x] == rank[y]) rank[x]++;
		}
	}
};
int main() {
	int N, M, T;
	cin >> N >> M >> T;
	vector<PP> edge;
	for (int i = 0; i < M; i++) {
		int a, b, t;
		cin >> a >> b >> t;
		a--; b--;
		edge.emplace_back(t, PII(a, b));
		G[a].emplace_back(b, t);
		G[b].emplace_back(a, t);
	}
	queue<int> Q;
	fill((int*)dist, (int*)(dist + N), 1 << 30);
	dist[0] = -1;
	Q.push(0);
	while (!Q.empty()) {
		int v = Q.front(); Q.pop();
		for (PII e : G[v]) {
			int to = e.first;
			if (dist[to] == 1 << 30 && dist[v] < e.second - 1) {
				dist[to] = dist[v] + 1;
				Q.push(to);
			}
		}
	}
	sort(edge.begin(), edge.end(), greater<PP>());
	UnionFind U(N + M);
	vector<ll> score(N + M);
	vector<ll> tim(N + M);
	for (int i = 0; i < N; i++) U.cnt[i] = 1;
	for (int i = 0; i < N; i++) {
		if (dist[i] == 1 << 30) {
			score[i] = -(1LL << 60);
		}
		tim[i] = T;
	}
	int k = N;
	for (int i = 0; i < M; i++) {
		int s = edge[i].second.first;
		int t = edge[i].second.second;
		if (U.same(s, t)) continue;
		s = U.find(s);
		t = U.find(t);
		ll ss = max(score[s] + (tim[s] - edge[i].first)*U.cnt[s], score[t] + (tim[t] - edge[i].first)*U.cnt[t]);
		U.unite(k, s);
		U.unite(k, t);
		tim[U.find(k)] = edge[i].first;
		score[U.find(k)] = ss;
		k++;
	}
	cout << score[U.find(k - 1)] + N*tim[U.find(k - 1)] << endl;
}


Measured memory_bytes: 33584
#include <stdio.h>

int binarySearch(int n,int *A,int key){
  int left = 0, right = n, mid;
  while(left<right){
    mid = (left + right)/2;
    if(key == A[mid]) return 1;
    if(key > A[mid]) left = mid+1;
    if(key < A[mid]) right = mid;
  }
  return 0;
}

int main(){
  int S[100000],T[50000],n,q,cnt=0,i;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    scanf("%d",&T[i]);

  for(i=0;i<q;i++)
    cnt += binarySearch(n,S,T[i]);

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



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

int main() {
  string S,T;
  cin >> S >> T;
  int ans=0;
  if(S[0]==T[0]) ans++;
  if(S[1]==T[1]) ans++;
  if(S[2]==T[2]) ans++;
  cout << ans;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  long a, b, c, x, y;
  readf("%s %s %s %s %s", &a, &b, &c, &x, &y);

  auto res = a * x + b * y;
  res = min(res, 2 * c * max(x, y));
  res = min(res, 2 * c * x + max(0, y - x) * b);
  res = min(res, 2 * c * y + max(0, x - y) * a);

  res.writeln;
}


Measured memory_bytes: 256
N = int(input())
C = [int(input())]
cindex = {C[0]: 0}
mod = 7 + 10 ** 9
counter = 0
for _ in range(N-1):
    c = int(input())
    if c != C[-1]:
        C.append(c)
        counter += 1
        if c not in cindex:
            cindex[c] = counter

DP = [[0, 1] for i in range(len(C))]
for i in range(1, len(C)):
    if cindex[C[i]] == i:
        DP[i][1] = DP[i-1][1]
    else:
        DP[i][0] = DP[cindex[C[i]]][1] 
        DP[i][1] = DP[i][0] + DP[i-1][1]
        DP[i][1] %= mod
        cindex[C[i]] = i
print(DP[-1][1])

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


int main()
{
    string S;
    cin >> S;

    if(S == "ABC"){
        cout << "ARC" << endl;
    }
    else if(S == "ARC"){
        cout << "ABC" << endl;
    }
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

signed main() {
  string s, t;
  cin>>s;
  int i=0;
  while (i < s.size()) {
    if (i+1 < s.size() && s[i] == 'B' && s[i+1] == 'C') {
      t += 'X';
      i += 2;
    } else {
      t += s[i];
      i++;
    }
  }
  ll ans = 0;
  vector<ll> v(t.size(), 0);
  v[t.size()-1] = t[t.size()-1] == 'X' ? 1: 0;
  for (int i=t.size()-2; i>=0; i--) {
    if (t[i] == 'X') {
      v[i] = v[i+1] + 1;
    } else if (t[i] == 'A') {
      v[i] = v[i+1];
      ans += v[i];
    } else {
      v[i] = 0;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2312
#include <cstdio>
#include <algorithm>
using namespace std;
long long a,b,c,d;
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	printf("%lld\n",max(max(a*c,a*d),max(b*c,b*d)));
	return 0;
}


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

int main(){
  string A,B,C;
  cin >> A >> B >> C;
  if (A[A.length()-1] == B[0] &&
      B[B.length()-1] == C[0]) {
    printf("YES\n");
  }
  else {
    printf("NO\n");
  }
}


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

using namespace std;
int main() {
  int a, b;
  cin >> a >> b;

  int num = 0;
  int tree[999];
  for (int i = 1; i < 1000; i++) {
    num += i;
    tree[i - 1] = num;
  }

  for (int i = 0; i < 999; i++) {
    if (tree[i] > a && tree[i + 1] > b && tree[i] - a == tree[i + 1] - b) {
      cout << tree[i] - a << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;

int main(void)
{
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/b;
	printf("%d %d %lf\n",d,r,f);
	return 0;
}


Measured memory_bytes: 2748
from functools import reduce
from collections import Counter
while True:
  n, k = map(int, input().split())
  if n == 0:
    break
  clst = [int(input()) for _ in range(n)]
  acc = reduce(lambda x, y:x* y, clst[:k])
  scores = [acc]
  for i in range(n - k):
    acc = acc // clst[i] * clst[i + k]
    scores.append(acc)
  
  score = 0
  for i in range(n):
    for j in range(i + 1, n):
      p = clst[i]
      q = clst[j]
      for x in range(i - k + 1, i + 1):
        if abs(j - x) >= k and 0 <= x <= n - k:
          score = max(score, scores[x] // p * q)
      for x in range(j - k + 1, j + 1):
        if abs(x - i) >= k and 0 <= x <= n - k:
          score = max(score, scores[x] // q * p)
  if score < max(scores):
    print("NO GAME")
  else:
    print(score - max(scores))


Measured memory_bytes: 6292
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

def GCD(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a%b
    return b

if K > max(A):
    print("IMPOSSIBLE")
else:
    gcdA = A[0]
    for i in range(1, N):
        gcdA = GCD(gcdA, A[i])
    print("POSSIBLE" if K % gcdA == 0 else "IMPOSSIBLE")

Measured memory_bytes: 14224
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main()
{
    long n, m;
    cin >> n >> m;
    map<long, long> a;
    long p = 0;
    string s;
    long sum = 0;
    long res = 0;
    for (long i = 0; i < m; ++i) {
        cin >> p >> s;
        if(s.compare("WA") == 0) {
            if (a.count(p) == 0) {
                a[p] = 1;
            }
            else if(a[p] != -1) {
                a[p]++;
            }
        }
        else {
            if(a[p] != -1) {
                sum += a[p];
                a[p] = -1;
                res++;
            }
        }
    }
    cout << res << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n;
    ans += (n / 500) * 1000;
    n = n % 500;
    ans += (n / 5) * 5;
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
Author: Deep Chaklasiya
*/

#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update> data_set;
#define fbo find_by_order
#define ook order_of_key




#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define piiii       pair<pii,pii>
#define viiii       vector<pair<pii,pii>>
#define mi          map<int,int>
#define mii         map<pii,int>
#define piii           pair<int,pair<int,int> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define ef else if





int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}

int logb(int base, int x) {
    return (log(x) / log(base));
}


template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}

void set_min(int &m,int a){
    if(m==-1||m>a)m=a;
}


signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int i,j,x,n,m,k,t;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++) cout<<"x";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.1415;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

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

vector<vector<int>> bingo(3, vector<int>(3));
vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;

	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

ll getGcd(ll a, ll b) {
	if (a < b) {
		ll temp = b;
		b = a;
		a = temp;
	}

	ll r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}

int main() {
	int A, B, C, D; cin >> A >> B >> C >> D;
	int index = 1;
	while (0 < A && 0 < D) {
		if (index % 2 != 0) {
			C -= B;
		}
		else {
			A -= D;
		}
		index++;
	}
	string ans = C <= 0 ? "Yes" : "No";
	cout << ans << endl;
}



Measured memory_bytes: 5444
def readinput():
    #a,b=list(map(float,input().split()))
    a,b=input().split()
    a=int(a)
    b=float(b+'000000000000000')
    return a,b

def main(a,b):
    #ans=int(a*b*10)//10
    b=int(b*1000)
    ans=a*b//1000
    return ans

if __name__=='__main__':
    a,b=readinput()
    ans=main(a,b)
    print(ans)


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

int n,k;
int a[1000+5];
int sum;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)  cin>>a[i];
	
	sort(a+1,a+n+1);
	
	for(int i=1;i<=k;i++) sum+=a[i];
	
	
	cout<<sum;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> blue(N);
  for (int i = 0; i < N; i++)
  cin >> blue.at(i);
  int M;
  cin >> M;
  vector<string> red(M);
  for (int i = 0; i < M; i++)
  cin >> red.at(i);
  int max = 0;

  for (int i = 0; i < N; i++) {
    int x = 0;
    for (int j = 0; j < N; j++) {
      if (blue.at(i) == blue.at(j))
      x++;
    }  
    for (int j = 0; j < M; j++) {
      if (blue.at(i) == red.at(j))
      x--;
    }

    if (x > max)
    max = x;
  } 

  cout << max << endl;
}

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

void solve(){
}
int main(){
    int n, m, sum;
    cin >> n >> m;
    vector<int>am(m);
    sum = 0;
    for(int i = 0; i < m; i++){
        cin >> am.at(i);
        sum += am.at(i);
    }
    if(n < sum){
        cout << "-1" << endl;
    }
    else{
        cout << n - sum << endl;
    }
    solve();
    return 0;
}



Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;

ll gcd( ll a, ll b ){//最大公約数
    ll tmp;
    if( a < b ) { tmp = a; a = b; b = tmp; }
    if( b < 1 ) return -1;

    if( a % b == 0 ) return b;
    return gcd( b, a % b );
}

ll lcm(ll a, ll b){//最小公倍数
    return a * b / gcd(a, b);
}

ll sosuu(ll x){
    for(int i = 2; i < x; i++){
        if(x % i == 0) return false;
    }

    return true;
}


//入力
int n;
P robot[100010];

int main(){

    cin >> n;
    for(int i = 0; i < n; i++) {
        int x, l;
        cin >> x >> l;
        robot[i].first = x + l;
        robot[i].second = x - l;
    }

    sort(robot, robot+n);

    int last = robot[0].first;

    int ans = 1;

    for(int i = 1; i < n; i++){
        if(last <= robot[i].second){
            ans++;
            last = robot[i].first;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

constexpr ll INF = 1LL << 62;
constexpr ll MOD = 1e9 + 7;

void dfs(ll node, vector<vector<ll> >& G, vector<bool>& used) {
    if (used[node]) {
        return;
    }
    used[node] = true;

    for (auto next : G[node]) {
        dfs(next, G, used);
    }
}

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

    ll N, M;
    cin >> N >> M;
    vector<vector<ll> > G(N + M);
    vector<bool> exist(M, false);
    for (ll i = 0; i < N; i++) {
        ll K;
        cin >> K;
        for (ll k = 0; k < K; k++) {
            ll l;
            cin >> l;
            G[i].push_back(l - 1 + N);
            G[l - 1 + N].push_back(i);
            exist[l - 1] = true;
        }
    }

    vector<bool> used(N + M, false);
    dfs(0, G, used);

    for (ll i = 0; i < N; i++) {
        if (!used[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    for (ll i = 0; i < M; i++) {
        if (!used[i + N] && exist[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}



Measured memory_bytes: 8948
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int num=scan.nextInt();
    int a[]=new int[num];
    int box=0, Ans=0;
    boolean flag1=true;
    for(int x=0; x<num; x++){
      a[x]=scan.nextInt();
      if(flag1){
        if(a[x]==1){
          box=1;
          flag1=false;
        }else{
          Ans++;
        }
      }else{
        if(box+1==a[x]){
          box++;
        }else{
          Ans++;
        }
      }
    }
    if(flag1){
      System.out.println(-1);
    }else{
      System.out.println(Ans);
    }
  }
}

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

using namespace std;

bool possible(long long longestLog, const vector<long long>& A, long long K) {
    long long N = A.size();
    long long numOfLongestLogs = 0;
    for (long long i = 0; i < N; ++i) {
        numOfLongestLogs += A[i] / longestLog;
        if (A[i] % longestLog == 0) {
            --numOfLongestLogs;
        }
    }
    return (numOfLongestLogs <= K);
}

void Main() {
    long long N, K;
    cin >> N >> K;
    vector<long long> A(N, 0LL);
    for (long long i = 0; i < N; ++i) {
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<long long>());

    long long ub = A.front();
    long long lb = 0LL;
    while (ub - lb > 1LL) {
        long long mid = (ub + lb) / 2LL;
        if (possible(mid, A, K)) {
            ub = mid;
        }
        else {
            lb = mid;
        }
    }
    cout << ub << endl;
    //if (ub == lb) {
    //    cout << ub << endl;
    //}
    //else {
    //    if (possible(lb, A, K)) {
    //        cout << lb << endl;
    //    }
    //    else {
    //        cout << ub << endl;
    //    }
    //}
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 4764
import bisect

six_list = [6 ** i for i in range(7)]
nine_list = [9 ** i for i in range(6)]

from functools import lru_cache


@lru_cache(maxsize=1000)
def six_nine(n):
    if n < 6:
        return n
    else:
        six = six_list[bisect.bisect_right(six_list, n) - 1]
        nine = nine_list[bisect.bisect_right(nine_list, n) - 1]
        return min(n // six + six_nine(n % six), 1 + six_nine(n - nine))


if __name__ == '__main__':
    x = int(input())
    print(six_nine(x))

Measured memory_bytes: 3936
#include<stdio.h>
int main(){
	char c;
	scanf("%c",&c);
	if(c=='a')printf("vowel\n");
	else if(c=='i')printf("vowel\n");
	else if(c=='u')printf("vowel\n");
	else if(c=='e')printf("vowel\n");
	else if(c=='o')printf("vowel\n");
	else printf("consonant\n");
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var num = Console.ReadLine().Split(' ').Select(_ => long.Parse(_)).ToArray();
        long[] list = new long[4];
        list[0] = num[0] * num[2];//ac
        list[1] = num[0] * num[3];//ad
        list[2] = num[1] * num[2];//bc
        list[3] = num[1] * num[3];//bd

        long max = list.Max();
        Console.WriteLine((max));

    }
}

Measured memory_bytes: 19044
#include<stdio.h>
#include<stdlib.h>
int comp(const void*a,const void*b){
	if(*(int*)a > *(int*)b)return 1;
	else return -1;
}
int main(){
	int n;scanf("%d",&n);int tri=0;
	int* arr = (int*)malloc(sizeof(int)*2003);
	for(int i=0 ;i<n;i++)scanf("%d",&arr[i]);
	qsort(arr,n,sizeof(int),comp);
	/*int stopper = -1,prev,k,big=0;
	for(int i=0;i<n;i++){
		stopper = -1;
		prev = i+2;
		for(int j=i+1;j<n;j++){
			if(j!=i+1 )prev = stopper;
			if(stopper == j) prev = j+1;
		for( k=prev;k<n;k++){
			if(arr[i]+arr[j] > arr[k]){//printf("%d %d %d\n",arr[i],arr[j],arr[k] );
				big++;
			}
			else if(k!=n-1){stopper = k;break;}
			if(k==n-1){stopper = n;}		
		}
		if(big!=0){tri+=(k-(j+1));}
	}
	
	}
	*/
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			for(int k = j+1;k<n;k++){
				if(arr[i]+arr[j] > arr[k])tri++;
				else break;
			}

		}
	}
	printf("%d",tri );
		
}
/*
4 - 3 4 2 1
1 2 3 4 5 6 7
1 3 5 7 9
218 786 704 233 645 728 389
218 233 389 645 704 728 786
*/

Measured memory_bytes: 128
#!/usr/bin/env python3
import math

def main():
    A, B, H, M = map(int, input().split())
    s = 30*H+0.5*M
    l = 6 * M
    C = A**2 + B**2 - 2*A*B*math.cos(math.radians(abs(l-s)))
    print(C**0.5)

if __name__ == "__main__":
    main()


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

int main(){
  int n;
  string s;
  cin >>n >>s;
  int red = 0, blue = 0;
  rep(i,n){
    if(s[i]=='R') red++;
    else blue++;
  }
  if(red>blue) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <string>
#include <map>
using namespace std;


int main (int argc, char const *argv[])
{
    int a,b; cin>>a>>b;
    int ans=0;
    int  used=1;
    while (used<b)
    {
        used--;
        used+=a;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;
#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++)

int main() {
    int N;
    cin >> N;
    map<ll, ll> stick;
    
    rep(i, N) {
        ll A;
        cin >> A;
        if (stick.count(A)) {
            stick[A]++;
        }
        else {
            stick[A] = 1;
        }
    }
    priority_queue<ll> ans;
    ans.push(0);
    ans.push(0);
    for (auto p : stick) {
        ll l = p.first;
        ll n = p.second;
        if (n >= 4) {
            ans.push(l);
            ans.push(l);
        }
        else if (2 <= n) {
            ans.push(l);
    
        }
    }
    ll h = ans.top();
    ans.pop();
    ll w = ans.top();
    cout << h*w << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> before(N);
  for (int i=0; i<N; i++) {
    cin >> before.at(i);
  }
  
  vector<int> after(N);
  
  for (int i=0; i<N; i++) {
    int max = 1;
    for (int j=0; j<N; j++) {
      if (before.at(j) > max) {
        max = before.at(j);
      }
    }
         
    after.at(i) = max;
         
	for (int j=0; j<N; j++) {
      if (before.at(j) == max) {
        before.at(j) = 0;
        break;
      }
    }
  }
         
  int score = 0;
  for (int i=0; i<N; i++) {
    if (i % 2 == 1) {
      score -= after.at(i);
    }
    else {
      score += after.at(i);
    }
  }
  
  cout << score << endl;
         
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
#define N 100005
vector<int> v[N];
vector<int> dp(N,-1);

void solve(int i, int p){
    //cout << i << " " << p << endl;
    dp[i]=0;
    for(auto x: v[i]){
        if(x==p) continue;
        if(dp[x]==-1) solve(x,i);
        dp[i]= max(dp[i],1+dp[x]);
    }
}

int main(){
    int n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int x,y; cin >> x >> y;
        v[x].push_back(y);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(dp[i]==-1) solve(i,i);
        ans= max(ans, dp[i]);
    }
    cout << ans;
}

Measured memory_bytes: 8960
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

int n, i;
int t, x, y;
int tt, xx, yy;

int main()
{
  //  freopen("test.in","r",stdin);

    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> tt >> xx >> yy;

        int dt = abs(tt - t);
        int dx = abs(xx - x);
        int dy = abs(yy - y);

        if (dt < dx + dy) {
            cout << "No";
            return 0;
        }

        if ((dt - dx - dy) & 1) {
            cout << "No";
            return 0;
        }

        swap(xx, x);
        swap(yy, y);
        swap(tt, t);
    }

    cout << "Yes";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
#define X first
#define Y second

void go() {
	int n;
	cin >> n;
	vector<int> a(n),b(n),c(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	for(int i = 0; i < n; i++) cin >> c[i];
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	ll res = 0;
	for(int i = 0; i < n; i++) {
		ll x,y;
		x = lower_bound(a.begin(),a.end(),b[i]) - a.begin();
		y = c.end() - upper_bound(c.begin(),c.end(),b[i]);
		// cout << *lower_bound(a.begin(),a.end(),b[i]) << " " << b[i] << " " << *upper_bound(c.begin(),c.end(),b[i]) << endl;
		res += x*y;
	}
	cout << res << endl;
}

int main() {
	//int t; cin >> t; for(;t--;)
	go();
	return 0;
}




Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
int main(void)
{
    char a[21];
	int i,n;
	scanf("%s",&a);
	n=strlen(a);
	for(i=n-1;i>=0;i--){
	    printf("%c",a[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2516
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
const ll mod=1e9+7;
 
#define pb push_back
#define mp make_pair


 
int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    ll n;
    cin>>n;
    vector<ll> a;
    if(n==1){
        cout<<0;
        return 0;
    }
    ll c=0;
    while (n % 2 == 0){  
        c++;
        n = n/2;  
    }  
    if(c>0)
        a.pb(c);
    c=0;
    for (int i = 3; i <= sqrt(n); i = i + 2){  
        while (n % i == 0){
            c++;
            n = n/i;  
        }  
        if(c>0)
            a.pb(c);
        c=0;
    }  
    if (n>2)  {
        a.pb(1);
    }
    ll ans=0;
    for(ll i=0;i<a.size();i++){
        //cout<<a[i]<<" ";
        ll cnt=0,p=a[i],r=1;
        while(p>0){
            cnt++;
            r++;
            p-=r;
        }
        ans+=cnt;
    }
    cout<<ans;
    
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int main() {
  int n;
  cin >> n;
  V<ll> a(n);
  rep(i, n) cin >> a[i];

  ll ans = 0;
  rep(i, n - 1) {
    if (a[i] % 2 != 0 && a[i + 1] > 0) {
      a[i]--;
      a[i + 1]--;
      ans++;
    }
  }
  rep(i, n) ans += a[i] / 2;
  cout << ans << endl;
}


Measured memory_bytes: 4048
S = input()
ans = 0
f = ""
for i in range(1 << len(S)-1):
    f = S[0]
    for j in range(len(S)-1):
        if ((i >> j) & 1) == 1:
            f += "+"
        else:
            f += "-"
        f += S[j+1]
    if eval(f) == 7:
        print(f+"=7")
        exit()

Measured memory_bytes: 3060
a, b, k = map(int, input().split())		# 5 7 2


ans=[]
count=0
for i in range(a, b+1):
	ans.append(i)
	count += 1
	if count >= k: break

count=0
for i in range(b, a-1, -1):
	ans.append(i)
	count += 1
	if count >= k: break

ans = sorted(set(ans))

for i in ans:
	print(i)




Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string.h>
#include <climits>
using namespace std;

int k,t,ans;//dp[10010][110];

int main(){
    //int t;
    //t=1;
    //cin>>t;

    //while(t--){
        cin>>k>>t;
        int a[110];
        for(int i=0;i<t;i++) cin>>a[i];
        //memset(dp,-1,sizeof dp);
        for(int i=0;i<t;i++){
            ans=max(a[i]-1-(k-a[i]),ans);
        }
        cout<<ans<<endl;
    //}

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#include <bitset>
#include <cmath>
#include <utility>
#define Maxn 100005
#define Maxm 1000005
#define lowbit(x) x&(-x)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define PI acos(-1.0)
#define LL long long 
#define Inf (1LL<<62)
#define inf 0x3f3f3f3f
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
using namespace std;
LL top_large_k[Maxn<<2];
LL top_small_k[Maxn<<2];
LL arr[Maxn<<2];
int main()
{
	int n;
	priority_queue<LL> q2;
	priority_queue<LL,vector<LL>,greater<LL> >q1;
	LL presum,sufsum,ans;
	//input;output;
	while(~scanf("%d",&n))
	{
		ans=-Inf;
		presum=sufsum=0;
		while(!q1.empty())
			q1.pop();
		while(!q2.empty())
			q2.pop();
		for(int i=1;i<=3*n;i++)
			scanf("%lld",arr+i);
		for(int i=1;i<=n;i++)
		{
			presum+=arr[i];
			q1.push(arr[i]);
			top_large_k[i]=presum;
		}
		for(int i=3*n;i>2*n;i--)
		{
			sufsum+=arr[i];
			q2.push(arr[i]);
			top_small_k[i]=sufsum;
		}
		for(int i=n+1;i<=2*n;i++)
		{
			if(arr[i]>q1.top())
			{
				presum+=arr[i]-q1.top();
				q1.pop();
				q1.push(arr[i]);
			}
			top_large_k[i]=presum;
		}
		for(int i=2*n;i>n;i--)
		{
			if(arr[i]<q2.top())
			{
				sufsum+=arr[i]-q2.top();
				q2.pop();
				q2.push(arr[i]);
			}
			top_small_k[i]=sufsum;
		}
		for(int i=n;i<=2*n;i++)
			ans=max(ans,top_large_k[i]-top_small_k[i+1]);
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 10740
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>

//by Skeef79

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

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

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

struct queue_on_stacks
{
	stack<pii> st1, st2;
	//first - elem
	//second - result
	void add(int x)
	{
		int to_add = (st1.empty() ? x : gcd(st1.top().second, x));
		st1.push({ x,to_add });
	}
	int get()
	{
		int fst = (st1.empty() ? 0 : st1.top().second);
		int sec = (st2.empty() ? 0 : st2.top().second);
		return gcd(sec, fst);
	}
	void del()
	{
		if (st2.empty())
		{
			while (!st1.empty())
			{
				int x = st1.top().first;
				st1.pop();
				int to_add = (st2.empty() ? x : gcd(x, st2.top().second));
				st2.push({ x,to_add });
			}
		}
		st2.pop();
	}
};

void solve()
{
	int n;
	cin >> n;
	vector<int> a(n);
	input(a);
	
	queue_on_stacks st;
	int ans = 0;
	for (int i = 0; i < n; i++)
		st.add(a[i]);
	for (int i = 0; i < n; i++)
	{
		st.del();
		ans = max(ans, st.get());
		st.add(a[i]);
	}
	cout << ans;
}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();

}

Measured memory_bytes: 1536
a,b,n=map(int,input().split())
m=0
if n<b:
	m=(a*n)//b
elif n==b:
	m=max((a*(n-1))//b,(a*n)//b-a*(n//b))
else:
	m=max((a*(b-1))//b,(a*n)//b-a*(n//b))
print(m)

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    ll h, w;
    cin >> h >> w;
    if(h==1 || w == 1) {cout << 1 << endl; return 0;}
    ll ans = (h*w+1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace PCK2015
{
	class Question02
	{
		static void Main()
		{
			var coins = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
			var sum = coins[0] + coins[1] * 5 + coins[2] * 10 + coins[3] * 50 + coins[4] * 100 + coins[5] * 500;
			Console.WriteLine(sum >= 1000 ? 1 : 0);
		}
	}
}

Measured memory_bytes: 9444
import java.io.PrintWriter;
import java.util.*;

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

        long sum = 0;
        String ar[] = S.split("");
        Queue<String> queue = new ArrayDeque<>();
        List<String> list = new ArrayList<>();
        for (String s : ar)
            queue.add(s);
        
        int old = 0;
        while (queue.size() >0) {
            while (queue.size()>0 && (list.size()==0 || list.get(0).equals(queue.peek()))) {
                list.add(queue.poll());
            };
            if (">".equals(list.get(0))) {
                if (old<list.size()) {
                    sum -= old;
                } else {
                    sum -= list.size();
                }
                sum += func(list.size());
            } else {
                old = list.size();
                sum += func(list.size());
            }
            list.clear();
        };

        PrintWriter out = new PrintWriter(System.out);
        out.println(sum);
        out.flush();
    }
    private static long func(int n) {
        if (n==1) {
            return n;
        } else {
            return n+func(n-1);
        }
    }
}

Measured memory_bytes: 85080
import sys

l, r = [int(_) for _ in input().split()]

res = 2019

res_l = l % 2019
res_r = r % 2019

if r - l + 1 >= 2019:
    print(0)
    sys.exit()
else:
    for i in range(l,r):
        res_i = i % 2019
        for j in range (l+1, r+1):
            res_j = j % 2019
            res = min(res,(res_i*res_j) % 2019)
            if res == 0:
                print(0)
                sys.exit()

print(res)

Measured memory_bytes: 3064
//If you are reading this then you are at wrong place.
#include<bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
bool prime [1000001];
void debug(lli a){cout<<a<<endl;}
lli sieve(lli a){memset(prime,true,sizeof(prime));lli p,i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli find_max(lli __a,lli __b){return __a^((__a^__b) & -(__a<__b));}
lli add(lli __a,lli __b,lli MOD){lli x = (__a+__b)%MOD; return x; }
lli mul(lli a,lli b,lli MOD){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b,lli MOD){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b,lli MOD){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
int main()
{
	//ifstream cin("testcase.txt");
	//ofstream cout("output.txt");	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);	
	cout.precision(20);
	lli t,i,j;
	//cin>>t;
	//memset(dp, -1, sizeof dp);
	t=1;
	lli counter1=0;
	while(t--)
	{
		counter1++;
		string a,b;
		cin>>a>>b;
		string c="";
		int i=0;
		int j=0;
		int z=0;
		while(1)
		{
			if(i%2==0)
			{
				c=c+a.at(j);
				j++;
			}
			else
			{
				c=c+b.at(z);
				z++;
			}
			i++;
			if(i>=a.size()+b.size())
				break;
		}
		cout<<c<<endl;
		
		//cout<<"Case #"<<counter1<<" ";
		//cout<<endl;	
	}	
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    int ans;
    cin >> n;
    if(n <= 9){
        ans = n;
    }else if(n <= 99){
        ans = 9;
    }else if(n <= 999){
        ans = n - 90;
    }else if(n <= 9999){
        ans = 909;
    }else if(n <= 99999){
        ans = n - 9090;
    }else{
        ans = 90909;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using Graph = vector<vector<int> >;
// MOD
const int MOD = 1000000007;

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int H, W;
int field[100][100];

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double PI=3.14159265358979323846;
bool seen[100][100];


string N[100];

bool memo[110];
bool flag;
Graph G;

int dist[100][100];

bool compare_f(pair<int, int> &x, pair<int, int> &y) {
  return x.second< y.second;
}

int dp[100000];

struct Unionfind{
    vector<int> par;

    Unionfind(int n) : par(n, -1){}

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

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

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

    int size(int x){
        return -par[root(x)];
    }
};

int main() {
    int K, A, B; cin >> K >> A >> B;
    string res = "NG";
    for(int i=A; i<=B; i++){
        if(i%K==0) res = "OK";
    }
    cout << res << endl;
}

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

int main(){
  int n,i,kotae=0;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(i=1;i<n;i++){
    if(a[i-1]==a[i]){
      kotae=1;
    }
  }
  if(kotae){
    cout<<"NO";
  }else{
    cout<<"YES";
  }
}

Measured memory_bytes: 1024
import sys
from collections import deque
import math
sys.setrecursionlimit(20000000)
#input = sys.stdin.readline
n,m = map(int,input().split())
x = []
LE = 0
RI = n
for i in range(m):
    a,b = map(int,input().split())
    LE = max(LE,a)
    RI = min(RI,b)
print(max(0,RI-LE+1))

Measured memory_bytes: 45544