akhauriyash/Code-Regression huggingface dataset:
//shan61916
#include <bits/stdc++.h>
    using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull ;
typedef double dll ;
ll dp[3010][3010];
string s1, s2, an ="";
ll len;
ll recurse(ll id1, ll id2) {
	if(id1 < 0 or id2 < 0) return 0;
	if(dp[id1][id2] != -1) return dp[id1][id2];
	if(s1[id1] == s2[id2]) {
		return dp[id1][id2] = 1 + recurse(id1-1,id2-1);
	}
	return dp[id1][id2] = max(recurse(id1-1,id2), recurse(id1, id2-1));
}
void print(ll id1, ll id2) {
 	if(id1 < 0  or id2 < 0) return ;
 	ll x = recurse(id1, id2);
 	if(s1[id1] == s2[id2]) {
 		an += s1[id1];
 		print(id1-1, id2-1);
 	}
 	else {
 		if(recurse(id1-1, id2) == x) print(id1-1, id2);
 		else {
 			print(id1, id2-1);
 		}
 	}
 }
int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  memset(dp, -1, sizeof(dp));  
  cin >> s1 >> s2;
  len = recurse((ll)s1.length()- 1, (ll)s2.length() -1);
  print((ll)s1.length()-1, (ll)s2.length()-1) ;
  reverse(an.begin(), an.end());
  cout << an;
  return 0;
} //good night.


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

typedef long long ll;

void init(vector< vector<ll> > &comb){
    for(ll i = 0; i < 51; i++){
        for(ll j = 0; j <= i; j++){
            if(j == 0 || j == i){
                comb[i][j] = 1LL;
            }else{
                comb[i][j] = comb[i-1][j-1]+comb[i-1][j];
            }
        }
    }
}

int main(void){
    vector< vector<ll> > comb(51, vector<ll>(51));
    init(comb);

    ll N, A, B; cin >> N >> A >> B;
    vector<ll> v(N);
    for(ll i = 0; i < N; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end(), greater<ll>());

    double avg = 0;
    for(ll i = 0; i < A; i++){
        avg += v[i];
    }
    avg /= (double)A;
    cout << fixed << setprecision(10) << avg << endl;

    if(v[0] != v[A-1]){
        ll X=0, Y=0;
        for(ll i = 0; i < N; i++){
            if(v[i] == v[A-1])X++;
        }
        for(ll i = 0; i < A; i++){
            if(v[i] == v[A-1])Y++;
        }
        cout << comb[X][Y] << endl;
    }
    else{
        ll ans = 0;
        ll X = 0;
        for(ll i = 0; i < N; i++){
            if(v[i] == v[0]){
                X++;
            }
        }
        for(ll i = A; i <= B; i++){
            ans += comb[X][i];
        }
        cout << ans << endl;
    }
}


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

int main() {
    long long N;
    long long ans = 0;
    vector<long long> RGB(3);
    cin >> N;
    vector<string> S(N);
    for(auto &x : S) {
        cin >> x;
    }

    for(int i = 0; i < N; i++) {
        for(int k = 1; k < S[i].size(); k++) {
            if(S[i][k - 1] == 'A' && S[i][k] == 'B') {
                ans++;
            }
        }
    }

    long long ab = 0, an = 0, nb = 0;

    for(int i = 0; i < N; i++) {
        if(S[i][0] != 'B' && S[i][S[i].size() - 1] == 'A') {
            an++;
        }
        if(S[i][0] == 'B' && S[i][S[i].size() - 1] == 'A') {
            ab++;
        }
        if(S[i][0] == 'B' && S[i][S[i].size() - 1] != 'A') {
            nb++;
        }
    }

    if(ab > 0) {
        if(an > 0 && nb > 0) {
            ans += ab + 1;
            an--;
            nb--;
        } else if(an > 0 && nb == 0) {
            ans += ab;
            an--;
        } else if(nb > 0 && an <= 0) {
            ans += ab;
            nb--;
        }else{
            ans+=ab-1;
        }
    }

    if(an > 0 && nb > 0) {
        ans += min(an, nb);
    }

    cout << ans << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, K;
vi va, vb;

void input() {
  cin >> N >> K;
  va.resize(N), vb.resize(N);
  rep(i, 0, N - 1) { cin >> va[i]; }
  rep(i, 0, N - 1) { cin >> vb[i]; }
}

void solve() {
  sort(all(va));
  sort(all(vb));
  reverse(all(vb));

  // binsearch
  auto isOK = [](int mid) {
    bool ret = true;
    int k = K;
    rrep(i, N - 1, 0) {
      if (va[i] * vb[i] > mid) {
        // vb[i]*kがmidを超えない最大のk
        k -= va[i] - (mid / vb[i]);
      }
      if (k < 0) {
        return false;
      }
    }

    return ret;
  };
  int ng = -1;  //
  int ok = (va[N - 1] * vb[0]);

  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (isOK(mid))
      ok = mid;
    else
      ng = mid;
  }
  cout << ok << endl;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
 
using namespace std;
 
#define D(x) cout << (#x) << " is " << x << endl;
#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;

lli dp[2003][2003];

int main()
{
    int s;
    cin >> s;
    lli ans = 0, mod = 1e9+7;
    for(int i=3; i<=2002; i++){
		dp[1][i] = 1;
	} 
	for(int i=2; i<=2000; i++){
		lli sm = 0;
		for(int j=3; j<=2000; j++){
			sm = (sm+dp[i-1][j-3])%mod;
			dp[i][j] = sm;
		}
	}
	for(int i=1; i<=2000&&s>=0; i++){
		ans = (ans+dp[i][s])%mod;
	}
	cout << ans << endl;

 
    return 0;
}


Measured memory_bytes: 34888
#include <cstdio>
#include <iostream>
#include <cstring>

char s[201000];
int main()
{
	scanf("%s", s + 1);
	int len = strlen(s + 1);
	for(int i = 1; i <= len; i++)
		if(s[i] == '?') printf("D");
		else printf("%c", s[i]);
}

Measured memory_bytes: 3952
import java.util.Scanner;
import java.util.TreeSet;
import java.util.Arrays;
public class Main {
 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(true){
           String x;
           x=sc.nextLine();
           if(x.equals("0"))break;
           int n=x.length();
           int ans=0;
           for(int i=0;i<n;i++){
                int dig=x.charAt(i)-'0';
                ans+=dig;
           }
           System.out.println(ans);
}
}
}


Measured memory_bytes: 26788
# coding: utf-8
# Your code here!

s=str(input())
a=0
k=s.count('K')
u=s.count('U')
p=s.count('P')
c=s.count('C')
while True:
    if k==0 or u==0 or p==0 or c==0:
        break
    else:
        a+=1; k-=1; u-=1; p-=1; c-=1
print(a)


Measured memory_bytes: 5560
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	var n, c, k int
	fmt.Scan(&n, &c, &k)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := make([]int, n)
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Ints(a)
	ans := 0
	i := 0
	for i < n {
		r := a[i] + k
		x := 0
		for i < n && a[i] <= r && x+1 <= c {
			i++
			x++
		}
		ans++
	}
	fmt.Println(ans)
}


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

using namespace std;

typedef long long ll;

int N;
ll P;
string S;

ll csum[200000 + 100];

int main() {
	cin >> N >> P >> S;

	if (P == 2) {
		ll ans = 0;
		for (int i = 0; i < S.size(); i++) {
			if ((S[i] - '0') % 2 == 0)ans += 1 + i;
		}
		cout << ans << endl;
		return 0;
	}
	if (P == 5) {
		ll ans = 0;
		for (int i = 0; i < S.size(); i++) {
			if ((S[i] - '0') % 5 == 0)ans += 1 + i;
		}
		cout << ans << endl;
		return 0;
	}

	map<int, ll> cnt;
	csum[0] = 0;
	cnt[0]++;
	ll times = 1;
	reverse(S.begin(), S.end());
	for (int i = 0; i < N; i++) {
		csum[i + 1] = (csum[i] + times * (S[i] - '0')) % P;
		cnt[csum[i + 1]]++;
		times *= 10, times %= P;
	}
	ll ans = 0;
	for (auto it = cnt.begin(); it != cnt.end(); it++) {
		ans += (*it).second * ((*it).second - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2556
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define vi vector<int>
#define pb(a) push_back(a)
using namespace std;

typedef long long ll;

typedef pair<ll,int> P1;
typedef pair<int,P1> P2;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

#define MAX_N 100002

map<int,int> dp[MAX_N];
vector<edge> G1[MAX_N],G2[MAX_N],G3[1000002];
int dp1[MAX_N];
priority_queue<P2,vector<P2>,greater<P2>> que;

P1 a[200001]={};

int main() {
	int k,t;
	cin>>k>>t;
	int a[101];
	rep(i,t)cin>>a[i];
	int n=t+1;
	int r=0;
	rep(i,k){
		int ma=0;
		int mn=n;
		rep(j,t){
			if(ma<a[j]&&j!=n){
				ma=a[j];
				mn=j;
			}
		}
		if(mn==n)r++;
		a[mn]--;
		n=mn;
	}
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 36608
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;


int main(){
    ll N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;

    cout << max({(N - 1) / A, (N - 1) / B, (N - 1) / C, (N - 1) / D, (N - 1) / E}) + 5 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    string s, t;
    cin >> s >> t;
    map<char, vector<int>> ss;
    for (int i = 0; i < s.size(); i++) {
        ss[s[i]].push_back(i+1);
    }
    long long ans = 0;
    for (int i = 0; i < t.size(); i++) {
        if (ss[t[i]].size() == 0) {
            puts("-1");
            return 0;
        }
        auto g = upper_bound(ss[t[i]].begin(), ss[t[i]].end(), ans % s.size());
        if (g == ss[t[i]].end()) {
            ans = (ans/s.size()+1) * s.size();
            ans += ss[t[i]][0];
        }
        else {
            ans = (ans/s.size()) * s.size();
            ans += *g;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1216
#include<iostream>
#include<map>
#include<algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main(){
    int n,max = 0;
    string s;
    cin>>n;
    map<string,int> memo;
    rep(i,n){
        cin>>s;
        memo[s]++;
    }

    for(auto x : memo){
        int v =  x.second;
        if(v > max) max = v;
    }

    for(auto it = memo.begin();it != memo.end();it++){
        if(it->second == max){
            cout<<it->first<<endl;
        }
    }


}

Measured memory_bytes: 25216
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


 
 
int main(int argc, char* argv[])
{
    int w,h,x,y;
    scanf("%d%d%d%d", &w, &h, &x, &y);

    double s=(double)w*h;
    if(w==x*2 && h==y*2) {
        printf("%.10lf 1\n", s/2);
    }
    else {
        printf("%.10lf 0\n", s/2);
    }

    return 0;
}



Measured memory_bytes: 128
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main(void){
	int A,B,C,D,P,ANS;
	cin>>A>>B>>C>>D>>P;
	if(P>C){B+=((P-C)*D);}
	ANS=min(A*P,B);
	cout<<ANS<<endl;
	return 0;
}


Measured memory_bytes: 3108
#include<set>
#include<map>
#include<ctime>
#include<queue>
#include<cmath>
#include<climits>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
    int f=1,x=0;char s=getchar();
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define MAXN 1000
#define INF 0x3f3f3f3f
int n,len,x[MAXN+5],y[MAXN+5],d[35];
void Print(int X,int Y){//贪心策略
    for(int i=1;i<=len;i++){
        if(abs(X)>abs(Y)){
            if(X>0) putchar('R'),X-=d[i];
            else putchar('L'),X+=d[i];
        }
        else{
            if(Y>0) putchar('U'),Y-=d[i];
            else putchar('D'),Y+=d[i];
        }
    }
    puts("");
    return ;
}

int main(){
    bool f[2]={0};
    n=read();
    for(int i=1;i<=n;i++)
        x[i]=read(),y[i]=read(),f[(x[i]+y[i])%2]=1;
    if(f[0]&&f[1]){//判断奇偶有无解
        puts("-1");
        return 0;
    }
    for(int i=30;i>=0;i--)
        d[++len]=(1<<i);
    if(f[0]) d[++len]=1;//奇偶处理
    printf("%d\n",len);
    for(int i=1;i<len;i++)
        printf("%d ",d[i]);
    printf("%d\n",d[len]);
    for(int i=1;i<=n;i++)
        Print(x[i],y[i]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int mod=998244353;
const int maxn=(4e5)+10;
int n,s[maxn];
int T[maxn],d[maxn];
int f[maxn],ans;
char S[maxn];
void update(int &x,int y) {
	x+=y; if (x>=mod) x-=mod;
}
int solve(int k) {
	for (int i=1,x=1;i<=n;i++,x++) {
		if (x>2*k) x=1;
		if (x<=k) T[i]=d[x]; else T[i]=d[x-k]^1;
	}
	for (int i=1;i<=n;i++) {
		if (T[i]<d[i]) return s[k]+1;
		if (T[i]>d[i]) return s[k];
	}
	return s[k]+1;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); scanf("%s",S+1);
	for (int k=1;k<=n;k++) {
		d[k]=S[k]-'0';
		s[k]=(s[k-1]*2+d[k])%mod;
	}
	for (int k=n;k>=1;k--)
		if (n%k==0&&(n/k)%2==1) {
			f[k]=2*k;
			for (int i=k*2;i<=n;i+=k) update(f[k],mod-f[i]);
			update(ans,(ll)f[k]*solve(k)%mod);
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4736
// @author: Amirul Islam

#include <bits/stdc++.h>
using namespace std;
#define LLI long long int
#define PII pair <int, int>

const int mx = 1e5+5;
const LLI INF = 1e10;

LLI dp[mx], w, val, N, W;

LLI max(LLI a, LLI b) {
    return (a > b ? a : b);
}

LLI knapsack(int N, int W) {
    for (int i = 0; i < mx; i++) dp[i] = INF;
    dp[0] = 0;
    for (int i = 1; i <= N; i++) {
        scanf("%lld %lld", &w, &val);
        for (int j = mx; j >= 0; j--) {
            if (j >= val) dp[j] = min(dp[j], dp[j-val] + w);
        }
    }
    LLI ret = 0;
    for (int i = 0; i < mx; i++) {
        if (dp[i] <= W) ret = max(ret, i);
    }
    return ret;
} 

int main() {
    scanf("%lld %lld", &N, &W);
    printf("%lld\n", knapsack(N, W));
    return 0;
}

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

struct Problem {

	void Solve() {
		UL W, H; cin >> W >> H;
		vector<pair<ULL, int>> P(W + H);
		rep(i, W) { cin >> P[i].first; P[i].second = i + 1; }
		rep(i, H) { cin >> P[i + W].first; P[i + W].second = -((int)i + 1); }
		sort(P.begin(), P.end());
		ULL ans = 0;
		ULL w = W + 1, h = H + 1;
		rep(i, W + H) {
			ULL p = P[i].first;
			if (P[i].second > 0) {
				ans += h * p; w--;
			}
			else {
				ans += w * p; h--;
			}
		}
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

const int INF = 1001001001;

int main()
{
    ll n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    rep(i, 0, n) cin >> w[i] >> v[i];
    vector<vector<ll>> dp(n+1, vector<ll> (W+1, 0));
    rep(i, 0, n){
        rep(j, 0, W+1){
            if(j + w[i] <= W){
                dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]], dp[i][j] + v[i]);
            }
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define ff first
#define ss second
#define pri 1000000007 
using namespace std;

int main() {
	
	ll r,d,x;
     cin>>r>>d>>x;
    for(ll j=0;j<10;j++){
    	x=r*x-d;
    	cout<<x<<endl;
    }

	// your code goes here
	return 0;
}

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

a.sort()
ans = 0
for i in range(N):
    if i == N-1:
        if a[i] == x:
            x -= a[i]
            ans += 1
        else:
            break
    elif a[i] <= x:
        x -= a[i]
        ans += 1
    else:
        break
print(ans)


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

using namespace std;

int main() {
  int n,k,q;
  cin >> n >> k >> q;
  vector<int> a(q),b(n);
  for(int i=0;i<q;i++){
    cin >> a.at(i);
    b.at(a.at(i)-1) += 1;
  }
  for(int i=0;i<n;i++){
    if(k + b.at(i) > q){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
   
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mx= 1000000000000000000;
ll a[100005],ret=0;
ll jogmod(ll a,ll b)
{
    if(b==0LL)
        return 0LL;
    ll x=jogmod(a,b/2);
    x=2*x;
    if(x>mx)
    {
        ret =-1;
        return 0LL;
    }
    if(b%2==1)
        x=a+x;
    if(x>mx)
    {
        ret =-1;
        return 0LL;
    }
    return x;
}
int main()
{
    int n,cnt=0;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        if(a[i]==0)
            cnt++;
    }
    if(cnt)
    {
        cout << 0 << endl;
        return 0;
    }
    sort(a,a+n);

    ll ans = a[n-1];

    for(int i=n-2;i>=0;i--)
    {
        //cout << a[i] << endl;
        ans = jogmod(a[i],ans);
        if(ret==-1)
        {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    ll N; cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    if (A[0] == 0) {cout << 0 << endl; return 0;}
    ll ans = 1;
    rep(i, N) {
      if (A[i] <= (ll)(1e18) / ans) {
        ans *= A[i];
      } else {
        ans = -1;
        break;
      }
    }
    cout << ans << endl;
    return 0;
}

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

using ll = long long;

int main() {
    ll a, b, c, d, ans = -1e18;
    cin >> a >> b >> c >> d;
    ans = max(a * c, ans);
    ans = max(a * d, ans);
    ans = max(b * c, ans);
    ans = max(b * d, ans);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
func main() {
	line := readLine()
	words := strings.Split(line, " ")
	k, _ := strconv.Atoi(words[0])
	//n, _ := strconv.Atoi(words[1])
	line = readLine()
	words = strings.Split(line, " ")
	a := make([]int, len(words))
	for i, word := range words {
		a[i], _ = strconv.Atoi(word)
	}
	maxDistance := 0
	for i := 1; i < len(a); i++ {
		distance := a[i] - a[i-1]
		if distance > maxDistance {
			maxDistance = distance
		}
	}
	distance := a[0] + k - a[len(a)-1]
	if distance > maxDistance {
		maxDistance = distance
	}
	fmt.Println(k - maxDistance)

}


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

int gcd(int x1, int x2){
    if(x1 % x2 == 0)
        return x2;
    else
        return gcd(x2, x1 % x2);
}

int main(){
    int i, j, k, aux, som1, som2, s = 0;
    scanf("%d", &aux);
    for(i = 1 ; i <= aux ; i++){
        for(j = 1 ; j <= aux ; j++){
            for( k = 1 ; k <= aux ; k++){
                som1 = gcd(i,j);
                som2 = gcd(k,som1);
                s += som2;
            }
        }
    }
    printf("%d", s);
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
 using namespace std;
 #define int long long
 #define endl "\n"
 const int mod=1e9+7;
 #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 #define clr(a,x) memset(a,x,sizeof(a))
 #define T int t;cin>>t; while(t--)
 #define vll vector<int> 
 #define v22 vactor<vector<int>>
#define pb push_back
 #define sz size
 #define str to_string
 #define um unordered_map<int,int>
 #define intt stoll
 #define sv() sort(a.begin(),a.end())
 #define vp vector<pair<int, int>> b(n) 
 vector<int> adj[1000001];    
 int v[1000001]={0};
int32_t main()
{
 int n,d=0,x=1000001,k;
 cin>>n>>k;
 vll a(n);
 for(int i=0;i<n;i++)
 cin>>a[i];
 int dp[n]={0};
 if(n<=k)
 cout<<a[n-1]-a[0]<<endl;
 else
 {
 dp[0]=0;

 for(int i=1;i<=k;i++)
 {
     dp[i]=abs(a[i]-a[0]);
 }
 for(int i=k+1;i<n;i++)
 {
   d=1000000000000;
  for(int j=1;j<=k;j++)
d=min(d,dp[i-j]+abs(a[i]-a[i-j]));
  dp[i]=d;
 }
 
 cout<<dp[n-1];
}
}

Measured memory_bytes: 28256
#include <iostream>
#include <set>
#define MAX 2001
using namespace std;
int sum;
void MST(int G[100][100],int n){
    set<int>u;
    set<int>t;
    int min=2001,minj;
    u.insert(0);
    for(int i=1;i<n;i++)
        t.insert(i);
    while(u.size()<n){
        for(set<int>::iterator it_u=u.begin();it_u!=u.end();it_u++)
        {
            for(set<int>::iterator it_t=t.begin();it_t!=t.end();it_t++)
                if(G[*it_u][*it_t]>=0)
                {
                    if(G[*it_u][*it_t]<min)
                    {
                        min=G[*it_u][*it_t];
                        minj=*it_t;
                    }
                }
        }
        sum+=min;
        u.insert(minj);
        t.erase(minj);
        min=MAX;
    }
}
int main()
{
    int n,G[100][100];
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>G[i][j];
    sum=0;
    MST(G,n);
    cout<<sum<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

ll MOD = 1000000007;

int main(int, char**) {
	string s; cin >> s;
	for (int i=0; i<s.size(); i++) {
		cout << 'x';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
s = list(map(str, input()))
if s[k-1] == 'A':
    s[k-1] = 'a'
elif s[k-1] == 'B':
    s[k-1] = 'b'
else:
    s[k-1] = 'c'
print(''.join(s))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int a[3][3]; 
	for(int i=0;i<3;i++)
	    for(int j=0;j<3;j++)
	        cin>>a[i][j];
	
	
	
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
	    int p; cin>>p;
	    for(int j=0;j<3;j++)
	        for(int k=0;k<3;k++)
	            if(a[j][k]==p) a[j][k]=-1;
	}
	for(int i=0;i<3;i++)
	{
	    if(a[i][0]==-1 && a[i][1]==-1 && a[i][2]==-1){ cout<<"Yes"; return 0; }
	}
	for(int i=0;i<3;i++)
	{
	    if(a[0][i]==-1 && a[1][i]==-1 && a[2][i]==-1){ cout<<"Yes"; return 0; }
	}
	if(a[1][1]==-1 && a[2][2]==-1 && a[0][0]==-1){ cout<<"Yes"; return 0; }
	if(a[1][1]==-1 && a[0][2]==-1 && a[2][0]==-1){ cout<<"Yes"; return 0; }
	cout<<"No";
	
	return 0;
}


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

const int N = 3e5 + 10, mod = 998244353;
typedef long long ll;
int n;
ll r, g, b, rg, rb, gb, ans = 1;
char s[N];

int main() {
    cin >> n;
    rep(i, 1, n) ans = ans * i % mod;
    n *= 3;
    scanf("%s", s + 1);
    rep(i, 1, n) {
        if (s[i] == 'R') {
            if (gb)
                ans = ans * gb % mod, --gb;
            else if (g)
                ans = ans * g % mod, --g, ++rg;
            else if (b)
                ans = ans * b % mod, --b, ++rb;
            else
                ++r;
        } else if (s[i] == 'G') {
            if (rb)
                ans = ans * rb % mod, --rb;
            else if (r)
                ans = ans * r % mod, --r, ++rg;
            else if (b)
                ans = ans * b % mod, --b, ++gb;
            else
                ++g;
        } else if (s[i] == 'B') {
            if (rg)
                ans = ans * rg % mod, --rg;
            else if (r)
                ans = ans * r % mod, --r, ++rb;
            else if (g)
                ans = ans * g % mod, --g, ++gb;
            else
                ++b;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 512
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let n: i32 = input();
    if n % 2 == 0 {
        println!("{}", n);
    } else {
        println!("{}", n * 2);
    }

}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    long long A, B, N;
    cin >> A >> B >> N;

    long long x = min(B-1, N);

    long long ans = (A * x) / B - A * (x / B);

    cout << ans << endl;
}

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

//#define getchar getchar_unlocked
//#define putchar putchar_unlocked
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define ff first
#define ss second
#define err stderr
#define out stdout

typedef long long int ll;
typedef long double ld;
typedef short int sh;

inline void readI(int *i)
{
	register int t=0;
	register char z=getchar();
	int znak=1;
	if (z=='-')
	{
		znak=-1;
	}
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
		if (z=='-')
		{
			znak=-1;
		}
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*i=(t*znak);
}
inline void readUI(int *i)
{
	register int t=0;
	register char z=getchar();
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*i=t;
}
inline void readL(ll *l)
{
	register ll t=0;
	register char z=getchar();
	int znak=1;
	if (z=='-')
	{
		znak*=-1;
	}
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
		if (z=='-')
		{
			znak=-1;
		}
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*l=(t*znak);
}
inline void readUL(ll *l)
{
	register ll t=0;
	register char z=getchar();
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*l=t;
}
inline void writeL(ll l)
{
	if (l==0)
	{
		putchar(48);
	}
	else
	{
		if (l<0)
		{
		   l*=-1;
		   putchar(45);
		}
		int _tab[21];
		int wsk=0;
		while (l>0)
		{
			++wsk;
			_tab[wsk]=(l%10)+48;
			l/=10;
		}
		for (int j=wsk; j>=1; --j)
		{
			putchar(_tab[j]);
		}
	}
}
inline void writeS(string s)
{
	int l=s.length();
	for (int i=0; i<l; ++i)
	{
		putchar(s[i]);
	}
}
inline void space()
{
	putchar(32);
}
inline void endl()
{
	putchar(10);
}

#define debug if(1)
#define debug2 if(1)
#define debug3 if(1)
#define debug4 if(1)
#define MAXV 100005

int n, w, masa, wartosc, suma;
ll INF=(1e18);
ll wynik;
ll plecak[MAXV];

int main()
{
	readUI(&n);
	readUI(&w);
	for (int i=1; i<=100000; ++i)
	{
		plecak[i]=INF;
	}
	for (int i=1; i<=n; ++i)
	{
		readUI(&masa);
		readUI(&wartosc);
		suma+=wartosc;
		for (int j=suma; j>=wartosc; --j)
		{
			plecak[j]=min(plecak[j], plecak[j-wartosc]+masa);
			if (plecak[j]<=w)
			{
				wynik=max(wynik, (ll)j);
			}
		}
	}
	fprintf (out, "%lld\n", wynik);
	return 0;
}
/*
*/




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

int main(void)
{
	int i,j,k;
	char word[100],output[1000],loopWord[2],tmpWord[2];
	int loop;
	
	while(scanf("%s",word)!=EOF)
	{
		i=0;
		j=0;
		while(word[i]!='\0')
		{
			//@があったら
			if(word[i]=='@')
			{
				//次の文字を見て繰り返す回数を見る
				i++;
				loopWord[0]=word[i];
				loop=atoi(loopWord);
				//printf("%d回\n",loop);
				//更に次の文字を見て繰り返される文字を見る
				i++;
				tmpWord[0]=word[i];
				for(k=1;k<loop;k++)
				{
					output[j]=tmpWord[0];
					j++;
				}
			}
			//それ以外の時
			else
			{
				output[j]=word[i];
				i++;
				j++;
			}
		}
		output[j]='\0';
		printf("%s\n",output);
	}
	
	return 0;
}

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

int main(){
    int n, d, x, y, cont = 0;
    
    scanf(" %d %d", &n, &d);
    
    for(int i = 0; i < n; ++i){
        scanf(" %d %d", &x, &y);
        
        if(sqrt(pow(x,2) + pow(y,2)) <= d)
            ++cont;
    }
    
    printf("%d", cont);


    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int l,r;
  int sum = 0;
  
  for (int i = 0; i < N; i++) {
  	cin >> l >> r;
    if (l >= r) 
      sum += l - r + 1;
    else
      sum += r - l + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
N = (10**5)+5

is_prime = [True for _ in range(N)]
is_prime[1] = False
for i in range(2,N) :
    if not is_prime[i] :
        continue
    j = i*2
    while j<N :
        is_prime[j] = False
        j += i

cnt_acc = [0 for _ in range(N)]
for i in range(1,N) :
    cnt_acc[i] = cnt_acc[i-1]
    if is_prime[i] and is_prime[(i+1)//2] :
        cnt_acc[i] += 1

q = int(input())
for _ in range(q) :
    l, r = map(int, input().split())
    print(cnt_acc[r] - cnt_acc[l-1])


Measured memory_bytes: 5144
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <algorithm>
#define MOD 1000000007
#define forn(a, n) for(int a = 0; a<(int) (n); ++a)
#define dforn(a, n) for(int a = (n)-1; a>=0; --a)
#define forall(a, all) for(__typeof(all.begin()) a = all.begin(); a != all.end(); ++a)
#define EPS 0.000000000001
typedef long long tint;
using namespace std;

int main()
{
	tint x, y;
	cin >> x >> y;
	tint ans = 0, s = x;
	while( s < (1LL<<62LL) && s <= y) {
		ans++;
		s *= 2;
	}
	cout << ans << endl;
	
	return 0;
}


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

char judgeScore(int, int, int);

int main(void)
{
    int amount_student, score_math, score_eng, score_jpn;

    while (true) {
        scanf("%d", &amount_student);
        
        if (amount_student == 0) {
            break;
        }
        
        for (int num_student = 0; num_student < amount_student; num_student++) {
            scanf("%d%d%d", &score_math, &score_eng, &score_jpn);
            printf("%c\n", judgeScore(score_math, score_eng, score_jpn));  
        }
    }
    
    return 0;
}

char judgeScore(int x, int y, int z)
{
    int average_all = (x + y + z) / 3; //切り捨てが起こっても大丈夫
    if (x == 100 || y == 100 || z == 100) {
        return 'A';
    } else if ((x+y) / 2 >= 90) {
        return 'A';
    } else if (average_all >= 80) {
        return 'A';
    } else if (average_all >= 70) {
        return 'B';
    } else if (average_all >= 50 && (x >= 80 || y >= 80)) {
        return 'B';
    } else {
        return 'C';
    }
}

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

string t = "0123456789";

int main(){
	int a,b;
	cin >> a >> b;
	a--;b--;
	string s;
	cin >> s;
	bool ok = true;
	if(s[a+1] != '-') ok = false;
	rep(i,s.size()){
		if(i == a+1) continue;
		bool num = false;
		rep(j,10){
			if(s[i] == t[j]) num = true;
		}
		if(!num) ok = false;
	}
	if(ok){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
    return 0;
}



Measured memory_bytes: 256
S = input()
S = list(S)
S = set(S)
S = list(S)
S.sort()
alpabet = 'abcdefghijklmnopqrstuvwxyz'
alphabet = list(alpabet)
count = 0
judge = 0

if(len(S) == 26):
  print('None')
else:
  for i in range(len(S)):
   count += 1
   if(S[i] != alphabet[i]):
      print(alphabet[i])
      judge = 1
      break
  if((count == len(S))and(judge==0)):
    print(alphabet[count])
  

  

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int a, b; cin >> a >> b;
    if (b % a == 0)
    {
        cout << a + b << endl;
        return 0;
    }
    else
    {
        cout << b - a << endl;
        return 0;
    }
}

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

int main(){
  int K, A, B;
  cin >> K >> A >> B;
  
  B /= K;
  B *= K;
  
  if(B >= A)
    cout << "OK" << endl;
  
  else
    cout << "NG" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	string s; cin>>s;
	rep(i,s.size()){
		if(s[i]=='7') return cout<<"Yes"<<endl,0;
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3548
#include <stdio.h>
#include <vector>
#include <string>
#include <utility>
#include <iostream>
using namespace std;

int main(void) {
  int n, m, i;
  vector< pair<string, int> >  v;
  vector< pair<string, int> >::iterator it;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    string s;
    int a = 1;
    cin >> s;
    for(it = v.begin(); it != v.end(); ++it) if((*it).first == s) {
      a = 0;
      (*it).second++;
      break;
    }
    pair<string, int> p = make_pair(s, 1);
    if(a) v.push_back(p);
  }
  scanf("%d", &m);
  for(i = 0; i < m; ++i) {
    string s;
    int a = 1;
    cin >> s;
    for(it = v.begin(); it != v.end(); ++it) if((*it).first == s) {
      a = 0;
      (*it).second--;
      break;
    }
    pair<string, int> p = make_pair(s, -1);
    if(a) v.push_back(p);
  }
  int max = 0;
  for(it = v.begin(); it != v.end(); ++it) if(max < (*it).second) max = (*it).second;
  printf("%d", max);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<bits/stdc++.h>
#include<sstream>
using namespace std;
string s,t; 
int main()
{
	cin>>s>>t;
	cout<<t<<s;
	
}


Measured memory_bytes: 3536
/*
4
10
8
8
6
*/
fn main() {
    let n = read();
    let mut d = Vec::new();
    for i in 0..n {
        d.push(read());
    }

    d.sort();
    d.dedup();

    println!("{}", d.len());
}

fn read() -> i32 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
A,B=map(int,input().split())
S=list(input())
Z=['0','1','2','3','4','5','6','7','8','9']
for i in range(A+B):
    if i!=A and S[i] in Z:
        pass
    elif i!=A:
        print('No')
        break
    elif S[A]!='-':
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
int ifcl(int p0[2],int p1[2],int p2[2],int p3[2]){
  long long x=p0[0],x0=p1[0]-x,x1=p2[0]-x,x2=p3[0]-x,x3=x2-x1,x4=x1-x0,x5=x2-x0;
  long long y=p0[1],y0=p1[1]-y,y1=p2[1]-y,y2=p3[1]-y,y3=y2-y1,y4=y1-y0,y5=y2-y0;
  long long c1=(x0*y1-y0*x1)*(x0*y2-y0*x2),c2=(x3*y4-y3*x4)*(x3*y1-y3*x1);
  long long d1=x1*x4+y1*y4,d2=x4*x5+y4*y5,d3=x2*x5+y2*y5,d4=x1*x2+y1*y2;
  if(c1==0&&c2==0)return (d1>0&&d2>0&&d3>0&&d4>0)?0:1;
  return (c1<=0&&c2<=0)?1:0;
}
int main(){
  int p[4][2],n,i;
  scanf("%d",&n);
  while(n--){
    for(i=0;i<8;i++)scanf(" %d",&p[i/2][i%2]);
    printf("%d\n",ifcl(p[0],p[1],p[2],p[3]));
  }
  return 0;
}

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

struct point {
    double x, y;
    point(double a, double b) {
        x = a, y = b;
    }
    point operator + (point p) {
        return point(x + p.x, y + p.y);
    }
    point operator - (point p) {
        return point(x - p.x, y - p.y);
    }
    point operator * (double k) {
        return point(x * k, y * k);
    }
    point operator / (double k) {
        return point(x / k, y / k);
    }
};

double norm(point p) {
    return p.x * p.x + p.y * p.y;
}

double dot(point a, point b) {
    return a.x * b.x + a.y * b.y;
}

double cross(point a, point b) {
    return a.x * b.y - a.y * b.x;
}

int main() {
    int n;
    scanf("%d", &n);
    rep(i, n) {
        vector<point> p(4,{0,0});
        rep(j, 4) {
            int x, y;
            scanf("%d %d", &x, &y);
            p[j].x = x;
            p[j].y = y;
        }
        point s1 = p[0] - p[1];
        point s2 = p[2] - p[3];
        if (dot(s1, s2) == 0) printf("1\n");
        else if (cross(s1, s2) == 0) printf("2\n");
        else printf("0\n");
    }
}


Measured memory_bytes: 3164
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int Z = sc.nextInt();
        System.out.println(Z+" "+X+" "+Y);
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;

int main(){
    int n,m; cin >> n >> m;
    vector<vector<int> > ki(n*3);
    vector<int> visit(n*3,0);
    rep(i,m){
        int u,v; cin >> u >> v;
        u--; v--;
        rep(j,3) ki[3*u+j].push_back(3*v+((j+1)%3));
    }
    int s,t; cin >> s >> t;
    s--; t--;
    s*=3; t*=3;

    queue<P> p;
    p.push(P(s,0));
    int ans=-1;
    while(!p.empty()){
        int now=p.front().first;
        int num=p.front().second;
        p.pop();
        if(visit[now]) continue;
        if(now==t){
            ans=num;
            break;
        }
        visit[now]++;
        rep(i,ki[now].size()) p.push(P(ki[now][i],num+1));
    }
    if(ans!=-1) ans/=3;
    cout << ans << endl;
return 0;
}

Measured memory_bytes: 17792
// -*- coding:utf-8-unix -*-

use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        k: u64,
        a: [u64; n],
    }

    let mut hm = HashMap::new();
    let mut current_town = 0;
    let mut offset = 0;
    let mut cycle = 0;
    hm.insert(current_town, 0);
    // println!("{:?}", a);
    for i in 1..n {
        // print!("{} ", current_town);
        current_town = a[current_town as usize] - 1;
        if i as u64 == k {
            println!("{}", current_town + 1);
            return;
        }

        // println!("to {}", current_town);
        if hm.contains_key(&current_town) == true {
            // println!("{:?}", hm);
            cycle = (i as u64 - hm.get(&current_town).unwrap()) as u64;
            offset = i as u64 - cycle;
            break;
        }

        hm.insert(current_town, i as u64);
    }

    // println!("offset: {}, cycle: {}", offset, cycle);
    let p = (k - offset) % cycle;
    for (key, value) in &hm {
        if *value == p + offset {
            println!("{}", key + 1);
            return;
        }
    }
}


Measured memory_bytes: 11444
N,P = map(int,input().split())
ans=1
i=2
if N==1:
  print(P)
  exit()
if N>=40 or P==1:
  print(1)
  exit()
  
while i<=(P**(2/N)):
  while P%(i**N) == 0:
    ans *= i
    P = P//(i**N)
  if i==2:
    i+=1
  else:
    i+=2
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vint a(n+1);
  ll sum=0;
  rep(i,n+1){
    cin>>a[i];
    sum+=a[i];
  }
  if(n==0){
    if(a[0]!=1){
        cout<<-1<<'\n';
    }
    else{
        cout<<1<<'\n';    
    }
      return(0);
  }
  else if(a[0]!=0){
    cout<<-1<<'\n';
    return(0);
  }

  ll ans=1,node=1;
  REP(i,1,n+1){
    node=min(node*2,sum);
    ans+=node;
    node-=a[i];
    sum-=a[i];
    if(node<0){
        cout<<-1<<'\n';
        return(0);
    }
  }
  cout<<ans<<'\n';
  return(0);
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
 
#define mem(dp,a)       memset(dp,a,sizeof dp)
#define ninja           ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb(x)           push_back(x)
#define mp(x,y)         make_pair(x,y)
#define all(c)          c.begin(), c.end()
#define ff              first
#define ss              second
#define nl              '\n'
#define inf             1e9+7
int main()
{
	ninja
    ll n; cin>>n;
    vector<ll> v(n);
    map<ll, ll> m;
    for(int i=0;i<n;i++)
    {
        cin>>v[i]; m[v[i]]++;
    }
    ll res=0;
    for(auto i:m){
        if(i.ss==1)
            continue;
        res+=((i.ss*(i.ss-1))/2);
    }
    vector<ll> final(n,res);
    for(int i=0;i<n;i++){
        if(!final[i])
            ;
        else
            final[i] = final[i]-(m[v[i]]-1);
    }
    for(auto i:final)
        cout<<i<<nl;
}


Measured memory_bytes: 12672
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

/* MACROS SAMPAH */
#define Jehian using
#define Norman namespace
#define Saviero std
#define cepet {ios_base::sync_with_stdio(0);cin.tie(0);}

Jehian Norman Saviero;

/* MACROS FOR TYPE */
typedef long l;
typedef long double ld;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

/* MACROS FOR PRINT */
#define nl printf("\n")
#define sp printf(" ")

/* MACROS FOR FUNCTION AND METHOD */
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define eb emplace_back
#define RESET(x) memset((x), 0, sizeof(x))
#define SET(x,y) for(int _je = sizeof(x)/sizeof(x[0]); _je--;) x[_je] = y
#define SQR(x) (x)*(x)
#define CUBE(x) SQR(x)*(x)
#define ALL(x) (x).begin(), (x).end()
#define ALLSIZE(x,n) (x), (x)+(n)

/* MACROS FOR ATTRIBUTE */
#define fi first
#define se second

/* MACROS FOR SCAN */
#define scc(x) scanf("%c", &x)
#define scd(x) scanf("%Lf", &x)
#define scf(x) scanf("%f", &x)
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scld(x) scanf("%Lf", &x)
#define scui(x) sci(x)
#define scul(x) scl(x)
#define scull(x) scll(x)

ull MAX_NUM = 1e18;

int main(){
	ll x, y;
	scll(x);
	scll(y);
	if (x % y == 0){
		puts("-1");
	} else {
		cout << x << endl;
	}
	return 0;
}

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

int main()
{
	
	int X,Y,a,b;

 /*  #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   #endif 
*/
   cin>>X>>Y;
   if(Y%2==1)
   {
     cout<<"No";
	 exit(0);   	

   }

   a = (4*X - Y)/2 ;

   b = X-a;

   if(a>=1 && b==0)
  {	cout<<"Yes";
     exit(0);
   }   
   
  if (a==0 && b>=1)
  {
	cout<<"Yes";
     exit(0);
  }

   if(a>=1 && b>=1)
   	cout<<"Yes";
   else
   	cout<<"No";

 }  


Measured memory_bytes: 3632
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, K = MAP()
if (A + B) < K:
	print(0, 0)
	exit()

if A < K:
	print(0, B - (K - A))
else:
	print(A - K, B)

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

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

  map<int,int> numbers;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    ++numbers[a];
  }

  int ans = 0;
  map<int,int>::iterator itr;
  for (itr = numbers.begin(); itr != numbers.end(); ++itr) {
    if (itr->second % 2) {
      ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992