akhauriyash/Code-Regression huggingface dataset:
//file_name:ABC102_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&y);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    int k;
    scanf("%d",&k);
    ll a[n] = {};
    ll num = 0;
    rep(i,n){
        scanf("%lld",&a[i]);
        if(a[i]==1){
            num = i;
        }
    }
    if(n==k){
        cout << 1 << endl;
        return 0;
    }

    ll ans = 0;
    int nn = 0;
    while(nn<n){
        if(ans==0){
            nn+=k;
            ans++;
        }else{
            nn+=k-1;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>
#include <fstream>
#include <bitset>
int longest_path(std::bitset<100>& bit_set, int current, const std::vector<std::vector<int>>& vec) {
	if (bit_set[current]) return 0;
	bit_set[current] = true;
	int max = 1;
	for (const auto next : vec[current]) {
		max = std::max(max, longest_path(bit_set, next, vec) + 1);
	}
	bit_set[current] = false;
	return max;
}

int main() {
	while (true) {
		int n; std::cin >> n; if (n == 0) break;
		std::vector<std::vector<int>> edges(100);
		for (auto i = 0; i < n; ++i) {
			int a, b; std::cin >> a >> b; --a; --b;
			edges[a].push_back(b);
			edges[b].push_back(a);
		}
		std::bitset<100> bit_set;
		int max = 0;
		for (auto i = 0; i < 100; ++i) {
			max = std::max(max, longest_path(bit_set, i, edges));
		}
		std::cout << max << '\n';
	}
}



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



int main(){
    char b; cin >>b;
    if(b=='A') cout<<'T'<<endl;
    if(b=='T') cout<<'A'<<endl;
    if(b=='C') cout<<'G'<<endl;
    if(b=='G') cout<<'C'<<endl;
}




Measured memory_bytes: 256
N,L=map(int,input().split())

nearZero = -10000
tgt = 0
ajiSum = 0

for i in range(1,N+1):
    aji = L + i - 1
    ajiSum += aji
    if abs(nearZero) > abs(aji):
        nearZero = aji
        tgt = i
        
print(ajiSum - nearZero)        

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define forn(i , n) for(int i=0;i<n;i++)


int main(){
    int S;
    cin >> S;
    
    int h = S / 3600;
    int m = (S % 3600) / 60;
    int s = (S % 3600) % 60;
    
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}

Measured memory_bytes: 3088
n = int(input())
X = [[int(i) for i in input().split()] for j in range(n)]

X.sort(key=lambda x:x[2], reverse=True)

for h in range(101):
    for w in range(101):
        x, y, z = X[0]
        d = z + abs(x-w) + abs(y-h)
        for x, y, z in X:
            d2 = z + abs(x-w) + abs(y-h)
            if z == 0:
                if d2 < d:
                    break 
            elif d2 != d:
                break
        else:
            print(w, h, d)
            exit()


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

int main() {
	int x,y;
	while(1){
		cin >> x >> y ; if(!x && !y) break;
		if(x<y) swap(x,y);
		int cnt=0;
		while(y!=0){
			x=x%y;
			swap(x,y);
			cnt++;
		}
		cout << x << ' ' << cnt << '\n' ;
	}
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {

	private static class Edge {
		int to;
		int c;

		public Edge(int to, int c) {
			this.to = to;
			this.c = c;
		}
	}

	static private List<Edge>[] g;
	static private List<Edge>[] rg;
	static private boolean[] reachable;
	static private boolean[] rreachable;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int p = sc.nextInt();

		g = new ArrayList[n];
		rg = new ArrayList[n];

		int[][] es = new int[m][3];
		for (int i = 0; i < n; i++) {
			g[i] = new ArrayList<>();
			rg[i] = new ArrayList<>();
		}
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			int c = sc.nextInt();
			g[a].add(new Edge(b, -(c - p)));
			rg[b].add(new Edge(a, c - p));
			es[i][0] = a;
			es[i][1] = b;
			es[i][2] = -(c - p);
		}

		reachable = new boolean[n];
		rreachable = new boolean[n];
		dfs(0);
		rdfs(n - 1);
		if (!reachable[n - 1]) {
			System.out.println(-1);
			return;
		}

		long[] score = new long[n];
		Arrays.fill(score, Long.MAX_VALUE);
		score[0] = 0;
		int count = 0;
		while (true) {
			boolean updated = false;
			for (int i = 0; i < es.length; i++) {
				if (score[es[i][0]] == Long.MAX_VALUE) continue;
				if (!rreachable[es[i][0]]) continue;
				if (!rreachable[es[i][1]]) continue;

				if (score[es[i][1]] > score[es[i][0]] + es[i][2]) {
					score[es[i][1]] = score[es[i][0]] + es[i][2];
					updated = true;
				}
			}

			count++;
			if (!updated) break;
			if (count > n) {
				System.out.println("-1");
				return;
			}
		}
		System.out.println(Math.max(0, -score[n - 1]));
	}

	private static void dfs(int v) {
		if (reachable[v]) return;
		reachable[v] = true;
		for (int i = 0; i < g[v].size(); i++) {
			dfs(g[v].get(i).to);
		}
	}

	private static void rdfs(int v) {
		if (rreachable[v]) return;
		rreachable[v] = true;
		for (int i = 0; i < rg[v].size(); i++) {
			rdfs(rg[v].get(i).to);
		}
	}
}


Measured memory_bytes: 40392
#include<bits/stdc++.h>
using namespace std;
int a,b,x,c[100];
void mutu(int y,int z,int zz){
    if(y+z==b){
        if(x>abs(y-z)) x=abs(y-z);
    }
    else{
        mutu(y+c[zz],z,zz+1);
        mutu(y,z+c[zz],zz+1);
    }
}
int main(){
    while(1){
        x=1000000;
        b=0;
    cin>>a;
    if(a==0) break;
    for(int i=0;i<a;i++){
        cin>>c[i];
        b+=c[i];
    }
    mutu(0,0,0);
    cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

const int INF = 1e9;

int di[] = {1, -1, 0, 0};
int dj[] = {0, 0, 1, -1};

int main() {
    int w, h;
    while (cin >> w >> h, w | h) {
        bool grid[40][40][4];
        Fill(grid, true);
        // left, right, up, down
        for (int i = 0; i < h; i++) grid[i][0][3] = false;
        for (int i = 0; i < h; i++) grid[i][w - 1][2] = false;
        for (int i = 0; i < w; i++) grid[0][i][1] = false;
        for (int i = 0; i < w; i++) grid[h - 1][i][0] = false;
        for (int i = 0; i < 2 * h - 1; i++) {
            int inp;
            if (i % 2) {
                for (int j = 0; j < w; j++) {
                    cin >> inp;
                    if (inp == 1) {
                        grid[i / 2][j][0] = false;
                        grid[i / 2 + 1][j][1] = false;
                    }
                }
            } else {
                for (int j = 0; j < w - 1; j++) {
                    cin >> inp;
                    if (inp == 1) {
                        grid[i / 2][j][2] = false;
                        grid[i / 2][j + 1][3] = false;
                    }
                }
            }
        }
        int dist[40][40];
        Fill(dist, INF);
        queue<pii> que;
        que.push(pii(0, 0));
        dist[0][0] = 1;
        while (!que.empty()) {
            pii cur = que.front();
            que.pop();
            for (int i = 0; i < 4; i++) {
                if (!grid[cur.first][cur.second][i]) continue;
                int ni = cur.first + di[i];
                int nj = cur.second + dj[i];
                if (dist[ni][nj] > dist[cur.first][cur.second] + 1) {
                    dist[ni][nj] = dist[cur.first][cur.second] + 1;
                    que.push(pii(ni, nj));
                }
            }
        }
        cout << (dist[h - 1][w - 1] == INF ? 0 : dist[h - 1][w - 1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define LL long long
#define db long double

using namespace std;
const int N=1e6+10,inf=1e9;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
int to[N],nt[N],c[N],hd[N],tot=1;
void adde(int x,int y,int z)
{
    ++tot,to[tot]=y,nt[tot]=hd[x],c[tot]=z,hd[x]=tot;
    ++tot,to[tot]=x,nt[tot]=hd[y],c[tot]=0,hd[y]=tot;
}
int ps,pt,lv[N],nhd[N];
queue<int> q;
bool bfs()
{
    memset(lv,0,sizeof(int)*(pt+1));
    lv[ps]=1,q.push(ps);
    while(!q.empty())
    {
	int x=q.front();
	q.pop();
	for(int i=hd[x];i;i=nt[i])
	{
	    int y=to[i];
	    if(c[i]>0&&!lv[y])
		lv[y]=lv[x]+1,q.push(y);
	}
    }
    return lv[pt];
}
int dfs(int x,int fw)
{
    if(x==pt) return fw;
    int an=0;
    for(int &i=nhd[x];i;i=nt[i])
    {
	int y=to[i];
	if(c[i]>0&&lv[y]==lv[x]+1)
	{
	    int dt=dfs(y,min(c[i],fw));
	    c[i]-=dt,c[i^1]+=dt;
	    fw-=dt,an+=dt;
	    if(!fw) break;
	}
    }
    return an;
}
int dinic()
{
    int an=0;
    while(bfs())
    {
	memcpy(nhd,hd,sizeof(int)*(pt+1));
	an+=dfs(ps,inf);
    }
    return an;
}
int n,an[N][2],ta,fe[N],mat[N],mk[N];
bool v[N];
void dd(int x)
{
    v[x]=1;
    for(int i=hd[x];i;i=nt[i])
    {
	int yy=to[i]-n,y=mat[to[i]];
	if(!y||v[y]||c[i]) continue;
	++ta,an[yy][0]=x,an[yy][1]=y;
	dd(y);
    }
}

int main()
{
    n=rd();
    ps=0,pt=n+n;
    for(int i=1;i<n;++i)
    {
	adde(ps,i+n,1);
	int t=rd();
	while(t--) adde(i+n,rd(),1);
    }
    for(int i=1;i<=n;++i) adde(i,pt,1),fe[i]=tot;
    if(dinic()<n-1){puts("-1");exit(0);}
    for(int i=1;i<n;++i)
    {
	for(int j=hd[i+n];j;j=nt[j])
	{
	    int y=to[j];
	    if(!c[j]&&y>=1&&y<=n){mat[i+n]=y,mk[y]=1;break;}
	}
    }
    int rt=1;
    while(mk[rt]) ++rt;
    dd(rt);
    if(ta<n-1){puts("-1");return 0;}
    for(int i=1;i<=ta;++i) printf("%d %d\n",an[i][0],an[i][1]);
    return 0;
}
 


Measured memory_bytes: 33536
// ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int N; cin >> N;
    string s; cin >> s;

    int ans = 0;

    int idx = 0;
    while(idx < N && s[idx] == '<') idx++;
    chmax(ans, N - idx);

    idx = N - 1;
    while(idx >= 0 && s[idx] == '>') idx--;
    chmax(ans, idx + 1);

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

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

using namespace std;

const int maxn = 1e5 * 3 + 20;
long long int n, a[maxn], ans;

int main()
{
    cin >> n;
    for (int i = 0; i < 3 * n; i++)\
        cin >> a[i];
    sort (a , a + (3 * n)); 
    reverse(a , a + (n * 3));
    for (int i = 0; i < n; i++)
        ans += a[i * 2 + 1];
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2560
fun Long.toAlphabetBase(): String {
    val chars = ('a' .. 'z').toList()
    fun f(length: Int, value: Long): String {
        return when(length) {
            0 -> ""
            else -> f(length - 1, value / 26) + chars[(value % 26).toInt()]
        }
    }
    fun length(value: Int): Long {
        return when(value) {
            0 -> 1L
            else -> 26 * length(value - 1)
        }
    }
    var value = this - 1
    var len = 1
    while (length(len) <= value) {
        value -= length(len++)
    }
    return f(len, value)
}
fun main() {
    val n = readLine()!!.trim().toLong()
    println(n.toAlphabetBase())
}

Measured memory_bytes: 36744
#include<iostream>
using namespace std;
typedef unsigned long long ullong;

ullong power(ullong x,ullong n,ullong M)
{
	if(n==0)return 1;
	ullong res=power(x*x%M,n/2,M);
	if(n%2==1)res=res*x%M;
	return res;
}

int main()
{
	ullong x,n;
	cin>>x>>n;
	cout<<power(x,n,1000000007)<<endl;
	return 0;
}

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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

void init(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const int N = 1e5+5;

int main()
{
	init();
	ll n, m, ans = 0;
	vector< pair<ll, ll> > arr(N);
	cin >> n >> m;
	lp(i, n)
		cin >> arr[i].first >> arr[i].second;
	sort(arr.begin(), arr.begin()+n);
	int idx = 0;
	while(m){
		ans += min(m, arr[idx].second) * arr[idx].first;
		m -= min(m, arr[idx].second);
		++idx;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));


#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

signed main(){
  int N; cin >> N;
  int minN = LONG_MAX;
  FOR1(x, sqrt(N)) {
    if (N % x == 0) {
      minN = min(minN, N / x + x);
      // dv("N / x", N / x);
      // dv("x", x);
    }
  }
  cout << minN - 2 << endl;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
priority_queue<ll> pq;
ll val;

int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &val);
		pq.push(val);
	}
	ll firstEle = pq.top();
	pq.pop();
	ll sum = 0;	
	sum += firstEle / 2;
	while(!pq.empty()) {
		sum += pq.top();
		pq.pop();
	}
	printf("%lld\n", sum);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())

m = min(x, y)
M = max(x, y)
dict = {x: a, y: b}
total_cost = 0
set_cost = min(a + b, 2 * c)

total_cost += m * set_cost

# 残りは M - m 枚をかう。Mに該当する金額は、dict[M]

total_cost += (M - m) * min(dict[M], 2 * c)
print(total_cost)



Measured memory_bytes: 3060
#include <iostream>

using namespace std;

void outputArray(int arr[], int n) {
    for (int i = 0; i < n; i++)
        if (i == n - 1) {
            cout << arr[i] << endl;
        } else {
            cout << arr[i] << " ";
        }
}

void selection_sort(int A[], int N) {
    int minValue, minIndex, temp, cnt=0;
    for (int i = 0; i < N - 1; i++) {
        minValue = A[i];
        minIndex = i;
        for (int j = i + 1; j < N; j++) {
            if (A[j] < minValue) {
                minValue = A[j];
                minIndex = j;
            }
        }
        if(minIndex != i) {
            temp = A[i];
            A[i] = A[minIndex];
            A[minIndex] = temp;
            cnt++;
        }
    }
    outputArray(A, N);
    cout << cnt << endl;
}

int main() {
    int n;
    int array[100];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> array[i];

    selection_sort(array, n);

    return 0;
}


Measured memory_bytes: 3116
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

template<typename T> struct Compress {
	map<T, int>mp;
	map<int, T>revmp;

	Compress(vector<T>vs) {
		setmp(vs);
	}

	Compress() :mp(), revmp() {

	}
	void setmp(vector<T>vs) {
		sort(vs.begin(), vs.end());
		vs.erase(unique(vs.begin(), vs.end()), vs.end());
		for (int i = 0; i < static_cast<int>(vs.size()); ++i) {
			mp[vs[i]] = i;
			revmp[i] = vs[i];
		}
	}

};

int main() {
	int N,K;cin>>N>>K;
	vector<pair<long long int, long long int>>ps;
	vector<long long int>xs, ys;
	for (int i = 0; i < N; ++i) {
		long long int x,y;cin>>x>>y;
		ps.emplace_back(x, y);
		xs.emplace_back(x);
		ys.emplace_back(y);
	}
	Compress<long long int> xcomp, ycomp;
	xcomp.setmp(xs);
	ycomp.setmp(ys);
	for (auto&p : ps) {
		p.first = xcomp.mp[p.first];
		p.second = ycomp.mp[p.second];
	}
	vector<vector<int>>plus(51, vector<int>(51));
	for (auto p : ps) {
		plus[p.second][p.first]++;
	}
	vector<vector<int>>sum(51, vector<int>(51));
	for (int i = 1; i <= 50; ++i) {
		for (int j = 1; j <= 50; ++j) {
			sum[i][j] = sum[i - 1][j] + sum[i][j - 1] 
				- sum[i - 1][j - 1] + plus[i - 1][j - 1];
		}
	}
	long long int ans = 5e18;
	for (int l = 0; l < xcomp.mp.size(); ++l) {
		for (int r = l+1; r <=xcomp.mp.size(); ++r) {
			for (int u = 0; u < ycomp.mp.size(); ++u) {
				for (int d = u+1; d <= ycomp.mp.size(); ++d) {
					int num = sum[d][r] - sum[d][l] - sum[u][r] + sum[u][l];
					if (num >= K) {
						long long int lx = xcomp.revmp[l];
						long long int rx = xcomp.revmp[r - 1];
						long long int uy = ycomp.revmp[u];
						long long int dy = ycomp.revmp[d - 1];
						ans = min(ans, (rx - lx)*(dy - uy));
					}
				}
			}
		}
	}
	cout << ans << endl;


	return 0;
}

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

#input = open(sys.argv[1], "r").readline

import fractions

def main():
    N = int(input())
    A = list(map(int, input().split()))

    if N <= 2:
        print(max(A))
        return
    
    L = [0]*(N+1)
    for i in range(N):
        L[i+1] = fractions.gcd(L[i],A[i])
#    print(L)
    R = [0]*(N+1)
    for i in range(N-1,-1,-1):
        R[i] = fractions.gcd(R[i+1],A[i])
#    print(R)
    ma = 1
    for i in range(1,N+1):
        ma = max(ma, fractions.gcd(L[i-1], R[i]))
    print(ma)
    
if __name__ == '__main__':
    main()


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

constexpr long Mod = 1000000007;
long N, M, c, ans = 1;

long modinv(long a){
    long ret = 1, n = Mod - 2;
    while(n){
        if(n & 1)
            ret = ret * a % Mod;
        a = a * a % Mod;
        n /= 2;
    }
    return ret;
}

long C(long b){
    long ret = 1, den = 1;
    for(; b; --b){
        ret = ret * (N - 1 + b) % Mod;
        den = den * b % Mod;
    }
    return ret * modinv(den) % Mod;
}

int main(){
    cin >> N >> M;
    for(int i = 2; i * i <= M; ++i){
        c = 0;
        while(!(M % i)){
            ++c;
            M /= i;
        }
        ans = ans * C(c) % Mod;
    }
    cout << ans * (M ^ 1 ? N : 1) % Mod << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 500005
//<<fixed << setprecision(9)

int arr[space];
int cnt[space];
int distinct;

const int block_size=700;

struct Query
{
    int l, r, idx;
    bool operator<(Query other) const
    {
        if(l/block_size != other.l/block_size) return l<other.l;
        return ((l/block_size)&1) ? r<other.r : r>other.r ;
    }
};

void add(int& x)
{
    cnt[arr[x]]++;
    if(cnt[arr[x]]==1) distinct++;
}
void remove(int& x)
{
    cnt[arr[x]]--;
    if(cnt[arr[x]]==0) distinct--;
}

int main()
{
    int n,i,j,t;
    boost;

    cin>>n>>t;

    rep(i,1,n+1) cin>>arr[i];

    Query Q[t];
    int ans[t];
    rep(i,0,t)
    {
        int l,r;
        cin>>l>>r;
        Q[i]={l,r,i};
    }
    sort(Q,Q+t);

    int cur_l = 1;
    int cur_r = 0;
    
    for (Query q : Q)
    {
        while (cur_l > q.l) {
            cur_l--;
            add(cur_l);
        }
        while (cur_r < q.r) {
            cur_r++;
            add(cur_r);
        }
        while (cur_l < q.l) {
            remove(cur_l);
            cur_l++;
        }
        while (cur_r > q.r) {
            remove(cur_r);
            cur_r--;
        }
        ans[q.idx] = distinct;
    }

    rep(i,0,t)cout<<ans[i]<<'\n';

    return 0;
}

Measured memory_bytes: 15508
import math
n = int(input())
s = input().split()
q = input()
t = input().split()
cnt = 0
for x in t:
    left = 0
    right = n
    while (left < right):
        mid = math.floor((left + right) / 2)
        if s[mid] == x:
            cnt += 1
            break
        elif int(x) < int(s[mid]):
            right = mid
        else:
            left = mid + 1
print(cnt)


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

using namespace std;

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

	int x, y;

	vector<int> y_x(8, -1);

	for (int i = 0; i < N; i++)
	{
		cin >> y >> x;

		y_x[y] = x;
	}

	vector<int> perm(8);

	for (int i = 0; i < 8; i++) { perm[i] = i; }

	bool ok = true;

	do
	{
		ok = true;

		for (int y = 0; y < 8; y++)
		{
			if (y_x[y] != -1 && perm[y] != y_x[y])
			{
				ok = false;
			}
		}

		if (ok == true)
		{
			for (int i = 0; i < 8; i++)
			{
				for (int j = 0; j < 8; j++)
				{
					if (i != j)
					{
						if (i - perm[i] == j - perm[j] || i + perm[i] == j + perm[j])
						{
							ok = false;
						}
					}
				}
			}
		}

		if (ok == true)
		{
			for (int i = 0; i < 8; i++)
			{
				for (int j = 0; j < 8; j++)
				{
					if (perm[i] == j)
					{
						cout << 'Q';
					}
					else
					{
						cout << '.';
					}
				}

				cout << endl;
			}
		}
	} while (next_permutation(perm.begin(), perm.end()));

	return 0;
}

Measured memory_bytes: 3104
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {
    
    int N; cin >> N;
    N %= 10;
    if (N == 3) {
        cout << "bon" << endl;
    }
    else if (N == 0 || N == 1 || N == 6 || N == 8) {
        cout << "pon" << endl;
    }
    else {
        cout << "hon" << endl;
    }


    
    return 0;
}






Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF (1LL<<62)
#define NINF ((-1)*(INF))
#define MOD (1000000007)

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int arr[n+5][n+5];
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			cin >> arr[i][j];
		}
	}
	vector<int> dp(1LL<<n, 0);
	dp[0] = 1;
	for(int i = 0; i < (1LL<<n)-1; i++)
	{
		int set_bits = 0;
		for(int j = 0; j < n; j++)
		{
			if(((1LL << j) & i))
				set_bits++;
		}
		for(int j = 0; j < n; j++)
		{
			if(((1LL << j) & i) == 0)
			{
				dp[i | (1LL << j)] = (dp[i | (1LL << j)] + arr[set_bits][j]*dp[i])%MOD;
			}
		}
	}
	cout << dp[(1LL<<n)-1];
}


Measured memory_bytes: 16640
from collections import Counter
N = int(input())
A = list(enumerate(list(map(int, input().split()))))
b = Counter([x[0]+x[1]+1 for x in A])
c = Counter([x[0]-x[1]+1 for x in A])
count = 0
for x in b.items():
    count += x[1] * c[x[0]]
print(count)

Measured memory_bytes: 170624
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.equals("ABC")){
            System.out.println("ARC");
        }else{
            System.out.println("ABC");
        }
    }
}


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

int main(){
  string s;
  int n;
  cin >> n>>s;
  int sum=0,ans=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='I') sum++;
    else sum--;
    ans = max(ans,sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    set<int> st;
    REP(i,n) {
        int a; cin >> a;
        st.insert(a);
    }

    CFYN(n == st.size())

    return 0;
}

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

int main()
{
	int64_t m, k;
	cin >> m >> k;

	int64_t n = (1LL << m);

	if (n <= 4)
	{
		vector<int> as(n);
		for (int i = 0; i < n; i++)
		{
			as[i] = i;
		}

		do
		{
			vector<int> bs(n);
			for (int i = 0; i < n; i++)
			{
				bs[i] = i;
			}
			do
			{
				bool f = true;
				for (int i = 0; i < n; i++)
				{
					int ia = 0, ib = 0;
					for (; as[ia] != i; ia++)
					{
					}
					for (; bs[ib] != i; ib++)
					{
					}
					int x = 0;
					for (int j = ia; j < n; j++)
					{
						x ^= as[j];
					}
					for (int j = 0; j <= ib; j++)
					{
						x ^= bs[j];
					}
					f &= x == k;
				}
				if (f)
				{
					for (auto &a : as)
					{
						cout << a << ' ';
					}
					for (auto &b : bs)
					{
						cout << b << ' ';
					}
					cout << endl;
					return 0;
				}
			} while (next_permutation(bs.begin(), bs.end()));
		} while (next_permutation(as.begin(), as.end()));

		cout << -1 << endl;

		return 0;
	}

	if (0 <= k && k < n)
	{
		for (int64_t i = n - 1; 0 <= i; i--)
		{
			if (i == k)
			{
				continue;
			}
			cout << i << ' ';
		}
		cout << k << ' ';
		for (int64_t i = 0; i < n; i++)
		{
			if (i == k)
			{
				continue;
			}
			cout << i << ' ';
		}
		cout << k << endl;
	}
	else
	{
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int N2 = (N - 1) / 2;
  int N3 = N2 + 2;
  int flag = true;
  for(int i=0; flag; ++i) {
    if(i >= N-1-i) break;
    if(S[i] != S[N-1-i]) {
      flag = false;
    }
  }
  for(int i=0; flag; ++i) {
    if(i >= N2-1-i) break;
    if(S[i] != S[N2-1-i]) {
      flag = false;
    }
  }
  for(int i=0; flag; ++i) {
    if(N2+1+i >= N-1-i) break;
    if(S[N2+1+i] != S[N-1-i]) {
      flag = false;
    }
  }
  cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define INFINITY 10000000000
#define N 500000

int count = 0;

void marge(int *A, int left, int mid, int right) {
  int n1, n2, i, j, k, L[N], R[N];

  n1 = mid - left;
  n2 = right - mid;
  for(i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for(i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = INFINITY;
  R[n2] = INFINITY;
  i = 0;
  j = 0;
  for(k = left; k < right; k++) {
    count++;
    if(L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    }
    else {
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int *A, int left, int right) {
  int mid;
  
  if(left + 1 < right) {
    mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    marge(A, left, mid, right);
  }
}

int main() {
  int i, n, A[N];

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

  mergeSort(A, 0, n);

  for(i = 0; i < n; i++) {
    if(i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", count);

  return 0;
    
}

Measured memory_bytes: 5584
#include<bits/stdc++.h>
using namespace std;
int n,d[1005],m,s;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>d[i];
	sort(d+1,d+1+n);
	for(int i=1;i<=n;i++){
		m=d[i-1];
		if(d[i]<=m) continue;
		s++;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	string s;
	cin >> s;
	rep(i, 4) {
		int a = 0;
		rep(j, 4) { 
			if (s[i] == s[j])a++;
		}
		if (a != 2) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

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

using namespace std;

double solve(int n, vector<double> &faceRate)
{
    vector<vector<double> > rate(n+1, vector<double>(n+1, 0));

    rate[0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < i; j++){
            rate[i][j] += rate[i-1][j] * (1 - faceRate[i-1]);
            rate[i][j+1] += rate[i-1][j] * faceRate[i-1];
        }
    }
    double sum = 0;
    for(int i = n; i > n / 2; i--){
        sum += rate[n][i];
    }
    return sum;
}

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

    vector<double> faceRate;
    for(int i = 0; i < n; i++){
        double per;
        cin >>per;
        faceRate.push_back(per);
    }

    printf("%.10lf\n", solve(n, faceRate));
    return 0;
}

Measured memory_bytes: 70784
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def PL(L) : print(*L, sep="\n")

K = I()

stack = [[1],[2],[3],[4],[5],[6],[7],[8],[9]]
ok = [[0,1], [0,1,2], [1,2,3], [2,3,4], [3,4,5], [4,5,6], [5,6,7], [6,7,8], [7,8,9], [8,9]]

i = 0
while len(stack) < K:
    p = stack[i]
    tm = ok[p[-1]]
    
    for t in tm:
        stack.append(p+[t])
    
    i += 1

# print(stack)

for i in stack[K-1]:
    print(i, end="")
print()


Measured memory_bytes: 58204
#include<cstdio>
int main(void)
{
    int a,b;
    scanf("%d %d" ,&a,&b);
    for(int i=0; i<10000; i++) {
        if(i*8/100==a && i/10==b) {
            printf("%d" ,i);
            return 0;
        }
    }
    printf("-1");
    return 0;
}


Measured memory_bytes: 128
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let a: Vec<usize> = read_vec();
    let mut right = 0;
    let mut sum = 0;
    let mut xor = 0;
    let mut ans = 0;

    for left in 0..n {
      while right < n  && sum + a[right] == xor^a[right] {
        //println!("sum = {}, xor = {}", sum, xor);
        sum += a[right];
        xor ^= a[right];
        right += 1;
      }
      //println!("[{}] sum = {}, xor = {}, left = {}, right = {}, ans = {}", left, sum, xor, left, right, ans);
      sum -= a[left];
      xor ^= a[left];
      ans += (right - left);
      if right < left {
        right = left;
        sum = 0;
        xor = 0;
      }
      //println!("[{}] sum = {}, xor = {}, left = {}, right = {}, ans = {}", left, sum, xor, left, right, ans);
      // println!("sum = {}, xor = {}", sum, xor);
      // println!("ans = {}", ans);
      // println!("left = {}, right = {}", left, right);
    }

    //println!("sum = {}, xor = {}", sum, xor);
    println!("{}", ans);
}


Measured memory_bytes: 10492
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
   
    if op=='?':
        break
    else:

        if op =="+":
            print(a+b)
        elif op =="-":
            print(a-b)
        elif op =="*":
            print(a*b)
        elif op =="/":
            print(a//b)


Measured memory_bytes: 5596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
const int N=1e5+5;
int n,a[N],b[N];
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    for(int i=1;i<=n;i++) scanf("%d",b+i);
    std::vector<int> g;
    long long sum=0;int ans=0;
    for(int i=1;i<=n;i++) {
        if(a[i]<b[i]) sum+=b[i]-a[i],ans++;
        if(a[i]>b[i]) g.push_back(b[i]-a[i]);
    }
    std::sort(g.begin(),g.end());
    for(int i=0;i<g.size()&&sum>0;i++) {
        sum+=g[i];ans++;
    }
    if(sum>0) printf("-1\n");
    else printf("%d\n",ans);
    return 0;
}


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

int c[200005] , b[200005] , a[200005];

int main()
{
    int n , m , ans;

    cin >> n >> m;

    ans = n;

    for(int i = 1 ; i<=n ; i++)
    {

        cin >> a[i];

        c[a[i]]++;

        int pos = a[i] - c[a[i]] + 1;
       // cout << pos << endl;

        if(pos>=1)
        {
            if(b[pos]==0)
            {
                ans--;
            }
            b[pos]++;
        }
    }
    for(int i = 1 ; i<=m ; i++)
    {
        int x , y;

        cin >> x >> y;

        int pos = a[x] - c[a[x]] + 1;
        b[pos]--;

        if(pos>=1)
        {
            if(b[pos]==0)
            {
                ans++;
            }
        }


        c[a[x]]--;
        a[x] = y;
        c[a[x]]++;

        pos = a[x] - c[a[x]] + 1;
        if(pos>=1)
        {
            if(b[pos]==0)
            {
                ans--;
            }
            b[pos]++;
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void read(int &res){
	res=0;char c;
	while((c=getchar())<48);
	do res=(res<<1)+(res<<3)+(c^48);
	while((c=getchar())>47);
}
int main(){
	int a[4];
	scanf("%d%d%d",&a[1],&a[2],&a[3]);
	sort(a+1,a+1+3);
	cout<<a[2]+a[1];
	return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INFLL=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void solve_(){
     string a,b;
    cin >> a >> b;
    
    static int dp[1000][1000];
    fill_n((int*)dp,1000*1000,0);
    
    rep(i,0,a.size()){
        rep(j,0,b.size()){
            if(i!=0) dp[i][j]=dp[i-1][j];
            if(j!=0) dp[i][j]=max(dp[i][j],dp[i][j-1]);
            
            if(a[i]!=b[j]) continue;
            
            if(i==0||j==0) dp[i][j]=1;
            else dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
        }
    }
    
    cout << dp[a.size()-1][b.size()-1] << endl;
}

void solve(){
    int n;
    cin >> n;
    rep(i,0,n) solve_();
}

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

Measured memory_bytes: 5116
import java.util.*;
import java.io.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                PrintWriter ou = new PrintWriter(System.out);
                int n = Integer.parseInt(sc.next());
                int x = Integer.parseInt(sc.next());
                int[] q = new int[n];
                int yono = 0;
                for(int i = 0 ; i < n ; i++){
                        q[i] = Math.abs(Integer.parseInt(sc.next()) - x);
                        if(q[yono] > q[i]) yono = i;
                }
                sc.close();
                boolean fia = true;
                for(int i = q[yono] ; fia ; i--){
                        boolean ebishu = true;
                        for(int j = 0 ; j < n && ebishu ; j++){
                                if(q[j] % i != 0) ebishu = false;
                        }
                        if(ebishu){
                                fia = false;
                                ou.print(i + "\n");
                        }
                }
                ou.flush();
        }
}

Measured memory_bytes: 59324
#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define printmx(matrix) Loop(i, matrix.size()) { Loop(j, matrix[i].size()) { cout << matrix[i][j] << " "; } cout << endl; }
#define rndf(d) (ll)((double)(d) + (d >= 0 ? 0.5 : -0.5))
#define floorsqrt(x) ((ll)sqrt((double)x) + ((ll)sqrt((double)x) * (ll)sqrt((double)x) <= (ll)(x) ? 0 : -1))
#define ceilsqrt(x) ((ll)sqrt((double)x) + ((ll)x <= (ll)sqrt((double)x) * (ll)sqrt((double)x) ? 0 : 1))
#define rnddiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) * 2 >= (ll)(b) ? 1 : 0))
#define ceildiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) == 0 ? 0 : 1))
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)

/*******************************************************/

int main() {
	ll W, H;
	int N;
	cin >> W >> H >> N;
	ll w = 0, e = W, n = H, s = 0;
	Loop(i, N) {
		ll x, y, c; cin >> x >> y >> c;
		switch (c) {
		case 1:
			w = max(w, x);
			break;
		case 2:
			e = min(e, x);
			break;
		case 3:
			s = max(s, y);
			break;
		case 4:
			n = min(n, y);
			break;
		}
	}
	if (e <= w || n <= s) cout << 0 << endl;
	else cout << (e - w) * (n - s) << endl;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();

        int count = 0;
        for(int i = 0;i < n;i++){

        	// 	isProbablePrime()はこのBigIntegerが素数である可能性が高い場合はtrue、必ず合成数である場合はfalseを返します
            BigInteger bi = new BigInteger(sc.next());
            if(bi.isProbablePrime(5)) count++;

        }
        System.out.println(count);

	}

}



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

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

		int N = sc.nextInt();
		int M = 1;
		for(; M*(M+1)<=2*N; M++) {
			if(M*(M+1)==2*N) {
				int[][] ans = new int[M+1][M];
				for(int i=0; i<M+1; i++) {
					for(int j=0; j<M; j++) {
						if(j<i) {
							ans[i][j] = ans[j][i-1];
						} else {
							ans[i][j] = (i>0 ? ans[i-1][M-1] : 0) + (j-i+1);
						}
					}
				}
				
				pw.println("Yes");
				pw.println(M+1);
				for(int i=0; i<M+1; i++) {
					pw.print(M + " ");
					for(int j=0; j<M; j++) {
						pw.print(ans[i][j] + (j==M-1 ? "\n" : " "));
					}
				}
				
				pw.close();
				sc.close();
				return;
			}
		}
		
		pw.println("No");
		
		pw.close();
		sc.close();
	}
}


Measured memory_bytes: 45092
// IN THE NAME OF ALLAH
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define F fisrt
#define S second


int main(){
	ll a , b , c , d , k;
	cin >> a >> b >> c >> d >> k;
	ll w = (c - a) * 60 + (d - b) - k;
	cout << w;
	return 0; 
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
string bins(int x, int n) {
  string res;
  rep(i,n) res += "01"[x&1], x >>= 1;
  reverse(rng(res));
  return res;
}

int main() {
  int n,K;
  scanf("%d%d",&n,&K);
  vvi d(n+1);
  rep(i,n+1) {
    string s;
    cin>>s;
    int m = sz(s);
    d[i] = vi(m);
    rep(j,m) d[i][j] = s[j]-'0';
  }

  for (int i = n; i >= 1; --i) {
    int m = 1<<i;
    rep(j,m) d[i-1][j>>1] += d[i][j];
  }

  rrep(e,n) {
    int msk = bn(e);
    for (int i = n; i > e; --i) {
      int m = 1<<i;
      rep(j,m) {
        if ((j>>e&1) == (j>>(e-1)&1)) continue;
        int nj = (j>>(e+1)<<e) | (j&msk);
        d[i-1][nj] += d[i][j];
      }
    }
  }

  drep(i,n+1) {
    int m = 1<<i;
    rep(j,m) {
      if (d[i][j] >= K) {
        cout<<bins(j,i)<<endl;
        return 0;
      }
    }
  }
  return 0;
}






















Measured memory_bytes: 9712
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		boolean flag = false;
		for(int i=0;i<3;i++) {
			if(N.charAt(i)=='7') {
				flag = true;
			}
		}
		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35752