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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

vector<ll> fct, inv;
void finit(int cmx, ll mod =MD){
	fct.resize(cmx+20); inv.resize(cmx+20);
	fct[0] = fct[1] = inv[1] = inv[cmx] = 1;
	for(int i=2;i<cmx+3;i++) fct[i] = fct[i-1] * i % mod;
	for(ll x=fct[cmx], n=mod-2; n > 0; n >>=1, x = x*x %mod)
		if(n & 1) inv[cmx] = inv[cmx] * x %mod;
	for(int i=cmx;i>=1;i--) inv[i-1] = inv[i] * i % mod;
}
ll nCk(ll n, ll k, ll mod =MD) {
	if(k > n || n <0 || k <0) return 0;
	ll ret =fct[n] * inv[k] % mod * inv[n-k] % mod;
	return ret;
}
int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	finit(n*2);
	ll ans = 0;
	rep2(i, 1, n+1){
		if(3*i > n) break;
		(ans  += nCk(n - 3*i + i -1 , i-1) ) %=MD;
	}
	cout <<ans <<"\n";
	return 0;
}



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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

int str2int(string s, map<char, int> &c_map) {
    int n = 0;

    REP(i, s.length()) {
        n |= c_map[s[i]] << (2 - i);
    }

    return n;
}

bool is_ok(string s, char c) {
    if (c == 'C') {
        if (s[0] == 'A') {
            if (s[1] == 'G' || s[2] == 'G') return false;
        } else {
            if (s.substr(1) == "AG") return false;
            if (s.substr(1) == "GA") return false;
        }
    }

    if (c == 'G') {
        if (s.substr(1) == "AC") return false;
    }

    return true;
}

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

    // +AG C
    // A+G C
    // AG+ C
    // +GA C
    // +AC G
    char c_list[] = {'A', 'C', 'G', 'T'};

    vector< map<string, ll>> dp;
    dp.assign(N-1, map<string, ll>());

    for (char c: c_list) {
        for (char d: c_list) {
            string s = " ";
            s += c;
            s += d;

            dp[0][s] = 1;
        }
    }

    REPS(i, N-2) {
        for(auto itr = dp[i-1].begin(); itr != dp[i-1].end(); ++itr) {
            string key = itr->first;
            ll value = itr->second;

            for (char c: c_list) {
                if (is_ok(key, c) == false) continue;

                string new_key = key + c;
                new_key = new_key.substr(1);

                dp[i][new_key] += dp[i-1][key];
                dp[i][new_key] %= MOD;
            }
        }
    }

    ll ans = 0;
    for(auto itr = dp[N-2].begin(); itr != dp[N-2].end(); ++itr) {
        ans += dp[N-2][itr->first];
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
    string S;
    cin >>S;
    vector<int>data(S.size()-2);
    for(int i=1;i<=S.size()-2;i++){
        int sannketa = (S[i-1]-'0')*100+(S[i]-'0')*10+(S[i+1]-'0');
        int sa=sannketa-753;
        if(sa<0)sa = -sa;
        data.at(i-1)=sa;
    }
    sort(data.begin(),data.end());
    cout <<data.at(0)<<endl;
}


Measured memory_bytes: 256
//要素の削除　https://riptutorial.com/ja/cplusplus/example/2156/%E8%A6%81%E7%B4%A0%E3%81%AE%E5%89%8A%E9%99%A4
/*回答の作り方　
(1)ある終了条件のifとreturn 0;
(2)別終了条件　else if,return 0;
(3)全体をwhile(1)でつなぐ,循環を構築するの3段階。
この循環手法はいろいろ応用が効く*/

#include <bits/stdc++.h>
using namespace std;
 
int main(){
 //各種カードを入力する。
  string A,B,C;
  cin>>A>>B>>C;

//カードの最初の指定方法
  char c=A[0];
  A.erase(0,1);
  while(1){
    if(c=='a'){
//カードがなくなったら
      if(A.size()==0){
        cout<<'A'<<endl;
//return 0で終了させる。
        return 0;
      }
//Aのカードを切る。while文なので循環をする。先頭のカードは、a,b,cのどれか。
      c=A[0]; A.erase(0,1);
    }else if(c=='b'){
//終了条件の書き方がポイント
      if(B.size()==0){
        cout<<'B'<<endl;
        return 0;
      }
//Bのカードを切る。
      c=B[0]; B.erase(0,1);
    }else{
      if(C.size()==0){
        cout<<'C'<<endl;
        return 0;
      }
      c=C[0]; C.erase(0,1); 
    }
  }
}


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

static const int NMAX = 100;

typedef struct _card {
    char mark;
    char value;
} card;

void print_cards(const int N, const card A[])
{
    for (int k=0; k < N-1; k++) cout << A[k].mark << A[k].value << " ";
    cout << A[N-1].mark << A[N-1].value << endl;
}

bool is_stable(const int N, const card A1[], const card A2[])
{
    for (int i=0; i < N; i++) {
        if (A1[i].mark != A2[i].mark) return false;
    }
    return true;
}

void bubbleSort(const int N, card A[])
{
    int flag = 1;

    while(flag) {
        flag = 0;
        for (int j=N-1; j > 0; j--) {
            if ( A[j].value < A[j-1].value ) {
                card tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                flag = 1;
            }
        }
    }
}

void selectSort(const int N, card A[])
{
    for (int i=0; i < N-1; i++) {
        int minj = i;
        for (int j = i+1; j < N; j++) {
            if ( A[j].value < A[minj].value ) {
                minj = j;
            }
        }
        if (minj != i) {
            card tmp = A[minj];
            A[minj] = A[i];
            A[i] = tmp;
        }
    }
}

int main (void) {

    int N;
    card A1[NMAX];
    card A2[NMAX];

    cin >> N;
    for (int i=0; i < N; i++) {
        cin >> A1[i].mark >> A1[i].value;
        A2[i] = A1[i];
    }

    bubbleSort(N, A1);
    selectSort(N, A2);

    print_cards(N, A1);
    cout << "Stable" << endl;
    print_cards(N, A2);
    if (is_stable(N, A1, A2)) {
        cout << "Stable" << endl;
    }
    else {
        cout << "Not stable" << endl;
    }
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
#define Maxn 100010
#define INF 1000000000

int n, Count;
long long a[Maxn], Tap, Res;
int main()
{
	scanf("%d", &n); Tap=INF;
	for (int i=1; i<=n; i++)
	{
		scanf("%lld", &a[i]);
		if (a[i]<0) Count++;
		Tap=min(Tap, abs(a[i]));
		Res+=abs(a[i]);
	}
	if (Count%2==1) Res-=(Tap*2);
	printf("%lld\n", Res);
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>

using namespace std;

void solve()
{
	stack<int> st;
	char ch[10];
	while(cin >> ch) {
		switch(ch[0]) {
			int tmp1, tmp2;
		case '-':
			tmp1 = st.top(); st.pop();
			tmp2 = st.top(); st.pop();
			st.push(tmp2 - tmp1);
			break;
		case '*':
			tmp1 = st.top(); st.pop();
			tmp2 = st.top(); st.pop();
			st.push(tmp1 * tmp2);
			break;
		case '+':
			tmp1 = st.top(); st.pop();
			tmp2 = st.top(); st.pop();
			st.push(tmp1 + tmp2);
			break;
		default:
			st.push(atoi(ch));
			break;
		}
	}
	cout << st.top() << endl;
}

int main()
{
	solve();
	return 0;
}


Measured memory_bytes: 3116
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  string S, T; cin >> S >> T;
  int ans = 0;
  for (int i = 0; i < S.length(); i++){
    if (S[i] != T[i]) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>

using namespace std;

int main(){
  int data[10];
  for(int i=0; i<10; i++)
    scanf("%d",data+i);
  sort(data,data+10,greater<int>());
  for(int i=0; i<3; i++)
    printf("%d\n",data[i]);
  return 0;
}

Measured memory_bytes: 0
def answer(a: str, b: str) -> str:
    if a == b:
        return 'EQUAL'

    if a < b or len(a) < len(b):
        return 'LESS'

    if a > b or len(a) > len(b):
        return 'GREATER'


def main():
    a = input()
    b = input()
    print(answer(a, b))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n,a; cin >> n >> a;
  REP(i,a+1) {
    if ((n-i) % 500 == 0) {
      COUT("Yes");
      return 0;
    }
  }
  COUT("No");
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        int max = 0;

        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            sum += num;
            max = Math.max(max, num);
        }

        System.out.println(max < sum-max ? "Yes" : "No");
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
using namespace std;

int n,m;
string s;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1=freopen("in","r",stdin);
    //stream2=freopen("out","w",stdout);
    if(stream1==NULL)return 0;
    //if(stream2==NULL)return 0;
#endif
    cin>>s;
    s[3]='8';
    cout<<s<<endl;
#ifdef LOCAL_DEFINE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    fclose(stream1);
    //fclose(stream2);
#endif
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = input()
N = len(S)

ans = 'Yes'

mid1 = (N - 1) // 2
mid2 = ((N + 3) // 2) - 1

one = S[:mid1]
two = S[mid2:]


if not(one == one[::-1] and two == two[::-1]):
    ans = 'No'

if not (S == S[::-1]):
    ans = 'No'

print(ans)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
	public static void main(String[] args) {
		//ABC086A(); 
		//ABC081A();
		TravelingPlan();
	}

	public static void ABC086A() {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if((a * b) % 2 == 0) {
			System.out.println("Even");
		}else {
			System.out.println("Odd");
		}
	}
	
	public static void ABC081A() {
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		char chr[] = str.toCharArray();
		int count = 0;
		for(int i = 0; i < 3; i++) {
			if(chr[i] == '1')
				count++;
		}
		System.out.println(count);
	}
	
	public static void TravelingPlan() {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] A = new int[N + 2];
		for(int i = 1; i < N + 1; i++) {
			A[i] = scan.nextInt();
		}
		A[0] = 0;
		A[N + 1] = 0;
		int ans = 0;
		
		for(int i = 1; i < N + 2; i++) {
			ans += Math.abs(A[i] - A[i - 1]);
		}

		for(int i = 1; i < N + 1; i++) {
			System.out.println(ans - Math.abs(A[i] - A[i - 1]) - Math.abs(A[i + 1] - A[i]) + Math.abs(A[i + 1] - A[i - 1]));
		}

	/*	
		for(int a = 0; a < N; a++) {
			int ans = 0;
			int pos = 0;
			for(int i = 0; i < N; i++) {
				if(i == a)
					continue;
				ans += Math.abs(A[i] - pos);
				pos = A[i];
			}
			if(a == N-1)
				ans += Math.abs(A[N-2]);
			else
				ans += Math.abs(A[N-1]);
			System.out.println(ans);
		}
		for(int i = 0; i < N; i++) {
			System.out.println(ans - A[i]);
		}
	*/
	}
}

Measured memory_bytes: 64188
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main() {
  int q = in();
  list<int> l;
  auto it = l.begin();
  while (q--) {
    int c = in();
    if (c == 0) it = l.emplace(it, in());
    if (c == 1) advance(it, in());
    if (c == 2) it = l.erase(it);
  }
  for (auto &x : l) cout << x << endl;
}



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

using namespace std;

int main(){
    long long n;
    cin >> n;
    long long ans = 0, rans = INT_MAX;
    for(long long i = 1; i <= sqrt(n); ++i){
        if(n % i == 0){
            ans = max(i, n / i);
            rans = min(rans, ans);
        }
    }
    string s = to_string(rans);
    cout << s.length();
    return 0;

}


Measured memory_bytes: 384
import itertools
N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]
tmp = list(itertools.permutations(list(range(N)),N))
length = []
for i in range(len(tmp)):
    tmplen = 0
    for j in range(N-1):
        tmplen += ((xy[tmp[i][j]][0]-xy[tmp[i][j+1]][0])**2+(xy[tmp[i][j]][1]-xy[tmp[i][j+1]][1])**2)**(1/2)
    length.append(tmplen)
print(sum(length)/len(length))

Measured memory_bytes: 9332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
#define int long long
const double PI = 3.141593;
const ll MOD = 1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
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;}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r){if (r * 2 > n)r = n - r;ll dividend = 1;ll divisor = 1;for (ll i = 1; i <= r; ++i){dividend *= (n - i + 1);divisor *= i;}return dividend / divisor;}


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

    int a, b;
    cin >> a >> b;
    if(a==1&&b==2||a==2&&b==1){
        cout << 3 << endl;
    }
    else if(a==2&&b==3||a==3&&b==2){
        cout << 1 << endl;
    }
    else{
        cout << 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef unsigned long ul;
typedef unsigned int ui;
const ul INF = 1LL<<60;

// O(1)
long N,Y,x,y,z,mod,lower,upper;
inline void solve3(){
  IN2(N,Y);
  Y/=1000;
  mod=Y%5;
  // cout<<"mod:"<<mod<<endl;
  lower=ceil((double)(5*N-Y)/4.0);
  upper=floor((double)(10*N-Y)/9.0);
  // cout<<"lower:"<<lower<<endl;
  // cout<<"upper:"<<upper<<endl;
  if(lower>=0)z=lower+abs(mod-lower%5);
  else if(upper>=mod)z=mod;
  else {
    OUT3(-1,-1,-1);
    return;
  }
  if(z<0||z>min(N,Y)||z>upper){
    OUT3(-1,-1,-1);
    return;
  }
  x=(Y+4*z-5*N)/5;
  y=(10*N-9*z-Y)/5;
  if(x<0||y<0||x>N||y>N)OUT3(-1,-1,-1);
  else OUT3(x,y,z);
}

// O(N)
// long N,Y,x,y,z,t;
// inline void solve2(){
//   IN2(N,Y);
//   REP(x,N+1){
//     t=5000*(N-x)-(Y-10000*x);
//     if(t%4000)continue;
//     z=t/4000;
//     if(z<0||z>N)continue;
//     y=N-x-z;
//     if(y<0||y>N)continue;
//     OUT3(x,y,z);
//     return;
//   }
//   OUT3(-1,-1,-1);
// }

// O(N^2)
// long N,Y,x,y,z;
// inline void solve(){
//   IN2(N,Y);
//   REP(x,N+1)REP(y,N-x+1){
//     z=N-x-y;
//     if(z<0)break;
//     if(10000*x+5000*y+1000*z==Y){
//       OUT3(x,y,z);
//       return;
//     }
//   }
//   OUT3(-1,-1,-1);
// }

int main(int argc,char**argv){
  BEGIN;
  solve3();
  END;
}


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    ll n, i;
    ump<ll , ll>mp;
    cin >> n;
    ll m1 = 0;
    rep(i,0,n){
        ll x;
        cin >> x;
        if(x == 1)m1++;
        ll j;
        if(x % 2 == 0){
            mp[2]++;
            while(x%2 == 0)x /= 2;
        }
        for(j = 3; j <= sqrt(x); j += 2){
            if(x % j == 0){
                mp[j]++;
                while(x % j == 0)x /= j;
            }
        }
        if(x > 2){
            mp[x]++;
        }
    }
    ll ans = 0;
    for(auto p : mp)ans = max(ans,p.ss);
    if(ans == 1 or m1 == n){
        cout << "pairwise coprime" << nl;
        return;
    }
    if(ans < n){
        cout << "setwise coprime" << nl;
        return;
    }
    cout << "not coprime" << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


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


int main()
{
	int n;
	string str[] = {"AC", "WA", "TLE", "RE"}, input;
	cin >> n;

	int hash[4] = {0};

	register int i;

	while (n--)
	{
		cin >> input;

		for (i = 0; i < 4; i++)
		{
			if (str[i] == input)
				hash[i]++;
		}

	}

	for (i = 0; i < 4; i++)
	{
		cout << str[i] << " x " << hash[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 3632
class UnionFind:
    def __init__(self, n=0):
        self.d = [-1]*n
    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.d[x]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def size(self, x):
        return -self.d[self.find(x)]


n, m = map(int, input().split())
uf = UnionFind(n)

for _ in range(m):
    a, b = map(int, input().split())
    uf.unite(a-1, b-1)

ans = 0
for i in range(n):
    ans = max(ans, uf.size(i))

print(ans)

Measured memory_bytes: 14376
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin >>N;
     vector<int> A(N);
   for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
    int a=0;
  int b=0;
  for (int i = 0; i < N; i++) {
  if(i%2==0){
    a +=A[i];
  }
  else{
    b +=A[i];
  }
  }
  cout << a-b<<endl;
}

Measured memory_bytes: 256
MOD = 998244353


def solve(s, k):
    one_count = []
    ones = 0
    for st in s:
        if st == "1":
            ones += 1
        else:
            one_count.append(ones)
            ones = 0
    one_count.append(ones)
    ss = sum(one_count)
    # print(ss)
    m = len(one_count)
    dp = [[[0] * (ss + 1) for _ in range(ss + 1)] for __ in range(m + 1)]
    dp[0][0][0] = 1
    for i in range(m):
        c = one_count[i]
        for j in range(ss + 1):
            for p in range(ss + 1):
                dp[i][j][p] %= MOD
                for q in range(ss + 1 - max(j, p)):
                    dp[i + 1][j + q][p + q] += dp[i][j][p]
                for q in range(-c, 0):
                    if j + q >= 0:
                        dp[i + 1][j + q][p] += dp[i][j][p]

    # print(dp)
    res = sum([dp[m][0][p] for p in range(min(k + 1, ss + 1))])
    # print(res)
    return res % MOD


def main():
    s, k_ = input().split()
    k = int(k_)
    res = solve(s, k)
    print(res)


def test():
    assert solve("0101", 1) == 4
    assert solve("01100110", 2) == 14
    assert solve("1101010010101101110111100011011111011000111101110101010010101010101", 20) == 113434815


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 101924
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	if(n<10){
		cout<<m+100*(10-n)<<endl;
	}
	else{
		cout<<m<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pr(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
#define BLACK 0
#define WHITE 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;



int main(void) {
    ll N;
    cin >> N;
    ll i, j;
    string s[MAX];
    ll cnt[5]={};
    
    for(i=0; i<N; i++) {
        cin >> s[i];
        
        if(s[i][0]=='M') cnt[0]++;
        if(s[i][0]=='A') cnt[1]++;
        if(s[i][0]=='R') cnt[2]++;
        if(s[i][0]=='C') cnt[3]++;
        if(s[i][0]=='H') cnt[4]++;
        
    }
    
    ll ans=0;
    
    for(i=0; i<1<<5; i++) {
        ll c=0;
        ll t=1;
        for(j=0; j<5; j++) {
            if(i>>j&1) {
                c++;
                t*=cnt[j];
            }
        }
        
        if(c==3) {
            ans+=t;
        }
        
    }
    
    pr(ans);
    
}






















Measured memory_bytes: 6144
n, m = [int(i) for i in input().split()]
e = [[] for _ in range(n)]
for _ in range(m):
    a, b = [int(i) - 1 for i in input().split()]
    e[a].append(b)
    e[b].append(a)
ans = [-2] * n
ans[0] = -1
q = [0]
for i in q:
    for j in e[i]:
        if ans[j] == -2:
            q.append(j)
            ans[j] = i
if - 2 in ans:
    print("No")
else:
    print("Yes")
    for i in ans[1:]:
        print(i+1)


Measured memory_bytes: 35164
n = gets.to_i
s = gets.chomp

if n % 2 == 0
  str1 = s[0..n/2-1]
  str2 = s[(n/2)..(n-1)]
  if str1 == str2
    puts 'Yes'
  else
    puts 'No'
  end
else
  puts 'No'
end

Measured memory_bytes: 1788
package main

import (
  "fmt"
  "strconv"
)

func main() {
  var S, str_count string
  fmt.Scan(&S)

  s_first := S[0:1]
  s_count := len(S) - 2
  s_last := S[s_count + 1:s_count + 2]
  str_count = strconv.Itoa(s_count)
  s := s_first + str_count + s_last
  fmt.Println(s)
}

Measured memory_bytes: 512
#include <stdio.h>

void main(void){
  int n=0,i;
  
  long N,D,X[200000],Y[200000];
  
  scanf("%ld %ld",&N,&D);
  
  for(i=0;i<N;i++){
    scanf("%ld %ld",&X[i],&Y[i]);
    if(X[i]*X[i]+Y[i]*Y[i]<=D*D)
      n+=1;
  }
  
  printf("%d\n",n);
}

Measured memory_bytes: 4856
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

bool chk(ll i, vector<int> &v){
  vector<bool> c(3, false);
  while(i != 0){
    int n = i % 10;
    rep(j, 3){
      if(v.at(j) == n) c.at(j) = true;
    }
    i /= 10;
  }
  rep(j, 3){
    if(c.at(j) == false) return false;
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  queue<pair<ll, bool>> q;
  q.push(make_pair(3, false));
  q.push(make_pair(5, false));
  q.push(make_pair(7, false));
  int ans = 0;
  vector<int> v = {3, 5, 7};
  while(!q.empty()){
    auto p = q.front(); q.pop();
    bool f = true;
    if(p.second == false){
      f = chk(p.first, v);
    }
    if(p.first <= n && f == true) ans++;
    p.first *= 10;
    rep(i, 3){
      if(p.first + v.at(i) > n) continue;
      q.push(make_pair(p.first+v.at(i), f));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define GODSPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;
int add(int a,int b){return (a%mod + b%mod)%mod;}
int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a,int b){return (a%mod * b%mod)%mod;}
int power(int a,int b,int MOD){int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
signed main()
{
    GODSPEED;
    int n,k;
    cin>>n>>k;
    vector<int>digits(10,0);
    for(int i=0;i<k;i++)
    {
         int d;
         cin>>d;
         digits[d]++;
    }
    for(int i=n;;i++)
    {
          int x=i;
          bool okay=false;
          while(x>0)
          {
              int d=x%10;
              if(digits[d]!=0)
              {
                  okay=true;
                  break;
              }
              x/=10;
          }
          if(okay)
            continue;
          cout<<i<<endl;
          return 0;

    }
}

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

const int MOD = 1e9 + 7;

int main() {
    int N, M, a;
    cin >> N >> M;
    vector<bool> ok(N+1, true);
    rep(i, M) {
        cin >> a;
        ok[a] = false;
    }

    vector<int> dp(N+1);
    dp[0] = 1;
    rep(i, N) {
        for (int j = i+1; j <= min(i+2, N); j++) {
            if (ok[j]) {
                dp[j] += dp[i];
                dp[j] %= MOD;
            }
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var;



int main() {
	
	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
	
	int N; std::cin >> N;
	std::set<char> s;
	rep(i, N) {
		char tmp; std::cin >> tmp;
		s.insert(tmp);
	}
	if (s.size() == 3)std::cout << "Three";
	else std::cout << "Four";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

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

using P = pair<long,long>; 
vector<P> G[100010];
bool used[100010];
int color[100010];
long N;

void dfs(long i,long d) {
  if ((d % 2 == 0)) color[i] = 0;
  else            color[i] = 1;
  used[i] = true;

  rep(j,G[i].size()) {
    P v = G[i][j];
    if (!used[v.first]) {
      dfs(v.first,v.second + d);
    }
  }
}
int main(void) {

  cin >> N;

  rep(i,N-1) {
    long u,v,w;
    cin >> u >> v >> w;
    u--;v--;
    G[u].push_back(P(v,w));
    G[v].push_back(P(u,w));
  }

  dfs(0,0);

  rep(i,N) {
    cout << color[i] <<  endl;
  }
  return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RFOR(i, a, b) for(int i = a; i >= b; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 1e9;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
int main() {
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    s[k-1] = tolower(s[k-1]);
    cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define mp make_pair
const int mod=1e9+7;
string convert(ll A)
{
  string ans="";
    while(A>0)
    {
        int x=(A-1)%26;
        ans+=x+'a';
        A=(A-1)/26;
    }
    reverse(ans.begin(),ans.end());
    return ans;
}

void solve()
{
  ll n;
  cin>>n;
  cout<<convert(n)<<endl;
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3668
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int a[100];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	sort(a, a + N);
	cout << a[N - 1] - a[0] << endl;
}

Measured memory_bytes: 256
void main() {
	auto S = rs;
	auto A = S[0..2].to!int;
	auto B = S[2..4].to!int;
	bool YYMM = 0 <= A && A <= 99 && 0 < B && B <= 12;
	bool MMYY = 0 <= B && B <= 99 && 0 < A && A <= 12;
	if(YYMM && MMYY) writeln("AMBIGUOUS");
	else if(YYMM) writeln("YYMM");
	else if(MMYY) writeln("MMYY");
	else writeln("NA");
}
// =======================111=1===========

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.ascii : toLower;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}

T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll INF = 5e15;
vector<vector<ll>> dp(110, vector<ll>(1e5 + 10, INF));
int main(){
    ll N, W;
    cin >> N >> W;
    for(ll i = 0; i <= N; i++) dp[i][0] = 0;
    for(ll i = 0; i < N; i++){
        ll w, v;
        cin >> w >> v;
        for(ll pre = 0; pre <= dp[i + 1].size(); pre++){
            dp[i + 1][pre] = dp[i][pre];
            if(pre >= v && dp[i][pre - v] < INF) dp[i + 1][pre] = min(dp[i + 1][pre], dp[i][pre - v] + w);
        }
    }
    ll ans = 0;
    for(ll i = 0; i < dp[N].size(); i++) if(dp[N][i] <= W) ans = i;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 87296
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	static class Word implements Comparable<Word>{
		String word;
		int cnt;

		Word(String word) {
			this.word = word;
			cnt = 1;
		}

		public int compareTo(Word o) {
			return o.cnt == this.cnt ? this.word.compareTo(o.word) : o.cnt - this.cnt;
		}
	}

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

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			sc.nextLine();
			String str[][] = new String[n][];
			for (int i = 0; i < n; i++) {
				str[i] = sc.nextLine().split(" ");
			}

			char cc[] = sc.nextLine().toCharArray();
			int c = cc[0];

			Word w[] = new Word[600 * n];
			LinkedList<String> list = new LinkedList<String>();
			int id = 0;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < str[i].length; j++) {
					if (str[i][j].charAt(0) == c) {
						if (!list.contains(str[i][j])) {
							list.add(str[i][j]);
							w[id] = new Word(str[i][j]);
							id++;
						} else {
							for (int k = 0; k < id; k++) {
								if (w[k].word.equals(str[i][j])) {
									w[k].cnt++;
									break;
								}
							}
						}
					}
				}
			}

			Arrays.sort(w, 0, id);
			if (id == 0) {
				System.out.println("NA");
			} else {
				String s = "";
				for (int i = 0; i < 5 && i < id; i++) {
					System.out.print(s + w[i].word);
					s = " ";
				}
				System.out.println();
			}
		}
	}
}

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

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

    cout << fixed << setprecision(12);

    vector<double> x(3), y(3), z(3);
    rep(i, 0, 3) cin >> x[i] >> y[i];

    rep(i, 0, 3) {
        z[i] = pow(x[(i + 1) % 3] - x[(i + 2) % 3], 2) +
               pow(y[(i + 1) % 3] - y[(i + 2) % 3], 2);
        z[i] = sqrt(z[i]);
    }

    double ix = 0.0, iy = 0.0, ans = 0.0;
    rep(i, 0, 3) {
        ix += x[i] * z[i];
        iy += y[i] * z[i];
    }
    ix /= (z[0] + z[1] + z[2]);
    iy /= (z[0] + z[1] + z[2]);

    rep(i, 0, 3) {
        double a, b, c, l;
        a = y[(i + 2) % 3] - y[(i + 1) % 3];
        b = -x[(i + 2) % 3] + x[(i + 1) % 3];
        c = -a * x[(i + 2) % 3] - b * y[(i + 2) % 3];
        l = abs(a * ix + b * iy + c) / sqrt(a * a + b * b);
        ans = max(ans, z[i] * l / (2 * l + z[i]));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
 typedef long long ll;
 
 void reader()
 {
 #ifndef ONLINE_JUDGE 
 freopen("input.txt","r",stdin);
 freopen("output.txt","w",stdout); 
 #endif
 }
 
 void fastIO()
 {ios_base::sync_with_stdio(false);cin.tie(NULL);}
 
 int main()
 {
 	reader();
 	fastIO();
 	long long int t=1;
 	//cin>>t;
 	while(t--)
 	{
 			int n;
 			cin>>n;
 			if(n%1000)
 			cout<<1000-(n%1000);
 		else
 			cout<<0;
 	}
 return 0;
 }

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <fstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


typedef  long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;


#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N=2e5+5;
ll mod=1e9+7;

ll mul (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll add (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a+b+mod)%mod;
}
ll fastpow(ll b, ll p)
{
    if(p==0)
        return 1;
    ll ans=fastpow(b,p/2);
    ans=mul(ans,ans);
    if(p%2)ans=mul(ans,b);
    return ans;
}
int n,k;
ll solve(deque<ll>&qq)
{
    ll ans=0;

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


            deque<ll>q=qq;
            priority_queue<int,vector<int>,greater<int>>pq;
            int co=k;
            for(int x=0; x<i&&q.size(); x++)
            {
                co--;
                pq.push(q.front());
                q.pop_front();
            }
            for(int x=0; x<j&&q.size(); x++)
            {
                co--;
                pq.push(q.back());
                q.pop_back();
            }
            if(co<0)
            {
                continue;
            }
            while(co>0&&pq.size())
            {
                if(pq.top()<0)
                    pq.pop();
                else
                    break;
                co--;

            }
            if(co<0)
                continue;
            ll total=0;
            while(pq.size())
                total+=pq.top(),pq.pop();
          ///  cout<<"i= "<<i<<" j= "<<j<<" total= "<<total<<endl;
            ans=max(ans,total);
        }

    }


    return ans;
}

int main()
{
    FIO
    cin>>n>>k;
    deque<ll>q1,q2;
    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;
        q1.push_back(x);
        q2.push_front(x);
    }
    cout<<max(solve(q1),solve(q2));


    return 0;
}



Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int dist[101][101];
signed main() {
    REP(i,101) REP(j,101) dist[i][j]=INF,dist[i][i]=0;
    int n,m;
    cin>>n>>m;
    vector<vector<int>> edges(m);
    REP(i,m) {
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        dist[a][b]=dist[b][a]=c;
        edges[i]={a,b,c};
    }
    REP(i,n) REP(j,n) REP(k,n) chmin(dist[j][k],dist[j][i]+dist[i][k]);
    int ans=0;
    REP(i,m) {
        int a=edges[i][0];
        int b=edges[i][1];
        int c=edges[i][2];
        bool used=0;
        REP(i,n) {
            REP(j,n) {
                if(dist[i][a]+c+dist[b][j]==dist[i][j]) {
                    used=1;
                }
            }
        }
        if(!used) {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll h, w;
  cin >> h >> w;
  ll ans = 1ll<<60;
  FOR(i, 1, h){
    ll d = h-i;
    ll a = w*i;

    ll b = (w+1)/2 * d;
    ll c = w/2 * d;
    ll mx = max(a, max(b, c));
    ll mn = min(a, min(b, c));
    chmin(ans, mx-mn);

    if(d < 2) continue;
    b = (d+1)/2 * w;
    c = d/2 * w;
    mx = max(a, max(b, c));
    mn = min(a, min(b, c));
    chmin(ans, mx-mn);
  }

  FOR(i, 1, w){
    ll d = w-i;
    ll a = h*i;

    ll b = (h+1)/2 * d;
    ll c = h/2 * d;
    ll mx = max(a, max(b, c));
    ll mn = min(a, min(b, c));
    chmin(ans, mx-mn);

    if(d < 2) continue;
    b = (d+1)/2 * h;
    c = d/2 * h;
    mx = max(a, max(b, c));
    mn = min(a, min(b, c));
    chmin(ans, mx-mn);
  }
  cout << ans << endl;
  return 0;
}

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

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

int t_sosu(int n){
	int count = 0;
	int total = 0;
	for(int i = 2; count < n; i++){
		if(is_sosu(i)){
			count++;
			total += i;
		}
	}
	return total;
}

int main(){
	int n;
	while(cin >> n){
		if(n == 0) break;
		cout << t_sosu(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 868
MOD=10**9+7
cnt=0; sum=0; prev=nil; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n, m = gsmi
a = gsmi.sort

#half = []
while m>0 do
  tar = a.pop/2
  m-=1
  idx = a.bsearch_index{|x|x>=tar}
  if idx.nil?
    tar = tar/2
    m-=1
  else
    num = a.size - idx
    min = min(m,num)
    min.times do |i|
      a[a.size-i-1]/=2
    end
    m -= min
  end
  a << tar
  a.sort!
end

puts a.inject(:+).to_i


Measured memory_bytes: 11272
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
int n,a[60];
const int mod=1000000007;
char s[2][60];
ll ans;
int main()
{
	scanf("%d",&n);
	scanf("%s",s[0]+1);
	scanf("%s",s[1]+1);
	int pnt=0,t=0;
	for(int i=1;i<=n-1;i++)	
	{
		if(s[0][i]!=s[0][i+1]) a[++pnt]=t,t=0;
		else t++;
	}	
	a[++pnt]=t;
	ans=1;
	for(int i=2;i<=pnt;i++)
		if(a[i-1]==0) ans=ans*2%mod;
		else if(a[i]==1) ans=ans*3%mod;
	ans=ans*(a[1]*3+3)%mod;
	printf("%lld",ans);	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int n;
    scanf("%d", &n);
    vector<int> dp(3);
    // dp[i] - the total cost such that we did activity i on the last considered day
    for (int day = 0; day < n; ++day) {
		vector<int> new_dp(3, 0);
		vector<int> c(3);
		for (int i = 0; i < 3; ++i) {
			scanf("%d", &c[i]);
		}
		// int a, b, c - a lot of implementation
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 3; ++j) {
				if (i != j) {
					new_dp[j] = max(new_dp[j], dp[i] + c[j]);
				}
			}
		}
		dp = new_dp;
	}
	printf("%d\n", max({dp[0], dp[1], dp[2]}));
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3820
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<queue>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;
const ll BIG = 1000000007;

int N;
int K;

int kake(int i) {
	if (i >= K) { return 0; }
	else return kake(2 * i) + 1;
}

double pos(int n) {
	if (n == 0) { return 1; }
	if (n % 2 == 1) { return 0.5*pos(n - 1); }
	if (n % 2 == 0) { return pos(n / 2)*pos(n / 2); }

}



int main() {

	cout << fixed << setprecision(10);

	cin >> N >> K;

	double ans = 0;

	for (int i = 1; i <= N; i++) {
		ans += pos(kake(i))/N;
	}

	cout << ans;

	
	
	system("PAUSE");
}

Measured memory_bytes: 504
#include<iostream>
#include<string>
#include<vector>

using namespace std;

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

	for (int i = 0; i < 19; i++)
	{
		if (str[i] == ',')
			cout << " ";
		else cout << str[i];
	}
	cout << "\n";
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N,M = map(int,input().split())

#cが多い
if 2*N < M:
    ans = N
    ans += (M - 2*N)//4
else:
#Sが多い
    ans = M//2
print(ans)


Measured memory_bytes: 6216