akhauriyash/Code-Regression huggingface dataset:
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
  int n = readln.chomp.to!int;
  long[] a = readln.chomp.split.map!(to!long).array;
  long sum = a.sum - a.front;
  long sub = a.front;
  long ans = abs(sum - sub);
  foreach (v; a[1..$-1]) {
    sum -= v;
    sub += v;
    ans = min(ans, abs(sum - sub));
  }
  ans.writeln;
}


Measured memory_bytes: 11136
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

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

int main() {
  long a, b;
  scanf("%ld %ld", &a, &b);
  long g = gcd(a, b);
  printf("%ld\n", a*b/g);
  return 0;
}


Measured memory_bytes: 128
import Control.Applicative
import Control.Monad

main = do
    n <- read<$>getLine
    if n == 0
       then return ()
       else do
           cards <- map (map read.words)<$>replicateM n getLine :: IO [[Int]]
           putStrLn $ unwords.map show.foldl countPoint [0,0] $ cards
           main

countPoint :: [Int] -> [Int] -> [Int]
countPoint [a,b] [a1,b1]
  | a1 > b1 = [a + a1+b1, b]
  | a1 < b1 = [a, b + a1+b1]
  | a1 == b1 = [a+a1, b+b1]

Measured memory_bytes: 8160
#include <bits/stdc++.h>
using namespace std;
 
typedef int i;
typedef long double d;
typedef pair<d,d> pd;
d PI = M_PI;
int main(){
    i minArmLength ,hourArmLength ,hours,minutes;
    cin >> hourArmLength >> minArmLength >> hours >> minutes;
 
    d minuteElapsed = hours*60+minutes;
    d hoursAngle =(double)minuteElapsed/60/12.0*360.0;
    d minutesAngle = (double)minutes/60.0*360.0;
 
    pd hoursPosition = {sin(PI*hoursAngle/180)*hourArmLength,cos(PI*hoursAngle/180)*hourArmLength};
    pd minutesPosition = {sin(PI*minutesAngle/180)*minArmLength ,cos(PI*minutesAngle/180)*minArmLength};
 
    d distance = sqrt(pow(hoursPosition.first-minutesPosition.first,2)+pow(hoursPosition.second-minutesPosition.second,2));
    cout << setprecision(30) << distance << '\n';
    return 0;
}

Measured memory_bytes: 4156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> p(A), q(B), r(C);
    REP(i, A) cin >> p[i];
    REP(i, B) cin >> q[i];
    REP(i, C) cin >> r[i];
    sort(p.begin(), p.end(), std::greater<ll>());
    sort(q.begin(), q.end(), std::greater<ll>());
    sort(r.begin(), r.end(), std::greater<ll>());
    vector<ll> ps(A, p[0]), qs(B, q[0]), rs(C, r[0]);
    REP(i, A-1) ps[i+1] = ps[i] + p[i];
    REP(i, B-1) qs[i+1] = qs[i] + q[i];
    REP(i, C-1) rs[i+1] = rs[i] + r[i];

    vector<P> v(A+B+C);
    REP(i, A) v[i] = P(0, p[i]);
    REP(i, B) v[i+A] = P(1, q[i]);
    REP(i, C) v[i+A+B] = P(2, r[i]);
    sort(v.begin(), v.end(), [](P x, P y) { return x.second > y.second;});

    ll ans = 0;
    ll xcount = 0, ycount = 0, count = 0;
    ll i = 0, j = 0, k = 0;
    for(ll i = 0; count < X + Y; i++){
        auto tmp = v[i];
        if (tmp.first == 0 && xcount < X){
            xcount++;
            count++;
            ans += tmp.second;
        }else if (tmp.first == 1 && ycount < Y){
            ycount++;
            count++;
            ans += tmp.second;
        }else if (tmp.first == 2){
            count++;
            ans += tmp.second;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9600
import math
from functools import reduce
def gcd(*nums):
    return reduce(math.gcd, nums)

K = int(input())
s = 0

for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(b, K+1):
            if b == c:
                s += gcd(a, b, c)
            else:
                s += 2*gcd(a, b, c)
print(s)

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

char p[128]={};
ll f() {
	stack<char> st;
	string r = "";
	for(auto c: s)
		if(isdigit(c)) r += c;
		else {
			while(st.size()&&p[st.top()]>=p[c]) {
				r += st.top(); st.pop();
			}
			st.push(c);
		}
	while(st.size()) { r += st.top(); st.pop(); }
	stack<ll> a;
	for(auto c: r)
		if(isdigit(c)) a.push(c-'0');
		else {
			ll x = a.top(); a.pop();
			ll y = a.top(); a.pop();
			a.push(c == '*' ? x * y : x + y);
		}
	return a.top();
}

int main() {
	ll ans;
	cin >> s >> ans;
	p['+']=1; p['*']=2; ll a1 = f();
	p['+']=1; p['*']=1; ll a2 = f();
	if(a1==ans&&a2==ans)puts("U");
	else if(a1==ans) puts("M");
	else puts(a2 == ans ? "L" : "I");
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n, i;
    cin >> n >> i;
    cout << n -i + 1 << endl;
}

Measured memory_bytes: 256
from collections import defaultdict

MOD = int(1e9) + 7


def main():
    N = int(input())
    C = [int(input()) for _ in range(N)]
    dp = [1] * (N+1)
    last = defaultdict(lambda: -1)
    for i in range(N):
        c = C[i]
        if last[c] != -1 and last[c] != i-1:
            dp[i+1] = (dp[i] + dp[last[c]+1]) % MOD
        else:
            dp[i+1] = dp[i]
        last[c] = i
    print(dp[N])


if __name__ == "__main__":
    main()


Measured memory_bytes: 81496
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val N = sc.nextInt
  val A = Array.fill(N)(sc.nextLong)

  var money = 1000L
  var stock = 0L
  val a = A.foldLeft(Seq.empty[Long])((z, x) => {
    if (z.nonEmpty && x == z.head) z
    else if (z.size >= 2 && z.head > z(1) && x > z.head) x +: z.tail
    else if (z.size >= 2 && z.head < z(1) && x < z.head) x +: z.tail
    else x +: z
  }).reverse

  val b = a.sliding(2).map(x => x.head < x.last).toSeq
  for (i <- b.indices) {
    if (b(i)) {
      stock += money / a(i)
      money -= stock * a(i)
    } else {
      money += stock * a(i)
      stock = 0
    }
  }

  money += stock * a.last
  stock = 0

  println(money)
}


Measured memory_bytes: 58084
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

N, i = nm()
print(1 if N == 1 else N - i + 1)

Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

void _main() {
  int n;
  cin >> n;
  int a[4];

  rep(i, 0, 4) {
    a[4-1-i] = n%10;
    n /= 10;
  }

  int op[2] = {1, -1};
  int ans_op[3];
  rep(i, 0, 2) rep(j, 0, 2) rep(k, 0, 2) {
    if (7 == a[0] + a[1]*op[i] + a[2]*op[j] + a[3]*op[k]) {
      ans_op[0]=op[i], ans_op[1]=op[j], ans_op[2]=op[k];
    }
  }

  cout << a[0];
  rep(i, 0, 3) {
    char op = (1 == ans_op[i]) ? '+' : '-';
    cout << op << a[i+1];
  }
  cout << "=7" << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 2000000000;

int a;

int main(){
  cin >> a;
  if(a<1200) cout<<"ABC"<<endl;
  else cout<<"ARC"<<endl;
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
import sys
def I():
    # 1 line 1 int
    return int(sys.stdin.readline().rstrip())
def LI():
    # 1 line n ints
    return list(map(int,sys.stdin.readline().rstrip().split()))
def S():
    # 1 line 1 string
    return sys.stdin.readline().rstrip()
def LS():
    # 1 line n strings
    return list(sys.stdin.readline().rstrip().split())

A = S()

if A[0] == A[1] == A[2] or A[1] == A[2] == A[3]:
   print("Yes")
else:
   print("No")




Measured memory_bytes: 9948
N,Q = list(map(int,input().split()))
S = input()
sums = [0]
for i in range(len(S)):
	if i == 0:
		continue
	sums.append(sums[i-1])
	if S[i-1]+S[i] == 'AC':
		sums[i] += 1

for i in range(Q):
	f,t = list(map(int,input().split()))
	print(sums[t-1]-sums[f-1])

Measured memory_bytes: 6220
#pragma GCC optimize("O2") 

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

typedef long long int ll;
typedef unsigned long long int ull;

#define test(t)		int t; cin>>t; while(t--)
#define f(i, a, b)	for(int i = a; i < b; ++i)
#define all(a)		a.begin(), a.end()
#define endl 		"\n"
#define deb(x)		cout << #x << "--" << x << "--" << endl;
#define deb2(x,y)	cout << #x << "-" << x << "-" << " ~~ " <<  #y << "-" << y << "-" << endl;
#define deb3(x,y,z)	cout << #x << "-" << x << "-" << " ~~ " <<  #y << "-" << y << "-" << " ~~ " << #z << "-" << z << "-" << endl;
#define deba(arr)	cout << #arr << " ~ [ "; for(auto n: arr) cout << n << " "; cout << "]" << endl;
#define fast 		ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define mx9		1000000007
#define mx7		10000007
#define mx6		1000006
#define mx5		200005
#define inf		1<<30                                 
#define eps		1e-9
#define mod		1000000007
#define PI		3.141592653589793238462643383279502884L

void solve()
{
  int m, n;
  cin >> m >> n;
  cout << m * n << endl;
}

int main()
{
    fast;
    //test(t)
        solve();
    return 0;
}

Measured memory_bytes: 3652
import sys
input = sys.stdin.readline
import numpy as np
from numba import njit


def read():
    N = int(input().strip())
    XYP = np.empty((N, 3), dtype=np.int32)
    for i in range(N):
        XYP[i] = np.fromstring(input().strip(), sep=" ")
    return N, XYP


@njit
def solve(N, XYP, INF=10**18):
    ans = np.full(N+1, INF, dtype=np.int64)
    vcost = np.zeros((2**N, N), dtype=np.int32)
    hcost = np.zeros((2**N, N), dtype=np.int32)

    # check 2**N pairs
    for intptn in range(2**N):
        for i in range(N):
            xi, yi, pi = XYP[i]
            v = abs(xi)
            h = abs(yi)
            for j in range(N):
                xj, yj, pj = XYP[j]
                if (intptn >> j) & 1 == 1:
                    v = min(v, abs(xj-xi))
                    h = min(h, abs(yj-yi))
            vcost[intptn, i] += v
            hcost[intptn, i] += h

    # check 3**N pairs
    for intptn in range(3**N):
        # split into two 2**N pairs
        p, intvptn, inthptn = intptn, 0, 0
        u = 0
        for i in range(N):
            if p % 3 == 1:
                intvptn += 1 << (N-i-1)
                u += 1
            elif p % 3 == 2:
                inthptn += 1 << (N-i-1)
                u += 1
            p //= 3
        s = 0
        for i in range(N):
            s += min(vcost[intvptn, i], hcost[inthptn, i]) * XYP[i, 2]
        ans[u] = min(ans[u], s)
    
    return ans


if __name__ == '__main__':
    inputs = read()
    ans = solve(*inputs)
    for a in ans:
        print(a)


Measured memory_bytes: 121168
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;


int main(){
   ll X,Y; cin >> X >> Y;
   cout << ((abs(X-Y) <= 1) ? "Brown" : "Alice") << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const ll INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n;
    cin >> n;
    ll c=0;
    for (ll i=1;i<=n;i++){
        c+=i;
        if (c>=n){
            for (ll j=1;j<=i;j++){
                if (j==c-n){
                    continue;
                }
                cout << j << endl;
            }
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,w;
    cin >> n >> w;
    vi wei(n),v(n);
    rep(i,n) cin >> wei[i] >> v[i];
    vector<vector<ll>> dp(110,vector<ll>(110000,LINF));
    dp[0][0] = 0;
    rep(i,n){
        rep(j,100100){
            if(j - v[i] >= 0){
                dp[i+1][j] = min(dp[i+1][j],dp[i][j-v[i]] + wei[i]);
            }
            dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
        }
    }
    ll ans = 0;
    rep(i,101000){
        if(dp[n][i] <= w){
            ans = max(ans,(ll)i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 95744
#include <iostream>
using namespace std;
int main() {
    char grid[51][51];
    int h = 0;
    int w = 0;
    int hcount = 0; //縦に#つづいてるのか
    int wcount = 0; //横に#つづいてるのか
    bool flag = true;
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> grid[i][j];
        }
    }

    for (int k = 0; k < h; ++k) {
        for (int i = 0; i < w; ++i) {
            //#ますの周りに#があるか
            if(k == 0) {
                hcount = 0;
            } else{
                hcount = k -1;
            }

            if(i == 0){
                wcount = 0;
            } else{
                wcount = i -1;
            }
            if(grid[k][i] == '#') {
                if (grid[k][wcount] != '#' && grid[hcount][i] != '#' && grid[k][i + 1] != '#' &&
                    grid[k + 1][i] != '#') {
                    flag = false;
                    break;
                }
            }
        }
    }

    if(flag){
        cout << "Yes";
    } else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
#枠を大きめに確保してout of rangeを避ける!
grid = ["."*(w+2)]
for _ in range(h):
    grid.append("." + input() + ".")
grid += ["."*(w+2)]

for i in range(1,h+1):
    for j in range(1,w+1):
        if grid[i][j]=="#":
            if not (grid[i][j-1]=="#" or grid[i][j+1]=="#"or \
                grid[i-1][j]=="#" or grid[i+1][j]=="#"):
                    print("No")
                    exit()
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
/* Uncomment only if you are not using GNU compiler->
*/
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>
/**/ 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()

//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

void solve()
{
    int n;
    cin>>n;
    int n1=100001;
    vi v(n1);
    ll sum=0;
    ll x,y;
    rep(i,n)
    {
        cin>>x;
        v[x]++;
        sum+=x;
    }
    int q;
    cin>>q;
    while(q--)
    {
        ll b,c;
        cin>>b>>c;
        sum+=(c-b)*v[b];
        v[c]+=v[b];
        v[b]=0;
        cout<<sum<<endl;
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
        tt++;
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


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

priority_queue<pair<int, bool> > q;

int main(void)
{
    int n, h;
    scanf("%d%d", &n, &h);
    for (int i = 0; i < n; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        q.push(make_pair(a, 1));
        q.push(make_pair(b, 0));
    }
    int ans = 0;
    while (h > 0) {
        int attack = q.top().first;
        bool multi_attack = q.top().second;
        q.pop();
        if (multi_attack) {
            int cnt = h / attack;
            if (h % attack) cnt++;
            h -= attack * cnt;
            ans += cnt;
        }
        else {
            h -= attack;
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int n; scanf("%d", &n);
	ll mx = 0, ans = 0;
	REP(i, n){
		ll a; scanf("%lld", &a);
		LAR(mx, a);
		ans += mx - a;
	}
	printf("%lld\n", ans);
}


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

int get_unique_long(std::vector<int> &Vec) {
  std::sort(Vec.begin(), Vec.end());
  Vec.erase(std::unique(Vec.begin(), Vec.end()), Vec.end());
  return Vec.size();
}

int main() {
  int N = 0;
  std::cin >> N;
  std::vector<int> D_vec(N, 0);

  for (int i = 0; i < N; i++) {
    int a = 0;
    std::cin >> a;
    D_vec[i] = a;
  }

  std::cout << get_unique_long(D_vec) << std::endl;
  return 0;
}

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

using namespace std;

const int maxn = 1e6 + 5;

int vis[maxn] , a[maxn] , isnp[maxn];

int main() {
	int n;
	ios::sync_with_stdio(0);
	cin >> n;
	for(int i = 2 ; i * i< maxn ; i++) {
		for(int j = 2 * i ; j < maxn ; j += i) {
			isnp[j] = 1;
		}
	}
	int tmp = a[0];
	for(int i = 0 ; i < n ; i++) {
		cin >> a[i];
		tmp = __gcd(a[i] , tmp);
	}
	bool flag = 0;
	for(int i = 0 ; i < n && !flag; i++) {
		int t = a[i];
		for(int j = 2 ; j <= t && !flag; j++) {
			if(!isnp[t]) {
				if(vis[t] && vis[t] != i && t > 1) {
					flag = 1;
				}
				vis[t] = i;
				break;
			}
			while(t % j == 0) {
				if(vis[j] && vis[j] != i && j > 1) {
					flag = 1;
					break;
				}
				vis[j] = i;
				t /= j;
			}
			
		}
	}
	
	/*
	for(int i = 2 ; i < maxn ; i++) {
		if(vis[i] > 1) {
			flag = 1;
			cout << i << endl;
		}
	}*/
	if(!flag) {
		cout << "pairwise coprime\n";
	}
	else if(tmp == 1){
		cout << "setwise coprime\n";
	}
	else {
		cout << "not coprime\n";
	}
	return 0;
}

Measured memory_bytes: 11740
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int INF=(int)1e9;
const int MOD=(int)1e9+7;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};



int main(){
  int K,S;
  int x,y,z;
  cin>>K>>S;

  int cont=0;
  for(x=0;x<=K;x++){
    for(y=0;y<=K;y++){
      z=S-x-y;
      if(0<=z&&z<=K)cont++;
    }
  }

  cout<<cont<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#define rep(x, l, r) for(int x = l; x <= r; x++)
#define repd(x, r, l) for(int x = r; x >= l; x--)
#define clr(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define MAXN
#define fi first
#define se second
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
const int INF = 1 << 30;
const int p = 1000000009;
int lowbit(int x){ return x & (-x);}
int fast_power(int a, int b){ int x; for(x = 1; b; b >>= 1){ if(b & 1) x = 1ll * x * a % p; a = 1ll * a * a % p;} return x % p;}

int main(){
	int x, y;
	scanf("%d%d", &x, &y);
	if(x * 500 >= y) puts("Yes");
	else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, K;
	cin >> N >> K;

	string S;
	cin >> S;

	vector<Int> row;
	row.push_back(0);

	char temp = S[0];
	for (Int i = 1; i < N; i++) {
		if (S[i] == temp) {
			continue;
		}
		else {
			temp = S[i];
			row.push_back(i);
		}
	}
	row.push_back(N);

	Int diff = 2 * K + 1;
	Int len = row.size();

	Int ans = 0;
	Int res;
	if (S[0] == '1') {
		for (Int i = 0; i < len; i+=2) {
			res = row[min(i + diff,len-1)] - row[i];
			ans = max(ans, res);
		}

		if (ans == 0)ans = N;

	}
	else {
		if (len - 1 <= diff - 1)ans = N;
		else {
			ans = max(ans, row[diff - 1] - row[0]);

			for (Int i = 1; i < len; i+=2) {
				res = row[min(i + diff,len-1)] - row[i];
				ans = max(ans, res);
			}
		}
	}

	//if (ans > N)ans = N;
	cout << ans << "\n";
}

Measured memory_bytes: 1528
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include <map>

using namespace std;

int main() {
	vector<char> data(3);
	for (int i = 0; i < 3; i++)
		cin >> data[i];
	int max = 0;
	int check = 0;
	for (int i = 0; i < 3; i++) {
		if (data[i] == 'R') {
			check++;
			if (check > max)
				max = check;
		}
		else
			check = 0;
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {
    int k,s;
    cin>>k>>s;
    int ans=0;
    rep(x,k+1){
        rep(y,k+1){
            int z=s-x-y;
            if(z>=0&&z<=k){
                ans++;
            }
        }
    }
    fin(ans);

}


Measured memory_bytes: 256
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>

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

    ll n, x;
    cin >> n >> x;

    vi arr(n);
    for (auto &it : arr) {
        cin >> it;
    }

    ll ans = 0;
    for (int i = 0; i < n - 1; i++) {
        ll sum = arr[i] + arr[i + 1];
        if (sum > x) {
            ans += sum - x;
            ll c = min(arr[i + 1], sum - x);
            arr[i + 1] -= c;
            sum -= c;
            arr[i] -= sum - x;
        }
    }

    cout << ans << "\n";
}


Measured memory_bytes: 1024
function Main(input) {
	tmp = input.split(" ");
	
	var a = parseInt(tmp[0]);
	var b = parseInt(tmp[1]);
	var r = 0;
	var rt = 0;
	r+=a;a--;
	r+=a;
	
	var a = parseInt(tmp[0]);
	var b = parseInt(tmp[1]);
	rt+=a;
	rt+=b;
	if(r<rt){
		r=rt;
	}
	rt = 0;
	
	rt+=b;
	rt+=a;
	if(r<rt){
		r=rt;
	}
	rt = 0;
	
	rt+=b;b--;
	rt+=b;
	if(r<rt){
		r=rt;
	}
	
	console.log(r);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
"use strict";
function main(input) {
    const line = input.split("\n");
    let arr = line[0].split(" ");
    const N = parseInt(arr[0]);
    const D = parseInt(arr[1]);
    let X = [];
    for (let i = 1; i < N + 1; i++) X.push(line[i].split(" ").map(Number));
    let ans = 0;
    for (let i = 0; i < N; i++) {
        for (let j = i + 1; j < N; j++) {
            let num = 0;
            for (let k = 0; k < D; k++)
                num += Math.pow((X[j][k] - X[i][k]), 2);
            if (Number.isInteger(Math.sqrt(num))) ans++;
        }
    }
    console.log(ans);
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29568
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,n;//由于数字可能很大，要开 long long 
int main()
{
    cin>>a>>b>>c;
    if(b>=a)
    {
        cout<<1<<endl;//第一天就爬上去了 
        exit(0);//快乐一生，可以停止了 
    }
    if(c>=b)
    {
        cout<<-1<<endl;//永远上不去了 
        return 0;//和外面的世界再见吧 
    }
    //没办法，还是要一系列计算其他结果 
    if((a-b)%(b-c)>=1) 
		n=1;//计算前判断一个特殊情况 
    cout<<((a-b)/(b-c)+n)*2+1<<endl;//其他的就只好按公式算出答案，输出
    return 0;//结束程序 
}

Measured memory_bytes: 256
plan = [{t: 0, x: 0, y: 0}]
gets.to_i.times do
  input = gets.split(' ').map(&:to_i)
  plan.push({ t: input[0], x: input[1], y: input[2] })
end

ans = nil

(plan.size - 1).times do |i|
  time = plan[i + 1][:t] - plan[i][:t]
  distance = (plan[i + 1][:x] - plan[i][:x]).abs + (plan[i + 1][:y] - plan[i][:y]).abs
  if (distance <= time) && (distance % 2 == time % 2)
    ans = 'Yes'
  else
    ans = 'No'
    break
  end
end
puts ans


Measured memory_bytes: 31356
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 400010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int a[3];
FOR(i,1,3) cin >> a[i];
  sort(a+1, a+4);
  cout << a[3] * 10 + a[2] + a[1];
    return 0;
}


Measured memory_bytes: 256
n,q = map(int,input().split())
s = input()
a = [0]*n
cnt = 0
A = 0
for i in range(n):
    if s[i] == 'A':
        A = 1
    elif A == 1 and s[i] == 'C':
        cnt += 1
        A = 0
    else:
        A = 0
        
    a[i] = cnt
    
for i in range(q):
    l,r = map(int,input().split())
    print(a[r-1]-a[l-1])

Measured memory_bytes: 6108
/*最大最小堆
https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/9/ALDS1_9_B
10
4 1 3 2 16 9 10 14 8 7
*/
#include<iostream>
using namespace std;
const int N=500001;
int a[N]; 
int h;
int left(int root){
	return root*2;
}
int right(int root){
	return root*2+1;
}
void maxHeapify(int *a,int root){
	int l=left(root);
	int r=right(root);
	int largest=root;
	if(l<=h&&a[l]>a[root])
		largest=l;
	if(r<=h&&a[r]>a[largest])
		largest=r;	
	if(largest!=root){
		swap(a[root],a[largest]);
		//printf("swap(%d,%d)\n",a[root],a[largest]) ;
		maxHeapify(a,largest);
	}	
}
void buildMaxHeap(int *a){
	for(int i=h/2;i>=1;i--)
		maxHeapify(a,i);
}
void solve(){
	buildMaxHeap(a);
	for(int i=1;i<=h;i++)
		printf(" %d",a[i]);
		printf("\n");
}
int main(){
while(~scanf("%d",&h)){
	for(int i=1;i<=h;i++)
		scanf("%d",&a[i]);
	solve();	
}		
	return 0;
}



Measured memory_bytes: 5076
import java.util.*;


public class Main{
    public static void main(String[] args) throws Exception{
        
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        String t = sc.next();

        if(t.startsWith(s)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35632
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
ll n,k;
ll ans;
ll dp[1<<17];
const ll mod = 1e9+7;
ll qpow(ll x,ll n)
{
    ll res =1;
    while(n>0)
    {
        if(n&1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}
int main(){
	cin>>n>>k;
	for(ll i=k;i>0;i--){
		dp[i]=qpow(k/i , n);
		for(ll j=i+i;j<=k;j+=i){
			dp[i]-=dp[j];
		}
	}
	for(ll i=1;i<=k;i++) ans=(ans+dp[i]*i)%mod;
	cout<<ans%mod<<endl;
	return 0;
}

Measured memory_bytes: 4356
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n,k,m,x=0,y=0,z=0,cnt=0,h=0,w=0,sum=0,ans=0,Max=-1, Min=3e9+1;
  string s,t;
  cin >> h >> w >> k;
  VS a(h);
  rep(i,h){
    cin >> a[i];
    rep(j,w){
      if(a[i][j]=='#')
        sum++;
    }
  }
  z = sum;
  for (int bit = 0; bit < (1<<h); bit++){
    for (int bit2 = 0; bit2 < (1<<w); bit2++){
      rep(l,h){
          rep(r,w){
            if(bit >> l & 1 || bit2 >> r & 1){
                if(a[l][r] == '#'){
                  z--;
                }
            }
          }
      }
      if(z == k){
        ans++;
      }
      z = sum;
    }
  }
  pri(ans);
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int A, B;
  cin>>A>>B;
  string S;
  cin>>S;
  string tmp1=S.substr(0, A), tmp2=S.substr(A+1, B);
  bool can = true;
  for(int i=0;i<tmp1.size();++i) {
    if(tmp1[i]=='-') can = false;
  }
  if(S[A]!='-') can = false;
  for(int i=0;i<tmp2.size();++i) {
    if(tmp2[i]=='-') can = false;
  }
  if(can) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define abs(x) ((x) > 0 ? (x) : -(x))
typedef long long ll;

int
main(int argc, char *argv[])
{
  int n, x[100], y[100], h[100], k = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; ++i){
    scanf("%d %d %d", &x[i], &y[i], &h[i]);
  }
  while(1){
    if(h[k] > 0) break;
    k++;
  }
  int H; int flag = 0;
  for(int cx = 0; cx <= 100; ++cx){
    for(int cy = 0; cy <= 100; ++cy){
      flag = 0;
      H = abs(cx - x[k]) + abs(cy - y[k]) + h[k];
      for(int i = 0; i < n; i++){
	if(max(H - abs(cx - x[i]) - abs(cy - y[i]), 0) != h[i]){
	  flag++;
	  break;
	}
      }
      if(flag == 0){
	printf("%d %d %d\n", cx, cy, H);
	goto sdf;
      }
    }
  }
 sdf:
  return 0;
}
  


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

int main(int,char**) {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int N;
    cin >> N;
    vector<long long int> a(N+1);
    for (int i = 0; i < N+1; ++i) {
        cin >> a[i];
    }
    
    vector<long long int> b(N+1, 0);
    for (int i = 0; i < N; ++i) {
        cin >> b[i];
    }
     
    long long int res = 0;
    for (int i = 0; i < N; ++i) {
        res += min(a[i], b[i]);
        b[i] -= min(a[i], b[i]);
        res += min(a[i+1], b[i]);
        a[i+1] = max(0ll, a[i+1] - b[i]);
    }
    
    cout << res << endl;
    
    return 0;
}


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

using namespace std;

int data[10];
int size;
int tmp[10];
bool use[11];

main(){
  while(cin >> data[0]){
    bool f = true;
    if(data[0] != -1) f = false;
    for(int i=1;i<10;i++){
      cin >> data[i];
      if(data[i] != -1) f = false;
    }
    if(f) break;
    fill(use, use+11, false);
    for(int i=0;i<10;i++){
      use[data[i]] = true;
    }
    size = 0;
    for(int i=1;i<=10;i++){
      if(!use[i]) tmp[size++] = i;
    }
    int ans = 0;
    do{
      int tmp2[10];
      int cnt = 0;
      for(int i=0;i<10;i++){
        if(data[i] == 0) tmp2[i] = tmp[cnt++];
        else tmp2[i] = data[i];
      }
      bool f2 = true;
      int mod = (tmp2[0] + tmp2[1] + tmp2[2]) % tmp2[9];
      for(int i=0;i<3;i++){
        int sum = 0;
        for(int j=0;j<3;j++){
          sum += tmp2[i*3+j];
        }
        if(sum % tmp2[9] != mod){
          f2 = false;
          break;
        }
        sum = 0;
        for(int j=0;j<3;j++){
          sum += tmp2[j*3+i];
        }
        if(sum % tmp2[9] != mod){
          f2 = false;
          break;
        }
      }
      if((tmp2[0] + tmp2[4] + tmp2[8]) % tmp2[9] != mod) f2 = false;
      if((tmp2[2] + tmp2[4] + tmp2[6]) % tmp2[9] != mod) f2 = false;
      if(f2) ans++;
    }while(next_permutation(tmp, tmp+size));
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <set> 
#include <iterator> 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)


int main()
{
    
    fastio();

        int n;
        cin>>n;
        int a[n];
        cn(a,n);
        int dp[n]={0};
        dp[0]=0;
        dp[1]=abs(a[1]-a[0]);
        for(int i=2;i<n;i++)
        {
            dp[i]= min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
        }
        cout<<dp[n-1]<<endl;
      

}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int N = Integer.parseInt(lines[0]);
		int M = Integer.parseInt(lines[1]);
		int[][] ks = new int[M][N];


		for (int i = 0; i < M; i++) {
			int k = sc.nextInt();
			for(int j = 0;  j < k; j++) {
				ks[i][sc.nextInt() - 1] = 1;
			}
		}

		int[] p = new int[M];
		for(int i = 0 ; i < p.length; i++) {
			p[i] = sc.nextInt();
		}

		int sum = 0;
		//Shift演算を使っているらしい
		for(int i = 0; i < (1 << N); i++) {
			boolean exist = true;
			for(int j2 = 0; j2 < ks.length; j2++) {
				int count = 0;
				for(int k = 0; k < ks[j2].length; k++) {
					if(ks[j2][k] == 1) {
						if((1 & i >> k) == 1) {
							count++;
						}
					}
				}
				if(count % 2 != p[j2] ) {
					exist = false;
					break;
				}
			}
			if(exist) {
				sum++;
			}

		}

		System.out.println(sum);
	}

}


Measured memory_bytes: 35800
alpha = "abcdefghijklmnopqrstuvwxyz"
from collections import Counter
n = int(input())
alp_max = [10**3] * 26
for i in range(n):
    C = Counter(input())
    for j in range(26):
        alp_max[j] = min(alp_max[j], C[alpha[j]])
ans = ""
for i in range(26):
    ans += alpha[i] * alp_max[i]
print(ans)


Measured memory_bytes: 3316
local mfl = math.floor
local x = io.read("*n")
local t = {}
for i = 1, x do
  t[i] = false
end
for i = 1, 6 do
  local v = 99 + i
  for j = x - v, 1, -1 do
    if t[j] then
      local klim = mfl((x - j) / v)
      for k = 1, klim do
        t[j + k * v] = true
      end
    end
  end
  do
    local klim = mfl(x / v)
    for k = 1, klim do
      t[k * v] = true
    end
  end
end
print(t[x] and 1 or 0)


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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

void solve() {
    int x;
    read(x);
    if (x >= 30) {
        print("Yes");
    }
    else {
        print("No");
    }
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
    //read(tt);
    FOR(tt) {
//        write("Case #", i + 1, ": ");
        solve();
    }
    
}



Measured memory_bytes: 3640
program main
  implicit none
  integer :: N,M
  integer,allocatable :: A(:,:)
  integer,allocatable :: B(:)
  integer,allocatable :: out(:)
  integer :: nans
  integer :: C
  integer :: i 
  read(*,*) N,M,C
  allocate(B(M))
  allocate(A(N,M))
  read(*,*) B(:)
  do i = 1,N
     read(*,*) A(i,:)
  end do
  allocate(out(N))
  out=matmul(A,B)
  nans=0
  do i = 1,N
     if (out(i)+C > 0) nans = nans + 1
  end do
  write(*,'(i0)') nans
  stop
end program main

Measured memory_bytes: 896
s = list(map(int, input()))
#print(s)
n = len(s)

l_sum = [0]
for i in range(n):
    x = (l_sum[-1] + int(s[n-i-1]) * (pow(10, i, 2019))) % 2019
    l_sum.append(x)

#print(l_sum)
l_sum.sort()
ans = 0
tmp = 0
cnt = 1
for i in range(1, len(l_sum)):
    if l_sum[i] == tmp:
        cnt += 1
    else:
        ans += cnt * (cnt - 1) // 2
        cnt = 1
        tmp = l_sum[i]

ans += cnt * (cnt - 1) // 2
print(ans)

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

int main()
{
    long long i,n,m,d,s=0;
    vector<long long>a;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>m;
        s+=m;
        a.push_back(m);
    }
    d=*max_element(a.begin(),a.end());
    if((s-d)<=d)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <climits>
#include <algorithm>
 
 
using namespace std;
 
int long long  N,A,B;
string S;
 
 
int main()
{
 
    cin >> N >> A >> B;
    
    int long long c0 = 0;
    int long long c1 = 0;
    int long long ca = 0;
 
      c0 = (N / (A + B))*A;
      c1 =  N % (A + B);
  
    
        ca = c0 +min( A, c1);
 
 
    cout << ca << "\n";
    return 0;
}

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

namespace P0025_Hit_and_Blow
{
    class Program
    {
        static void Main(string[] args)
        {
            
            var outputs = new List<string>();

            while (true)
            {
                var line = Console.ReadLine();
                if (line == null) break;
                                
                var A = line.Split(' ');
                var B = Console.ReadLine().Split(' ');
                int hit = 0;
                int blow = 0;

                for (int i = 0; i < 4; i++) 
                {
                    if (B[i] == A[i]) hit++;
                    else if (A.Contains(B[i])) blow++;
                }
                
                outputs.Add(hit + " " + blow);

            }

            foreach (var output in outputs)
            {
                Console.WriteLine(output);
            }

        }
    }
}

Measured memory_bytes: 5812