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

  int N ;
  cin >> N ;
  ll ans = pow(3,N) ;
  vector<int> A(N) ;
  rep(i,N) cin >> A.at(i) ;
  ll count = 1 ;
  rep(i,N){
    if( A.at(i)%2 == 0 ) count*= 2 ;
    else count *= 1 ;
  }
  cout << ans - count << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ab = sorted([[a[i], b[i]] for i in range(n)], key=lambda x: x[1])

    num=1
    while num < n:
        num *= 2
    num-=1
    inf=10**9+1

    m=num+n
    segtree=[inf]*m
    for i in range(num,m):
        segtree[i] = ab[i - num][0]
    for i in range(num-1,-1,-1):
        j=2*i+1
        if j>=m:
            segtree[i]=inf
        elif j+1>=m:
            segtree[i]=segtree[j]
        else:
            segtree[i] = min(segtree[j], segtree[j + 1])

    #探す
    def search(s):
        i=0
        while i < num:
            k = 2 * i + 1
            if k+2<=m:
                if segtree[k+1] <= s:
                    i = k + 1
                    continue
            if k+1<=m:
                if segtree[k] <= s:
                    i = k
                    continue
            return - 1
        return i - num
    
    #更新
    #def update_good(i, s):
    #    while True:
    #        if segtree[i] > s:
    #            segtree[i] = s
    #            i = (i - 1) // 2
    #            continue
    #        break
    
    def update(i, s):
        segtree[i]=s
        while i!=0:
            k=(i - 1) // 2
            if i % 2 == 1:
                temp = min(segtree[min(i + 1, m - 1)], segtree[i])
            else:
                temp = min(segtree[i-1],segtree[i])
            if segtree[k]!=temp:
                segtree[k] = temp
                i = k
                continue
            break

    cnt = 0
    for i in range(n):
        a,b=ab[i][0],ab[i][1]
        if a > b:
            t = search(b)
            if t <= i:
                print("No")
                return 0
            update(num + i, a)
            update(num + t, a)
            ab[i][0], ab[t][0] = ab[t][0], a
            cnt+=1
    if cnt <= n - 2:
        print("Yes")
    else:
        print("No")
    
main()

Measured memory_bytes: 119272
N = input()
A = list(map(int, input().split()))
N = int(N)
MA = max(A)
s=0
LS = [0 for i in range(0,MA)]
for i in range(0,N):
  k=1
  while A[i]*k<=MA:
    LS[A[i]*k-1] +=1
    k +=1
for j in range(0,N):
  if LS[A[j]-1]==1:
    s+=1
print(s)

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

const int N=2010;
const int mod=1000000007;
const int inv2=(mod+1)/2;

vi e[2010];

int dp[2010][2010][3],size[2010];
int fac[2010],pow2[2010];

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

void dfs(int k)
{
	dp[k][1][0]=1;size[k]=1;
	for (vi::iterator p=e[k].begin();p!=e[k].end();p++)
	{
		dfs(*p);
		for (int j=size[k];j;j--)
			for (int x=2;x>=0;x--)
			{
				for (int l=1;l<=size[*p];l++)
				{
					if (x<2)
						for (int y=0;y<2;y++)
							dp[k][j+l-1][x+1]=(ll(dp[k][j][x])*dp[*p][l][y]+dp[k][j+l-1][x+1])%mod;
					for (int y=0;y<=2;y++)
					{
							dp[k][j+l][x]=(ll(dp[k][j][x])*dp[*p][l][y]%mod*(y==0 ? inv2 : 1)+dp[k][j+l][x])%mod;
							//if (k==2) printf("%d %d %d %d %d\n",dp[2][2][0],j,x,l,y);
					}
				}
				dp[k][j][x]=0;
			}
		size[k]+=size[*p];
	}
}

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int n;scanf("%d",&n);
	for (int i=2;i<=n;i++)
	{
		int x;scanf("%d",&x);e[x].pb(i);
	}
	memset(dp,0,sizeof(dp));
	dfs(1);
	fac[0]=1;for (int i=1;i<=n;i++) fac[i]=ll(fac[i-1])*i%mod;
	pow2[0]=1;for (int i=1;i<=n;i++) pow2[i]=pow2[i-1]*2%mod;
	int ans=0;
	for (int i=1;i<=n;i++)
		for (int j=0;j<=2;j++)
		{
			int t=ll(fac[i])*pow2[i]%mod*dp[1][i][j]%mod*(j==0 ? inv2 : 1)%mod;
			if ((n-i)&1) ans=(ans-t+mod)%mod; else ans=(ans+t)%mod;
		}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 48000
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
const int MAX=3100;
const int INF=1e9+10;
string s,t;
int dp[MAX][MAX];
string lcs(string a,string b,int n,int m){
	if(!n||!m) return "";
	if(a[n-1]==b[m-1]) return lcs(a,b,n-1,m-1)+a[n-1];
	if(dp[n-1][m]>dp[n][m-1]) return lcs(a,b,n-1,m);
	else return lcs(a,b,n,m-1);
}
int main(){
	cin>>s>>t;
	for(int i=1;i<=s.length();i++){
		for(int j=1;j<=t.length();j++){
			if(s[i-1]==t[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	cout<<lcs(s,t,s.length(),t.length());
	return 0;
}

Measured memory_bytes: 67584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;

int main()
{
    string s;
    cin >> s;
    if (s[s.length() - 1]=='s'){
        s.append("es");
    }else{
        s.append("s");
    }
    cout << s;
    return 0;
}


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

int main(){
    long long n;
    long long ans = 0;
    long long f = 5;
    cin>>n;
    if (n%2==1){
        cout<<'0';
        return 0;
    }
    else{
        ans += n/10;
        n/=10;
        for (int i=1;i<26;i++){
            ans+=n/f;
            f*=5;
        }
        cout<<ans;
    }
}

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int h, w, k;
int t = 0;

bool check(v3& a){
	int m = 0;
	rep(i, h){
		rep(j, w){
			if(a[i][j] == '#') m++;
		}
	}
	if(m == k) return true;
	else return false;
}

void paint(int l, int m, v3 a){
	int hc = 0;
	int wc = 0;
	while(hc < h){
		if(l & (1<<hc)){
			rep(i, w){
				a[hc][i] = 'r';
			}
		}
		hc++;
	}
	while(wc < w){
		if(m & (1<<wc)){
			rep(i, h){
				a[i][wc] = 'r';
			}
		}
		wc++;
	}
	if(check(a)) t++;
}

void com(v3& a){
	for(int l = 0; l < (1<<h); l++){
		for(int m = 0;m < (1<<w); m++){
			paint(l, m, a);
		}
	}
}


int main(){
	cin >> h >> w >> k;
	v3 a(h,vector<char>(w));
	rep(i, h){
		rep(j, w){
			cin >> a[i][j];
		}
	}
	com(a);
	cout << t << endl;
}


Measured memory_bytes: 3616
// Confessions of a Dangerous Mind

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 2e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 3e-16;

/*
	Keep moving forward. Take the Leap of Faith
*/

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

	string s, t; cin >> s >> t;
    
    long long cnt = 0, n = ll(s.size());

    for(long long i = 0; i < n; i++){
    	cnt += s[i] == t[i];
    }
    
    cout << cnt;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    vector<int> vec = {1, 9, 7, 4};
    rep(i, 4) {
        int N;
        cin >> N;
        rep(i, 4) {
            if (vec[i] == N) {
                vec[i] = -1;
            }
        }
    }
    rep(i, 4) if (vec[i] != -1) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}

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

typedef long long ll;

int main(){
    int h, w;
    cin >> h >> w;
    string c[h];
    for(int i = 0; i < h; i++)
    {
        cin >> c[i];
    }
    for(int i = 0; i < h; i++)
    {
        cout << c[i] << endl << c[i] << endl;
    }
    
    
    return 0;
}

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

using namespace std;

int main(){
  int h[10];
  for(int i = 0; i < 10; i++)
    cin >> h[i];
  sort(h, h + 10, greater<int>());
  for(int i = 0; i < 3; i++)
    cout << h[i] << "\n";
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define simplify ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;


int32_t main()
{
    simplify
    int x,y;
    cin>>x>>y;

    if(y>=2*x && y<=4*x && y%2==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }



    return 0;
}


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

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

using namespace std;

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

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

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

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

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

int H, N;
int DP[20010];

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

	cin >> H >> N;
	int A, B;
	int ans = INF;
	fill(DP, DP + 20010, INF);
	DP[0] = 0;
	rep(i, 0, N)
	{
		cin >> A >> B;
		rep(j, 0, 20010)
		{
			if (DP[j] != INF && j + A < 20010)
			{
				chmin(DP[j + A], DP[j] + B);
			}
		}
	}

	rep(i, H, 20010)
	{
		if (DP[i] != INF)
		{
			chmin(ans, DP[i]);
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

constexpr int INF = numeric_limits<int>::max() / 2;

struct Edge
{
    int from, to, len, cost;
    Edge(int from, int to, int len, int cost) : from(from), to(to), len(len), cost(cost) {}
};

using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;

struct State
{
    int cur, dist, cost;
};

// 逆順にしているので注意
bool operator<(const State &e, const State &f)
{
    return (e.dist != f.dist) ? (e.dist > f.dist) : (e.cost > f.cost);
}

// 単一始点最短経路, O(ElogV)
int dijkstra(const Graph &g)
{
    int ret = 0;
    std::vector<int> d((int)g.size(), INF), mcost((int)g.size(), INF);
    d[0] = 0;
    mcost[0] = 0;
    std::priority_queue<State> que;
    que.push(State{0, 0, 0}); // (pos, dist, cost)
    while (!que.empty())
    {
        int dist = que.top().dist;
        int v = que.top().cur;
        int c = que.top().cost;
        // cout << "pop " << v << " " << dist << " " << c << endl;
        que.pop();
        if (d[v] < dist || (d[v] == dist && mcost[v] < c))
            continue;
        ret += c;
        for (const auto &e : g[v])
        {
            if (d[e.to] < d[v] + e.len || (d[e.to] == d[v] + e.len && mcost[e.to] <= e.cost))
                continue;
            d[e.to] = d[v] + e.len;
            mcost[e.to] = e.cost;
            que.push(State{e.to, d[e.to], e.cost});
            // cout << "push " << e.to << " " << d[e.to] << " " << e.cost << endl;
        }
    }
    return ret;
}

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

    int n, m;
    while (cin >> n >> m, n || m)
    {
        Graph g(n);
        for (int i = 0; i < m; i++)
        {
            int u, v, d, c;
            cin >> u >> v >> d >> c;
            u--;
            v--;
            g[u].push_back(Edge(u, v, d, c));
            g[v].push_back(Edge(v, u, d, c));
        }
        cout << dijkstra(g) << endl;
    }
}



Measured memory_bytes: 4412
import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    long A = scan.nextLong();
    long B = scan.nextLong();
    long N = scan.nextLong();
    scan.close();

    System.out.println(B>N ? (int)Math.floor(A*N/B) : (int)Math.floor(A*(B-1)/B));
  }
}

Measured memory_bytes: 27044
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define sec second
using namespace std;


const int MAXN=1e5+100;
const ll INF=2e18;

ll x[MAXN],dp[MAXN],dp2[MAXN];

int main() {
   // cout << "HI" <<endl;
    ll n,E,T;
    cin>>n>>E>>T;
    x[0]=0;
    for(int i=1;i<=n;i++){
        cin>>x[i];
        x[i]*=2;
        dp[i]=INF;
    }
    E*=2;
    dp[0]=0;
    dp2[0]=-x[1]*2;
    for(int i=1;i<=n;i++){
        int j=lower_bound(x+1,x+n+1,(x[i]-T))-x;

        if(x[j]>x[i]-T&&j){
            j--;
        }

        dp[i]=dp[j]+T*2;

        if(j>0){
            dp[i]=min(dp[i],dp2[j-1]+x[i]*2);
        }


        dp2[i]=min(dp2[i-1],dp[i]-x[i+1]*2);
      //  cout<<i<<' '<<dp[i]<<' '<<dp2[i]<<' '<<j<<endl;

    }

    cout<<(dp[n]+E)/2<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(b==1) return a;else if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n,k);
    vector<int> vec(n),minus,plus;
    rep(i,n){
        in(vec[i]);
        if(vec[i]>=0)plus.push_back(vec[i]);
        else minus.push_back(-vec[i]);
    }
    reverse(all(minus));
    //折り返したら再び戻ってくることはない
    int distance=0,ans=1000000000;
    if(plus.size()>=k)ans=plus[k-1];
    if(minus.size()>=k)ans=min(ans,minus[k-1]);
    for(int p_index=0;p_index<k-1;p_index++){
        int m_index=k-2-p_index;
        if(plus.size()>p_index&&minus.size()>m_index){
            distance=plus[p_index]+minus[m_index]+min(plus[p_index],minus[m_index]);
            ans=min(ans,distance);
        }
    }
    out(ans);
}

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

using namespace std;

vector<vector<int>> edges;
vector<int> length;
vector<int> active;
vector<int> a;

void dfs(int u, int parent) {
    auto p = lower_bound(active.begin(), active.end(), a[u]);
    bool back = false;
    int prev = 0;
    if (p == active.end()) {
        active.push_back(a[u]);
        back = true;
    } else {
        prev = *p;
        *p = a[u];
    }
    length[u] = active.size();
    for (int v: edges[u]) {
        if (v != parent) {
            dfs(v, u);
        }
    }
    if (back) {
        active.pop_back();
    } else {
        *p = prev;
    }
}
int main() {
    int n;
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    edges.resize(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        edges[u - 1].push_back(v - 1);
        edges[v - 1].push_back(u - 1);
    }
    length.resize(n);
    active.reserve(n);
    dfs(0, -1);
    for (int x: length) {
        cout << x << "\n";
    }
    return 0;
}


Measured memory_bytes: 30000
a,b,c,d,e,f = map(int, input().split())

sugar = []
for i in range(f):
    for j in range(f):
        y = i*c + j*d
        if y <= f:
            sugar.append(y)

water = []
for i in range(0, f//100+1):
    for j in range(0, f//100+1):
        x = i*a*100 + j*b*100
        if x <= f:
            water.append(x)
max_concentration = 0
ans1, ans2 = 0, 0
for x in water:
    for y in sugar:
        if x == 0 and y == 0:
            continue
        elif e * (x // 100) < y:
            continue
        elif x + y > f:
            continue
        else:
            concentration = (100 * y) / (x+y)
            if max_concentration <= concentration:
                max_concentration = concentration
                ans1 = x+y
                ans2 = y
print("{} {}".format(ans1, ans2))

Measured memory_bytes: 12440
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, c = 0;
    string s;
    cin >> n;
    map<string, ll> m;
    for (ll i = 0; i < n; i++)
        cin >> s, sort(s.begin(), s.end()), m[s]++;
    for (auto e : m)
        c += e.second * (e.second - 1) / 2;
    cout << c;
    return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) {
    const int NUM = 60001;
    vector<bool> prime(NUM, true);
    prime[1] = false;
    for (int i = 2; i < NUM; ++i) {
        if (prime[i]) {
            for (int j = i + i; j < NUM; j+=i) {
                prime[j] = false;
            }
        }
    }
    int n, u, d;
    while (cin>>n) {
        for (int i = n-1; i > 1; --i) {
            if (prime[i]) {
                d = i;
                break;
            }
        }
        for (int i = n + 1; i < NUM; ++i) {
            if (prime[i]) {
                u = i;
                break;
            }
        }
        cout << d << " " << u << endl;
    }
    return 0;
}


Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{
	int n,a,k,sum=0;
	cin>>n>>a;
	for(int i=0;i<=n;i++)
	{
		for(int j=i;j<=n;j++)
		{
			k=a-i-j;
			if(k<=n&&j<=k)
			{
				if(i!=j&&j!=k&&k!=i)sum+=6;
				else if(i==j&&j==k)sum++;
				else sum+=3;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

int main() {
  std::string s;
  std::cin >> s;

  if (s == "AAA" || s == "BBB")
    std::cout << "No" << '\n';
  else
    std::cout << "Yes" << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct CWW{CWW(){ios::sync_with_stdio(false);cin.tie(0);}}cww;
int main()
{
	vector<int> vc(3);
	for( auto&& x : vc )
	{
		cin >> x;
	}
	sort( vc.begin(), vc.end() );
	cout << ( vc[0] == 5 && vc[1] == 5 && vc[2] == 7 ? "YES" : "NO" ) << endl;
	return 0;
}

Measured memory_bytes: 256
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  a := nextInt()
  b := nextInt()
  c := nextInt()
  x := nextInt()

  count := 0
  for i := 0; i <= a; i++ {
    for j := 0; j <= b; j++ {
      for r := 0; r <= c; r++ {
		  if (i * 500 + j * 100 + r * 50) == x {
			  count++
		  }
      }
    }
  }
  fmt.Println(count)

}

func nextString() (string) {
	sc.Scan()
	v := sc.Text()
	return v
}

func nextInt() (int) {
	sc.Scan()
	v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}

func nextFloat() (float64) {
	sc.Scan()
	v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}


Measured memory_bytes: 640
// https://atcoder.jp/contests/abc114/tasks/abc114_a
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    cout << (n == 3 || n == 5 || n == 7 ? "YES\n" : "NO\n");

    return 0;
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int x;
	cin >> x;
	int pnts = 0;
	while (x >= 5) {
		if (x >= 500) {
			x -= 500;
			pnts += 1000;
		} else {
			x -= 5;
			pnts += 5;
		}
	}
	cout << pnts << '\n';	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

	for (long long i = 1; i <= 3500; i++) {
		for (long long j = 1; j <= 3500; j++) {
			long long s = 4 * i * j - n * i - n * j, t = i * j * n;
			if (s != 0 && t % s == 0 && t / s > 0) {
				cout << i << " " << j << " " << t / s << endl;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define rall(v)     (v).rbegin(),(v).rend()
#define gcd(a,b)    __gcd((a),(b))
#define fill(a,value) memset(a,value,sizeof(a));
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
#define sum(v)+x    accumulate(v.begin(), v.end(),x);
typedef pair<int,int> pii;  
typedef vector<int> vi;
signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int a,b;
    cin>>a>>b;
    print(max(0ll,a-2*b))
    
    
    
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<int64_t> ACC(N + 1, 0);
  for (int i = 0; i < N; i++) {
    ACC[i + 1] = ACC[i] + A[i];
  }
  vector<int64_t> B;
  for (int i = 0; i < N + 1; i++) {
    for (int j = i + 1; j < N + 1; j++) {
      B.emplace_back(ACC[j] - ACC[i]);
    }
  }
  vector<int64_t> sets;
  for (int64_t bit = 60; bit > -1; bit--) {
    vector<int64_t> cands;
    if (sets.empty()) {
      for (int64_t b : B) {
        if ((b >> bit) & 1) cands.emplace_back(b);
      }
    } else {
      for (int64_t b : sets) {
        if ((b >> bit) & 1) cands.emplace_back(b);
      }
    }
    if ((int)cands.size() >= K) sets = cands;
  }
  if (sets.empty()) {
    cout << 0 << '\n';
  } else {
    int64_t res = sets[0];
    for (int64_t b : sets) {
      res &= b;
    }
    cout << res << '\n';
  }
  return 0;
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int k, x;
    cin >> k >> x;
    if (500 * k >= x)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

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

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
            int n,k=0,a[108];
            cin>>n;
            REP(i,1,n){
                cin>>a[i];
                if(i%2!=0&&a[i]%2!=0) k++;
            }  
            cout<<k;
       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


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

int main(){
    int N, Y;
    cin >> N >> Y;
    int a = 0;
    int b = 0;

    for(int i = 0; i <= Y/10000; i++){
        for(int l = 0; l <= N-i; l++){
            if(10000*i+5000*l+1000*(N-i-l) == Y){
                a = i;
                b = l;
            }
        }
    }

    if(a == 0 && b == 0 && 1000*(N-a-b) != Y){
        cout << -1 << " " << -1 << " " << -1 << endl;
    }
    else{
        cout << a << " " << b << " " << N-a-b << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner scn = new Scanner(System.in);
      	int x = scn.nextInt();
      	int y = scn.nextInt();
      	if(y % 2 == 1){
          System.out.println("No");
          return;
        }
      	if(x*2>y){
          System.out.println("No");
          return;
        }
        if(x*4<y){
          System.out.println("No");
          return;
        }
      	System.out.println("Yes");
	}
}



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

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

int main()
{
    string s;
    int k = 0, u = 0, p = 0, c = 0;

    cin >> s;

    for( int i = 0; i < s.size(); i++ )
    {
        if( s[i] == 'K' )
            k++;
        else if( s[i] == 'U' )
            u++;
        else if( s[i] == 'P' )
            p++;
        else if( s[i] == 'C' )
            c++;
        else;
    }

    cout << min( min( k, u ), min( p, c ) ) << endl;
    return 0;
}


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

int p(int x, int y){
    int ret = 1;
    while(y-- > 0)  ret *= x;
    return ret;
}

int main(){
    int n;
    while(cin >> n){
        int ret = 0;
        if(n%2){
            ret = 2*p(3,n/2+1-1) - 1;
        }else{
            ret = p(3,n/2) - 1;
        }
        cout << ret << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <algorithm>
#include <cstdio>

static const size_t n_max = 100000;
static int S[n_max];

int main() {
  size_t n, q;
  scanf("%zu", &n);
  for (size_t i = 0; i < n; i++)
    scanf("%d", S + i);
  scanf("%zu", &q);
  int c = 0;
  for (size_t i = 0; i < q; i++) {
    int t;
    scanf("%d", &t);
    if (std::binary_search(S, S + n, t))
      c++;
  }
  printf("%d\n", c);
  return 0;
}

Measured memory_bytes: 2948
N=int(input().strip())
t=[]
x=[]
y=[]
for i in range(N):
    tm, xm, ym=map(int,input().strip().split(' '))
    t.append(tm)
    x.append(xm)
    y.append(ym)
tn=0
xn=0
yn=0
fl=True
for i in range(N):
    tn=t[i]-tn
    xn=x[i]-xn
    yn=y[i]-yn
    #print(tn,xn,yn)
    if tn<abs(xn)+abs(yn) or tn%2!=(xn+yn)%2:
        fl=False
        break
if fl:
    print('Yes')
else:
    print('No')

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll sum = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
    }
    for (int i = 0; i < n; i++) {
        sum -= a[i];
        ans += (a[i] * (sum % MOD)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4652
#include <iostream>

void printRectangle(int H, int W) {
	//print first line
	for (int j = 0; j < W; j++) {
		std::cout << "#";
	}
	std::cout << "\n";

	//print middle
	for (int i = 0; i < H-2; i++) {
		std::cout << "#";
		for (int j = 0; j < W-2; j++) {
			std::cout << ".";
		}
		std::cout << "#\n";
	}

	//print bottom line
	for (int j = 0; j < W; j++) {
		std::cout << "#";
	}
	std::cout << "\n\n";
}

int main()
{
	int H, W;
	std::cin >> H >> W;

	while (H != 0 || W != 0) {
		printRectangle(H, W);
		std::cin >> H >> W;
	}

	return 0;
}




Measured memory_bytes: 3108
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAX_N = 2000;
const int MAX_C = 1000000000;

int W, H, N;
ll X1[MAX_N], X2[MAX_N], Y1[MAX_N], Y2[MAX_N];

int G[MAX_N*4+1][MAX_N*4+1];

vector<ll> compress(ll *c1, ll *c2){
    vector<ll> xs;
    rep(i,N){
        for(int d = 0; d <= 1; d++){
            int tx1 = c1[i] + d;
            int tx2 = c2[i] + d;
            xs.push_back(tx1);
            xs.push_back(tx2);
        }
    }
    xs.push_back(MAX_C+1);
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    rep(i,N){
        c1[i] = find(xs.begin(), xs.end(), c1[i]) - xs.begin();
        c2[i] = find(xs.begin(), xs.end(), c2[i]) - xs.begin();
    }
    return xs;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    cin >> N;
    rep(i,N){
        cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
        assert(X1[i] < X2[i]);
        assert(Y1[i] < Y2[i]);
    }
    vector<ll> X = compress(X1, X2);
    vector<ll> Y = compress(Y1, Y2);
    memset(G, 0, sizeof(G));
    rep(i,N){
        G[Y1[i]][X1[i]]++;
        G[Y2[i]][X2[i]]++;
        G[Y1[i]][X2[i]]--;
        G[Y2[i]][X1[i]]--;
    }
    for(int y = 0; y < Y.size()-1; y++){
        for(int x = 1; x < X.size()-1; x++){
            G[y][x] += G[y][x-1];
        }
    }
    for(int x = 0; x < X.size()-1; x++){
        for(int y = 1; y < Y.size()-1; y++){
            G[y][x] += G[y-1][x];
        }
    }
    ll ans = 0;
    rep(y,Y.size()-1){
        rep(x,X.size()-1){
            if(G[y][x]) ans += (X[x+1]-X[x])*(Y[y+1]-Y[y]);
        }
    }
    cout << ans << endl;
	return 0;
}


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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  string s;
  if(A == B && A != C && B != C)s = "Yes";
  else if(A == C && A != B && C != B)s = "Yes";
  else if(B == C && B != A && C != A)s = "Yes";
  else s = "No";
  cout << s << endl;
}

Measured memory_bytes: 256
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 read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
  (0..n).map(|_| read_vec()).collect()
}

pub trait LexicalPermutation {
  /// Return `true` if the slice was permuted, `false` if it is already
  /// at the last ordered permutation.
  fn next_permutation(&mut self) -> bool;
}

impl<T> LexicalPermutation for [T] where T: Ord {
  /// Original author in Rust: Thomas Backman <serenity@exscape.org>
  fn next_permutation(&mut self) -> bool {
    // These cases only have 1 permutation each, so we can't do anything.
    if self.len() < 2 { return false; }

    // Step 1: Identify the longest, rightmost weakly decreasing part of the vector
    let mut i = self.len() - 1;
    while i > 0 && self[i-1] >= self[i] {
      i -= 1;
    }

    // If that is the entire vector, this is the last-ordered permutation.
    if i == 0 {
      return false;
    }

    // Step 2: Find the rightmost element larger than the pivot (i-1)
    let mut j = self.len() - 1;
    while j >= i && self[j] <= self[i-1]  {
      j -= 1;
    }

    // Step 3: Swap that element with the pivot
    self.swap(j, i-1);

    // Step 4: Reverse the (previously) weakly decreasing part
    self[i..].reverse();

    true
  }
}

fn main() {
  let n: usize = read();
  let mut xy: Vec<(isize, isize)> = Vec::new();
  for _ in 0..n {
    let tmp: Vec<isize> = read_vec();
    xy.push((tmp[0], tmp[1]));
  }
  let mut dist: f64 = 0.0;

  let mut permutations: Vec<usize> = (0..n).map(|i| i+1).collect();
  let n_factory = factorial(n);
  loop {
    for i in 0..n-1 {
      dist += distance(xy[permutations[i]-1], xy[permutations[i+1]-1]);
    }
    if !permutations.next_permutation() { break; }
  }
  println!("{}", dist/(n_factory as f64));
}

fn distance((x1, y1): (isize, isize), (x2, y2): (isize, isize)) -> f64 {
  let x_dis = std::cmp::max(x1, x2) - std::cmp::min(x1, x2);
  let y_dis = std::cmp::max(y1, y2) - std::cmp::min(y1, y2);
  ((x_dis as f64).powf(2.0) + (y_dis as f64).powf(2.0)).sqrt()
}

fn factorial(n: usize) -> usize {
  if n == 0 {
    1
  } else {
    n * factorial(n-1)
  }
}

Measured memory_bytes: 4352
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()

typedef long long LL;
typedef long double LD;

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

    sort(all(L));

    sum = 0;
    for (int i = 0; i < N-1; i++)
        sum += L[i];

    if (L[N-1] < sum) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int dp[10005][20005];
int A[10005];
int B[10005];
int main() {
  ios::sync_with_stdio(false);
  int H, N;
  cin >> H >> N;
  for (int i=0; i<N; i++) {
    cin >> A[i] >> B[i];
  }
  int INF = 1 << 28;
  for (int i=0; i<=N; i++) {
    for (int j=1; j<=H; j++) {
      dp[i][j] = INF;
    }
  }
  for (int i=0; i<N; i++) {
    for (int j=0; j<=H; j++) {
      dp[i+1][j] = min(dp[i][j], dp[i+1][j]);
      dp[i+1][j] = min(dp[i+1][j], dp[i+1][max(0,j-A[i])] + B[i]);
    }
  }
  cout << dp[N][H] << endl;
}

Measured memory_bytes: 79232
n = int(input())
info = []
t1 = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
t2 = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
t3 = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
t4 = [[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]]
for i in range(n):
  info.append(list(input().split()))
  info[i] = [int(n) for n in info[i]]

for j in range(len(info)):
  if info[j][0] == 1:
    if info[j][1] == 1:
      t1[0][info[j][2]-1] += info[j][3]
    if info[j][1] == 2:
      t1[1][info[j][2]-1] += info[j][3]
    if info[j][1] == 3:
      t1[2][info[j][2]-1] += info[j][3]
  if info[j][0] == 2:
    if info[j][1] == 1:
      t2[0][info[j][2]-1] += info[j][3]
    if info[j][1] == 2:
      t2[1][info[j][2]-1] += info[j][3]
    if info[j][1] == 3:
      t2[2][info[j][2]-1] += info[j][3]
  if info[j][0] == 3:
    if info[j][1] == 1:
      t3[0][info[j][2]-1] += info[j][3]
    if info[j][1] == 2:
      t3[1][info[j][2]-1] += info[j][3]
    if info[j][1] == 3:
      t3[2][info[j][2]-1] += info[j][3]
  if info[j][0] == 4:
    if info[j][1] == 1:
      t4[0][info[j][2]-1] += info[j][3]
    if info[j][1] == 2:
      t4[1][info[j][2]-1] += info[j][3]
    if info[j][1] == 3:
      t4[2][info[j][2]-1] += info[j][3]
  
for k in range(0,3):
  [print(" %d"%i, end="")for i in t1[k]]
  print()
print("####################")
for k in range(0,3):
  [print(" %d"%i, end="")for i in t2[k]]
  print()
print("####################")
for k in range(0,3):
  [print(" %d"%i, end="")for i in t3[k]]
  print()
print("####################")
for k in range(0,3):
  [print(" %d"%i, end="")for i in t4[k]]
  print()


Measured memory_bytes: 5752
#include<stdio.h>
int main(void)
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if((x+r)<=W && (y+r)<=H && 0<=(x-r) && 0<=(y-r)){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x,y;
    x = a+b;
    y=c+d;
    if(x>y){
         cout<<"Left"<<endl;
    }
    else if(x<y){
         cout<<"Right"<<endl;
    }
    else{
        cout<<"Balanced"<<endl;
    }
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    
    vector<int> takoyaki(n);
    
    for (int i = 0; i < n; i++) {
        cin >> takoyaki.at(i);
    }
    
    int sum = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            sum += takoyaki.at(i) * takoyaki.at(j);
        }
    }
    
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;
const int MOD = 1'000'000'007;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

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

// const int MAX = 1010;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    ll maxi = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    maxi = a[a.size() - 1];
    ll half = maxi / 2;
    ll r = 0;
    for (int i = 0; i < n; i++)
    {
        if (abs(maxi - a[i] * 2) < abs(maxi - r * 2))
        {
            r = a[i];
        }
    }
    cout << maxi << ' ' << r << endl;
    return 0;
}

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

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

    int n;
    cin >> n;
    vector<int> arr(n);
    for (int &x : arr) {
        cin >> x;
    }
    vector<int> suf(n+1);
    for (int i = n-1; i >= 0; --i) {
        suf[i] = __gcd(suf[i+1], arr[i]);
    }
    int pre = 0, ans = 0;
    for (int i = 0; i < n; ++i) {
        int curr = __gcd(pre, suf[i+1]);
        ans = max(ans, curr);
        pre = __gcd(pre, arr[i]);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 100000

int A[MAX],n;
int partition(int p,int r){
    int x,i,j,t;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++){
        if(A[j]<=x){
            i++;
            t=A[i];
            A[i]=A[j];
            A[j]=t;
        }
    }
    t=A[i+1];
    A[i+1]=A[r];
    A[r]=t;
    return i+1;
}

int main(){
    int i,q;

    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    q=partition(0,n-1);

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

    printf("\n");
    return 0;
}


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

#define mp make_pair
#define pb push_back

using namespace std;

typedef long long ll;

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

vector <char> v;

int main()
{
    ios_base::sync_with_stdio(false);
    string s;
    int ans=0 , t=1;
    cin>>s;
    if(s[0]==s[s.length()-1])
    {
        if(!(s.length()%2))
            cout<<"First";
        else
            cout<<"Second";
    }
    else
    {
        if((s.length()%2))
            cout<<"First";
        else
            cout<<"Second";
    }
    return 0;
}


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

int main() {
  int c1;
  while( cin >> c1 ) {
    int c2, c3;
    int counter = 0;
    cin >> c2 >> c3;
    for( int i = 1; i <= 10; i++ ) {
      if( i == c1 || i == c2 || i == c3 ) { continue; }
      if( c1 + c2 + i <= 20 ) { counter++; }
    }
    cout<< ( counter * 100 / 7 >= 50 ? "YES" : "NO" ) << endl;
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
ll a[1005][1005];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll N,M,i,j;
    memset(a,0,sizeof a);
    cin>>N>>M;
    string s1[N]; cin.ignore();
    for(i=0;i<N;i++)
    { cin>>s1[i]; }
    for(i=0;i<N;i++)
    {
        for(j=0;j<M;j++)
        {
            if(i==0&&j==0) 
            { if(s1[i][j]=='.') a[i][j]=1; else a[i][j]=0;}
            else if(i==0) 
            { if(s1[i][j]=='.') a[i][j]=a[i][j-1]; else a[i][j]=0;}
            else if(j==0) 
            { if(s1[i][j]=='.') a[i][j]=a[i-1][j]; else a[i][j]=0;}
            else 
            { 
                if(s1[i][j]=='.') a[i][j]=(a[i-1][j]+a[i][j-1])%mod;
                else a[i][j]=0;
            }
        }
    }
    cout<<a[N-1][M-1]%mod<<endl;
    return 0;
}

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

using namespace std;

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

    int A, B;
    cin >> A >> B;
    
    if ((A - B) % 2 == 0) {
        cout << abs(A - (A - B) / 2) << "\n";
    } else {
        cout << "IMPOSSIBLE\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a,b,c,d,e,f,g;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	e=a+b+c+d;
	f=e/60;
	g=e%60;
	printf("%d\n%d\n",f,g);
	return 0;
}

Measured memory_bytes: 596
#!/usr/bin/env python3
import sys
import copy


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    H, W, K = MI()
    cells = []
    ans = 0
    for i in range(H):
        row = input()
        rows = []
        for item in range(len(row)):
            if row[item] == ".":
                rows.append(0)
            else:
                rows.append(1)
        cells.append(rows)

    for i in range(2**H):
        for j in range(2**W):
            iBi = format(i, '0'+str(H)+'b')
            jBi = format(j, '0'+str(W)+'b')

            tmp_cell = copy.deepcopy(cells)

            for ii in range(H):
                for jj in range(W):
                    if str(iBi)[ii] == '1' or str(jBi)[jj] == '1':

                        tmp_cell[ii][jj] = 0
            if sum(map(sum, tmp_cell)) == K:
                ans += 1

    print(ans)

    # oj t -c "pypy3 main.py"
    # acc s main.py -- --guess-python-interpreter pypy


main()


Measured memory_bytes: 78096
import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
X = []
for _ in range(N):
    x, y = map(int, input().split())
    X.append((x * 2, y * 2))
X = sorted(X, key = lambda x: -x[1])
x0, y0 = X[0]
ans = 0
for x, y in X[1:]:
    ans = max(ans, y0 - y + abs(x - x0))
    a = (abs(x - x0) - (y0 - y)) // 2
    if a < 0: continue
    x0 += a if x0 < x else -a
    y0 += a
print(ans // 2)

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

  reverse(all(s));
  rep(i,4) reverse(all(divide[i]));
  bool can = true;
  for(int i=0;i<s.size();){
      bool can2 = false;
      for(int j=0;j<4;++j){
          string di = divide[j];
          if(s.substr(i,di.size()) == di){
              can2 = true;
              i+=di.size();
          }
      }
      if(!can2) {
          can = false;
          break;
      }
  }
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, k;
	cin >> num >> k;
	vector<int> d(num + k, INF), dp(num + k, INF);
	rep(i, num)
		cin >> d[i];
	dp[0] = 0;
	rep(i, num - 1) {
		for(int j = 1; j <= k; j++)
			chmin(dp[i + j], dp[i] + abs(d[i] - d[i + j]));
	}
	cout << dp[num - 1] << "\n";
	return 0;
}

Measured memory_bytes: 4024