akhauriyash/Code-Regression huggingface dataset:
#define P(x) cout << #x " = " << x << endl
#define PP(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define PPP(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl

#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;

using ll = long long;
int n, x;
int s[200];
const int mod = 1000000007;
ll dp[200][100001];

int main()
{
    cin >> n >> x;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    sort(s, s + n, greater<int>());
    for (int i = 0; i < n; ++i) {
        fill(dp[i], dp[i] + x + 1, 0);
    }
    // PP(s[0], s[1]);
    dp[0][x % s[0]] = 1;
    dp[0][x] += n - 1;
    for (int i = 0; i < n - 1; ++i) {
        for (int k = 0; k <= x; ++k) {
            dp[i + 1][k % s[i + 1]] += dp[i][k];
            dp[i + 1][k % s[i + 1]] %= mod;
            dp[i + 1][k] += dp[i][k] * (n - i - 2);
            dp[i + 1][k] %= mod;
        }
    }
    ll ans = 0;
    for (int i = 0; i <= x; ++i) {
        ans = (ans + (i * dp[n - 1][i]) % mod) % mod;
    }
    cout << ans << endl;
}

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

typedef char GRID;

#define WHITE '.'
#define BLACK '#'

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

	vector<vector<GRID>> grid(H, vector<GRID>(W));

	for (int Hi = 0; Hi < H; Hi++)
	{
		for (int Wi = 0; Wi < W; Wi++)
		{
			cin >> grid.at(Hi).at(Wi);
		}
	}

	for (int Hi = 0; Hi < H; Hi++)
	{
		int AmountOfWhite;	AmountOfWhite = 0;
		for (int Wi = 0; Wi < W; Wi++)
		{
			if (grid.at(Hi).at(Wi) == WHITE) AmountOfWhite++;
		}

		if (AmountOfWhite == W)
		{
			for (int Wi = 0; Wi < W; Wi++)
			{
				grid.at(Hi).at(Wi) = EOF;
			}
		}
	}
	
	for (int Wi = 0; Wi < W; Wi++)
	{
		int AmountOfWhite; AmountOfWhite = 0;
		for (int Hi = 0; Hi < H; Hi++)
		{
			if ((grid.at(Hi).at(Wi) == WHITE) || (grid.at(Hi).at(Wi) == EOF)) AmountOfWhite++;
		}

		if (AmountOfWhite == H)
		{
			for (int Hi = 0; Hi < H; Hi++)
			{
				grid.at(Hi).at(Wi) = EOF;
			}
		}
	}

	bool doPrint;
	for (int Hi = 0; Hi < H; Hi++)
	{
		doPrint = false;
		for (int Wi = 0; Wi < W; Wi++)
		{
			if (!(grid.at(Hi).at(Wi) == EOF))
			{
				cout << grid.at(Hi).at(Wi);
				doPrint = true;
			}
		}
		if (doPrint == true) cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
signed main() {

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

  int n, p;
  cin >> n >> p;

  string s;
  cin >> s;

  int fre[10005];
  memset(fre, 0, sizeof fre);
  fre[0] = 1;

  if (p == 2 || p == 5) {
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
      int d = s[i] - '0';
      if (d % p == 0) ans += i+1;
    } 
    cout << ans << '\n';
    return 0;
  }
  
  long long ans = 0, num = 0, mul = 1;
  for (int i = n-1; i >= 0; --i) {
    int d = s[i] - '0';
    num = d * mul + num;
    num %= p;
    mul = mul * 10 % p;

    ans += fre[num];
    fre[num]++;
  }

  cout << ans << '\n';
}

Measured memory_bytes: 720
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin >> n;
	while(n--){
		int m, p = 0, c, u = 0, d = 0;
		cin >> m >> p;
		while(--m){
			cin >> c;
			if(c > p){ u = max(u, c - p); }
			if(c < p){ d = max(d, p - c); }
			p = c;
		}
		cout << u << " " << d << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

signed main()
{
	int N;
	cin >> N;
	for (int i = N; i <= 999; i++)
	{
		if (i < 10)
		{
			cout << i << endl;
			return 0;
		}
		if (i < 100)
		{
			if (i / 10 == i % 10)
			{
				cout << i << endl;
				return 0;
			}
		}
		if (i < 1000)
		{
			if ((i / 10) % 10 == i % 10 && i / 100 == i % 10)
			{
				cout << i << endl;
				return 0;
			}
		}
	}
}



Measured memory_bytes: 3192
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector as V

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n, k] <- getIntList
    mapM print [ mulMod (comb (n - k + 1) i) (comb (k - 1) (i - 1)) | i <- [1..k]]


moduloN :: Int
moduloN = 10 ^ 9 + 7

modN = flip mod moduloN

mulMod x y = modN $ x * y

finv :: Int -> Int
finv k = finvs V.! k
    where finvs :: V.Vector Int
          finvs = V.generate (10 ^ 5 + 1) finv'
              where finv' 0 = 1
                    finv' n = modN $ finvs V.! (n - 1) * inv n

inv :: Int -> Int
inv k = invs V.! k
    where inv' 1 = 1
          inv' n = modN (-(invs V.! r) * q)
              where (q, r) = moduloN `divMod` n
          invs :: V.Vector Int
          invs = V.generate (10 ^ 5 + 1) inv'

fact :: Int -> Int
fact k = facts V.! k
    where fact' 0 = 1
          fact' n = modN $ n * (facts V.! (n - 1))
          facts :: V.Vector Int
          facts = V.generate (10 ^ 5 + 1) fact'

comb :: Int -> Int -> Int
comb n k | n < 0 || k < 0 || n < k = 0
         | otherwise = modN $ modN (fact n * finv k) * finv (n - k)

Measured memory_bytes: 17788
n, m = gets.split.map(&:to_i)
colors = (1..n).map { gets.split.map(&:to_f) }
dist = (0..n-1).map do |i|
  (0..n-1).map do |j|
    colors[i].zip(colors[j]).map {|x, y| (x - y) ** 2 }.inject(:+)
  end
end

sum = [0]
(1..(1<<n)-1).each do |x|
  i = 0
  i += 1 until x[i] == 1
  y = x - (1 << i)
  sum[x] = sum[y]
  (0..n-1).each do |j|
    sum[x] += dist[i][j] if y[j] == 1
  end
end

answer = (0..(1<<n)-1).select {|x| x.to_s(2).count(?1) == m }.map {|x| sum[x] }.max
printf("%.7f\n", answer)


Measured memory_bytes: 20212
/*
    こういう分かりづらい上に間違いやすい問題やめろ
 */

#include <cstdio>
#include <algorithm>
using namespace std;

int n;
int now;
int ans;
bool err;

int main() {

    scanf("%d", &n);
    scanf("%d", &now);
    ans = now;
    for (int i=0; i<n; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        now += a-b;
        if (now < 0) err = true;
        ans = max(ans, now);
    }

    printf("%d\n", err?0:ans);
}

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

int main(){
 
    int k, a, b;
    cin >> k >> a >> b;
    
    for ( int i = a; i <= b; i++ ){
        if ( i % k == 0 ){
            cout << "OK" << endl;
            return 0;
        }
    }
    
    cout << "NG" << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,k,arr[150],j=1;
    cin>>a>>b>>k;
    if(a>b)
        swap(a,b);
    arr[0]=1;
    for(int i=2; i<=a; i++)
    {
        if(a%i==0&&b%i==0)
        {
            arr[j]=i;
            //cout<<arr[j]<<" ";
            j++;
        }
    }
    sort(arr,arr+j,greater<int>());
    cout<<arr[k-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <unordered_map>
#define maxn 100005
#define mod 998244353
using namespace std;
typedef long long LL;
int main()
{
    char s[15];
    scanf("%s",s+1);
    if(s[3]==s[4]&&s[5]==s[6])
        printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 888
from collections import deque

q=int(input())

S=deque()

for i in range(q):
    query=list(map(int,input().split()))
    
    if query[0]==0:
       
        if query[1]==0:
            S.appendleft(query[2])
        elif query[1]==1:
            S.append(query[2])
        
    elif query[0]==1:
        print("{}".format(S[query[1]]))
        
    elif query[0]==2:
        if query[1]==0:
            S.popleft()
        elif query[1]==1:
            S.pop()




Measured memory_bytes: 21980
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int x;
    cin >> x;

    vector<vector<int64_t>> dp(6, vector<int64_t>(x + 1));

    irep(i, x)
    {
        dp[0][i] = (i % 100 == 0) ? 1 : 0;
    }
    rep(i, 5)
    {
        irep(j, x)
        {
            dp[i + 1][j] = 0;
            irep(k, 100)
            {
                if (j - k * (101 + i) >= 0) {
                    dp[i + 1][j] += dp[i][j - k * (101 + i)];
                }
            }
        }
    }

    if (dp[5][x] == 0) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
ll dis[305][305];
int ans[305][305];
vector<pair<int,int> >v[305];
vector<int> v1[305];
bool vis[305]={0};

int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int n,m,l;
    cin>>n>>m>>l;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i==j) dis[i][j]=0;
            else dis[i][j]=1e18;
        }
    }
    for(int i=0;i<m;i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        if(c>l) continue;
        dis[a][b]=c;
        dis[b][a]=c;

    }
    for(int k=1;k<=n;k++)
        {
            for(int i=1;i<=n;i++)
            {
                for(int j=1;j<=n;j++)
                {
                    dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
                }
            }
        }
    for(int i=1;i<=n;i++)
    {

        for(int j=i+1;j<=n;j++)
        {
            if(dis[i][j]<=l)
            {
                v1[i].push_back(j);
                v1[j].push_back(i);
                //cout<<i<<' '<<j<<'\n';
            }
        }

    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
            ans[i][j]=1e9;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
            vis[j]=false;
        queue<pair<int,int> >q;
        q.push({i,0});
        vis[i]=true;
        while(!q.empty())
        {
            int t=q.front().F;
            int x=q.front().S;
            ans[i][t]=x;

            q.pop();
            //cout<<t<<'\n';
            for(int j=0;j<v1[t].size();j++)
            {
                if(!vis[v1[t][j]])
                    {
                        vis[v1[t][j]]=true;
                        q.push({v1[t][j],x+1});
                    }
            }
        }

    }
   /* for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
            cout<<ans[i][j]<<' ';
        cout<<'\n';
    }*/
    int q1;
    cin>>q1;
    while(q1--)
    {
        int c,d;
        cin>>c>>d;
        if(ans[c][d]==1e9) cout<<"-1"<<'\n';
        else cout<<ans[c][d]-1<<'\n';
    }
}


Measured memory_bytes: 2176
n = int(input())
import math
import numpy as np
xy = []
for i in range(n):
    array = list(map(int, input().split()))
    xy.append(array)


def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
l = []

k=0
for i in range(0,n-1):
	for j in range(i+1,n):
		
		l.append(math.sqrt((xy[i][0] -xy[j][0])**2 + (xy[i][1] - xy[j][1])**2))
		
		k += 1
print
a = (n-1) * math.factorial(3)/k
l_sum = np.sum(np.array(l) *a)

print(l_sum/math.factorial(3))




Measured memory_bytes: 21288
def f(x, P):
    y = x
    z = x
    while y > 0 or z <= 100:
        if y not in P:
            return y
        y -= 1
        if z not in P:
            return z
        z += 1


x, N = map(int, input().split())
if N:
    P = list(map(int, input().split()))
    print(f(x, P))
else:
    print(x)


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

using namespace std;

int main() {
    long long int A;
    string B_s;
    cin >> A >> B_s;
    vector<char> B(0);
    for(char b : B_s){
        if(b != '.') B.push_back(b);
    }

    long long B100 = 0;
    for(int i=0; i<B.size(); i++){
        B100 += (B.at(i)-'0')*pow(10, 2-i);
    }
    long long int ans = A*B100 / 100;
    cout << ans << endl;
}

Measured memory_bytes: 3856
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {

	string s;
	cin >> s;
	int p1, p2;
	int n = s.length();
	rep(i, n) {
		if (s[i] == 'A') {
			p1 = i;
			break;
		}
	}
	for (int i = n - 1; i > p1; i--) {
		if (s[i] == 'Z') {
			p2 = i;
			break;
		}

	}
	cout << p2 - p1 + 1;

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
    int x;
    int i;

    for (i = 1; i <= 10000; i++)
    {
        scanf("%d", &x);
        if (x == 0)
        {
            break;
        }
        printf("Case %d: %d\n", i, x);
    }

    return 0;
}


Measured memory_bytes: 2564
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;

int cnt[10][10];
int main() {
    int n;
    cin >> n;
    
    for (int a = 1; a <= n; a++)
    {
        string s = to_string(a);
        cnt[s[0]-'0'][s[s.size()-1]-'0']++;
    }
    ll ans = 0;
    for (int i=1; i<10;i++) {
        for (int j=1; j<10; j++) {
            ans += cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
#define ps puts("")
#define fi first
#define nd second
#define mset(x) memset((x), 0, sizeof (x))
#define mk make_pair
#define sqr(x) ((x)*(x))
#define pii pair<int,int>
#define lch (o<<1)
#define rch (o<<1|1)
using namespace std;
typedef long long ll;
ll read() {ll x = 0;char f = 1, ch = getchar();while(ch < '0' || ch > '9') {if(ch == '-')f = -1;
ch = getchar();}while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0';ch = getchar();}return x * f;}
void write(ll x) {if(x < 0) x = -x, putchar('-');if(x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(ll x) {write(x);puts("");}
const int N = 600000;
ll n, x, ans, a;
ll gcd(ll x, ll y) {
	if(!y) return x;
	return x % y? gcd(y, x % y) : y;
}
int main() {
	n = read(),x = read();
	for(int i = 1; i <= n; ++i) {
		a= read();
		a = abs(a - x);
		if(!ans) ans = a;
		else ans = gcd(ans, a);
	}
	writeln(ans);
	return 0;
}

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

using ll = long long;

using namespace std;

//0 -> a-1
#define rep(i, a) for (int i = 0; (i) < (int)(a); (i)++)
//a -> b-1
#define reps(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++)
//a-1 -> 0
#define rrep(i, a) for (int i = (int)a - 1; (i) >= 0; (i)--)
//a-1 -> b
#define rreps(i, a, b) for (int i = (int)(a)-1; (i) >= (int)(b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
//next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
(v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v) \
	sort(all(v)); \
	(v).erase(unique(all(v)), v.end())
#define CIN(type, x) \
	type x;          \
	cin >> x
#define YES(f) if ((f)) {cout << "YES" << endl;} else {cout << "NO" << endl;}
#define Yes(f) if ((f)) {cout << "Yes" << endl;} else {cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
//b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
//c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(12)
#define RS resize
#define CINV(v, N)             \
	do                         \
	{                          \
		v.RS(N);               \
		rep(i, N) cin >> v[i]; \
	} while (0);

#define RCINV(v, N)             \
	do                          \
	{                           \
		v.RS(N);                \
		rrep(i, N) cin >> v[i]; \
	} while (0);
#define MOD 1000000007

template <class T>
inline T GET()
{
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
	int N;
	cin >> N;
	vector<int> v(N);
	rep(i, N) cin >> v[i];
	reps(i, 1, N+1) {
		if (v[i-1] > i) {
			cout << -1 << endl;
			return;
		}
	}
	vector<int> res;
	rep(i, N) {
		int j = i + 1 - v[i];
		if (j == 0) {
			res.push_back(v[i]);
			continue;
		}
		res.insert(res.end() - j, v[i]);
	}
	rep(i, N) {
		cout << res[i] << endl;
	}
}

void solve()
{
}


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

public class MainClass
{
	public const long Giri = 1000000007;
	
	public struct Pos
	{
		public int X{get;set;}
		public int Y{get;set;}
	}
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		
		var poses = new Pos[n];
		for(int i = 0; i < n; i++)
		{
			var p = Input().ToInt();
			poses[i] = new Pos(){X=p[0], Y=p[1]};
		}
		
		long kai = 1;
		for(int i = n; i >= 1; --i)
		{
			kai *= i;
		}
		
		long kai2 = kai / n;
		
		double wa = 0;
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j < n; j++)
			{
				var pos1 = poses[i];
				var pos2 = poses[j];
				
				if(i == j)
					continue;
				
				var l = (pos1.X - pos2.X) * (pos1.X - pos2.X) + (pos1.Y - pos2.Y) * (pos1.Y - pos2.Y);
				wa += Math.Sqrt(l)*kai2;
			}
		}

		Console.WriteLine(wa /= kai);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
using namespace std;
int aa[213456];
signed main() {
	for (int h = 0; h < 10; h++) {
		aa[h] = 123;
	}
	int n, m, a, b, sum = 0, ans = 0; string s; cin >> n >> m;
	for (int h = 0; h < m; h++) {
		cin >> a >> b;
		if (n != 1 && a == 1 && b == 0) { sum = 1; }
		if (aa[a] == 123) {
			aa[a] = b;
		}
		else {
			if (aa[a] != b) { sum = 1; }
		}
	}
	if (sum == 1) { cout << -1 << endl; return 0; }
	for (int h = 1; h <= n; h++) {
		if (n == 1 && m == 0) { cout << 0; }
		else if (h == 1 && aa[h] == 123) { cout << 1; }
		else if (aa[h] == 123) {
			cout << 0;
		}
		else { cout << aa[h]; }
	}
	cout << endl;
}

Measured memory_bytes: 256
S = input()
S1 = S[0]+S[1]
S2 = S[2]+S[3]

if '01' <= S1 and S1 <= '12':
    
    # YYMM フォーマット と MMYY フォーマットのどちらの可能性もある場合
    if '01' <= S2 and S2 <= '12':
        print('AMBIGUOUS')
        
    # MMYY フォーマットのみである場合
    else:
        print('MMYY')
        
# YYMM フォーマットのみである場合        
elif '01' <= S2 and S2 <= '12':
    print('YYMM')

# どちらの可能性もない場合   
else:
    print('NA')

Measured memory_bytes: 3064
#include<iostream>

using namespace std;


int gcd(int x, int y) {
	if (x < y) {
		int tmp = x;
		x = y;
		y = tmp;
	}

	while (y != 0) {
		int tmp = x%y;
		x = y;
		y = tmp;
	}
	return x;
}

int main() {
	int x, y;

	cin >> x >> y;

	cout << gcd(x, y) << endl;

	return 0;
}

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

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var n = vals[0];
        var a = vals[1];
        var b = vals[2];

        var blue = (n / (a + b)) * a + Math.Min(n % (a + b), a);

        Console.WriteLine(blue);
    }
}

Measured memory_bytes: 13268
n = gets.to_i
f = false
n.times do |i|
  if n < 4 then
    break
  end
  a = n - 7 * i
  if a >= 0 then
    if a == 0 then
      f = true
      break
    end
    if a % 4 == 0 then
      f = true
      break
    end
  end
end
if f then
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int MAX = 510000;
const int MOD = 1e9 + 7;
vector<ll> fac(MAX);
vector<ll> finv(MAX);
vector<ll> inv(MAX);
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
vector<P> prime(ll a)
{
    vector<P> tmp;
    for(int i = 2; i <= a; i++)
    {
        int count = 0;
        while(a % i == 0)
        {
            count++;
            a /= i;
        }
        if(count > 0)
        {
            tmp.push_back(P(i, count));
        }
    }
    return tmp;
}

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<P> vp;
    vp = prime(m);
    COMinit();
    ll ans = 1;
    for(auto itr = vp.begin(); itr != vp.end(); itr++)
    {
        ll val = (*itr).second;
        ans = ans * COM(n-1+val, n-1) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 12160
#include<vector>
#include<set>    // multiset
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;


int main(){
  if(df) printf("*debug mode*\n");
  int h,w,n; cin >>h >>w >>n;
  li ans=0,temp=0;
  while(temp<n){
    int& x=h>w?w:h;
    temp+=h+w-x;
    ans++;
    x--;
    if(df)printf("%ld\n",temp);
  }
  cout << ans;
}

/// confirm df==0 ///


Measured memory_bytes: 256
n = gets.to_i
array = gets.split(' ').map {|a| a.to_i }

puts array.join(' ')

for i in 1..n-1
    k = array[i]
    j = i - 1
    while j >= 0 and array[j] > k
        array[j+1] = array[j]
        j = j - 1
    end
    array[j+1] = k
    puts array.join(' ')
end

Measured memory_bytes: 8760
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = GetNumbers();
            var count = Enumerable
                .Range(nums[0], nums[1] - nums[0] + 1)
                .Count(x => nums[2] % x == 0);
            Console.WriteLine(count);
        }

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static List<int> GetNumbers()
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
        }

        static List<string> GetStrings()
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToList();
        }
    }
}

Measured memory_bytes: 10088
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2005;
int a[N],b[N][N],n,x,ans=9e18;
signed main(){
	scanf("%lld%lld",&n,&x);
	for (int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for (int i=1;i<=n;i++){
		b[i][i]=a[i];
		for (int j=i+1;j<=n;j++)b[i][j]=min(b[i][j-1],a[j]);
	}
	for (int i=0;i<n;i++){
		int temp=i*x;
		for (int j=1;j<=n;j++){
			int k=j-i;
			if (k<=0)temp+=min(b[k+n][n],b[1][j]);
			else temp+=b[k][j];
		}
		ans=min(ans,temp);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 31104
#include<cstring>
#include<iostream>
using namespace std;
int main(void)
{
	string s;
	cin>>s;
	if(s=="SUN") cout<<"7"<<endl;
	if(s=="MON") cout<<"6"<<endl;
	if(s=="TUE") cout<<"5"<<endl;
	if(s=="WED") cout<<"4"<<endl;
	if(s=="THU") cout<<"3"<<endl;
	if(s=="FRI") cout<<"2"<<endl;
	if(s=="SAT") cout<<"1"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[100010],ba[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1000][1000];
vector<ll> va,vb,vc;

int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>cd[i][j];
        }
    }
    
    for(int i=-1;i<=n;i++){
        C "#";
        for(int j=0;j<m;j++){
            if(i==-1 or i==n)C "#";
            else C cd[i][j];
        }
        C "#" E;
    }
    
    
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)





int main() {
	ll r;
	in(r);
	outn(r * r);

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    string s, t;
    cin >> s;
    t = s;
    reverse(ALL(t));
    int ans = 0;
    rep(i, s.size()) {
        if(s[i] != t[i]) ans++;
    }
    cout << ans / 2 << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>

int main() {
    std::string S, T;
    std::cin >> S >> T;
    
    size_t len = S.size();
    
    bool ans = false;
    for (size_t start=0; start<len; start++) {
        bool is_same = true;
        for (size_t i=0; i<len; i++) {
            if (S[(start+i)%len] != T[i])
                is_same = false;
        }
        if (is_same) {
            ans = true;
            break;
        }
    }
    if (ans)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}

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


ll GCD(ll a, ll b){
    if(a < b) swap(a, b);
    if(a % b == 0) return (b);
    else{
        GCD(b, a % b);
    }
}

vector<ll> divisor(ll n){
    vector<ll> ret;
    for(ll i = 1; i * i <= n; ++i){
        if(n % i == 0 ){
            ret.push_back(i);
            if(i * i != n) ret.push_back(n/i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

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

int main(){
    ll a, b; cin >> a >> b;
    ll gcd = GCD(a, b);
    vector<ll> divisors = divisor(gcd);
    ll ans = 1;
    for(auto d: divisors){
        if(is_prime(d)) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
  int a, b, x;
  cin >> x >> a >> b;
  int ax , bx ;
  ax = a - x;
  bx = b - x;
  if(ax < 0) ax *= -1;
  if(bx < 0) bx *= -1;
  
  if(ax > bx){
    cout << "B" << endl;
  }else{
    cout << "A" << endl;
  }
  return 0;
}

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


int X;

void read() {
    cin >> X;
}


void work() {
    for (int i = X;; ++i) {
        for (int p = 2; p * p <= i; ++p) {
            if (i % p == 0) {
                goto _fail;
            }
        }
        cout << i << endl;
        break;
    _fail:;
    }
}


int main() {
    read();
    work();
    return 0;
}


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

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

    int count = 0;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == t[i]) ++count;
    }

    cout << count <<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
    int n,k,x,y;
    scanf("%d%d%d%d",&n,&k,&x,&y);
    long long ans=0;
    ans+=min(k,n)*x;
    ans+=max(0,n-k)*y;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def conb(n,r): 
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = inp()
xy = [inpl() for i in range(n)]
res = 0
m = math.factorial(n)*(n-1)//conb(n,2)
for i in range(n):
    for j in range(i+1,n):
        tmp = math.sqrt((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2)
        res += tmp*m
print(res/math.factorial(n))


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

signed main() {
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  vector<int> A(M), B(M);
  for (int i = 0; i < M; ++i) cin >> A[i] >> B[i], --A[i], --B[i];

  vector<vector<int>> adj(N, vector<int>(N));
  for (int i = 0; i < M; ++i) {
    adj[A[i]][B[i]] = 1;
    adj[B[i]][A[i]] = 1;
  }

  vector<vector<int>> sup_g(N);
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < N; ++j)
      if (i != j && !adj[i][j])
        sup_g[i].push_back(j);

  vector<int> color(N);
  vector<vector<int>> size(N, vector<int>(2));
  function<bool(int, vector<int> &)> dfs_color = [&](int u, vector<int> &cnt) {
    for (int v : sup_g[u]) {
      if (color[v]) {
        if (color[v] == color[u]) return false;
      } else {
        color[v] = 3 - color[u];
        ++cnt[color[v] & 1];
        if (!dfs_color(v, cnt)) return false;
      }
    }
    return true;
  };

  for (int i = 0; i < N; ++i) {
    if (color[i]) continue;
    color[i] = 1;
    size[i][1] = 1;
    if (!dfs_color(i, size[i])) {
      cout << -1 << endl;
      return 0;
    }
  }

  bitset<1024> dp;
  dp[0] = 1;
  for (int i = 0; i < N; ++i) {
    if (size[i][0] + size[i][1]) {
      dp = dp << size[i][0] | dp << size[i][1];
    }
  }

  int ans = 0x3f3f3f3f;
  for (int i = 0; i < N + 1; ++i) {
    if (dp[i] == 0) continue;
    auto c2 = [](int n) { return n * (n - 1) / 2; };
    ans = min(ans, c2(i) + c2(N - i));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5120
N,M=$<.read.split.map(&:to_i)
require 'prime'

def f(a,n)
    if a.empty?
        return (n*N<=M&&M%n==0 ? n : 1)
    end
    p,mi = a[0]
    max = 0
    (mi+1).times do |i|
        x = f(a[1..-1], n*(p**i))
        max = x if max < x
    end
    max
end

# p Prime.prime_division(M)
p f(Prime.prime_division(M),1)



Measured memory_bytes: 3964
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define debug cout<<"****************"<<endl
using namespace std;
typedef long long ll;
inline void ju() {
	freopen("***.in","r",stdin);
	freopen("***.out","w",stdout);
}
inline ll rd() {
	ll x=0,f=1; char c=getchar();
	while((c<'0'||c>'9')&&(c!='-')) c=getchar();
	if(c=='-') f=-1,c=getchar();
	while(c>='0'&&c<='9') {
		x=(x<<3)+(x<<1)+c-'0';
		c=getchar();
	}
	return x*f;
}
int a[10];
int main() {
	for(int i=1;i<=3;++i) a[i]=rd();
	sort(a+1,a+4);
	if(a[1]==5&&a[2]==5&&a[3]==7) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# 任意のiに対して ai <= bi にできればよい

lessA = 0
lessB = 0

for a, b in zip(A, B):
    if a > b:
        lessB += a - b
    elif a < b:
        lessA += (b - a) // 2

if lessB <= lessA:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 4600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

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

    vector<ll> a(n);
    ll sum= 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    sort(all(a)); reverse(all(a));
    vector<ll> divisor;
    for(int i = 1; i < sqrt(sum)+1; i++){
        if(sum%i == 0){
            divisor.push_back(i);
            divisor.push_back(sum/i);
        }
    }
    sort(all(divisor)); reverse(all(divisor));

    ll ans = 0;
    for(int i = 0; i < divisor.size(); i++){
        ll div = divisor[i];
        vector<ll> r(n);
        for(int j = 0; j < n; j++){
            r[j] = a[j]%div;
        }
        sort(all(r));
        ll neg = 0;
        ll pos = 0;
        for(int j = 0; j < n; j++){
            if(r[j] != 0){
                pos += div-r[j];
            }
        }
        for(int j = 0; j < n; j++){
            if(r[j] == 0){continue;}
            neg += r[j];
            pos -= div-r[j];
            if(neg==pos){
                break;
            }
        }
        if(pos <= k){
            cout << div << endl;
            return 0;
        }

    }

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a, b;
int main(void){
    // Your code here!
    cin >> a >> b;
    int r = a + b, t = a - b, y = a * b;
    int res;
    res = (r > t ? r : t);
    res = (res > y ? res : y);
    cout << res << endl;
}


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

#define ul unsigned long int
#define ull unsigned long long
#define li long long int

int main()
{
  string s,p;

  cin>>s>>p;
  s=s+s;

  if (s.find(p)!=string::npos) cout <<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}



Measured memory_bytes: 3220
// Problem : E - Coprime
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 	
int mod=1e9+7;
int MAXN=1e6+1;
int po(int x,int y,int m)  { if (y==0) return 1; int t=po(x,y/2,m)%m; t=(t*t)%m; if (y&1) return (t*x)%m;	return t%m; }

vector<bool> prime(MAXN,true); 
unordered_map<int,int> m;
vector<int> spf(MAXN); 

int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  
// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
void getFactorization(int x) 
{ 
	set<int> s;
    while (x != 1) 
    { 
        s.insert(spf[x]); 
        x = x / spf[x]; 
    }
    for (auto it:s)
    	m[it]++; 
} 
  

signed main() {

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
     sieve(); 
     
     int n;
     cin>>n;
     vector<int> v(n);
     int x;
     cin>>x;
    int  result=x;
     getFactorization(x);
     for (int i=1;i<n;++i){
     	cin>>x;
     	result = gcd(x, result); 
     	getFactorization(x);
     }
     int count=0;
   	for (int i=2;i<=MAXN;++i){
   		if (m[i]==0)
   			continue;
   		if (m[i]!=1){
   			count=1;
   			break;
   			}
   	}
   if (count==0)
		cout<<"pairwise coprime"<<endl;
	else if (result==1)
		cout<<"setwise coprime"<<endl;
	else
		cout<<"not coprime"<<endl;
   	return 0;
}

Measured memory_bytes: 58288
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [i64;n]
    }
    let mut x = 0;
    for i in 0..n {
        if i % 2 == 0 {
            x += a[i];
        } else {
            x -= a[i];
        }
    }
    x /= 2;
    let mut v = Vec::new();
    v.push(x);
    for i in 0..n-1 {
        let vi = v[i];
        v.push(a[i]-vi);
    }
    for i in &v {
        println!("{}", i*2);
    }
}


Measured memory_bytes: 9468
N = int(input())
A = list(map(int, input().split()))

if 0 in A:
        ans = [0]
else:
    ans = [1]*N
    
    for i,a in enumerate(A):
        if i==0:
            ans[i] = a
        else:
            ans[i] = ans[i-1]*a

        if ans[i] > 10**18:
            ans[-1] = -1
            break
    
print(ans[-1])

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

void disp(vector<ll> cand){
	rep (i, cand.size()){
		cerr << cand[i] << ' ';
	} // end rep
	cerr << endl;
}

ll s2ll(string s){
	stringstream ss(s);
	ll res;
	ss >> res;

	return res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string S; cin >> S;
	int n = S.length();

	ll res = s2ll(S);
	for (int i = 1; i < (1<<(n-1)); ++i){
		int prev = 0;
		vector<ll> cand; cand.clear();
		for (int j = 0; j < (n-1); ++j){
			if (i & (1<<j)){
				string T = S.substr(prev, j - prev + 1);
				ll val = s2ll(T);
				cand.push_back(val);
				prev = j + 1;
			} // end if
		} // end for
		string T = S.substr(prev);
		ll val = s2ll(T);
		cand.push_back(val);
//		disp(cand);
		res += accumulate(ALL(cand), 0LL);
	} // end for
	
	cout << res << endl;			

	return 0;
}

Measured memory_bytes: 256
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18+5;

// defines...
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

// chess moves...
// int dx[] = {+0, +0, -1, +1}; ///Up-down, Left-Right
// int dy[] = {+1, -1, +0, +0};
// int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
// int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1};
// int dx[] = {-2, -2, -1, -1,  1,  1,  2,  2}; ///Knight's Move
// int dy[] = {-1,  1, -2,  2, -2,  2, -1,  1};

// structs...
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

// functions...
ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b)*b);
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}


int ara[100001];
vector<vi> edge(100001);
void task()
{
    //code here...
    
    int n, m, x, y, ans=0;
    
    cin >> n >> m;
    
    for(int K=1; K<=n; K++) cin >> ara[K];
    
    while(m--){
		cin >> x >> y;
		edge[x].PB(y);
		edge[y].PB(x);
	}
	
	for(int K=1; K<=n; K++){
		//if(bfs(K)) ans++;
		bool ok = 1;
		for(int L=0; L<sz(edge[K]); L++){
			if(K!=edge[K][L] && ara[edge[K][L]]>=ara[K]) ok = 0;
		}
		
		if(ok) ans++;
	}
	
	cout << ans << "\n";
}


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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    task();

    return 0;
}


Measured memory_bytes: 8676
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#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 debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
#define debug2(x, y) cout << #x << " = " << x << "   " << #y << " = " << y << nl;
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
const int MAXN = 100005;
ll mod=1000000007;


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt;
  tt = 1;
  // cin>>tt;
  while(tt--){
    string s,t;
    cin>>s>>t;
    string ans = "~";
    int n = s.size();
    int m = t.size();
    rep(i,0,n - m){
      string s2 = s;
      bool ok = true;
      rep(j,0,m-1){
        if(s[i+j]==t[j] || s[i+j]=='?'){
          s2[i+j] = t[j];
        }
        else{
          ok = false;
          false;
        }
      }
      if(ok){
        replace(s2.begin(), s2.end(), '?', 'a');
        ans = min(ans, s2);
      }
    }

    if(ans == "~"){
      cout<<"UNRESTORABLE"<<nl;
    }
    else{
      cout<<ans<<nl;
    }
  }
  return 0;
}


Measured memory_bytes: 3596
import sys
from itertools import product

n, *abc = map(int, sys.stdin.readline().split())
*l, = map(int, sys.stdin.read().split())

def main():
    cand = []
    for p in product([0, 1, 2, 3], repeat=n):
        group = [[] for _ in range(4)]
        for i in range(n):
            group[p[i]].append(l[i])
        cost = 0
        for i in range(1, 4):
            if not group[i]: 
                break
            cost += 10 * (len(group[i]) - 1)
            group[i] = sum(group[i])
        else:
            group = group[1:]
            for i in range(3):
                cost += abs(abc[i] - group[i])
            cand.append(cost)
        
    print(min(cand))

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 5016
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial;

void main(){
    writeln(totalSum(readln.chomp));
}

long totalSum(string str){
    long total=0;
    foreach(i,s;str){
        auto num=[s].to!long;
        auto headPattern=2^^i;
        auto tl=str.length-i-1;
        auto tailSum=10L^^tl+2L^^(tl-1)*(5L^^tl-1)/4;
        total+=num*headPattern*tailSum;
    }
    return total;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>

int main()
{
    int N;
    int *A;
    scanf("%d\n", &N);
    
    A = (int *)malloc(N* sizeof(int));
   
   for(int k=0; k<N; k++)
   {
     A[k] = 0;
   }
  
   int i;
   while(scanf("%d",&i)==1)
   {
      A[i-1]++;
    }

   for(int k=0; k<N; k++)
   {
     printf("%d\n",A[k]);
   }
   
   free(A);
  
   return 0;
}

Measured memory_bytes: 2224