akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    INF = 10 ** 18
    ans = 1
    is_INF = False
    for a in A:
        ans *= a
        if ans > INF:
            is_INF = True
            break
    if is_INF:
        if 0 in A:
            print(0)
        else:
            print(-1)
    else:
        print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 83004
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}
ll lcm(ll l,ll a){
    return a/__gcd(l,a)*l;
}


int main(){
    int n,m;cin >> n >> m;
    rep(i,m){
        int k;cin >> k;
        n-=k;
    }
    if(n<0)n=-1;
    cout << n << endl;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>

using namespace std;

void change(int *x,int *y){
	*x=*x+*y;
	*y=*x-*y;
	*x=*x-*y;
	return;
}
int main(void){

	int a,b,c;

	cin>>a>>b>>c;

	if(a>b) change(&a,&b);
	if(b>c) change(&b,&c);
	if(a>b) change(&a,&b);
	
	cout<<a<<" "<<b<<" "<<c<<endl;

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    int c = 0;
    if (a > b) {
        c += a--;
    } else {
        c += b--;
    }
    if (a > b) {
        c += a--;
    } else {
        c += b--;
    }
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forv(i,a) for(auto& i:a)
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define pb push_back
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
typedef long long ll;
int re(){int x=0; bool neg=false;char c;while (c!='-' && (c<'0'||'9'<c)) c=getchar();if (c=='-'){neg=true;c=getchar();}while ('0'<=c && c<='9'){x=x*10+c-'0';c=getchar();}if (neg) x=-x;return x;}
void rout(int x) {if (x>9) rout(x/10); putchar(x%10+'0');}
const int N=300010;
const int mod=1e9+7;
int n,m,cnt;
int f[N],d[N],g[N];
pii a[N];
int pw(int a, int n)
{
    if (n==1) return a;
    int tg=pw(a,n/2);
    tg=(tg*tg)%mod;
    if (n%2) return (tg*a)%mod;
    return tg;
}
int cal(int n, int k)
{
    if (n<k) return 0;
    if (!n||!k||n==k) return 1;
    return d[n]*g[n-k]%mod*g[k]%mod;
}
 main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    //freopen("grid2.inp","r",stdin);
    cin>>n>>m>>cnt; d[0]=1;
    forinc(i,1,n+m+2) d[i]=(d[i-1]*i)%mod;
    forinc(i,1,n+m+2) g[i]=pw(d[i],mod-2);
    forinc(i,1,cnt)
    {
        int x,y; cin>>x>>y;
        a[i]={x,y};
    }
    sort(a+1,a+cnt+1);
    a[++cnt]={n,m};
    forinc(i,1,cnt)
    {
        f[i]=cal(a[i].fi+a[i].se-2,a[i].fi-1);
        forinc(j,1,i-1)
        {
            f[i]=(f[i]-f[j]*cal(a[i].fi-a[j].fi+a[i].se-a[j].se,a[i].fi-a[j].fi)%mod+mod)%mod;
        }
    }
    cout<<f[cnt];
}


Measured memory_bytes: 6400
N, M = map(int, input().split())
li = [0] * M
ans = 0
for i in range(N):
    A = list(map(int, input().split()))
    for j in A[1:]:
        li[j-1] += 1
        if li[j-1] == N:
            ans += 1

print(ans)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define rep(i,N) for(ll i=0; i<N; i++)
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
 
int main(){
    ll a, b; cin >> a >> b;
    ll n = __gcd(a,b);
      
    ll ans = 1;
    if(n % 2 == 0){
        ans++;
        while(n % 2 == 0) n /= 2;
    }
  
    for (ll i = 3; i*i <= n; i+=2) {
        if(n % i == 0){
            ans++;
            while (n%i == 0) n /= i;
        }
      	if(n == 1) break;
	}
  	if(n != 1) ans++;
 
    cout << ans << endl;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    
    string s;
    cin>>s;
    if ((int)s.length() == 3) reverse(s.begin(), s.end());
    out(s);
    return 0;
}


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

using namespace std;

int main(){
	int n, m;
	while(cin >> n >> m && n > 0){
		vector<int> h(n);
		vector<int> w(m);
		for(int i = 0; i < n; i++)
			cin >> h[i];
		for(int i = 0; i < m; i++)
			cin >> w[i];
		int ans = 0;
		int x,y;
		// for(int i = 0; i < n; i++){
			// for(int j = i; j < n; j++){
			// 	// ?§??????¨??????????±???????
			// 	x = 0;
			// 	for(int k = i; k <= j; k++){
			// 		x += h[k];
			// 	}

			// 	for(int l = 0; l < m; l++){
			// 		y = 0;
			// 		for(int p = l; p < m; p++){
			// 			y += w[p];
			// 			if(y == x){
			// 				ans++;
			// 				break;
			// 			}
			// 		}
			// 	}
			// }
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				int p = i;
				int q = j;
				x = 0;
				y = 0;
				while(true){
					if(x >= y){
						y += w[q];
						q++;
						if(q > m) break;
					}else{
						x += h[p];
						p++;
						if(p > n) break;
					}
					// cout << i << " " << p << " " << j << " " << q << " " << endl;
					// cout << x << " " << y << endl;
					if(x == y){
						// cout << "!!!" << endl;
						ans++;
					}
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3116
import copy
import math
import string
import heapq
import bisect
import sys
sys.setrecursionlimit(10**7)

# max(a-b,b-a) < c < a+b

N = int(input())
L = list(map(int,input().split()))
L.append(2**63)
L.sort()

ans = 0;
for i in range(N):
    for j in range(N):
        if i >= j:
            continue
        l = bisect.bisect_left(L,max(L[i]-L[j],L[j]-L[i])+1)
        r = bisect.bisect_right(L,L[i]+L[j]-1)
        cnt = r-l;
        if L[l] <= L[i] < L[r]:
            cnt -= 1
        if L[l] <= L[j] < L[r]:
            cnt -= 1
        ans += cnt
print(ans//3)


Measured memory_bytes: 52056
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let x: usize = iterator.next().unwrap().parse().unwrap();
    let y: usize = iterator.next().unwrap().parse().unwrap();
    let z: usize = iterator.next().unwrap().parse().unwrap();

    return format!("{} {} {}", z, x, y);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;

/* -- template -- */

int main(){
    int N, M;cin >> N >> M;
    int G[N][N];
    rep(i, N)
        rep(j, N)
            if(i == j)
                G[i][j] = 0;
            else
                G[i][j] = INF;
    int a[M], b[M], c[M];
    rep(i, M){
        cin >> a[i] >> b[i] >> c[i];
        --a[i];--b[i];
        G[a[i]][b[i]] = G[b[i]][a[i]] = c[i];
    }
    for(int k = 0;k < N;++k){
        for(int i = 0;i < N;++i){
            for(int j = 0;j < N;++j){
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
    int ans = 0;
    for(int i = 0;i < M; ++i){
        bool flg = false;
        for(int j = 0; j < N; ++j){
            if(G[j][a[i]] + c[i] == G[j][b[i]])flg = true;
        }
        if(!flg)ans++;
    }
    cout << ans;
    //cout << G[0][3] << endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<long long> vec(N);
  std::priority_queue<int> que;
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    que.push(vec.at(i));
  }
  int x;
  long long sum = 0;
  for (int i = 0; i < M; i++) {
    x = que.top();
    que.pop();
    que.push(x / 2);
  }
  while (!que.empty()) {
    sum += que.top();
    que.pop();
  }
  cout << sum << endl;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
template<class T>inline bool chmax(T& a, T b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T& a, T b){if(a > b){a = b; return 1;}return 0;}
const ll INF = 1LL<<60;
//const int dy[4] = {0, 1, 0, -1};
//const int dx[4] = {1, 0, -1, 0};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

void solve(){
    string s, t; cin >> s >> t;
    if(t.size() > s.size()){
        cout << "UNRESTORABLE" << endl;
        exit(0);
    }
    vector<string> vec;
    for(int i=0; i<s.size()-t.size()+1; i++){
        bool flag = true;
        for(int j=0; j<t.size(); j++){
            if(s[i+j] != '?' && s[i+j] != t[j]){
                flag = false;
            }
        }
        if(flag){
            //cout << i << endl;
            string res = s;
            res.replace(i, t.size(), t);
            //cout << res << endl;
            REP(i, res.size()){
                if(res[i] == '?') res[i] = 'a';
            }
            vec.pb(res);
        }
    }
    if(vec.empty()){
        cout << "UNRESTORABLE" << endl;
        exit(0);
    }
    sort(ALL(vec));
    cout << vec[0] << endl;
}

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

Measured memory_bytes: 3648
if __name__ == "__main__":
    x = input()

    count = 0
    ans = len(x)
    for i in range(len(x)):
        if x[i] == 'S':
            count += 1
        elif count > 0 and x[i] == 'T':
            ans -= 2
            count -= 1
        else:
            count = 0

    print(ans)


Measured memory_bytes: 3500
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mp make_pair
#ifdef LOCAL
#define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define check(...) assert(__VA_ARGS__)
#else
#define debug(fmt, ...)
#define check(...)
#endif

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

    vi h(2), s(2);
    cin >> h[0] >> s[0] >> h[1] >> s[1];
    int who = 0;
    while (true) {
        int other = 1 - who;
        h[other] -= s[who];
        if (h[other] <= 0) {
            break;
        }
        who = other;
    }
    if (who == 0) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}


Measured memory_bytes: 3100
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	ll N; cin >> N;
	vector<ll> a(N); rep(i,N)cin >> a[i];

	map<ll, ll> p;
	rep(i, N) p[a[i]]++;

	vector<ll> b(100001);

	auto begin = p.begin(), end = p.end();
	ll cnt = 0;
	for (auto it = begin; it != end; it++) {
		if (it->second >= 4) {
			b[cnt] = it->first;
			cnt++;
			b[cnt] = it->first;
			cnt++;
		}
		else if(it->second >= 2) {
			b[cnt] = it->first;
			cnt++;
		}
	}

	sort(ALL(b)); reverse(ALL(b));

	cout << b[0] * b[1] << endl;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int n, k;
i64 mod_pow(i64 x, i64 y, i64 mod){
	i64 res = 1;
	while(y > 0){
		if(y & 1) res = res * x % mod;
		x = x*x %mod;
		y >>= 1;
	}
	return res;
}
void solve(){
	cin >> n >> k;
	
	i64 ans = k;
	ans *= mod_pow(k-1, n-1, LINF);
	
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

using namespace std;

int main()
{
  int count;
  int out_count = 0;
  int first = 0;
  int second = 0;
  int third = 0;
  int point = 0;

  string h = "HIT";
  string o = "OUT";
  string home = "HOMERUN";

  cin>>count;

  while(1){
    string v;
    cin>>v;

    if(v == o){
      ++out_count;
      if(out_count%3 == 0){
        cout<<point<<endl;
        point = 0;
        first = 0;
        second = 0;
        third = 0;
      }
      if(out_count == count*3){
        break;
      }
    }
    else if(v == h){
      if(third == 1){
        point += 1;
        third = 0;
      }
      if(second == 1){
        third = 1;
        second = 0;
      }
      if(first == 1){
        second = 1;
      }
      first = 1;
    }
    else if(v == home){
      if(third == 1){
        point += 1;
        third = 0;
      }
      if(second == 1){
        point += 1;
        second = 0;
      }
      if(first == 1){
        point += 1;
        first = 0;
      }
      ++point;
    }
  }
  return 0;
}

Measured memory_bytes: 3152
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
//#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
ll gcd(ll a,ll b){
	return (b==0?a:gcd(b,a%b));
}
map<ll,int>ma;
vvi in;
int main(){
	int n;
	cin>>n;
	in=vvi(n);
	rep(i,n){
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		in[i]=vi{a,b,c};
		ma[a*1000000001ll+b]=c;
	}
	ll a=0,b=1,sum,sx,sy,gx,gy,area,gc_d=1;
	rep(q,n){
		loop(x,-1,2)loop(y,-1,2)if(x!=0&&y!=0){
			sum=0;
			sx=min(in[q][0],in[q][0]+x);
			gx=max(in[q][0],in[q][0]+x);
			sy=min(in[q][1],in[q][1]+y);
			gy=max(in[q][1],in[q][1]+y);
			loop(i,sx,gx+1)loop(j,sy,gy+1)sum+=ma[i*1000000001ll+j];
			area=abs(x*y);
			gc_d=gcd(sum,area);
			sum/=gc_d;
			area/=gc_d;
			if(a*area<b*sum){
				a=sum;
				b=area;
			}
		}
	}
	cout<<a<<" / "<<b<<endl;
}

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

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

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

int main() {

    int N, K;
    cin >> N >> K;

    int i = 1;
    int count = 0;
    while(i-1 < N){
        i *= K;
        count++;
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
static const int MAX = 100001;
static const int INFTY = (1 << 30);
int V;
std::vector<std::pair<int, int> > G[MAX];

void dijkstra(int r) {
    std::priority_queue<std::pair<int, int> > pq;
    bool visited[MAX];
    int d[MAX];
    for (int i = 0; i < V; i++) {
        visited[i] = false;
        d[i] = INFTY;
    }
    d[r] = 0;
    pq.push({0, r}); //dist from target * -1, current node
    visited[r] = true;

    while ( !pq.empty() ) {
        std::pair<int, int> f = pq.top(); pq.pop();
        int current = f.second;
        visited[current] = true;

        if (d[current] < f.first * (-1)) continue;

        for (unsigned long i = 0; i < G[current].size(); i++) {
            int target = G[current][i].first;
            if (visited[target]) continue;
            if (d[target] > d[current] + G[current][i].second) {
                d[target] = d[current] + G[current][i].second;
                pq.push({d[target] * (-1), target});
            }
        }
    }

    for (int i = 0; i < V; i++) {
        (d[i] == INFTY) ? std::cout << "INF" << std::endl : std::cout << d[i] << std::endl;
    }
}



int main()
{
    int E, r, source, target, cost;
    std::scanf("%d %d %d", &V, &E, &r);
    for (int i = 0; i < E; i++) {
        std::scanf("%d %d %d", &source, &target, &cost);
        G[source].push_back({target, cost});

    }
    dijkstra(r);
    return 0;
}



Measured memory_bytes: 13132
K, N = map(int, input().split())

A = [int(i) for i in input().split()]

max = 0
for i in range(N):
    if i == 0:
        dis = A[i] + K - A[-1]
    else:
        dis = A[i] - A[i - 1]

    if max < dis:
        max = dis


print(K - max)

Measured memory_bytes: 26228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int p, q, r;
	cin >> p >> q >> r;
	int ans = INF;
	ans = min(ans, p + q);
	ans = min(ans, p + r);
	ans = min(ans, r + q);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  int a[222222];
  cin>>n;
  int f=0;
  for(int i=0;i<n;i++)cin>>a[i];
  int ans=a[n-1];
  for(int i=n-1;i>=0;i--){
    if(a[i]>i)f=1;
    if(i==n-1)continue;
    if(a[i]+1==a[i+1])continue;
    if(a[i]+1<a[i+1])f=1;
    else ans+=a[i];
  }
  if(f)cout<<"-1"<<endl;
  else cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483646
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
 
static const int N = 105;
 
struct vertex {
    int id;
    int d;
    bool operator<(const vertex & another) const {
        return (d != another.d ? d>another.d : id>another.id);
    }
};
 
int main() {
    vvi mx(N, vi(N, -1));
    int n;
    cin >> n;
    Loop(i, n) {
        Loop(j, n) {
            int a;
            cin >> a;
            mx[i][j] = a;
        }
    }
     
    vector<bool> color(N, 0);
    priority_queue<vertex> pq;
    pq.push({ 0,0 });
    int cnt = 0;
    int ret = 0;
    while(pq.size() > 0) {
        if (cnt == n) break;
        vertex v = pq.top();
        pq.pop();
        if (color[v.id] == 1) continue;
        color[v.id] = 1;
	cnt++;
        ret += v.d;
        Loop(j, n) {
            if (mx[v.id][j] != -1 && color[j] != 1){
                pq.push({ j, mx[v.id][j] });
            }
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  int x[11]={};
  x[a]++; x[b]++; x[c]++;
  if(x[5]==2 &&x[7]==1)
    cout<<"YES";
  else cout<<"NO";
  cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int gcd(int a, int b){
	return (b > 0)? gcd(b, a % b) : a ;
}
int main(){
	int N, K; 
	cin >> N >> K; 
	int A[100010] = {}; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; 
	}
	int kouyakusuu = A[0]; 
	int saidai = A[0]; 
	for(int i = 1; i < N; i++){
		saidai = max(saidai, A[i]); 
		kouyakusuu = gcd(kouyakusuu, A[i]); 
	}
	if(K <= saidai && K % kouyakusuu == 0){cout << "POSSIBLE" << endl;}
	else{cout << "IMPOSSIBLE" << endl;}
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <set>

std::string alphabet = "abcdefghijklmnopqrstuvwxyz";

int main()
{
  std::set<char> chars;
  std::string s;
  std::cin >> s;

  for ( char c : s ) {
    chars.insert(c);
  }

  bool full = true;
  char ans;
  for ( char c : alphabet ) {
    if (!chars.count(c)) {
      full = false;
      ans = c;
      break;
    }
  }
  if ( full ) {
    std::cout << "None\n";
  } else {
    std::cout << ans << std::endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 2147483647;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
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 mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}


vector<pair<int, int>>v;
int a, b, ans, dp[3005][3005];
int main() {
	cin >> a >> b;
	v.resize(a);
	for (int i = 0; i < a; ++i) {
		cin >> v[i].first >> v[i].second;
	}
	sort(all(v));
	for (int i = 1; i <= a; ++i) {
		for (int j = 0; j < b; ++j) {
			ans = max(ans, dp[i - 1][j] + v[i - 1].second);
			if (j - v[i - 1].first >= 0) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - v[i - 1].first] + v[i - 1].second);
			}
			chmax(dp[i][j], dp[i - 1][j]);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 37120
#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;
//typedef pair<int,int> p;
typedef long long int ll;
typedef pair<ll,ll> p;

int main(void){
  vector<ll> a;
  int N,M;
  cin >> N >> M;
  for(int i=0;i<N;i++){
    ll tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end());
  vector<p> ap;
  //vector<p> bp;
  ll num=1;
  for(int i=1;i<N;i++){
    if(a[i] != a[i-1]){
      ap.push_back(make_pair(a[i-1],num));
      num=1;
    }else{
      num++;
    }
  }
  if(a[N-1] != a[N-2]){
     ap.push_back(make_pair(a[N-1],1));
  }else{
     ap.push_back(make_pair(a[N-1],num));
  }
  
  for(int i=0;i<M;i++){
    ll b,c;
    cin >> b >> c;
    ap.push_back(make_pair(c,b));
  }
  sort(ap.begin(),ap.end());
  ll sum = 0;
  ll total = 0;
  for(int i=0;i<ap.size();i++){
    p item = ap[ap.size()-1-i];
    ll num = item.first;
    ll amo = item.second;
    //cout << num << " " << amo << endl;
    if(total + amo <= N){
      sum = sum + amo*num;
      total = total + amo;
      if(total == N)
	break;
    }else{
      int res = N - total;
      sum = sum + res*num;
      break;
    }
  }
  cout << sum << endl;
  return 0;
}


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

using namespace std;

long long a[100005], dp[100005], n, k;

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

    for(int i = 1; i <= n; ++i){
        cin >> a[i];
    }

    for(long long i = 2; i <= n; ++i){
        dp[i] = 999999999;
        for(long long j = 1; j <= min(i - 1, k); ++j){
            dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
        }
    }

    cout << dp[n];

    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define int long long
#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 FOR(i,s,n) for(int i = s;i < (int)n;++i)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;--i)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
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;}
constexpr int INF = 1e18;

signed main(){
	int A,B,C;
	cin >> A >> B >> C;
	int X = C - A - B;
	if(X <= 0)out("No");
	else if(4 * A * B < X * X)out("Yes");
	else out("No");
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_162
{
    class E
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] nk = ReadInts();
            long n = nk[0];
            long k = nk[1];
            long mask = 1000000000 + 7;
            long res = 0;
            long[] cnts = new long[k + 1];
            for(long i = k; i >= 1; i--)
            {
                long cnt = Pow(k / i, n, mask);
                for(long j = 2; i * j <= k; j++)
                {
                    cnt = (cnt - cnts[i * j] + mask) % mask;
                }

                cnts[i] = cnt;
                res += cnt * i;
                res %= mask;
            }
            WriteLine(res);
        }

        static long Pow(long x,long y,long mask)
        {
            long res = 1;
            long div = x;
            long dig = 1;
            while (dig <= y)
            {
                if ((dig & y) > 0)
                {
                    res *= div;
                    res %= mask;
                }
                div *= div;
                div %= mask;
                dig *= 2;
            }
            return res;
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 28268
def main(N, K, xs):

    if xs[0] >= 0:
        return xs[K-1]
    if xs[-1] <= 0:
        return abs(xs[-1 * K])

    for i, x in enumerate(xs):
        if x == 0:
            xs.pop(i)
            if K == 1:
                return 0
            K = K-1
            N = N-1
        if x > 0:
            zi = i
            break

    result = None

    if zi - K >= 0:
        result = -1 * xs[zi - K]
    if zi + K - 1 <= N-1:
        if result == None:
            result = xs[zi + K - 1]
        result = min(result, xs[zi + K - 1])

    for i in range(K-1):
        if zi - K + i + 1 < 0:
            continue
        if zi - 1 + i + 1 > N-1:
            continue
        l = abs(xs[zi-K+i+1])
        r = abs(xs[zi-1+i+1])
        if result == None:
            result = 2 * min(l, r) + max(l, r)
        else:
            if result > 2 * min(l, r) + max(l, r):
                result = 2 * min(l, r) + max(l, r)
    return result

N, K = [int(i) for i in input().split(' ')]
xs = [int(i) for i in input().split(' ')]

print(main(N, K, xs))


Measured memory_bytes: 58648
#include<bits/stdc++.h>
int main(){
  int N,M;
  std::cin >> N >> M;
  std::vector<int>H(N);
  for(auto& e : H) std::cin >> e;
  std::vector<std::vector<int>>edge(N);
  for(int i = 0; i < M; ++i){
    int s,t; std::cin >> s  >> t;
    --s;--t;
    edge[s].emplace_back(t);
    edge[t].emplace_back(s);
  }
  int ans = 0;
  int cv = 0;
    std::for_each(edge.begin(), edge.end(),[&](auto& v){ int maxi = -1;
        std::for_each(v.begin(), v.end(), [&](int id){ maxi = std::max(maxi,H[id]);});
        if(maxi == -1 or H[cv] > maxi){
            ++ans;
        }
        ++cv;
    });
  std::cout << ans << std::endl;
}



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

int top = -1, S[105];

void push(int x){
  top++;
  S[top] = x;
}

int pop(){
  top--;
  return S[top+1];
 }

int main(void)
{
  char data[10];
  int S[105], a, b, n;

  while(scanf("%s", data) != EOF){
    if(data[0] == '+'){
      a = pop();
      b = pop();
      push(b+a);
    }
    else if(data[0] == '-'){
      a = pop();
      b = pop();
      push(b-a);
    }
    else if(data[0] == '*'){
      a = pop();
      b = pop();
      push(b*a);
    }
    else{
      n = atoi(data);
      push(n);
    }
  }
  printf("%d\n", pop());

    return 0;
}

Measured memory_bytes: 548
N = int(input())
a = list(map(int, input().split()))

a.sort()
set_a = list(set(a))

import collections
count = collections.Counter(a)

ans = 0
for i in range(len(set_a)):
    cnt = count[set_a[i] + 1] + count[set_a[i] - 1] + count[set_a[i]]
    ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 14816
#include <stdio.h>
#include <math.h>

int main (void)
{
  int n, dimention, x[10][10], i, j, k, count = 0, sum = 0;

  scanf("%d %d", &n, &dimention);

  for(i = 0; i < n; i++){
    for(j = 0; j < dimention; j++){
      scanf("%d", &x[i][j]);
    }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      if(i < j){
		for(k = 0; k < dimention; k++){
		  sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
		}
		if(fmod(sqrt((double)sum), 1.0) == 0.0)
	  		count++;
        sum = 0;
      }
    }
  }

  printf("%d", count);

  return 0;
}


Measured memory_bytes: 256
H = int(input())
W = int(input())
N = int(input())

max_h_w = max([H, W])
min_h_w = max([H, W])

count = 0
for i in range(min_h_w):
    N -= max_h_w
    count += 1
    if N <= 0:
        break
print(count)

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

int solve(int x){
  int a=0;
  while(x>0){
    x/=2;
    a++;
  }
int b=1;
  for(int i=1;i<a;i++){
b*=2;
  }
  return b;
}


int main(){
 int n;
  cin>>n;
  int c=solve(n);
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int a,b;
    cin>>a>>b;
    if((a==1||a==3)&&(b==3||b==1))
       {
           cout<<2<<nl;
       }
       else if((a==2||a==3)&&(b==2||b==3))
        {
            cout<<1<<nl;
        }
        else
        {
            cout<<3<<nl;
        }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long int64;

int main(void){
    int s;
    cin>>s;
    int s1,s2;
    s1=s/100;
    s2=s%100;
    if(1<=s1&&s1<=12&&1<=s2&&s2<=12){
        cout<<"AMBIGUOUS"<<endl;
    }else if(1<=s2&&s2<=12){
        cout<<"YYMM"<<endl;
    }else if(1<=s1&&s1<=12){
        cout<<"MMYY"<<endl;
    }else{
        cout<<"NA"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
from functools import reduce
from fractions import gcd


def least_common_multiple(iter):
    '''
    最小公倍数を返す
    '''
    lcm = lambda x, y: x*y//gcd(x, y)
    return reduce(lcm, iter)


n = int(input())
t = [int(input()) for _ in range(n)]
print(least_common_multiple(t))


Measured memory_bytes: 5128
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=10000000;
const ll INF=1000000001;
const ll LINF=4000000000000000010;
const double EPS=1e-9;
int main(){
    int n,l;cin>>n>>l;
    int a[100010];
    int s,ma=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i){
            if(a[i-1]+a[i]>ma){
                ma=a[i]+a[i-1];
                s=i;
            }
        }
    }
    if(ma<l){
        cout<<"Impossible"<<endl;
        return 0;
    }
    cout<<"Possible"<<endl;
    for(int i=1;i<s;i++){
        cout<<i<<endl;
    }
    for(int i=n-1;i>=s;i--){
        cout<<i<<endl;
    }
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int n;cin >>n;
    ll cnt5=0;
    ll cnt3=0;
    ll cnt15=0;
    ll cnt25=0;
    ll cnt75=0;
    unordered_map<int,int>mp;
    for (int i = 1; i <=n; ++i) {
        int c=i;
        for(int j=2;j*j<=c;j++){
            while(c%j==0){
                mp[j]++;
                c/=j;
            }
        }
        if(c!=1)mp[c]++;
    }
    for(auto p:mp){
        if(p.second>=74)cnt75++;
        if(p.second>=2)cnt3++;
        if(p.second>=4)cnt5++;
        if(p.second>=14)cnt15++;
        if(p.second>=24)cnt25++;
    }
//    cout <<cnt3<<" "<<cnt5<<" "<<cnt15<<" "<<cnt25<<" "<<cnt75<<endl;
    ll ans=0;
    ans+=cnt75;
    ans+=(cnt3>0)?(cnt3-1)*cnt25:0;
    ans+=(cnt5>0)?(cnt5-1)*cnt15:0;
    ans+=(cnt3>1)?(cnt3-2)*((cnt5-1)*cnt5)/2:0;
    cout <<ans <<endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
/* Coding space */
int main(){
  int n; cin >> n;
  map<char,ll> m;
  rep(i,n){
    string in; cin >> in;
    m[in[0]]++;
  }
  const string march = "MARCH";
  ll ans = 0;
  rep(i,5)for(int j=i+1; j<5; j++)for(int k=j+1;k<5;k++){
    ans += m[march[i]] * m[march[j]] * m[march[k]];
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        ArrayList<int[]>[] map = new ArrayList[n+1];
        for(int i=0;i<=n;i++) map[i] = new ArrayList<>();
        for(int i=1;i<=m;i++){
            int p = sc.nextInt();
            int y = sc.nextInt();
            map[p].add(new int[]{y,i});
        }
        PriorityQueue<Node> res = new PriorityQueue<>();

        for(int i=1;i<=n;i++){
            if(map[i].size()==0) continue;
            Collections.sort(map[i],new myc());
            for(int j=0;j<map[i].size();j++){
                String s = getName(i,j+1);
                res.add(new Node(s,map[i].get(j)[1]));
            }
        }
        while(res.size()>0){
            System.out.println(res.poll().s);
        }
    }
    static String getName(int idx, int p){
        String IDX = Integer.toString(idx);
        String P = Integer.toString(p);
        StringBuilder ans = new StringBuilder();
        for(int i=0;i<6-IDX.length();i++) ans.append(0);
        ans.append(IDX);
        for(int i=0;i<6-P.length();i++) ans.append(0);
        ans.append(P);
        return ans.toString();
    }
    static class myc implements Comparator<int[]>{
        public int compare(int[] a, int[] b){
            return a[0]-b[0];
        }
    }
    static class Node implements Comparable<Node>{
        String s;
        int id;
      public Node(String s_, int id_){
            this.s = s_;
            this.id = id_;
        }
        public int compareTo(Node e){return this.id-e.id;}
    }
}


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

int main() 
{string s,t;
cin>>s>>t;
long x=0;
for(auto i=0; i<s.length(); i++)
{
    if(s[i]!=t[i])
    {
        ++x;
    }
}
cout<<x;
    return 0;
}

Measured memory_bytes: 3820
import Control.Arrow (second)
import Data.List
import qualified Data.Vector.Unboxed as V
import qualified Data.ByteString.Char8 as B

solve :: V.Vector Int -> Int
solve xs = V.foldl gcd (V.minimum xs) xs

main = do
  Just n <- fmap fst . B.readInt <$> B.getLine
  xs <- V.unfoldrN n (fmap (second B.tail) . B.readInt) <$> B.getLine
  print $ solve xs



Measured memory_bytes: 3708
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535;

int find(vint& p, int x) {
	if (p[x] == x) return x;

	return p[x] = find(p, p[x]);
}
void unite(vint& p,int x,int y) {
	x = find(p, x);
	y = find(p, y);
	p[x] = y;
}

int main(void) {
	int n, m, cnt = 0;
	cin >> n >> m;
	vint p(n+1),r(n+1);
	for (int i = 1; i <= n; i++) {
		cin >> p[i];
		r[i] = i;
	}
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		unite(r, a, b);
	}

	for (int i = 1; i <= n; i++) {
		if (find(r, p[i]) == find(r, i))cnt++;
	}
	cout << cnt << endl;
	return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;
mt19937 mrand(time(0));
ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; }
ll get(ll l, ll r) { return get(r - l + 1) + l; }

const int P = 998244353;
int n, K, l[20], r[20], f[200100];
void upd(int &x, int y) { (x += y) >= P ? x -= P : 0; }
signed main() {
    scanf("%d %d", &n, &K);
    for(int i = 1; i <= K; i++)
        scanf("%d %d", &l[i], &r[i]);
    f[1] = 1;
    for(int i = 2; i <= n; i++) {
        for(int j = 1; j <= K; j++)
            if(i - l[j] >= 1) upd(f[i], (f[i - l[j]] + P - (i - r[j] - 1 >= 0 ? f[i - r[j] - 1] : 0)) % P);
        upd(f[i], f[i - 1]);
    }
    // for(int i = 1; i <= n; i++) printf("%d ", f[i] + P - f[i - 1]); puts("");
    printf("%d\n", (f[n] + P - f[n - 1]) % P);
    fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
    return 0;
    /* 取模直接除，爆零两行泪
     * 不开ll见祖宗
     */
}

Measured memory_bytes: 4612
import java.util.*;

public class Main{
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        String msg = "No";
        if(a + b == c || b + c == a || c + a == b){
            msg = "Yes";
        }
        System.out.println(msg);
    }
}

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

int main(){
  int n;
  cin >> n;
  vector<int> b(n-1);
  rep(i,n-1){
    cin >> b[i];
  }
  int sum= b[0]+b[n-2];
  //cout << sum << endl;
  rep(i,n-2){
    sum += min(b[i],b[i+1]);
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
struct Point { long double px, py; };
Point Minus(const Point& a, const Point& b) { return Point{ a.px - b.px,a.py - b.py }; }
long double norm(const Point& a) { return a.px * a.px + a.py * a.py; }
long double abs(const Point& a) { return sqrtl(norm(a)); }
long double arg(const Point& a) { return atan2l(a.py, a.px); }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
int ccw(const Point& p0, const Point& p1, const Point& p2) {
	Point a = Minus(p1, p0), b = Minus(p2, p0);
	if (crs(a, b) > 1e-10) return 1;
	if (crs(a, b) < -1e-10) return -1;
	if (dot(a, b) < -1e-10) return 2;
	if (norm(a) < norm(b)) return -2;
	return 0;
}
bool its(const Point& p1, const Point& p2, const Point& p3, const Point& p4) { return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0); }
int contain(vector<Point> v, Point p) {
	bool in = false;
	for (int i = 0; i < v.size(); ++i) {
		Point a = Minus(v[i], p), b = Minus(v[(i + 1) % v.size()], p);
		if (a.py > b.py) swap(a, b);
		if (a.py <= 0 && 0 < b.py)
			if (crs(a, b) < 0) in = !in;
		if (crs(a, b) == 0 && dot(a, b) <= 0) return 1;
	}
	return in ? 2 : 0;
}
bool connect(vector<Point>p1, vector<Point>p2) {
	for (int i = 0; i < p1.size(); i++) {
		for (int j = 0; j < p2.size(); j++) {
			if (its(p1[i], p1[(i + 1) % p1.size()], p2[j], p2[(j + 1) % p2.size()]) == true)return true;
		}
	}
	for (int i = 0; i < p2.size(); i++) { if (contain(p1, p2[i]) != 0)return true; }
	for (int i = 0; i < p1.size(); i++) { if (contain(p2, p1[i]) != 0)return true; }
	return false;
}
vector<Point>r[200]; int n, t; vector<int>X[200]; bool unused[200];
int main() {
	while (true) {
		cin >> t; if (t == 0)break;
		for (int h = 0; h < t; h++) {
			for (int i = 0; i < 200; i++) { r[i].clear(); r[i].resize(4); X[i].clear(); unused[i] = false; }
			cin >> n; int cnt = 0;
			for (int j = 0; j < n; j++) {
				cin >> r[cnt][0].px >> r[cnt][0].py >> r[cnt][1].px >> r[cnt][1].py;
				cin >> r[cnt][2].px >> r[cnt][2].py >> r[cnt][3].px >> r[cnt][3].py; cnt++;
			}
			for (int i = 0; i < cnt; i++) {
				for (int j = i + 1; j < cnt; j++) {
					if (connect(r[i], r[j]) == true) { X[i].push_back(j); X[j].push_back(i); }
				}
			}
			queue<int>Q; int ans = 0;
			for (int i = 0; i < cnt; i++) {
				if (unused[i] == true)continue;
				Q.push(i); unused[i] = true; ans++;
				while (!Q.empty()) {
					int a1 = Q.front(); Q.pop();
					for (int j = 0; j < X[a1].size(); j++) {
						if (unused[X[a1][j]] == false) { unused[X[a1][j]] = true; Q.push(X[a1][j]); }
					}
				}
			}
			cout << ans << endl;
		}
	}
	return 0;
}

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

int main() {
  int N;
  int ask=0;
  cin>>N;
  rep(i,N){
    int x;
    cin>>x;
    if(x%2 ==0){
      if(x%3!=0 and x%5!=0){
      ask++;
      }
    }
  }
  if(ask==0){
    cout<<"APPROVED";
  }
  else{
    cout<<"DENIED";
  }
}


Measured memory_bytes: 256
n,m=[int(x) for x in input().split()]
l=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)
# print(l)

done=[0]*n


def dfs(j):
  que=[j]
  cnt=1
  done[j]=1
  while(que):
    now=que.pop(0)

    for i in l[now]:
      if done[i]!=1:
        que.append(i)
        done[i]=1
        cnt+=1

  return cnt

ma=0
for j in range(n):
  if done[j]!=1:
    now=dfs(j)
  else:
    now=0
  ma=max(now,ma)
  
print(ma)


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

using namespace std;

#define int long long
int pref[250005], suff[250005], ans, prefix[250005], h , w, a, b;

const int mod = 1e9 + 7;

int BinPow(int x,int n){
    if(n == 0)
        return 1;
    if(n == 1)
        return x;
    else{
        int sum = BinPow(x, n / 2) % mod;
        sum*=sum; sum%=mod;
        if(n % 2 != 0)
            sum *= x, sum%=mod;
        return sum;
    }
}

int C(int x,int n){
    if(x < 0 || x > n || n < 0) return 0;
    int sum = pref[n] * suff[x]; sum %= mod;
    sum*=suff[n - x]; sum %= mod;
    return sum;
}

signed main(){
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> h >> w >> a >> b;
    pref[0] = 1;
    for(int i = 1; i <= 250000; i++){
        pref[i] = pref[i - 1]*i;
        pref[i] %= mod;
    }
    suff[0] = 1;
    for(int i = 1; i <= 250000; i++)
        suff[i] = BinPow(pref[i], mod - 2);
    for(int i = 1; i <= 100000; i++){
        if(i >= h - a + 1){
            prefix[i] += C(b - 1, i + b - 2);
            pref[i] %= mod;
            prefix[i] += prefix[i - 1];
        }
    }
    ans = C(h - 1,h + w - 2);
    for(int i = 1; i <= h; i++){
        if(i >= h - a + 1){
            int dist = w - b;
            int dist1 = h - i + 1;
            ans -= C(b - 1, i + b - 2)*C(dist1 - 1,dist + dist1 -2 );
            ans %= mod;
            if(ans < 0) ans += mod;
        }
    }
    cout << ans;
}


Measured memory_bytes: 4992