akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>

using namespace std;

typedef pair<int,int> pii;

char G[501][501];
int g[501][501];

int main(void){

	int h,w;
	while(cin >> h >> w,h|w){
		fill(g[0],g[501],0);
		for(int i=0;i<h;i++)cin >> G[i];

		for(int i=0;i<w;i++)g[0][i]=(G[0][i]=='.');
		for(int i=1;i<h;i++){
			for(int j=0;j<w;j++){
				if(G[i][j]=='.')g[i][j]=g[i-1][j]+1;
			}
		}

		int ans=0;
		for(int i=0;i<h;i++){
			stack<pii> st;
			for(int j=0;j<w;j++){
				if(st.empty() || st.top().first<g[i][j])st.push(pii(g[i][j],j));
				else if(st.top().first>g[i][j]){
					int pos;
					while(!st.empty() && st.top().first>=g[i][j]){
						pos=st.top().second;
						ans=max(ans,(j-st.top().second)*st.top().first);
						st.pop();
					}
					st.push(pii(g[i][j],pos));
				}
			}
			
			while(!st.empty()){
				ans=max(ans,(w-st.top().second)*st.top().first);
				st.pop();
			}
			
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 2428
from bisect import bisect_left
from collections import deque
N=int(input())
A=[int(input()) for i in range(N)]

ans=1
data=deque([A[0]])
for i in range(1,N):
    a=A[i]
    b=bisect_left(data,a)
    if b==0:
        data.appendleft(a)
        ans+=1
    else:
        data[b-1]=a

print(ans)

Measured memory_bytes: 53336
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

bool req[5101] = {false};

bool solve(int index, int N, int K, const VI& seq, int sum){
  int nsum = sum + seq[index];
  if(req[index]){
    return req[index];
  }
  if(nsum >= K){
    req[index] = true;
    solve(index+1, N, K, seq, sum);
    return req[index];
  }
  REP(i, index+1, N){
    req[index] = solve(i, N, K, seq, nsum) || req[index];
    if(!req[index]){
      break;
    }
  }
  return req[index];
}

int main(){
  int N, K;
  scanf("%d %d\n", &N, &K);

  VI seq = VI(N);
  REP(i, 0, N){
    int tmp;
    scanf("%d ", &tmp);
    seq[i] = tmp;
  }
  sort(seq.rbegin(), seq.rend());

  solve(0, N, K, seq, 0);

  int ans = N;
  REP(i, 0, N){
    if(req[i]){
      ans--;
    }
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    sc.close();
    if ((A >= 1 && A <= 9) && (B >= 1 && B <= 9)) {
      System.out.println(A * B);
    } else {
      System.out.println(-1);
    }
  }
}


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

using namespace std;

int main(){
	int w,h,n;
	
	while(cin >> h >> w >> n){
		if(!(w|h|n)) break;
		
		bool dir[h][w];
		int dp[h+1][w+1],t;
		fill((int *)dp, (int *) dp + (h+1) * (w+1), 0);
		dp[0][0] = n-1;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> t;
				if(t == 1){
					dir[i][j] = true;
				}else{
					dir[i][j] = false;
				}
			}
		}
		
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(dp[i][j] % 2 == 0){
					dp[i][j+1] += dp[i][j] / 2;
					dp[i+1][j] += dp[i][j] / 2; 
				}else{
					if(dir[i][j]){ //east
						dir[i][j] = false;
						dp[i][j+1] += dp[i][j] / 2 + 1;
						dp[i+1][j] += dp[i][j] / 2;
					}else{
						dir[i][j] = true;
						dp[i][j+1] += dp[i][j] / 2;
						dp[i+1][j] += dp[i][j] / 2 + 1;
					}
				}
			}
		}

		int x = 0, y = 0;
		while(x < h && y < w){
			if(dir[x][y]){
				y++;
			}else{
				x++;
			}
		}
		cout << x+1 << " " << y+1 << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
ll sq=500;
vector<ll> badget(1000,0);

void Main(){
    ll n;cin>>n;
    ll d;cin>>d;
    ll a;cin>>a;
    vector<pair<ll,ll>> x(n);
    For(i,0,n){
        cin>>x[i].first>>x[i].second;
    }
    sort(ALL(x));
    x.push_back(make_pair(ll(10000000000),ll(0)));
    For(i,0,n){
        if(x[i].second-badget[i/sq]<=0) continue;
        else{
            ll hp=x[i].second-badget[i/sq];
            ll bakugeki=(hp+a-1)/a;
            //cout<<"x = "<<x[i].first+d<<" num = "<<bakugeki<<endl;
            ans+=bakugeki;
            auto itr=upper_bound(ALL(x),make_pair(x[i].first+2*d,ll(10000000000)));
            ll right=itr-x.begin()-1;
            //cout<<right<<endl;
            ll left=i;
            while(left%sq!=0&&left<right){
                x[left].second-=bakugeki*a;
                left++;
            }
            while(right%sq!=0&&left<right){
                x[right].second-=bakugeki*a;
                right--;
            }
            while(left<right){
                badget[left/sq]+=bakugeki*a;
                left+=sq;
            }
            if(left==right) x[right].second-=bakugeki*a;
        }
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li n;
li a[202];
int main() {
    cin >> n;
    rin{
        cin >> a[i];
    }

    li mi = a[0];
    li now = 1000;
    li kabu = 0;

    repp(i, 1, n) {
        if (a[i] > mi) {
            // miで購入, a[i]で売却
            kabu += now / mi;
            now %= mi;
            now += kabu * a[i];
            kabu = 0;
            mi = a[i];
        }
        mi = min(mi, a[i]);
    }
    cout << now << endl;


    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
    //#include<cstdio>
    #include<iostream>
    #include<fstream>
    #include<string.h>
    #include<algorithm>
    #include<functional>
    using namespace std;
     
    int main(void){
     
    	int N,L;
    	char S[101][101];
    	int Sn[101];
     
    	for (int i = 0; i < 101; i++){
    		for (int j = 0; j < 101; j++)S[i][j] = 0;
    		Sn[i] = i;
    	}
    	
     
    	cin >> N>>L;
    	for (int i = 0; i < N; i++)cin >> S[i];
    	
    	while(1){
    		int act = 0;
    		for (int j = N-1; j >0 ; j--){
    			if (strcmp(S[Sn[j]], S[Sn[j - 1]]) < 0){
    				int dammy = Sn[j - 1];
    				Sn[j - 1] = Sn[j];
    				Sn[j] = dammy;
    				act++;
    			}
    		}
    		if (act == 0)break;
    	}
    	
    	for (int i = 0; i < N; i++)printf("%s", S[Sn[i]]);
    	printf("\n");
     
    	return 0;
    }

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

void chmax(int& a, int b){
    a = max(a, b);
}

int main(){
    int H, W;
    cin >> H >> W;
    string S[101];
    S[0] = string('!', W+1);
    int ER, EC;
    for(int i=1; i<=H; i++){
        cin >> S[i];
        S[i].insert(0, "!");
        if(S[i].find('E') != -1){
            ER = i;
            EC = S[i].find('E');
        }
    }

    int RS[101][101] = {0}, CS[101][101] = {0};
    for(int i=1; i<=H; i++) for(int j=1; j<=W; j++){
        RS[i][j] = RS[i][j-1];
        CS[i][j] = CS[i-1][j];
        if(S[i][j] == 'o'){
            RS[i][j]++;
            CS[i][j]++;
        }
    }

    static int dp[101][101][101][101];
    for(int u=0; ER-u>0; u++) for(int d=0; ER+d<=H; d++){
        for(int l=0; EC-l>0; l++) for(int r=0; EC+r<=W; r++){
            int ub = max(ER-u, d+1), db = min(ER+d, H-u);
            int lb = max(EC-l, r+1), rb = min(EC+r, W-l);
            if(ER-u-1 > 0){
                int add = 0;
                if(ER-u-1 >= d+1) chmax(add, RS[ER-u-1][rb] - RS[ER-u-1][lb-1]);
                chmax(dp[u+1][d][l][r], dp[u][d][l][r] + add);
            }
            if(EC-l-1 > 0){
                int add = 0;
                if(EC-l-1 >= r+1) chmax(add, CS[db][EC-l-1] - CS[ub-1][EC-l-1]);
                chmax(dp[u][d][l+1][r], dp[u][d][l][r] + add);
            }
            if(ER+d+1 <= H){
                int add = 0;
                if(ER+d+1 <= H-u) chmax(add, RS[ER+d+1][rb] - RS[ER+d+1][lb-1]);
                chmax(dp[u][d+1][l][r], dp[u][d][l][r] + add);
            }
            if(EC+r+1 <= W){
                int add = 0;
                if(EC+r+1 <= W-l) chmax(add, CS[db][EC+r+1] - CS[ub-1][EC+r+1]);
                chmax(dp[u][d][l][r+1], dp[u][d][l][r] + add);
            }
        }
    }
    cout << dp[ER-1][H-ER][EC-1][W-EC] << endl;
    return 0;
}


Measured memory_bytes: 236160
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
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;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
//using namespace atcoder;

void solve(){
	int k;
	cin>>k;
	string s="";
	rep(i,k)s+="ACL";
	cout<<s;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
int n,m,x;
int a[15][15];
ll sum[15],tmp[15];
ll res=0x3f3f3f3f;
void dfs(int i)
{
    res=min(res,tmp[0]);
    bool flag=true;
    for(int j=1;j<=m;++j)
    {
        if(tmp[j]-a[i][j]<x)
            flag=false;
    }
    if(flag)
    {
        for(int j=0;j<=m;++j)
            tmp[j]-=a[i][j];
        res=min(res,tmp[0]);
    }
    for(int j=i+1;j<=n;++j)
        dfs(j);
    if(flag)
    {
        for(int j=0;j<=m;++j)
            tmp[j]+=a[i][j];
    }
}
int main(void)
{
    sync;
    cin>>n>>m>>x;
    for(int i=1;i<=n;++i)
    {
        for(int j=0;j<=m;++j)
        {
            cin>>a[i][j];
            sum[j]+=a[i][j];
        }
    }
    for(int i=1;i<=m;++i)
        if(sum[i]<x)
        {
            cout<<-1<<endl;
            return 0;
        }
    for(int i=1;i<=n;++i)
    {
        for(int j=0;j<=m;++j)
            tmp[j]=sum[j];
        dfs(i);
    }
    cout<<res<<endl;
    return 0;
}

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

using namespace std;


int main()
{
	int n,m;
	cin >> n >> m;
	vector<string> arr(n);
	for(int i = 0; i < n; i++) cin >> arr[i];
	int mod = (int)1e9+7;
	vector<vector<int>> dp(n, vector<int>(m));
	dp[0][0] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(i == 0 && j == 0) continue;
			if(arr[i][j] == '#') continue;
			int x = 0, y = 0;
			if(i > 0) x = dp[i-1][j];
			if(j > 0) y = dp[i][j-1];
			dp[i][j] = x%mod+y%mod;
			dp[i][j] %= mod;
		}
	}
	cout << dp[n-1][m-1];
}


Measured memory_bytes: 9416
(defun main ()
  (let ((5-num 0)
        (7-num 0))
    (loop :for x := (read t nil)
          :while x
          :do (ecase x
                (5 (incf 5-num))
                (7 (incf 7-num))))
    (write-line
     (if (and (= 5-num 2)
              (= 7-num 1))
         "YES"
         "NO"))))

(main)


Measured memory_bytes: 3432
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from heapq import heappop

n, k = li()
v = list(li())

ans = 0

for x in range(-(-k//2)):
    if 2*x > k:
        continue

    get = k - x
    if get >= n:
        cnt = 0
        heap = sorted(v)

        while heap[0] < 0 and cnt < x:
            _ = heappop(heap)
            cnt += 1

        ans = max(ans, sum(heap))

    else:
        for i in range(get+1):
            cnt = 0
            heap = sorted(v[:i] + v[n-(get-i):])
            while heap[0] < 0 and cnt < x:
                _ = heappop(heap)
                cnt += 1

            ans = max(ans, sum(heap))

print(ans)

Measured memory_bytes: 42984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int N;
    cin >> N;
    cout << N * 800 - N / 15 * 200 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#include <math.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
const int MAX = 710000;

/*-----Library-----*/

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

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

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

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

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

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

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*-----Library-----*/
int n,a,b;
int h[114514];
P max_h(){
    P re=P(h[0],0);
    for(int i=1;i<n;i++){
        if(re.first<h[i]){
            re=P(h[i],i);
        }
    }
    return re;
}
int dp[3100][6100];
signed main(){
    int n,t;
    cin>>n>>t;
    P f[114514];
    for(int i=0;i<n;i++){
        cin>>f[i].first>>f[i].second;
    }
    sort(f,f+n);
    int p=f[n-1].first;
    for(int i=0;i<=n;i++){
        dp[i][0]=0;
    }
    for(int i=0;i<=t+p;i++){
        dp[0][i]=0;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<=t+p;j++){
            if(j>=f[i].first){
                if(j-f[i].first<t)dp[i+1][j]=max(dp[i][j],dp[i][j-f[i].first]+f[i].second);
                else dp[i+1][j]=max(dp[i][j],dp[i+1][j-1]);
            }
            else dp[i+1][j]=max(dp[i][j],dp[i+1][j-1]);
        }
    }
    
    cout<<dp[n][t+p]<<endl;
}


Measured memory_bytes: 145408
#include <iostream>

#define N_MAX 100000

using namespace std;

int main(){
    int N, M;
    int div_max = 0;
    int div_tmp;
    cin >> N >> M;
    for(int i = 1; i*i <= M; i++){
        if(M%i == 0){
            if(M/i >= N){
                div_max = max(div_max, i);
            }
            if(i >= N){
                div_max = max(div_max, M/i);
            }
        }
    }
    cout << div_max << '\n';
}

int max(int a, int b){
    if(a > b) return a;
    else return b;
}

Measured memory_bytes: 504
n,m=map(int,input().split())
s=[list(map(int,input().split())) for i in range(n)]
p=[list(map(int,input().split())) for i in range(m)]
man=0
inde=1
for i in range(n):
    arr=[abs(s[i][0]-p[0][0])+abs(s[i][1]-p[0][1])]
    for j in range(1,m):
        man=abs(s[i][0]-p[j][0])+abs(s[i][1]-p[j][1])
        if man<min(arr):
            arr.append(man)
            inde=j+1
    print(inde)
    inde=1

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	static int[][][] dp;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int prev = -1;
		int count = 0;
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if (prev == a) {
				count++;
				prev = -1;
			} else {
				prev = a;
			}
		}
		System.out.println(count);
	}
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int main(){
    V v(5);
    rep(i,5)cin>>v[i];
    int res=-inf;
    int num;
    rep(i,5){
        string s=to_string(v[i]);
        int range=(10-(s.back()-'0'))%10;
        if(range>res){
            res=range;
            num=i;
        }
    }
    int ans=0;
    rep(i,5){
        ans+=v[i];
        if(i!=num){
            int range=(10-(to_string(v[i]).back()-'0'))%10;
            ans+=range;
        }
    }
    cout<<ans<<endl;
}



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

using namespace std;

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 0; i < n - 2; i++)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
t = input()

ans = float("inf")
flag = False
for i in range(len(s)):
    curr = 0
    for j in range(len(t)):
        if i + j >= len(s):
            flag = True
            break
        if t[j] != s[i + j]:
            curr += 1
    if flag:
        break
    ans = min(ans, curr)
print(ans)


Measured memory_bytes: 9036
#include<stdio.h>

int main(void)
{
	int a, b, c, d,score1=0,score2=0;

	scanf("%d %d %d %d",&a,&b,&c,&d);
	score1 = a + b + c + d;

	scanf("%d %d %d %d", &a, &b, &c, &d);
	score2 = a + b + c + d;

	if (score1 > score2)printf("%d\n",score1);
	else printf("%d\n",score2);

	return 0;
}

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

int main() {
    ll X, Y;
    cin >> X >> Y;

    ll count = 0;
    ll x = X;
    while (x <= Y) {
        ++count;
        x *= 2;
    }
    cout << count << endl;

    return 0;
}


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

#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)

using namespace std;

using I = int;
using L = long;
using F = float;
using S = string;
using SS = stringstream;
using C = char;
using LL = long long;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using VVI = vector<vector<int>>;
using VVL = vector<vector<long>>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

template <class T>
void PrintVector(const vector<T> & v) {
  for (const auto & e: v) {
    cout << e << endl;
  }
}

template <class T>
void PrintVector(const vector<T> & v, unsigned n) {
  rep(i, 0, n - 1) {
    cout << v[i] << endl;
  }
}

int main(int argc, char const *argv[]) {
  const int kMax = 8010;
  S s;
  int n, m;
  int ans = 0;
  cin >> n >> m;
  if (n % 2 == 0 || m % 2 == 0) cout << "Even\n";
  else cout << "Odd\n";

  return 0;
}


Measured memory_bytes: 256
n = int(input())
lst = list(map(int,input().split()))
ans = 0
for i in range(n - 1):
    if (lst[i] > lst[i + 1]):
        sa = lst[i] - lst[i + 1]
        ans = ans + sa
        lst[i + 1] = lst[i]
print(ans)


Measured memory_bytes: 32144
#include<iostream>
#include<algorithm>
#include<string.h>
#include<set>
#include<vector>
using namespace std;
#define INF 1<<21

int N,M;
int a[1005];
int b[1005];
int c[1005];
int dist[105][105];

int main(){
    int ans;
    cin>>N>>M;
    ans=M;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i==j)dist[i][j]=0;
            else dist[i][j]=INF;
        }
    }

    for(int i=0;i<M;i++){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;b[i]--;
        dist[a[i]][b[i]]=c[i];
        dist[b[i]][a[i]]=c[i];
    }

    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }

    for(int i=0;i<M;i++){
        bool check=0;
        for(int j=0;j<N;j++){
            if(dist[j][a[i]]+c[i]==dist[j][b[i]])check=1;
        }
        if(check)ans--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int n,l;
    cin>>n>>l;
    
    vector<int> taste(n);
    int sum=0;
    int taste_min=10000;
    int min_index=0;
    for(int i=0;i<n;i++){
        taste[i]=l+i;
        sum+=taste[i];
        if(taste_min>abs(taste[i])){
            taste_min=abs(taste[i]);
            min_index=i;
        }
    }
    
    cout<<sum-taste[min_index]<<endl;
    
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {

	var a int
	fmt.Scan(&a)

	list := make([]int, a)
	for i := 0; i < a; i++ {
		fmt.Scan(&list[i])
	}

	min := 100000.0
	for i := 0; i < a; i++ {
		aTotal := 0
		bTotal := 0
		for j := 0; j <= i; j++ {
			aTotal += list[j]
		}
		for k := i + 1; k < a; k++ {
			bTotal += list[k]
		}

		if math.Abs(float64(aTotal-bTotal)) < min {
			min = math.Abs(float64(aTotal - bTotal))
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long n, x, m;
	cin >> n >> x >> m;
	long long N = min(n + 1, m + 2);
	vector<long long> a(N);
	vector<int> vis(m);
	a[1] = x;
	vis[x] = 1;
	long long ans = 0;
	for (int i = 2; i < N; i++) {
		a[i] = a[i - 1] * a[i - 1] % m;
		if (vis[a[i]]) {
			long long sum1 = accumulate(a.begin() + 1, a.begin() + vis[a[i]], 0LL);
			vector<long long> cycle;
			for (int j = vis[a[i]]; j < i; j++) {
				cycle.push_back(a[j]);
			}
			n -= vis[a[i]] - 1;
			long long sum2 = accumulate(cycle.begin(), cycle.end(), 0LL);
			long long sum3 = accumulate(cycle.begin(), cycle.begin() + n % cycle.size(), 0LL);
			cout << sum1 + sum2 * (n / cycle.size()) + sum3 << "\n";
			return 0;
		} else {
			vis[a[i]] = i;
		}
	}
	ans = accumulate(a.begin(), a.end(), 0LL);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string n;    
    cin >> n;    
  
    if(n[0] == n[1] && n[0]== n[2] || n[1] == n[2] && n[1]== n[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;     
    }
    
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> H(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> H[i];
  }
  for (int i = n - 2 ; i >= 0; i--) {
    if (H[i] <= H[i + 1]) {
      continue;
    }
    if (H[i] == H[i + 1] + 1) {
      H[i] -= 1;
      continue;
    }
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
using ll = long long;
const double pi = atan(1.0)*4;
int main()
{
    double a,b,x;
    cin>>a>>b>>x;
    double h = b;
    double w = x*2/h/a;
    if(w <= a)
        printf("%.10f\n",atan(h/w)/pi*180);
    else {
        double rest = a*a*b-x;
        double w = a;
        double h = rest*2/w/a;
        printf("%.10f\n",atan(h/w)/pi*180);
    }
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
struct Node{
  int parent,left,right;
};
Node T[100005];
int n,D[1000005],hei[1000005];

void setDepth(int u, int p){
  if(u==-1)return;
  D[u]=p;
  setDepth(T[u].left,p+1);
  setDepth(T[u].right,p+1);
}

int setHeight(int u){
  int h=0,hh=0;
  if(T[u].left!=-1){
    h=setHeight(T[u].left)+1;
  }
  if(T[u].right!=-1){
    hh=setHeight(T[u].right)+1;
  }
  if(h>hh)return hei[u]=h;
  else return hei[u]=hh;
}
int get(int u){
  if(T[u].parent==-1){
    return -1;
  }
  if(T[T[u].parent].right!=-1&&T[T[u].parent].right!=u){
    return T[T[u].parent].right;
  }
  if(T[T[u].parent].left!=-1&&T[T[u].parent].left!=u){
    return T[T[u].parent].left;
  }
  return -1;
}
int main(){
  int i=0,j=0,k=0,c=0,l=0,r=0,Tc=0;
  int id=0;
  cin>>n;
  for(i=0;i<n;i++){
    T[i].parent=T[i].left=T[i].right=-1;
  }
  for(i=0;i<n;i++){
    cin>>id>>l>>r;
    T[id].left=l;
    T[id].right=r;
    if(l!=-1)T[l].parent=id;
    if(r!=-1)T[r].parent=id;
  }
  for(i=0;i<n;i++){
    if(T[i].parent==-1){
      Tc=i;
    }
  }
  setDepth(Tc,0);
  setHeight(Tc);
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, ",i,T[i].parent,get(i));
    int c=0;
    if(T[i].left!=-1)c++;
    if(T[i].right!=-1)c++;
    printf("degree = %d, depth = %d, height = %d, ",c,D[i],hei[i]);
    if(T[i].parent==-1)cout<<"root"<<endl;
    else if(T[i].left==-1&&T[i].right==-1)cout<<"leaf"<<endl;
    else cout<<"internal node"<<endl;
    //cout<<"[";
    //for(j=0,Tc=T[i].left;Tc!=-1;j++,Tc=T[Tc].right){
      //while(1){
      //if(j)cout<<", ";
      //cout<<Tc;
	//if(T[i].left==-1||T[i].left==T[T[i].left].right)break;
    //}
    //cout<<"]"<<endl;
    /*while(1){
      if(T[i].left==-1)break;
      
    }*/
  }
  return 0;
}



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

int main() {
   int a;
   cin>>a;
   if(a==25){
      cout<<"Christmas"<<endl;
   }
   else if(a==24){
            cout<<"Christmas Eve"<<endl;
   }
        else if(a==23){
           cout<<"Christmas Eve Eve"<<endl;
        }
             else if(a==22){
                cout<<"Christmas Eve Eve Eve"<<endl;
             }

}



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

int main(){
int N;
  cin >> N;
 vector<tuple<string,int,int>> v(N);
  for(int i=0;i<N;i++){
    string a;
    int b;
    cin >> a >> b;
    v[i] = make_tuple(a,-b,i);
  }
  sort(v.begin(), v.end());
  for(int i=0;i<N;i++){
      int A,y;
      string x;
      tie(x,y,A) = v[i];
    cout << A+1 << endl;
  }
} 

Measured memory_bytes: 256
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

l,r = nm()

MOD = 2019

ans = 10**9
for i in range(l,min(r,l+2019)+1):
  for j in range(i+1,min(r,i+MOD)+1):
    ans=min(ans,((i%MOD)*(j%MOD))%MOD)

print(ans)


Measured memory_bytes: 40940
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef long double ld;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}


  
int main(){
    ll n,y;
    cin>>n>>y;
    
    for(ll i = 0; i<=n; i++){
        for(ll j = 0; j<=n; j++){
            ll l = n-i-j;
            if(10000*j + 5000*i + 1000*l == y){
                if(abs(i)+abs(j)+abs(l)<=n){
                    cout<<j<<" "<<i<<" "<<l<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
}
 
    
    



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

signed main(){
  int n;
  cin>>n;
  int a[n];
  r(i,n)cin>>a[i];
  sort(a,a+n);
  int x=a[n-1];
  int s=0;
  r(i,n-1)s+=a[i];
  if(s>x)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define riterator reverse_iterator
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 5e4;
const int mxP = 1e6;
struct AEdge
{
	int u,v,w;
} ae[N+3];
int uf[N*6+3];
bool ispw2[mxP+3][2];
int n,m,q,p,g;

int gcd(int x,int y) {return y==0?x:gcd(y,x%y);}

int getid(int x,int j,int k) {return (j*3+k)*n+x;}
int findfa(int u) {return u==uf[u]?u:uf[u]=findfa(uf[u]);}
void unionfa(int u,int v)
{
	int x = findfa(u),y = findfa(v);
	if(x!=y) {uf[x] = y;}
}

int main()
{
	scanf("%d%d%d%d",&n,&m,&q,&p); g = p;
	for(int i=1; i<=n*6; i++) uf[i] = i;
	for(int i=1; i<=m; i++)
	{
		scanf("%d%d%d",&ae[i].u,&ae[i].v,&ae[i].w);
		g = gcd(g,abs(ae[i].w-ae[1].w));
	}
	p = gcd(p,3*g);
	int z = ae[1].w%g;
	for(int i=1; i<=m; i++)
	{
		int w = (ae[i].w-z)/g%3,u = ae[i].u,v = ae[i].v;
//		printf("w=%d\n",w);
		for(int j=0; j<2; j++) for(int k=0; k<3; k++)
		{
			unionfa(getid(u,j,k),getid(v,j^1,(k+k+w)%3));
			unionfa(getid(v,j,k),getid(u,j^1,(k+k+w)%3));
		}
	}
	for(int i=0,x=z; i<p; i++,x=(x<<1)%p) ispw2[x][i&1] = true;
	while(q--)
	{
		int u,v,l; scanf("%d%d%d",&u,&v,&l); bool ans = false;
		for(int j=0; j<2; j++) for(int k=0; k<3; k++)
		{
			int tmp = (z+l+(3-k)*g)%p;
			if(ispw2[tmp][j])
			{
//				printf("(%d,%d,%d),(%d,%d,%d)\n",v,0,0,u,j,k);
				int uu = findfa(getid(v,0,0)),vv = findfa(getid(u,j,k));
				if(uu==vv) {ans = true; break;}
			}
		}
		if(ans==true) puts("YES"); else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 4096
#include<iostream>
using namespace std;
#define MAX 100000
#define rep(i,n) for (int i = 0; i < (n); i++)
using ll = long long;

int n, k;
ll T[MAX];


// 最大積載慮 P の k 台のトラックで何個の荷物を積めるか？
int check(ll P) {
  int i = 0;
  for (int j=0; j<k; j++) {
    ll s = 0;
    while (s + T[i] <= P) {
      // cout << "個数= " << i+1 << " 荷物重量= " << s + T[i] << " P= " << P << endl;
      s += T[i];
      i++;
      if (i == n) return n;
    }
  }
  return i;
}


int solve() {
  ll left = 0;
  ll right = 100000 * 10000; // 荷物の個数 x 1個当たりの最大重量
  ll mid;
  while (right - left > 1) {
    mid = (left + right) / 2;
    int v = check(mid); // mid == P を決めて何個積めるかチェック
    // if (mid < 30) cout << "left= " << left << " mid= " << mid << " right= " << right << " v=" << v << endl; 
    if ( v >= n ) right = mid; // Pを減らす余地あり
    else left = mid;
  }
  return right;
}


int main() {
  cin >> n >> k;
  rep(i, n) cin >> T[i];
  ll ans = solve();
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3872
using System;

class Program
{
    static void Main(string[] args)
    {
        var x = Console.ReadLine().Split();
        var a = x[0];
        var b = x[1];
        var c = x[2];

        if (a[a.Length - 1] == b[0] && b[b.Length - 1] == c[0])
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 11092
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    int n = Integer.parseInt(data[0]);
    int m = Integer.parseInt(data[1]);
    
    int result = n*(n-1)/2 + m*(m-1)/2;
    System.out.println(result);
  }
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> t(n);
  vector<int> x(n);
  vector<int> y(n);
  int i;
  int ch = 0;
  for(i = 0; i < n; i++)
  {
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
  if((x.at(0)+y.at(0)-t.at(0))%2!=0||x.at(0)+y.at(0)-t.at(0)>0)
  {
    ch = 1;
  }
  for(i = 0; i < n-1; i++)
  {
    if((abs(x.at(i+1)-x.at(i))+abs(y.at(i+1)-y.at(i))-(t.at(i+1)-t.at(i)))%2!=0||abs(x.at(i+1)-x.at(i))+abs(y.at(i+1)-y.at(i))-(t.at(i+1)-t.at(i))>0)
    {
      ch = 1;
      break;
    }
  }
  if(ch == 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1408
using System;

namespace ITP1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int taro = 0;
            int hanako = 0;
            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                string t = input[0];              
                Array.Sort(input);
                if (input[0] == input[1])
                {
                    taro++;
                    hanako++;
                }
                else if (input[0] == t)
                {
                    hanako += 3;
                }
                else
                {
                    taro += 3;
                }
            }
            Console.WriteLine(taro+" "+hanako);
        }
    }
}

Measured memory_bytes: 9912
#include<stdio.h>

int main(void)
{
  int d, s, i;

  while(scanf("%d",&d)!=EOF)
    {
      s = 0;
      for(i=d;i<=600-d;i=i+d)
	{
	  s += d * (i*i);
	}
      printf("%d\n",s);
    }
  return 0;
}

Measured memory_bytes: 592
#import <stdio.h>
#import <stdlib.h>
#if !defined(MIN)
#define MIN(A,B)    ((A) < (B) ? (A) : (B))
#endif

#if !defined(MAX)
#define MAX(A,B)    ((A) > (B) ? (A) : (B))
#endif

int gcd(int a, int b){
    int M = MAX(a, b);
    int m = MIN(a, b);
    
    if (m == 0) {
        return M;
    }
    int r = M % m;
    if (r==0) return m;
    else return gcd(r,m);
}

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        int N;
        scanf("%d", &N);
        int *numbers = (int*)malloc(N * sizeof(int));
        
        int n;
        int i = 0;
        while (scanf("%d", &n) != EOF) {
            numbers[i] = n;
            i++;
        }
        
        int g = numbers[0];
        for(int i=1;i<N;i++){
            g=gcd(numbers[i],g);
        }
        printf("%d\n",g);

        free(numbers);
    }
    return 0;
}


Measured memory_bytes: 2660
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;
 
map<ll,int> prime(ll n) {
    map<ll,int> res;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            n /= i;
            res[i]++;
        }
    }
    if(n != 1) res[n]++;
    return res;
}
 
int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
 
    int flag = 1;
    map<ll,int> mp;
    for(int i = 0; i < n; i++){
        map<ll,int> mp1 = prime(a[i]);
        for(auto x : mp1){
            if(x.first == 1) continue;
            if(mp[x.first] == 1) { flag = 0; break; };
            mp[x.first] = 1;
        }
        if(flag == 0) break;
    }
    if(flag == 0){
        int aa = a[0];
        for(int i = 1; i < n; i++) aa = __gcd(aa,a[i]);
        if(aa == 1) flag = 2;
    }
    
    if(flag == 0) cout << "not coprime" << endl;
    else if (flag == 1) cout << "pairwise coprime" << endl;
    else cout << "setwise coprime" << endl;
 
	return 0;
}

Measured memory_bytes: 8476
N=int(input())
G=[[] for _ in range(N)]
for _ in range(N-1):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    G[a].append([b,c])
    G[b].append([a,c])
Q,K=map(int,input().split())
K-=1
dist=[-1 for _ in range(N)]
dist[K]=0
q=[K]
while len(q)>0:
    v=q.pop()
    for p in G[v]:
        nv=p[0]
        if dist[nv]!=-1:
            continue
        dist[nv]=dist[v]+p[1]
        q.append(nv)
for _ in range(Q):
    x,y=map(int,input().split())
    print(dist[x-1]+dist[y-1])


Measured memory_bytes: 50332
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n, m;
	cin >> n >> m;
	cout << (n * (n - 1) + m * (m - 1)) / 2 << endl;
}

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

namespace c
{
    class Program
    {
        public static readonly long INF = 999999999999;
        public static readonly long MOD = 1000000007;

        static void Main(string[] args)
        {
            var nk = Scanner.IntScan();
            var h = Scanner.IntScan();

            var dp = new long[nk[0] + 10];
            for (var i = 0; i < nk[0]; i++) dp[i] = INF;
            dp[0] = 0;

            for(var i = 0; i < nk[0]; i++)
            {
                for(var j = 1; j <= nk[1]; j++)
                {
                    if(i - j >= 0) Ex.Chmin(ref dp[i], dp[i - j] + Math.Abs(h[i] - h[i - j]));
                }
            }
            Console.WriteLine(dp[nk[0] - 1]);
        }
    }

    public class Scanner
    {
        public static string[] Scan() => Console.ReadLine().Split(' ');
        public static int[] IntScan() => Array.ConvertAll(Scan(), int.Parse);
        public static long[] LongScan() => Array.ConvertAll(Scan(), long.Parse);
        public static string[] Scan(int n) => Enumerable.Repeat(0, n).Select(_ => Scan()[0]).ToArray();
        public static int[] IntScan(int n) => Enumerable.Repeat(0, n).Select(_ => IntScan()[0]).ToArray();
        public static long[] LongScan(int n) => Enumerable.Repeat(0, n).Select(_ => LongScan()[0]).ToArray();

    }

    public class Ex
    {
        public static bool Chmin(ref int a, int b) { if (a > b) { a = b; return true; } return false; }
        public static bool Chmin(ref long a, long b) { if (a > b) { a = b; return true; } return false; }
        public static bool Chmax(ref int a, int b) { if (a < b) { a = b; return true; } return false; }
        public static bool Chmax(ref long a, long b) { if (a < b) { a = b; return true; } return false; }
        public static int[] SubArr(int[] arr, int begin, int n) { int[] a = new int[arr.Length]; Array.Copy(arr, begin, a, 0, n); return a; }
    }
}


Measured memory_bytes: 19680
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int dfs(int v, int n, int *visited, int table[n][n]) {
    int all_visited = 1, i;

    REP(i,n) {
        if (!visited[i]) {
            all_visited = 0;
            break;
        }
    }

    if (all_visited) {
        return 1;
    }

    int count = 0;

    REP(i,n) {
        if (!table[v][i]) continue;
        if (visited[i]) continue;

        visited[i] = 1;
        count += dfs(i, n, visited, table);
        visited[i] = 0;
    }

    return count;
}

int main() {
    int r[] = {0, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200};
    int rc[] = {0, 0, 0, 0, 0, 0, 0, 0};
    int n = iin(), l = 0, h = 0, a, i, j;
    REP(i, n) {
        a = iin();
        if (a < r[8]) {
            REP(j,8) {
                if (r[j] <= a && a < r[j + 1] && !rc[j]) {
                    rc[j] = 1;
                    l++;
                }
            }
        } else {
            h++;
        }
    }
     printf("%d %d\n", (l > 0 ? l : 1), l+h);
    return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define PI (acos(-1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define MAXN 1123456
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

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

  int n;
  cin>>n;

  map<string, ll> m;
  while (n--) {
    string s;
    cin>>s;
    sort(all(s));
    m[s] += 1;
  }

  ll ans=0;
  trav(p,m) {
    ans += (p.snd*(p.snd-1))/2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 11264
n, m = map(int, input().rstrip().split())

if n == 1:
    print(m)
    exit()


def enum_div(num):
    ret = list()
    for i in range(1, int(num ** 0.5) + 1):
        if num % i == 0:
            ret.append(i)
            if i != num // i:
                ret.append(num // i)
    return ret


div = sorted(enum_div(m), reverse=True)

for i in div:
    if m // n >= i:
        print(i)
        break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define IT set<node>::iterator
#define getchar nc
using namespace std;
inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read()
{
    register int x=0,f=1;register char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
    return x*f;
}
inline void write(register int x)
{
    if(!x)putchar('0');if(x<0)x=-x,putchar('-');
    static int sta[20];register int tot=0;
    while(x)sta[tot++]=x%10,x/=10;
    while(tot)putchar(sta[--tot]+48);
}
struct node
{
    int l,r;
    mutable int v;
    node(int L, int R=-1, int V=0):l(L), r(R), v(V) {}
    bool operator<(const node& o) const
    {
        return l < o.l;
    }
};
set <node> s;
IT split(int pos)
{
    IT it = s.lower_bound(node(pos));
    if (it != s.end() && it->l == pos) 
        return it;
    --it;
    int L = it->l, R = it->r, V = it->v;
    s.erase(it);
    s.insert(node(L, pos-1, V));
    return s.insert(node(pos, R, V)).first;
}
void assign_val(int l,int r,int val)
{
    IT itr=split(r+1),itl=split(l);
    s.erase(itl,itr);
    s.insert(node(l,r,val));
}
int n,m,ans; 
int main()
{
	n=read(),m=read();
	s.insert(node(1,n,1));
	for(register int i=1;i<=m;++i)
	{
		int l=read(),r=read();
		if(l!=1)
			assign_val(1,l-1,0);
		if(r!=n)
			assign_val(r+1,n,0);
	}
	IT itr=split(n+1),itl=split(1);
	for(;itl!=itr;++itl)
		ans+=itl->v*(itl->r-itl->l+1);
	write(ans);
	return 0;
}


Measured memory_bytes: 3456