akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long

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

    memcpy(b, a, sizeof(a));
  	
  	sort(b, b + N, greater<>());
  	int max_value = b[0];
  	int second_value = b[1];
  
  	if (max_value == second_value) {
      	for ( int i = 0 ; i < N ; i++ ) {
      		cout << max_value << "\n";
    	}  
    } else {
      	for ( int i = 0 ; i < N ; i++ ) {
          	if ( a[i] != max_value ) {
              	cout << max_value << "\n";
            } else {
              	cout << second_value << "\n";
            }
    	}  
    }

    return 0;
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int deck[60];
int tmpdeck[60];

int main(){ _;
  int n,r,p,c;
  while(cin>>n>>r,!(n==0&&r==0)){
    REP(i,n) deck[i]=n-i;
    REP(i,r){
      cin>>p>>c;
      p--;
      copy(deck+p,deck+p+c,tmpdeck);
      copy(deck,deck+p,tmpdeck+c);
      copy(tmpdeck,tmpdeck+p+c,deck);
    }
    cout<<deck[0]<<endl;
  }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
inline void write(int x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}
char s[105];
int main()
{
	cin>>s;
	int len=strlen(s);
	cout<<s[0]<<len-2<<s[len-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

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

    ll arr[]  ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll k;
    cin >> k;
    cout << arr[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	
	int X;
	cin >> X;
	
	vector<int> a;
	a.push_back(1);
	int limit = sqrt(1000);
	for( int i = 2; i <= limit; ++i ){
		int j = 2;
		while( pow(i, j) <= 1000 ){
			a.push_back(pow(i, j));
			j++;
		}
	}
	
	sort(a.begin(), a.end());
	
	int ans = 0;
	
	for( int i = a.l_ength()-1; 0 <= i; --i ){
		if( a[i] <= X ){
			ans = a[i];
			break;
		}
	}
	
	cout << ans << endl;
	
	return 0;
	
}

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

const long long INF = 1LL << 60;

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

INT a[100001],h[100001];


int main() {
	int n,i=0;

	cin >> n;

    rep(j, n) {
        cin >> h[j];
        a[j] = INF;
    }
    a[0] = 0;

    for (int i = 1; i < n; i++) {
        chmin(a[i], a[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1)chmin(a[i], a[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << a[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <map>
#include <vector>

using namespace std;


int main(){
    int N;
    cin >> N;
    vector <string> word;

    map <string, int> m;
    for (int i = 0; i < N; i++){
        string S;
        cin >> S;

        if (m[S] == 0){
            word.push_back(S);
        }
        m[S] ++;
    }

    int M;
    cin >> M;

    for (int i = 0; i < M; i++){
        string T;
        cin >> T;
        m[T] --;
    }
    
    int ans = 0;
    for (int i = 0; i < word.size(); i++){
        if (m[word[i]] > ans){
            ans = m[word[i]];
        }
    }
    
    cout << ans << endl;

    return 0;
}

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


dp = [0 for i in range(f//100+1)]
dp[0] = 1
for i in range(f//100+1):
    if dp[i]:
        if i + a <= f//100:
            dp[i+a] = 1
        if i + b <= f//100:
            dp[i+b] = 1
dd = [0 for i in range(f+1)]
dd[0] = 1
for i in range(f+1):
    if dd[i]:
        if i + c <= f:
            dd[i+c] = 1
        if i + d <= f:
            dd[i+d] = 1

water = [i for i in range(1,f//100+1) if dp[i]]
sugar = [i for i in range(f+1) if dd[i]]
ans = -1
ww, ss= 0,0
for w in water:
    for s in sugar:
        if w*100+s <= f and e*w >= s:
            if ans < 100 * s / (100*w+s):
                ans = 100*s / (w*100+s)
                ww,ss=w*100,s

print(ww+ss,ss)


Measured memory_bytes: 39920
MODC = 998244353

n,s = gets.strip.split.map(&:to_i)
a = gets.strip.split.map(&:to_i)

dp = Array.new(s+1,0)
dp[0] = 1
a.each do |e|
  s.downto(0) do |i|
    if i >= e
      dp[i] += dp[i]+dp[i-e]
    else
      dp[i] += dp[i]
    end
    dp[i] %= MODC
  end
end
p dp[s]

Measured memory_bytes: 14300
#include <iostream>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void Dijkstra(Graph& G, ll s, Array& d, Array& u, ll l) {//O(|E|log|V|)
	d.resize(G.size());
	u.resize(G.size());
	REP(i, d.size())d[i] = INF;
	REP(i, u.size())u[i] = INF;
	d[s] = 0;
	u[s] = 0;
	vector<ll> q(G.size());
	REP(i, G.size()) q.push_back(i);
	while (q.size()>0) {
		ll uu = INF;
		ll dd = INF;
		ll v = -1;
		ll k = -1;
		REP(i,q.size()) {
			if (uu > u[q[i]] || (uu == u[q[i]] && dd > d[q[i]])) {
				v = q[i];
				uu = u[q[i]];
				dd = d[q[i]];
				k = i;
			}
		}
		if (k == -1) break;
		q.erase(q.begin()+k);

		for (auto e : G[v]) {
			ll nu = uu;
			ll nd = dd+e.cap;
			if (nd > l) {
				nd = e.cap;
				nu++;
			}
			if (u[e.to] > nu || (u[e.to] == nu && d[e.to] > nd)) {
				u[e.to] = nu;
				d[e.to] = nd;
			}
		}
	}
}

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

	ll n, m, l;
	cin >> n >> m >> l;
	Graph g(n);
	REP(i, m) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		if (c <= l) add_edge(g, a, b, c, true, c);
	}

	Matrix ans(n);
	Matrix d(n);

	REP(i, n) {
		Dijkstra(g, i, d[i], ans[i], l);
	}
	/*
	for (auto i : ans) {
		for (auto j : i) {
			cout << j << " ";
		}
		cout << endl;
	}
	*/

	ll q;
	cin >> q;

	REP(i, q) {
		ll s, t;
		cin >> s >> t;
		s--; t--;
		if (ans[s][t] != INF) {
			cout << ans[s][t] << endl;
		}
		else {
			cout << -1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0,ans=0;
bool graph[8][8];

 int main(){
     ll k;  cin >> k;

     for(int i=1;i<=k;i++){
         ans+=( (i+(k/i)*i)*(k/i) )/2;
     }
     cout << ans << endl;
    }

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int A,B,cnt=0;
    cin>>A>>B;
    string S;
    char C[]={'0','1','2','3','4','5','6','7','8','9'};
    cin>>S;
    if(S.size()!=A+B+1){cout<<"No"<<endl;return 0;}
    for(int i=0;i<A+B+1;i++){
        cnt=0;
        if(i==A){
            if(S[i]!='-'){cout<<"No"<<endl;return 0;}
        }
        else{
        for(int j=0;j<10;j++){
            if(S[i]==C[j]){
                cnt+=1;
            }
        
        }
        if(cnt==0){cout<<"No"<<endl;return 0;}
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
/**
*    created: 04.07.2020 20:45:53
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    string s;
    cin >> s;
    if (s[0] == '9' || s[1] == '9') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second
#define pb push_back

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N;cin>>N;
  double tax=1.08;
  int X=ceil(N/tax);
  // print(X*tax);
  if(floor(X*tax)==N){
    print(X);
  }
  else{
    print(":(");
  }
  

}


Measured memory_bytes: 256
m,d = map(int,raw_input().split())
c = 0
for i in xrange(1,m+1):
	for j in xrange(1,d+1):
		if j >= 20 and j%10 >= 2:
			if (j/10) * (j%10) == i:
				c += 1
				#print i,j
print c

Measured memory_bytes: 2568
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0){
		return a;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1) * a % MOD;
	}
}

int main(void){
	string s;
	cin>>s;
	rep(i,3){
		if(s[i] == s[i+1]){
			cout<<"Bad"<<endl;
			return 0;
		}
	}
	cout<<"Good"<<endl;
	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a;
    cin >> a;
    int s = a % 60; a /= 60;
    int m = a % 60; a /= 60;
    int h = a % 60; a /= 60;
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3100
n = gets.to_i
array = gets.chomp.split(' ').map(&:to_i)
puts array.join(' ')
for i in 1..(n-1) do
  v = array[i]
  j = i - 1
  while j >= 0 && array[j] > v
    array[j+1] = array[j]
    j -= 1
    array[j+1] = v
  end
  puts array.join(' ')
end

Measured memory_bytes: 8672
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

//------------------------------------------------------
#define int ll

class UnionFind {
private:
    vector<ll> par, sizes;

public:

    UnionFind(ll n) : par(n), sizes(n, 1) {
        rep(i, n) par[i] = i;
    }

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

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

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

    ll size(int x) {
        return sizes[root(x)];
    }
};

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

    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    vector<pii> bridge;
    vector<ll> ans;

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        bridge.push_back(MP(a, b));
    }

    reverse(all(bridge));
    ll unconvenience = n * (n - 1) / 2;

    rep(bi, m) {
        ans.push_back(unconvenience);
        int a = bridge[bi].first, b = bridge[bi].second;
        if (!uf.same(a, b)) unconvenience -= uf.size(a) * uf.size(b);
        uf.unite(a, b);
    }
    reverse(all(ans));
    for (auto a : ans) cout << a << endl;
    return 0;
}

Measured memory_bytes: 4596
import java.util.Scanner;
import java.util.Stack;

public class Main {
    static int WHITE = 0;
    static int GRAY = 1;
    static int BLACK = 2;
    static int[] color;
    static int[] d;
    static int[] f;
    static int time;
    static int n;
    static int[][] m;
    static int[] nt; // 当前u访问过的最大的节点编号

    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        n = input.nextInt();
        m = new int[n][n];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++) {
                m[i][j] = 0;
            }
        }
        for(int i = 0; i < n; i++) {
            int v = input.nextInt();
            int in = input.nextInt();
            for(int j = 0; j < in; j++) {
                int u = input.nextInt();
                m[v-1][u-1] = 1;
            }
        }
        dfs();

        for(int i = 0; i < n; i++) {
            System.out.println(i+1 + " " + d[i] + " " + f[i]);
        }

    }
    static void dfs() {
        // 初始化
        color = new int[n];
        d = new int[n];
        f = new int[n];
        for(int i = 0; i < n; i++) {
            color[i] = WHITE;
        }
        time = 0;
        for(int u = 0; u < n; u++) {
            if(color[u] == WHITE) {
                dfs_visit(u);
            }
        }
    }

    // 递归实现
//    static void dfs_visit(int u) {
//        color[u] = GRAY;
//        d[u] = ++time;
//        for(int v = 0; v < n; v++){
//            if(m[u][v] == 0) continue;
//            if(color[v] == WHITE) {
//                dfs_visit(v);
//            }
//        }
//        color[u] = BLACK;
//        f[u] = ++time;
//    }

    // 栈实现
    static void dfs_visit(int r) {
        nt = new int[n];
        for (int i = 0; i < n; i++) {
            nt[i] = 0;
        }

        Stack<Integer> S = new Stack<>();
        S.push(r);
        color[r] = GRAY;
        d[r] = ++time;

        while(!S.isEmpty()) {
            int u = S.peek();
            int v = next(u);
            if(v != -1) {
                if(color[v] == WHITE) {
                    color[v] = GRAY;
                    d[v] = ++time;
                    S.push(v);
                }
            } else {
                S.pop();
                color[u] = BLACK;
                f[u] = ++time;
            }
        }
    }

    // 按编号顺序获取与u相邻的v
    static int next(int u) {
        for(int v = nt[u]; v < n; v++) {
            nt[u] = v + 1;
            if(m[u][v] == 1) return v;
        }
        return -1;
    }
}



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

int arr[35];

int main(){
	#ifdef LOCAL_DEFINE
		freopen("../a.in","r",stdin);
		freopen("../a.out", "w",stdout);
	#endif

	int n,m;
	cin >> n >> m;
	for(int i=0;i<n;i++){
		int t;
		cin >> t;
		while(t--){
			int x;
			cin >> x;
			arr[x]++;
		}
	}
	int ans  = 0;
	for(int i=0;i<=m;i++){
		if(arr[i]==n){
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<long long> A(N), B(N);
  for (int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
  }
  long long S = 0;
  for (int i = N - 1; i >= 0; i--){
    int r = (A[i] + S) % B[i];
    if (r != 0){
      S += B[i] - r;
    }
  }
  cout << S << endl;
}

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

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

  int ans = 0;
  for (auto c : S) {
    if (c == '+') {
      ans++;
    } else if (c == '-') {
      ans--;
    }
  }

  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	long long ans = 0;
	int mn = v[0];
	for (int i = 1; i < n ; i++) {
		ans += max(0, v[i-1] - v[i]);
		v[i] += max(0, v[i - 1] - v[i]);
	}
	cout << ans;
}


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

int main(){
    while(1){
        int m,f,r;
        cin >> m >> f >> r;
        if(m==-1 && f==-1 && r==-1) break;
        if(m==-1 || f==-1 || m+f<30){
            cout << "F" << endl;
        }else if(m+f<50){
            if(r<50){
                cout << "D" << endl;
            }else{
                cout << "C" << endl;
            }
        }else if(m+f<65){
            cout << "C" << endl;
        }else if(m+f<80){
            cout << "B" << endl;
        }else{
            cout << "A" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#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 all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

ll N;
cin >> N;
ll ans = N-1;
for( ll i = 1 ; i*i <= N ; i++) {
    if(N % i == 0) {
        ans = min(ans, i + (N / i) - 2);
    }
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
// ---------- begin karatsuba multiplication ----------
fn karatsuba<T>(a: &[T], b: &[T], c: &mut [T], zero: T, buf: &mut [T]) 
where T: std::marker::Copy +
         std::ops::Add<Output = T> +
         std::ops::Sub<Output = T> +
         std::ops::Mul<Output = T> +
{
    let n = a.len();
    if n <= 32 {
        for (i, a) in a.iter().enumerate() {
            for (c, b) in c[i..].iter_mut().zip(b.iter()) {
                *c = *c + *a * *b;
            }
        }
        return;
    }
    if n & 1 == 1 {
        karatsuba(&a[1..], &b[1..], &mut c[2..], zero, buf);
        let x = a[0];
        let y = b[0];
        c[0] = c[0] + x * y;
        for (c, (a, b)) in c[1..].iter_mut().zip(a[1..].iter().zip(b[1..].iter())) {
            *c = *c + x * *b + *a * y;
        }
        return;
    }
    let m = n / 2;
    karatsuba(&a[..m], &b[..m], &mut c[..n], zero, buf);
    karatsuba(&a[m..], &b[m..], &mut c[n..], zero, buf);
    let (x, y) = buf.split_at_mut(m);
    let (y, z) = y.split_at_mut(m);
    let (z, buf) = z.split_at_mut(n);
    for z in z.iter_mut() {
        *z = zero;
    }
    for (x, (p, q)) in x.iter_mut().zip(a.iter().zip(a[m..].iter())) {
        *x = *p + *q;
    }
    for (y, (p, q)) in y.iter_mut().zip(b.iter().zip(b[m..].iter())) {
        *y = *p + *q;
    }
    karatsuba(x, y, z, zero, buf);
    for (z, (p, q)) in z.iter_mut().zip(c[..n].iter().zip(c[n..].iter())) {
        *z = *z - (*p + *q);
    }
    for (c, z) in c[m..].iter_mut().zip(z.iter()) {
        *c = *c + *z;
    }
}

fn multiply<T>(a: &[T], b: &[T], zero: T) -> Vec<T>
where T: std::marker::Copy +
         std::ops::Add<Output = T> +
         std::ops::Sub<Output = T> +
         std::ops::Mul<Output = T> +
{
    let mut i = 0;
    let mut j = 0;
    let mut ans = vec![zero; a.len() + b.len()];
    let mut buf = vec![zero; 4 * (a.len() + b.len())];
    let mut c = Vec::with_capacity(a.len() + b.len());
    while i < a.len() && j < b.len() {
        let x = a.len() - i;
        let y = b.len() - j;
        let z = std::cmp::min(x, y);
        c.clear();
        c.resize(2 * z, zero);
        karatsuba(&a[i..(i + z)], &b[j..(j + z)], &mut c, zero, &mut buf);
        for (ans, c) in ans[(i + j)..].iter_mut().zip(c.iter()) {
            *ans = *ans + *c;
        }
        if x <= y {
            j += x;
        } else {
            i += y;
        }
    }
    ans.truncate(a.len() + b.len() - 1);
    ans
}
// ---------- end karatsuba multiplication ----------

use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    it.next(); // eat n
    let mut m: usize = it.next().unwrap().parse().unwrap();
    let len = 100_000;
    let mut a = vec![0usize; len + 1];
    for s in it {
        let x: usize = s.parse().unwrap();
        a[x] += 1;
    }
    let cnt = multiply(&a, &a, 0);
    let mut ans = 0;
    for (i, c) in cnt.iter().enumerate().rev() {
        let v = std::cmp::min(m, *c);
        ans += v * i;
        m -= v;
    }
    println!("{}", ans);
}

fn main() {
    run();
}


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


void solve(long long N, long long M, long long V, long long P, std::vector<long long> A){
    sort(A.begin(), A.end());
     auto check = [&](int i){
        if(N-P < i){
            return true;
        }
        ll m = A[i] + M;
        if(m < A[N-P]){
            return false;
        }
        ll sum = 0;
        for(int j = 0;j < N;j++){
            if(j == i){
                continue;
            }
            if(N - P < j){
                sum += M;
            }else{
                sum += max(min(M, m - A[j]),0LL);
            }
        }
        return sum >= (V-1) * M;
    };
    int ng = 0;
    int ok = N;
    if(check(0)){
        cout<<N<<endl;
        return;
    }
    while(ok - ng > 1){
        int mid = (ok + ng)/2;
        if(check(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout<<N-ok<<endl; 
    return;
}

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


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

int main()
{
    long long N, M, A, B;
    cin >> N >> M;
    vector<long long> H(N, 0), R(N, 1);
    for (long long i = 0; i < N; i++)
        cin >> H[i];
    while (M--)
    {
        cin >> A >> B;
        A -= 1;
        B -= 1;

        if (H[A] > H[B]) R[B] = 0;
        else if (H[A] < H[B]) R[A] = 0;
        else 
        {
            R[A] = R[B] = 0;
        }
    }
    long long sum = 0;
    for (long long i = 0 ; i < R.size(); i++)
    {
        if (R[i] == 1) sum += 1;
    }
    cout << sum << endl;


}

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

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

	int n = s.size();
	int ans = 0;

	if (n % 2 == 0) {
		for (int i = 0; i < n / 2; i++) {
			if (s[i] != s[n - i - 1]) ans++;
		}
	}
	else {
		for (int i = 0; i < n / 2; i++) {
			if (s[i] != s[n - i - 1]) ans++;
		}
	}

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

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

int main(){

    int a,b,c;
    cin >> a>>b>>c;

    if(a+b>=c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

int main()
{
    int n; cin >> n;
    vector<double> v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());
    double ans = 0;
    rep(i, n)
    {
        if(i == 0)
        {
            ans = v[0];
        }
        else
        {
            ans = (ans + v[i]) / 2;
        }
    }
    cout << std::fixed << std::setprecision(15) << ans << endl;
    return 0;    
}

Measured memory_bytes: 3840
H,N = map(int,input().split())
M=[list(map(int,input().split())) for _ in range(N)]
M = sorted(M,reverse=True)

DP=[float('inf')]*(H+1)
DP[0]=0
for i in range(H):
    for a,b in M:
        DP[min(i+a,H)] = min(DP[min(i+a,H)],DP[i]+b)
print(DP[-1])


Measured memory_bytes: 44124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    ll ans=0;
    for(int i=n-1;i>=0;i--){
        a[i]+=ans;
        if(a[i]%b[i]==0) continue;
        if(a[i]<b[i]) ans+=b[i]-a[i];
        else if(a[i]>b[i]) ans+=b[i]*((a[i]+b[i]-1)/b[i])-a[i];
        //cout<<ans<<endl;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 4844
import sys
from collections import deque

input = sys.stdin.readline


def dfs(G, v, p, counter):
    stack = deque([(v, p)])
    while stack:
        v, p = stack.pop()
        for c in G[v]:
            if c == p:
                continue
            counter[c] += counter[v]
            stack.append((c, v))


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

    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)

    counter = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        p -= 1
        counter[p] += x

    dfs(G, 0, -1, counter)

    print(*counter)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62196
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class AFallingAsleep {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        string s[100];
        int t[100];
        string x;
        in >> n;
        rep(i, n){
            in >> s[i] >> t[i];
        }
        in >> x;

        bool flg = false;
        int cnt = 0;
        rep(i, n){
            if(flg){
                cnt += t[i];
                continue;
            }else{
                if(s[i] == x) flg = true;
            }
        }

        out << cnt << endl;
	}
};


int main() {
	AFallingAsleep solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 524288 // 2^19
#define HALFN 262144 // 2^18
#define INFTY 1000000001 // 10^9 + 1

int count = 0, L[HALFN] = {0}, R[HALFN] = {0};

void merge(int *A, int left, int mid, int right) {
  int i, j, k, n1, n2;
  
  n1 = mid - left;
  n2 = right - mid;

  // L[0...n1], R[0...n2] を生成
  for (i = 0; i < n1; i++)
    L[i] = A[left + i];
  for (i = 0; i < n2; i++)
    R[i] = A[mid + i];
  L[n1] = INFTY;
  R[n2] = INFTY;

  for (i = 0, j = 0, k = left; k < right; k++) {
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    }
    else {
      A[k] = R[j];
      j++;
    }
    count++;
  }
}

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);
    merge(A, left, mid, right);
  }
}

int main(void){
  int i, n, S[N] = {0};
  
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &S[i]);

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

  return 0;
}

Measured memory_bytes: 4616
#include<iostream>
#include<string>
#include<stdlib.h>
using namespace  std;
struct NodeB
{
	int key;
	NodeB *left;
	NodeB *right;
};
NodeB *head = NULL;
void insert(int key)
{
	NodeB *next = head;
	NodeB *prev = NULL;
	bool isLeft = true;
	while (next != NULL)
	{
		prev = next;
		if ((*next).key >= key)
		{
			next = (*next).left;
			isLeft = true;
		}
		else if ((*next).key <= key)
		{
			next = (*next).right;
			isLeft = false;
		}
	}
	if (prev == NULL)
	{
		head = (NodeB *)malloc(sizeof(NodeB));
		(*head).key = key;
		(*head).left = NULL;
		(*head).right = NULL;
		return;
	}
	if (isLeft)
	{
		(*prev).left = (NodeB *)malloc(sizeof(NodeB));
		(*(*prev).left).key = key;
		(*(*prev).left).left = NULL;
		(*(*prev).left).right = NULL;
	}
	else
	{
		(*prev).right = (NodeB *)malloc(sizeof(NodeB));
		(*(*prev).right).key = key;
		(*(*prev).right).left = NULL;
		(*(*prev).right).right = NULL;
	}
	
}
void inOrder(NodeB *h)
{
	if (h == NULL)return;
	inOrder((*h).left);
	cout << " " << (*h).key;
	inOrder((*h).right);
}
void preOrder(NodeB *h)
{
	if (h == NULL)return;
	cout << " " << (*h).key;
	preOrder((*h).left);
	preOrder((*h).right);
}
void print()
{
	inOrder(head);
	cout << endl;
	preOrder(head);
	cout << endl;
}
bool find(int key)
{
	NodeB *next = head;
	while (next != NULL)
	{
		if ((*next).key == key)
		{
			return true;
		}
		else if ((*next).key < key)
		{
			next = (*next).right;
		}
		else if ((*next).key > key)
		{
			next = (*next).left;
		}
	}
	return false;
}
int main()
{
	int m;
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		string inst;
		cin >> inst;
		if (inst.compare("insert") == 0)
		{
			int key;
			cin >> key;
			insert(key);
		}
		else if (inst.compare("print") == 0)
		{
			print();
		}
		else if (inst.compare("find") == 0)
		{
			int key;
			cin >> key;
			if (find(key))
			{
				cout << "yes" << endl;
			}
			else
			{
				cout << "no" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 13716
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define int ll

const int md = 1000000007;
const int INF = 1<<30;



signed main(){
    int w,h,x,y;
    cin >> w >> h >> x >> y;

    double ans = (w*h + 0.0)/2;
    printf("%.7f ", ans);

    double mx = (w+0.0) / 2;
    double my = (h+0.0) / 2;

    if(mx == double(x) and my == double(y)) printf("1\n");
    else printf("0\n");

}


Measured memory_bytes: 256
// Watch.cs

using System;

class Watch {

	static int waru1(int n, out int amari) {
		amari = n % 3600;
		return n / 3600;
	}

	static int waru2(int n, out int amari2) {
		amari2 = n % 60;
		return n / 60;
	}

	public static void Main() {

		int n = int.Parse(Console.ReadLine());
		int amari;
		int h = waru1(n, out amari);
		int amari2;
		int m = waru2(amari, out amari2);
		Console.WriteLine(h + ":" + m + ":" + amari2);


	}
}

Measured memory_bytes: 9216
import sys

input = sys.stdin.readline

N, M = map(int, input().split(" "))
m = set()

for _ in range(M):
    a, b = map(int, input().split(" "))
    if a < b:
        m.add((a,b))
    else:
        m.add((b,a))


for i in range(2, N):
    if (1, i) in m and (i, N) in m:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")



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

int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << (H - h) * (W - w);
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
	char s1[11], s2[11], s3[11];
	char dif = 'A' - 'a';
	scanf("%s%s%s", s1, s2, s3);
	printf("%c%c%c\n", s1[0] + dif, s2[0] + dif, s3[0] + dif);
	return 0;
}

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

int main()
{
	int x, y, z;
	cin >> x >> y >> z;
	for (int i = 1;; i++) {
		if (y * i + z * (i + 1) > x) {
			cout << i - 1 << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
def GetPoint(a, b, p):
    if (a == 0 and b == 1) or (a == 1 and b == 2) or (a == 2 and b == 0):
        return p
    else:
        return 0


N, K = map(int, input().split())
G, C, P = map(int, input().split())
s = input()
A = [[] for i in range(K)]
for i in range(N):
    c = i % K
    if s[i] == 'r':
        A[c].append(0)
    elif s[i] == 's':
        A[c].append(1)
    else:
        A[c].append(2)

ans = 0

for S in A:
    l = len(S)
    dp = [[0 for i in range(3)] for i in range(l + 1)]
    for i in range(l):
        dp[i + 1][0] = max(dp[i][1], dp[i][2]) + GetPoint(0, S[i], G)
        dp[i + 1][1] = max(dp[i][0], dp[i][2]) + GetPoint(1, S[i], C)
        dp[i + 1][2] = max(dp[i][0], dp[i][1]) + GetPoint(2, S[i], P)

    ans += max(dp[l][0], dp[l][1], dp[l][2])

print(ans)


Measured memory_bytes: 24928
N = int(input())
S = input()
MOD = 10**9+7
A = [0 if S[i]=='W' else 1 for i in range(2*N)]
A = [(A[i]+i+1)%2 for i in range(2*N)]


ans = 1
l = 0
r = N
flag = True
for i in range(2*N):
    if A[i] == 0:
        l += 1
    
    else:
        ans = (ans*l)%MOD
        r -= 1
        l -= 1
        if l < 0:
            flag = False
            break
if r != 0:
    flag = False

for i in range(1,N+1):
    ans = (ans*i)%MOD
if not flag:
    ans = 0
print(ans)


Measured memory_bytes: 56184
#include<bits/stdc++.h>
using namespace std;
#define pb  push_back
#define mod 1000000007
#define INF 1e18
#define maxx 1000033;
typedef  long long ll;
int gcd(int a,int b){
	if(a<b)
		swap(a,b);
	if(a%b==0)
		return b;
	return gcd(b,a%b);
}
int prime[1000033];
int main()
{
	
	for (int i = 0; i <1000033 ; ++i)
	{
		prime[i]=INT_MAX;
	}
	for (int i = 2; i <1000033; ++i)
	{
		if(prime[i]==INT_MAX){
			for (int j = i; j <1000033; j+=i)
			{
				prime[j]=min(i,prime[i]);
			}
		}
	}
	// for (int i = 0; i < 10; ++i)
	// {
	// 	cout<<prime[i]<<" ";
	// }
	// cout<<endl;
	int n;
	cin>>n;
	int arr[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>arr[i];
	}
	int f=3;
	int gc=arr[0];
	for (int i = 1; i < n; ++i)
	{
		// cout<<gcd(6,10);
		gc=gcd(gc,arr[i]);

	}
	if(gc==1)
		f=2;
	if(f==2){
		// map<int,bool> m;
		int falg=1;
		map<int,bool> m;
		int num=prime[arr[0]];
		m[num]=true;		
		for (int i = 1; i < n; ++i)
		{
			if(prime[arr[i]]!=INT_MAX&&m[prime[arr[i]]])
				falg=0;
			m[prime[arr[i]]]=true;
		}
		if(falg==1)
			f=1;
	}
	if(f==1)
		cout<<"pairwise coprime";
	else if(f==2)
		cout<<"setwise coprime";
	else
		cout<<"not coprime";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 15108
//go:generate echo "https://atcoder.jp/contests/abc177/tasks/abc177_b"
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) String() string {
	s.Scan()
	return s.Text()
}

func (s *scanner) StringSlice(l int) []string {
	if l == 0 {
		return []string{}
	}
	sl := make([]string, l, l)
	for i := range sl {
		sl[i] = s.String()
	}
	return sl
}

func solve(s, t string) int {
	maxMatch := 0
	for i := 0; i+len(t) <= len(s); i++ {
		match := 0
		for ci, sc := range s[i : i+len(t)] {
			if sc == rune(t[ci]) {
				match++
			}
		}
		if maxMatch < match {
			maxMatch = match
		}
	}
	return len(t) - maxMatch
}

func main() {
	scan := newScanner(os.Stdin)
	s, t := scan.String(), scan.String()
	fmt.Println(solve(s, t))
}


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

#define INF (1 << 30) - 1 + (1 << 30)

int a[262144], n2, lazy[262144];

void lazyeval(int i) {
  if (lazy[i] == INF) return;
  a[i] = lazy[i];
  if (i < n2 - 1) {
    lazy[2 * i + 1] = lazy[2 * i + 2] = lazy[i];
  }
  lazy[i] = INF;
}
int find(int s, int t, int i, int l, int r) {
    lazyeval(i);
  if (s <= l && r <= t) return a[i];
  if (t <= l || r <= s) return INF;
  int cl, cr;
  cl = find(s, t, i * 2 + 1, l, (l + r) / 2);
  cr = find(s, t, i * 2 + 2, (l + r) / 2, r);
  return min(cl, cr);
}

// int findsingle(int i) {
//   int j = i + n2 - 1;
//   int val = a[i + n2 - 1];
//   if (lazy[j] != INF) val = lazy[j];
//   while (j > 0) {
//     j = (j - 1) / 2;
//     if (lazy[j] != INF) val = lazy[j];
//   }

//   return val;
// }

void updaterange(int s, int t, int i, int l, int r, int x) {
  lazyeval(i);
  // cout << s << " " << t << " " << i << " " << l << " " << r << endl;
  if (s <= l && r <= t) {
    a[i] = x;
    if (i < n2 - 1) {
      lazy[2 * i + 1] = lazy[2 * i + 2] = a[i];
    }
    return;
  }
  if (t <= l || r <= s) return;
  updaterange(s, t, i * 2 + 1, l, (l + r) / 2, x);
  updaterange(s, t, i * 2 + 2, (l + r) / 2, r, x);

  a[i] = min(a[i * 2 + 1], a[i * 2 + 2]);
}

int main() {
  int n, q, com, s, t, x;

  cin >> n >> q;
  n2 = 1;
  while (n > n2) n2 *= 2;
  for (int i = 0; i < n2 * 2; i++) a[i] = lazy[i] = INF;

  for (int i = 0; i < q; i++) {
    cin >> com >> s>>t;
    if (com == 0) {
      cin >> x;
      updaterange(s, t + 1, 0, 0, n2, x);
    } else
      cout << find(s,t + 1, 0, 0, n2) << endl;
  }
  return 0;
}


Measured memory_bytes: 5172
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

int a[2010], n, x;
int d[2010][2010];
int INF = 1e16;

int solve(int m){
    int res = 0;
    rep(i, 0, n){
        res += d[i][m];
    }
    return res + x * m;
}

signed main(){
    cin >> n >> x;
    rep(i, 0, n) cin >> a[i];
    int ans = INF;
    rep(i, 0, n) rep(j, 0, n) d[i][j] = INF;
    rep(i, 0, n){
        int t = INF;
        rep(j, 0, n){
            int id = (i - j + n) % n;
            t = min(t, a[id]);
            d[i][j] = t;
        }
    }
    rep(i, 0, n){
        ans = min(ans, solve(i));
    }
    cout << ans << endl;
}

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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    if(n % 2 == 0) cout << n << endl;
    else cout << 2*n << endl;

    return 0;
}

Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <list>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

#define xx first
#define yy second
#define $1 first
#define $2 second

const ll MOD = 1e9 + 7;

ll fast_power(ll base, ll power) {
	ll result = 1;
	while (power > 0) {
		if (power & 1) { result = (result*base) % MOD; }
		base = (base*base) % MOD;
		power >>= 1;
	}
	return result;
}

int fastpower(int a, int b) {
	int res = 1;
	a %= MOD;
	while (b) {
		if (b & 1) res = (res * a) % MOD;
		a *= a; a %= MOD;
		b >>= 1;
	}
	return res;
}


void solve() {
	ll n, k;
	cin >> n >> k;
	vector<ll> dp(k + 1, 0);
	for (int gd = k; gd >= 1; --gd) {
		ll total_multiples = k / gd;
		ll temp = fast_power(total_multiples, n);
		temp %= MOD;
		temp %= MOD;
		int extra = 0;
		for (int j = gd * 2; j <= k; j += gd) {
			extra = (extra + dp[j]) % MOD;
		}
		dp[gd] = (temp - extra + MOD) % MOD;
	}

	int ans = 0;
	for (int i = 1; i <= k; ++i) {
		int add = (dp[i] % MOD * i % MOD) % MOD;
		ans += add, ans %= MOD;
	}

	cout << ans << '\n';


}
int main() {

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

Measured memory_bytes: 4000
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define inl(a) cin >> a
#define prl(a) cout << a << " "
#define outl(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<int,pair<int,int> > >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define N 100005
int dp[N][3];
int main()
{
    int i,n;
    in(n);
    vi a(n),b(n),c(n);
    rep(i,n)
        in3(a[i],b[i],c[i]);
    dp[0][0]=a[0],dp[0][1]=b[0],dp[0][2]=c[0];
    lp(i,1,n)
    {
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][1],dp[i-1][0]);
    }
    out(max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])));



}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;
int main(){
  int N;
  cin >> N;
  int cnt = 0;
  for( int i=1;i<=N;i++ )
    {
      if( i%2 == 0)
	continue;
      int div = 0;
      for( int j=1;j<=i;j++)
	{
	  if( i%j==0 )
	    div ++;
	}
      if(div == 8)
	cnt ++;
    }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#define ll long long int
using namespace std;

int main(){

    ll N,a,b,ret,_ret;
    cin >> N;

    a = N;
    b = 1;
    ret = a + 1 - 2;

    for (int i=1; i<=10000000; i ++){
        if(a%i == 0){
            _ret = (a/i) + (b*i) - 2;
            if(ret > _ret){
                ret = _ret;
            }
        }
    }

    cout << ret<< endl;


    return 0; 
}

Measured memory_bytes: 256