akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;

string my_readln() { return chomp(readln()); }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto tokens = my_readln().split();
	auto N = tokens[0].to!uint;
	auto K = tokens[1].to!uint;
	auto a = my_readln.split.to!(long[]);

	auto dp = new long[](100005);

	foreach (i; 0..K)
	{
		if (dp[i] == 1) continue;
		foreach (j; 0..N)
		{
			dp[i+a[j]] = 1;
		}
	}

	writeln(dp[K] == 1 ? "First" : "Second");
	stdout.flush();
}

Measured memory_bytes: 3836
# 099a https://atcoder.jp/contests/abc099/tasks/abc099_a

# 入力
N = int(input()) # Nはコンテスト開催数　N回目

# 処理
if N < 1 or N > 1998:
    answer = '値が制約外です'
elif N <= 999:
    answer = 'ABC'
else:
    answer = 'ABD'

# 出力
print(answer)

Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N; 
  
  if (N % 2 == 0) {
    cout << 0.5 << endl;
  }
  else
    cout << (N + 1) / (2.0 * N) << endl;
}


Measured memory_bytes: 256
<?php

while ($stdin = fgets(STDIN)) {
    $line[] = trim($stdin);
}
foreach ($line as $key => $value) {
    $data[] = explode(' ', $value);
}

//foreach ($data as &$line) {
//    $line = array_map(function($val) { return (int)$val; }, $line);
//}


$K = (int)$data[0][0];
$S = $data[1][0];

$len = strlen($S);

if ($len > $K) {
    $ans = substr($S, 0, $K) . '...';
} else {
    $ans = $S;
}


printf('%s', $ans);


Measured memory_bytes: 16140
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * @author:26019
 */
public class Main {


    public static void main(String[] args) throws Exception {
        solve();
    }

    private static void solve() throws Exception {
        //BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File("C:\\Users\\26019\\Downloads\\out.txt"))));
        FastScanner cin = new FastScanner();
        int n = cin.nextInt();
        int[] arr = cin.readArray(n);
        long curMoney = 1000;
        for (int i = 1; i < n; i++) {
            long stocks = 0;
            if (arr[i] > arr[i - 1]) stocks = curMoney / arr[i - 1];
            curMoney += stocks * (arr[i] - arr[i - 1]);
        }
        System.out.println(curMoney);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("C:\\Users\\26019\\Downloads\\P1190_9.in"))));
        StringTokenizer st = new StringTokenizer("");

        FastScanner() throws FileNotFoundException {
        }

        public String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        public String nextLine() { // 读取带空格的字符串
            String res = null;
            try {
                res = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return res;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}


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


int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if((b-a <= k && c-a <= k && d-a <= k && e-a <= k)
  && (c-b <= k && d-b <= k && e-b <= k)
  && (d-c <= k && e-c <= k )
  && (e-d <= k )) cout << "Yay!"<< endl;
  else cout << ":(" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x1= a*c;
	int y1 = a*d;
	int x2 = b*c;
	int y2 = b*d;;
//	cout<<x1<<endl;
	cout<<max(x1,max(x2,max(y1,y2)))<<endl;
}


Measured memory_bytes: 3632
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	//ll x;
	double x;
	int cnt = 0;
	double sum = 100;

	cin >> x;

	for (; ; ) {
		if (sum >= 1000000000000000000) {
			//break;
		}
		if (sum >= x) {
			break;
		}
		sum *= 1.01;
		ll sum2 = sum;
		sum = sum2;
		cnt++;
		
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long unsigned n, k, ans = 1;
	scanf("%llu%llu", &n, &k);
       ans = k;
	for(int i = 2; i <=n; i++){
		ans*=(k-1);
	}
	printf("%llu", ans);
	return 0;
}

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

int main() {
	long double sum=0.0;
int i,j,t;
	cin>>t;
	int x[t+10],y[t+10];
	for(i=0;i<t;i++)
	{
		cin>>x[i]>>y[i];
	}
	for(i=0;i<t;i++)
	{
		for(j=i+1;j<t;j++)
		{
			sum+=(sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])));
		}
	}
	//cout<<sum;
	long double p=t/2.0;
	long double d=sum/p;
	printf("%0.10Lf",d);
}

Measured memory_bytes: 256
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
 
ll pwr(ll base, ll p, ll mod){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}
 
 
int n, color[100005];
set<int> adj[100005], orig[100005];
bool removed[100005];
 
 
int main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    cin>>n;
    if(n == 1){
    	cout<<"First";
    	return 0;
    }
 
 
    int e = n-1;
    while(e--){
 
    	int a, b;
    	cin>>a>>b;
    	adj[a].insert(b);
    	adj[b].insert(a);
    }
 
    priority_queue<ii> pq;
    for(int i=1;i<=n;i++){
    	pq.push(ii(-(int)adj[i].size(), i));
    	color[i] = -1;
    }
 
    while(!pq.empty()){
 
    	int v = pq.top().ss;
    	int deg = -pq.top().ff;
    	pq.pop();
 
// cout<<"popped "<<v<<" "<<deg<<endl; 
 
    	if(color[v] != -1){
    		continue;
    	}
 
// cout<<"retained "<<v<<" "<<deg<<endl;
 
 		assert(deg <= 1);

    	if(deg == 0){
    		color[v] = 0;
    		cout<<"First";
    		return 0;
    	}
 
    	if(deg == 1){
    		int vv = (*adj[v].begin());
    		color[vv] = 0;
    		color[v] = 1;
    		for(auto it : adj[vv]){
    			adj[it].erase(vv);
    			pq.push(ii(-(int)adj[it].size(), it));
    		}
    		adj[v].clear();
    		adj[vv].clear();
    		continue;
    	}
 
    	// assert(0);
    }
 
// for(int i=1;i<=n;i++)	cout<<color[i]<<" ";cout<<endl;
    cout<<"Second";
    return 0;
}







Measured memory_bytes: 20472
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {



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

    /////////////////////
    // Write code below /
    /////////////////////
    int x,y,z;
    cin >>x>>y>>z;
    
    cout <<z<<" "<<x<<" "<<y<<"\n";
    
    
    return 0;
}


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

/*
    バイトがn件あり、m日後までに受け取れる報酬の総和を最大化する。
    例：m=4、(4,3),(4,1),(2,2)
    ペア(a,b)について、
    ペアをaの値でソートし、頭から順に実行していく。
    ただし、残りi日のタイミングでiより大きいaを持つペアは消す。
    forループ。i=0からスタートし、i=m-1の間で、ペアの配列を順番に走査。
    配列のaがm-i<aであれば、配列の頭を削除し、続ける。
*/
/*
void solve(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> v;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        v.emplace_back(make_pair(a,b));
    }
    sort(v.rbegin(), v.rend());
    cout << v[0].first << " " << v[0].second << " " << v[1].first << " " << v[1].second << " " << endl;
    int sum = 0;
    int pointer = 0;
    for(int i=0; i<m; i++){
        //int a = v[pointer].first;
        //int b = v[pointer].second;
        while(m-i<v[pointer].first){
            pointer++;
        }
        sum += v[pointer].second;
        pointer++;
    }
    cout << sum << endl;
}
*/
/*
これは正しくない。
*/

/*
正しいやり方。
制約の厳しい方から順に見ていく。すなわち、
i=1~mについて、a<=iを満たすペアの中で最もbが大きいものを取り出し、bを加算。
*/

void solve(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> v1;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        v1.emplace_back(make_pair(a,-b));
    }
    //第一要素は昇順、第二要素は降順
    sort(v1.begin(), v1.end());
    vector<pair<int,int>> v;
    rep(i,n){
        int a,b;
        a = v1[i].first;
        b = v1[i].second;
        v.emplace_back(make_pair(a,-b));
    }
    int sum = 0;
    int pointer = 0;
    priority_queue<int> q;
    for(int i=1; i<=m; i++){
        //cout << "start!!!" << endl;
        //cout << i << " " << pointer << " " << v.at(pointer).first << " " << v.at(pointer).second << endl;
        while(pointer < v.size() && v.at(pointer).first <= i){
            //cout << "v.size:" << v.size() << " pointer:" << pointer << endl;
            q.push(v.at(pointer).second);
            pointer++;
        }
        if(!q.empty()) {
            //cout << "q.top():"<< q.top() << endl;
            sum += q.top();
            q.pop();
        }
    }
    cout << sum << endl;
}

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

Measured memory_bytes: 2676
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main(){
	FIO
	
	set<int> s1, s2, s3;
	s1.insert({1, 3, 5, 7, 8, 10, 12});
	s2.insert({4, 6, 9, 11});
	s3.insert({2});
	int x, y;
	cin >> x >> y;
	if(s1.find(x) != s1.end() && s1.find(y) != s1.end())puts("Yes");
	else if(s2.find(x) != s2.end() && s2.find(y) != s2.end())puts("Yes");
	else if(s3.find(x) != s3.end() && s3.find(y) != s3.end())puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
/*
编号1-n的城镇
1是首都
镇i可以传送到ai（1≤ai≤N）
保证任何城镇可以经过多次到达首都
改变若干个传送的终点ai，使得对于每一个城镇都有传送k次恰好到达首都
输出 改变ai的最小数量

首先1连向1
然后变成了一棵树
贪心若一颗子树到当前节点的深度等于k-1就将此点连向根节点一条边 
*/
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
int n, k, ans = 0;
int cnt = 1, head[maxn], a[maxn];
struct Node {int v, nxt;} G[maxn << 1];
void ins(int u, int v) {G[cnt] = (Node) {v, head[u]}; head[u] = cnt++;}
int dfs(int x, int deep) {
	int ret = deep;
	for (int i = head[x]; i; i = G[i].nxt) {
		ret = max(ret, dfs(G[i].v, deep + 1));
	}
	if(a[x] != 1 && ret - deep == k - 1) return ++ans, 0;
	else return ret;
}
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	if(a[1] != 1) ans = a[1] = 1;
	for (int i = 2; i <= n; ++i) ins(a[i], i);
	dfs(1, 0); 
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 6528
from collections import deque
ans=[]
while True:
    w,h=map(int,input().split())
    if w==0 and h==0:
        break
    lr=[]
    ud=[]
    dist=[[-1]*(w+2) for _ in range(h+2)]
    dist[1][1]=1
    lr.append([1 for _ in range(w+1)])
    ud.append([1 for _ in range(w+2)])
    lr.append([1]+list(map(int,input().split()))+[1])
    for i in range(h-1):
        ud.append([1]+list(map(int,input().split()))+[1])
        lr.append([1]+list(map(int,input().split()))+[1])
    lr.append([1 for _ in range(w+1)])
    ud.append([1 for _ in range(w+2)])

    q=deque()
    q.append([1,1])
    while q:
        x,y=q.popleft()
        if 0<=y-1 and lr[x][y-1]==0:
            if dist[x][y-1]==-1 or dist[x][y-1]>dist[x][y]+1:
                q.append([x,y-1])
                dist[x][y-1]=dist[x][y]+1
        if y+1<=w+1 and lr[x][y]==0:
            if dist[x][y+1]==-1 or dist[x][y+1]>dist[x][y]+1:
                q.append([x,y+1])
                dist[x][y+1]=dist[x][y]+1
        if 0<=x-1 and ud[x-1][y]==0:
            if dist[x-1][y]==-1 or dist[x-1][y]>dist[x][y]+1:
                q.append([x-1,y])
                dist[x-1][y]=dist[x][y]+1
        if x+1<=h+1 and ud[x][y]==0:
            if dist[x+1][y]==-1 or dist[x+1][y]>dist[x][y]+1:
                q.append([x+1,y])
                dist[x+1][y]=dist[x][y]+1
    if dist[h][w]==-1:
        ans.append(0)
    else:
        ans.append(dist[h][w])
for i in ans:
    print(i)


Measured memory_bytes: 6032
#include <iostream>
#include <vector>

#define RANKING 3
int main(){
	int x;
	int ranking[RANKING] = {0};
	for(int i = 0; i < 10; i++){
		std::cin >> x;
		for(int i = 0; i < RANKING; i++){
			if(ranking[i] < x){
				for(int j = RANKING-1; j > i; j--){
					ranking[j] = ranking[j-1];
				}
				ranking[i] = x;
				break;
			}
		}
	}
	for(int i = 0; i < RANKING; i++){
		std::cout << ranking[i] << std::endl;
	}
	return 0;
}

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

int main() {
    int n, k, q; cin >> n >> k >> q;
    vector<int> a(n), b;
    for (int i = 0; i < n; i++) cin >> a[i];
    b = a; sort(b.begin(), b.end());
    int ans = 2e9; int minval = 0;
    for (int i = 0; i < n; i++) {
        if (i > 0 && b[i] <= minval) continue;
        int t = b[i];
        vector<int> v, w;
        for (int j = 0; j < n; j++) {
            if (a[j] < t) {
                if (v.empty()) continue;
                if (v.size() >= k) {
                    sort(v.rbegin(), v.rend());
                    while (v.size() >= k) {
                        w.emplace_back(v.back());
                        v.pop_back();
                    } 
                }
                v.clear();
            } else {
                v.emplace_back(a[j]);
            }
        }
        if (!v.empty()) {
            if (v.size() >= k) {
                sort(v.rbegin(), v.rend());
                while (v.size() >= k) {
                    w.emplace_back(v.back());
                    v.pop_back();
                }
            }
        }        
        if (w.size() < q) continue;
        sort(w.begin(), w.end());
        ans = min(ans, w[q-1] - w[0]);
        minval = max(minval, w[0]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<cstring>
#include<algorithm>
#include<string>
#include<stack>
#include<cmath>
#include<map>
#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define per(i,l,r) for(int i=(r-1);i>=l;i--)
#define P pair<int,int>
#define ll long long
using namespace std;
ll a[100005],b[100005];
int main ()
{
	int n;
	cin>>n;
	rep(i,0,n+1)cin>>a[i];
	rep(i,0,n)cin>>b[i];
	ll s=0;
	rep(i,0,n)
	{
		if(b[i]>=a[i])s+=a[i],b[i]-=a[i],a[i]=0;	
		else  a[i]-=b[i],s+=b[i],b[i]=0;
		if(b[i]>=a[i+1])s+=a[i+1],b[i]-=a[i+1],a[i+1]=0;	
		else  a[i+1]-=b[i],s+=b[i];
	}
	cout<<s;
//	while(1);
	return 0;
}

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

#define int long long
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()

#define fast ios::sync_with_stdio(0); cin.tie(0)
#define print(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1> void __f(const char* name, Arg1&& arg1){
    cout << name << ": " << arg1 << '\n';
}

template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

int32_t main(){
    
    fast;
    
    int a,b; cin >> a >> b;
    int socket = 1;
    int cnt = 0;
    
    while(socket<b){
        socket--;
        socket = socket + a;
        cnt++;
    }

    cout << cnt << '\n';
    return 0;
} 

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

int main() {
    int Q;
    cin >> Q;
    for(int i=0; i<Q; ++i) {
        int N;
        cin >> N;

        int cnt = 0;
        set<int> rec;
        while(N >= 10) {
            int next = 0;
            for(int j=1; ; ++j) {
                int mod10j = N % static_cast<int>(pow(10, j));
                if(mod10j == N) {
                    break;
                } else {
                    next = max(next, N / static_cast<int>(pow(10, j)) * mod10j);
                }
            }
            N = next;
            if(rec.count(N) == 1) {
                cnt = -1;
                break;
            } else {
                rec.insert(N);
                cnt += 1;
            }
        }
        cout << cnt << endl;
    }
}


Measured memory_bytes: 3292
S = input()
T = input()

min_length = 10000
len_def = len(S) - len(T)
for i in range(len_def + 1):
    counter = 0
    for j in range(len(T)):
        if S[j + i] != T[j]:
            counter += 1

    if counter < min_length:
        min_length = counter
print(min_length)


Measured memory_bytes: 9028
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e7+7;
ll f[N];
int main(){
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		for(ll j=i;j<=n;j+=i){
			f[j]++;
		}
	}
	ll ans=0;
	for(ll i=1;i<=n;i++){
		ans+=i*f[i];
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 81712
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll _pow(ll a, ll n) {
	if(n==0) return 1;
	else {
		ll res = 1;
		ll buf = a;
		while(n>0) {
			if(n%2==1) {
				res *= buf;
				res %= MOD;
			}
			buf *= buf;
			buf %= MOD;
			n/=2;
		}
		return res;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	vector<ll> fact(100010,0);
	fact[0]=1;
	fact[1]=1;
	FOR(i,2,100010) {
		fact[i]=i*fact[i-1];
		fact[i]%=MOD;
	}
	vector<ll> v(n+1,0);
	v[1]=fact[n];
	FOR(i,2,n+1) {
		v[i]=v[i-1]+fact[n]*_pow(i,MOD-2);
		v[i]%=MOD;
	}
	ll ans=0;
	REP(i,n) {
		ll aa=i+1,bb=n-i;
		ans+=v[aa]*a[i];
		ans+=v[bb]*a[i];
		ans-=v[1]*a[i];
		ans%=MOD;
	}
	cout<<(ans%MOD+MOD)%MOD<<endl;
	return 0;
}


Measured memory_bytes: 2560
h,w = map(int, input().split())
a = [''] * h
for i in range(h):
    a[i] = input()

row = [False] * h
col = [False] * w
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            row[i] = True
            col[j] = True

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j], end = '')
        print()

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

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,k,g,m,br=0;
    cin >> n >> k;
    vector<int> v(n+1,0);
    for (int i=0;i<k;i++)
    {
        cin >> g;
        for (int i=0;i<g;i++)
        {
            cin >> m;
            v[m]++;
        }
    }
    for (int i=1;i<=n;i++)
        if(v[i]==0)
            br++;
    cout << br;
}


//freopen("testcases/17.in", "r", stdin);
//freopen("output.txt", "w", stdout);


Measured memory_bytes: 3632
import sys


def _i(): return int(sys.stdin.readline().strip())


def main():
    n = _i()
    s = 0
    for i in range(1, n+1):
        m = n // i
        l = (m*(m+1)) // 2
        s += i*l
    return s


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


Measured memory_bytes: 62912
import java.util.*;

public class Main{

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

        int K = sc.nextInt();
        int S = sc.nextInt();
        sc.close();
        
        long count = 0;
        for(int i = 0; i <= K; i++){
            for(int j = 0; j <= K; j++){
                int z = S - i - j;
                if(z >= 0 && z <= K)
                    count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
import scala.io.StdIn

object Main extends App {
  val Array(n, m) = StdIn.readLine.split(" ").map(_.toInt)

  val ans = (n to m).count(i => {
    ( i / 10000) == (i % 10) && (i % 10000 / 1000) == (i % 100 / 10)
  })

  println(ans)
}


Measured memory_bytes: 27732
#include <bits/stdc++.h>
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define MOD 1000000007
#define PSET(x,y) fixed<<setprecision(y)<<x
#define ll long long
#define ld long double
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define lop(i,a,b) for(ll i=a;i<b;i++)
#define lopr(i,a,b) for(ll i=a;i>=b;i--)
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define ff first
#define ss second
#define pi pair<int,int>
#define pll pair<ll, ll>
#define si set<int>
#define sll set<ll>
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
#define state tuple<int,int,int>
#define graph map<ll,list<ll>>

const ld PI = asin(1) * 2;
inline int sbt(int x){return __builtin_popcount(x);} //returns number of set bits

using namespace std;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif

#define SIZE

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    fast_io()
    
    ll n,W;
    cin>>n>>W;

    ll wt[n], v[n];
    lop(i,0,n)
    	cin>>wt[i]>>v[i];

	ll dp[n+1][W+1];
	lop(i,0,n+1){
		lop(w,0,W+1){
			if(i==0 || w==0)
				dp[i][w] = 0;
			else if(wt[i-1]<=w)
				dp[i][w] = max(dp[i-1][w], v[i-1] + dp[i-1][w-wt[i-1]]);
			else
				dp[i][w] = dp[i-1][w];

			// cout<<dp[i][w]<<" \n"[w==W];
		}
	}

	cout<<dp[n][W];
    return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <queue>
#include <cstring>
 
using namespace std;
 
#define MAX 20
#define INF 1e9
 
int H,W,ax,ay,bx,by;
char field[MAX][MAX];
string str;
const int dx[] = {-1,0,0,1,0};
const int dy[] = {0,-1,1,0,0};
 
struct State{
    int sx,sy,gx,gy;
    State(int sx,int sy,int gx,int gy) : sx(sx),sy(sy),gx(gx),gy(gy) {}
};
 
bool inField(int y,int x){
    return 0 <= y && y < H && 0 <= x && x < W;
}
 
int getDir(char ch){
    if(ch == '4') return 0;
    if(ch == '8') return 1;
    if(ch == '2') return 2;
    if(ch == '6') return 3;
    return 4;
}
 
void bfs(){
    int size = str.size();
    bool visited[MAX][MAX][MAX][MAX][MAX];
    memset(visited,0,sizeof(visited));
    visited[ay][ax][by][bx][0] = true;
    queue<State> Q;
    queue<int> Count;
    Q.push(State(ax,ay,bx,by));
    Count.push(0);
    while(!Q.empty()){
	State s = Q.front(); Q.pop();
	int cnt = Count.front(); Count.pop();
 
	if(s.sx == s.gx && s.sy == s.gy){
	    cout << cnt << " " << s.sy << " " << s.sx << endl;
	    return;
	}
 
	int dir = getDir(str[cnt%size]);
	int Gx = s.gx + dx[dir], Gy = s.gy + dy[dir];
	if(!inField(Gy,Gx)) Gx = s.gx, Gy = s.gy;
 
	for(int i = 0 ; i < 5 ; i++){
	    int nx = s.sx + dx[i], ny = s.sy + dy[i];
	    if(!inField(ny,nx)) continue;
	    if(field[ny][nx] == '#') continue;
	    if(visited[ny][nx][Gy][Gx][(cnt+1)%size]) continue;
	    visited[ny][nx][Gy][Gx][(cnt+1)%size] = true;
	    Q.push(State(nx,ny,Gx,Gy));
	    Count.push(cnt+1);
	}
    }
    cout << "impossible" << endl;
}
 
int main(){
    while(cin >> H >> W, (H|W)){
	for(int i = 0 ; i < H ; i++){
	    for(int j = 0 ; j < W ; j++){
		cin >> field[i][j];
		if(field[i][j] == 'A'){
		    ax = j, ay = i;
		}else if(field[i][j] == 'B'){
		    bx = j, by = i;
		}
	    }
	}
	cin >> str;
	bfs();
    }
    return 0;
}

Measured memory_bytes: 6288
def slimes(a):
    n = len(a)
    d = [[0] * (n + 1) for _ in range(n + 1)]
    prefix = [0] * (n + 1)
    for i in range(1, n + 1):
        prefix[i] = prefix[i - 1] + a[i - 1]

    for l in range(2, n + 1):
        for x in range(n - l + 1):
            z = x + l
            d[x][z] = min(d[x][y] + d[y][z] for y in range(x + 1, z)) + (prefix[z] - prefix[x])

    return d[0][n]


def main():
    input()  # n
    a = [int(x) for x in input().split()]
    return slimes(a)


print(main())


Measured memory_bytes: 43924
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

class UnionFind{
  public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
  public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  int n,q; cin >> n >> q;
  vl a(n); rep(i,n) cin >> a[i];
  rep(i,q) {
    ll x; cin >> x;
    ll sum = 0, ans = 0;
    int right = 0;
    rep(left,n) {
      while(right < n && sum + a[right] <= x){
        sum += a[right];
        right++;
      }
      ans += right - left;
      sum -= a[left];
    }

    cout << ans << endl;
  }
}


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

using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  s += s;

  vector<int> res(n + 2);

  auto test = [&](int a, int b) {
    res[0] = a;
    res[1] = b;
    for (int i = 2; i < n + 2; i++) {
      res[i] = res[i - 2];
      if (s[i - 1] == 'x') res[i] ^= 1;
      if (res[i - 1] == false) res[i] ^= 1;
    }
    return (res[0] == res[n] && res[1] == res[n + 1]);
  };

  for (auto a : {0, 1}) {
    for (auto b : {0, 1}) {
      if (test(a, b)) {
        for (int i = 0; i < n; i++) {
          cout << (res[i] ? 'S' : 'W');
        }
        cout << '\n';
        return 0;
      }
    }
  }

  cout << -1 << '\n';
  return 0;
}


Measured memory_bytes: 3892
n, m = STDIN.gets.chomp.split(' ').map(&:to_i)

class Student
  attr_reader :num, :a, :b

  def initialize(num, a, b)
    @num = num
    @a = a
    @b = b
  end

  def to_s
    "Student    #{num}: #{a}, #{b}"
  end
end

class Checkpoint
  attr_reader :num, :c, :d

  def initialize(num, c, d)
    @num = num
    @c = c
    @d = d
  end
  def to_s
    "Checkpoint #{num}: #{c}, #{d}"
  end
end

students = n.times.map{|i| Student.new(i+1, *(STDIN.gets.chomp.split(' ').map(&:to_i)) ) }
checkpoints = m.times.map{|i| Checkpoint.new(i+1, *(STDIN.gets.chomp.split(' ').map(&:to_i)) ) }

students.each do |s|
  puts checkpoints.min{|c1, c2|
    (s.a - c1.c).abs + (s.b - c1.d).abs <=> (s.a - c2.c).abs + (s.b - c2.d).abs
  }.num
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second

int n, k;
vector<int>edge[2010];

int par[2010];
int dep[2010];
int sz[2010];
int dp[2010];
int dp2[2010];
void dfs(int x){
	dp[x]=0; dp2[x]=0; sz[x]=0;
	for(int y:edge[x]){
		if(par[x]==y) continue;
		par[y]=x;
		dep[y]=dep[x]+1;
		dfs(y);
		sz[x]+=sz[y];
		dp[x]+=dp[y]; dp2[x]+=dp2[y];
	}
	if(dep[x] == k/2) dp[x] += sz[x];
	if(dep[x] == k-k/2) dp2[x] += sz[x];
	sz[x]+=1;
}

int main()
{
	read(n, k);
	if(k == 1){
		printf("%d\n", n-2);
		return 0;
	}
	for(int i=1; i<n; ++i){
        int a, b; read(a, b);
        edge[a].pb(b);
        edge[b].pb(a);
	}
	int ans = n;
	for(int c=1; c<=n; ++c){
		fill(par+1, par+n+1, false);
		dep[c]=0;
		dfs(c);
		int ds = 0;
		for(int d:edge[c]) ds+=dp[d];
		for(int d:edge[c]) ans=min(ans, ds-dp[d]+dp2[d]);
	}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;cin >> n >> m;
	ll ans=0;
	if(n==1 && m==1) ans=1;
	else if(n==1 || m==1){
		ans=max((ll)0,max(n-2,m-2));
	}
	else{
		ans=(n-2)*(m-2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
path=[list(map(int,input().split())) for _ in range(3)]
city=[1,1,1,1]

for i in range(3):
    city[path[i][0]-1]=city[path[i][0]-1]-1
    city[path[i][1] - 1] = city[path[i][1] - 1] - 1
city.sort()
if (city[1]==-1)and(city[2]==0):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	bool is_visited = false;
} node;
typedef struct {
	int to;
	int cost;
	P <int, int> change;
} edge;

int main( void ){
	int x, y; cin >> x >> y;
	int diff = abs( abs( y ) - abs( x ));
	bool diff_sign = signbit( x ) != signbit( y );
	if (y == 0){
		cout << diff + !diff_sign << endl;
	}
	else if (signbit( x ) != signbit( y ))
		cout << diff + 1 << endl;
	else {
		if (y - x < 0)
			cout << diff + 2 << endl;
		else
			cout << diff << endl;
	}
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 3572
#include<iostream>
using namespace std;
void insert(int a[],int n) {
	int key;
	for (int k = 0; k < n - 1; k++)
		cout << a[k] << " ";
	cout << a[n - 1] << endl;
	for (int i = 1; i < n; i++)
	{
		key = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > key)
		{
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = key;
		for (int k = 0; k < n - 1; k++)
			cout << a[k] << " ";
		cout << a[n - 1] << endl;
	}
}
int main()
{
	int n;
	int a[200];
	while (cin >> n)
	{
		for (int i = 0; i < n; i++)
			cin >> a[i];
		insert(a, n);
	}
	
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define NIL -1
typedef long long ll;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll MOD = 1000000007;


ll gcd(ll a, ll b){
    if (a, b) {
        ll tmp = a;
        a = b;
        b = tmp;
    }

    ll r = a % b;
    while(r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

void solve() {

    ll a, b, result;
    cin >> a >> b;

    result = a * b / gcd(a, b);
    cout << result << endl;
    return;
}

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

}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
from collections import defaultdict
ns = defaultdict(set)
for i in range(n-1):
    u,v,c = map(int, input().split())
    u -= 1
    v -= 1
    ns[u].add((c,v))
    ns[v].add((c,u))
# print(ns)
k = len(bin(n-1))-2
# 深さ
def cdepth(root=0):
    # rootを根としたときの深さ
    ps = [None] * n
    ps[0] = -1
    q = [0]
    while q:
        u = q.pop()
        for c,v in ns[u]:
            if ps[v] is None:
                ps[v] = u
                q.append(v)
    # psを元から持っている場合、引数のnsをpsにしてこの下だけで良い
    depth = [None] * n
    depth[root] = 0
    q = [root]
    while q:
        u = q.pop()
        for c,v in ns[u]:
            if depth[v] is None:
                depth[v] = depth[u] + 1
                q.append(v)
    return depth, ps
def dijkstra(start):
    import heapq
    vals = [None] * n
    h = [(0, start)] # (距離, ノード番号)
    vals[start] = 0
    while h:
        val, u = heapq.heappop(h)
        for d, v in ns[u]:
            if vals[v] is None or vals[v]>val+d:
                vals[v] = val+d
                heapq.heappush(h, (vals[v], v))
    return vals

# ダブリング
def double(ps):
    # global: n=psのサイズ
    k = 0
    while pow(2,k)<n:
        k += 1
    prev = [[None]*n for _ in range(k)] # ノードjから2^i個上の上司
    for j in range(n):
        prev[0][j] = ps[j]
    for i in range(1,k):
        for j in range(n):
            p = prev[i-1][j]
            if p>=0:
                prev[i][j] = prev[i-1][p]
            else:
                prev[i][j] = p
    return prev
            

# k: 必要桁数を定める必要アリ
def cprev(u,i):
    """uからi個上の頂点を返す
    """
    for j in range(k):
        if i>>j&1:
            u = prev[j][u]
    return u

# k: 必要桁数を定める必要アリ
def lca(u,v):
    if depth[u]<depth[v]:
        v = cprev(v, depth[v]-depth[u])
    else:
        u = cprev(u, depth[u]-depth[v])
    if u==v:
        return u
    for i in range(k-1, -1, -1):
        if prev[i][u]!=prev[i][v]:
            u = prev[i][u]
            v = prev[i][v]
    return prev[0][u]

q,K = map(int, input().split())
K -= 1
dist = dijkstra(K)
ans = [None]*q
for i in range(q):
    x,y = map(int, input().split())
    x -= 1
    y -= 1
    ans[i] = dist[x] + dist[y]
write("\n".join(map(str, ans)))

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) (x).begin(),(x).end()
#define Ceil(x, n) (((((x))+((n)-1))/n))
#define CeilN(x, n) (((((x))+((n)-1))/n)*n)

#define INF 2e7
#define INF_LL 1LL<<60
#define ll long long
typedef pair<ll, ll>    P;

ll gcd(ll a, ll b){
    ll tmp;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }

    ll r = a%b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

vector<int> Eratosthenes(const int N )
{
    std::vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    std::vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

int main()
{
    int n;
    cin >> n;
    vector<int> inp(n);
    REP(i, n) cin >> inp[i];
    vector<int> prime;
    prime = Eratosthenes(1005);

    vector<int> ans(1000001, 0);

    REP(i, n) {
        REP(j, prime.size()) {
            int div = prime[j];
            if(div > sqrt(inp[i])) continue;
            if(inp[i] % div == 0) {
                ans[div]++;
                if(div != inp[i]/div) ans[inp[i]/div]++;
                //cout << inp[i] << " " << div << endl;
            }
        }
        ans[inp[i]]++;
    }

    bool flag = false;

    REP(i, 1000001) {
        if(i != 1) if(ans[i] > 1) flag = true;
    }

    if(ans[1] == n || !flag) {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    int num = inp[0];

    REP(i, n-1) {
        num = gcd(num, inp[i+1]);
    }

    if(num > 1) {
        cout << "not coprime" << endl;
    } else {
        cout << "setwise coprime" << endl;
    }

    //cout << prime.size() << endl;

    return 0;
}

Measured memory_bytes: 11128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

vector<int> dy = {1, 0, -1, 0};
vector<int> dx = {0, 1, 0, -1};
int main() {
    int a, b;
    cin >> a >> b;
    cout << (a ^ b) << endl;
}


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

int main(){
  int a[3];

  for( int i = 0; i < 3; i++ ){
    cin >> a[i];
  }
  
  for( int i = 0; i < 2; i++ ){
    for( int j = i + 1; j < 3; j++ ){
      if( a[i] > a[j] ){
	int tmp = a[i];
	a[i] = a[j];
	a[j] = tmp;
      }
    }
  }

  for( int i = 0; i < 2; i++ ){
    cout << a[i] << ' ';
  }

  cout << a[2] << endl;;
}



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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int a,b,c;
  cin>>a>>b>>c;
  swap(a,b);
  swap(a,c);
  cout<<a<<" "<<b<<" "<<c<<endl;

}

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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define trav(e, x) for (auto &(e) : (x))
#define pb(x) push_back(x)
#define eb(x...) emplace_back(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define lc(i) 2*i
#define rc(i) 2*i+1
//#define int long long
using namespace std;
using ii = pair<int, int>;
using vi = vector<int>;

const int N = 1e5 + 5, MOD = 1e9 + 7, INF = 1e9 + 5;

signed main() {
    FAST_IO;
    //setIO("input.txt", "output.txt");

    double d, t, s;
    cin >> d >> t >> s;
    if (d / s <= t) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3760
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b;cin>>a>>b;
    map<int,int>m;
    m[a]++;m[b]++;
    for(int i=1;i<=3;i++){
        if(!m[i])
            cout<<i<<endl;
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const int i_INF = 2147483647;
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; }

int main() {
	while (true) {
		int a, b, n;
		cin >> a >> b;

		if (a == 0)return 0;

		cin >> n;
		int d[111][111];
		bool h[111][111];

		rep(i, 0, 111)rep(j, 0, 111) {
			h[i][j] = true;
			d[i][j] = 0;
		}

		rep(i, 0, n) {
			int x, y;
			cin >> x >> y;
			h[x][y] = false;
		}

		d[1][1] = 1;

		rep(i, 1, b + 1)rep(j, 1, a + 1) {
			if (i == 1 && j == 1)continue;
			bool x = h[j - 1][i];
			bool y = h[j][i - 1];
			if (x == true) {
				if (y == true)d[j][i] = d[j - 1][i] + d[j][i - 1];
				else d[j][i] = d[j - 1][i];
			}
			else {
				if (y == true)d[j][i] = d[j][i - 1];
				else d[j][i] = 0;
			}
		}
		cout << d[a][b] << endl;
	}
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない
//UnionFind

const int maxn=100000;

int main(){
    
    int n,m;
    int ans=1;
    int cnt[maxn];
    bool red[maxn];
    
    cin >> n>>m;
    
    rep(i,n){
        cnt[i]=1;
        red[i]=0;
    }
    red[0]=1;
    
    rep(i,m){
        int from,to;
        scanf("%d%d",&from,&to);
        from--;to--;
        cnt[from]--;
        cnt[to]++;
        if(red[from]&&!red[to]){
            red[to]=true;
            ans++;
        }
        if(cnt[from]==0&&red[from]){
            ans--;
            red[from]=false;
        }
        
    }
    
    cout << ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 768