akhauriyash/Code-Regression huggingface dataset:
//arc083_c.cpp
//Thu Jun  7 06:33:10 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;

int main(){
	int a,b,c,d,e,f;
	cin >> a >> b >> c >> d >> e >> f;

	int maxconc = 0;
	int ans1 = 0;
	int ans2 = 0;


	for (int i=0;a*i*100<=f;i++){
		for (int j=0;b*j*100<=f;j++){
			if (i==0 && j==0){
				continue;
			}
			for (int k=0;a*i*100+b*j*100+c*k<=f;k++){
				for (int l=0;a*i*100+b*j*100+c*k+d*l<=f;l++){
					if ((float)(c*k+d*l)/(a*i+b*j)<=(float)e){
						int total = a*i*100+b*j*100+c*k+d*l;
						int sugar = c*k+d*l;
						int temp = 10000*sugar/total;
						if (maxconc < temp){
							maxconc = temp;
							ans1 = total;
							ans2 = sugar;
						}
					}
				}
			}
		}
	}

	if (ans1==0 && ans2 == 0){
		ans1=100*a;
	}

	cout << ans1 << " " <<ans2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    vector<int> v;
    for(int i=0;i<5;i++){
        int k;
        cin>>k;
        v.push_back(k);
    }
    int a;
    cin>> a;
    sort(v.begin(),v.end());
    if(v[4]-v[0]>a)
    cout<<":("<<endl;
    else
    cout<<"Yay!"<<endl;
    return 0;
}


Measured memory_bytes: 256
import os
import sys

if os.getenv('LOCAL'):
    sys.stdin = open('_in.txt', 'r')

sys.setrecursionlimit(2147483647)
INF = float('inf')

N, A, B, C, D = list(map(int, sys.stdin.readline().split()))
S = '.' + sys.stdin.readline().rstrip()


def can_go(s, e):
    i = s + 1
    while i <= e:
        if S[i - 1] == S[i] == '#':
            return False
        i += 1
    return True


def solve2():
    assert D < C
    if not can_go(A, C) or not can_go(B, D):
        return False
    i = B
    while i <= D:
        if S[i - 1] == S[i] == S[i + 1] == '.':
            return True
        i+=1
    return False


def solve():
    if C < D:
        return can_go(A, D)
    return solve2()


if solve():
    print('Yes')
else:
    print('No')


Measured memory_bytes: 41072
N = int(input())

P_list = input().split()

P_list_int = [int(p) for p in P_list]


correct_cnt = 0
min_val = 200000
for i in range(N):
    if(P_list_int[i] <= min_val):
        min_val = P_list_int[i]
        correct_cnt += 1

print(correct_cnt)

Measured memory_bytes: 25768
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int a, b, c;
	long long k;
	scanf("%d%d%d%lld", &a, &b, &c, &k);
	if (k & 1) printf("%d\n", b - a); else printf("%d\n", a - b);
	return 0;
}


Measured memory_bytes: 128
<?php
fscanf(STDIN,"%d %d",$N,$K);
$S=strval(trim(fgets(STDIN)));
$length = strlen($S);
$array = [];
$counter = 1;

//1,0が何個連続するかの配列作成、1始まり0終わり(例010011→[0,1,1,2,2,0])
if(substr($S,0,1) === "0"){
  $array[] = 0;
}
for($i=0;$i<$N-1;$i++){
  if(substr($S,$i,1) !== substr($S,$i+1,1)){
    if(substr($S,$i,1) === "1"){
      $array[] = $counter;
    }else{
      $array[] = $counter;
    }
    $counter = 1;
  }else {
    $counter += 1;
  }
}
if(substr($S,$i,1)==="0"){
  $array[] = $counter;
}else{
  $array[] = $counter;
  $array[] = 0;
}

$size = count($array);
//配列の大きさの半分以上の回数指示できれば全員逆立ちできる
if($K>=$size/2){
  $max = $N;
}else{
  //初期値計算
  $value = 0;
  for($i=0;$i<$K*2+1;$i++){
    $value += $array[$i];
  }
  $max = $value;
  $value -= $array[0]+$array[1];
  //逆立ちの最大値を求める(尺取法)
  for($i=2;$i<$size-$K*2+1;$i+=2){
    //最後のみ次の値がないので足す回数が1回のみ
    if($i===$size-$K*2){
      $value += $array[$i+$K*2-1];
    //次の値を足す(尺の右側を進める)
    }else{
      $value += $array[$i+$K*2-1]+$array[$i+$K*2];
    }
    //最大値更新
    if($value > $max){
      $max = $value;
    }
    //尺の左側を進める
    $value -= $array[$i]+$array[$i+1];
  }
}
echo $max;


Measured memory_bytes: 18060
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int up = 0;
		int down = 0;
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			char c = s.charAt(i);
			if (c == '(') {
				for (int j = 0; j < down; j++) {
					sb.insert(0, '(');
				}
				for (int j = 0; j < down; j++) {
					sb.append(')');
				}
				down = 0;
				sb.append(c);
				up++;
			} else {
				if (up == 0) {
					down++;
				} else {
					sb.append(c);
					up--;
				}
			}
		}
		for (int j = 0; j < down; j++) {
			sb.insert(0, '(');
		}
		for (int j = 0; j < down; j++) {
			sb.append(')');
		}
		for (int i = 0; i < up; i++) {
			sb.append(')');
		}
		System.out.println(sb);
	}
}


Measured memory_bytes: 22740
N,M = map(int,input().split())
l = []
r = []
for i in range(M):
    a,b = map(int,input().split())
    if a == 1:
        l.append(b)
    elif b == N:
        r.append(a)
s = set(l).intersection(set(r))
print("POSSIBLE" if len(s) else "IMPOSSIBLE")

Measured memory_bytes: 21852
#include<iostream>
using namespace std;
#define inRange(x,a,b) (a <= x && x <= b)

int main(){
    int x;
    cin >> x;
    for(int i = 0; i*100 <= x; i++){
        if(inRange(x-i*100, 0, i*5)){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

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

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }

typedef long long ll;
using namespace std;

int main() {
    
    int n, m;
    cin >> n >> m;
    vector<int> a(n-1+m, 0), b(n-1+m, 0);
    vector<int> indeg(n, 0);
    vector<vector<int>> src(n, vector<int>());
    vector<vector<int>> dst(n, vector<int>());
    
    REP(i, n-1+m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        indeg[b[i]]++;
        src[b[i]].emplace_back(a[i]);
        dst[a[i]].emplace_back(b[i]);
    }

    deque<int> st;
    vector<int> sorted, invsorted(n, 0);
    REP(i, n) if (indeg[i] == 0) st.emplace_back(i);

    while (!st.empty()) {

        int v = st.back();
        st.pop_back();
        invsorted[v] = sorted.size();
        sorted.push_back(v);

        for (int c : dst[v]) {
            if (--indeg[c] == 0) {
                st.emplace_back(c);
            }
        }

    }

    REP(i, n) {
        int maxi = 0, maxis = -1;
        for (int c : src[i]) {
            if (chmax(maxis, invsorted[c])) {
                maxi = c + 1;
            }
        }
        cout << maxi << endl;
    }

    
}

Measured memory_bytes: 13820
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define rrep(i,n) ll(i)=(n);ll now=-1;while((i)--&&(now++||1))
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll N, ll M, vector<ll> L, vector<ll> R){
    ll min_id = 0, max_id = N;
    rep(i, M) {
        chmax(min_id, L.at(i));
        chmin(max_id, R.at(i));
    }
    cout << max(0LL, max_id - min_id + 1) << "\n";
}

int main() {
    ll N;
    ignore_ret(scanf("%lld",&N));
    ll M;
    ignore_ret(scanf("%lld",&M));
    vector<ll> L(M);
    vector<ll> R(M);
    for(int i = 0 ; i < M ; i++){
        ignore_ret(scanf("%lld",&L[i]));
        ignore_ret(scanf("%lld",&R[i]));
    }
    solve(N, M, move(L), move(R));
    return 0;
}

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

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

    if ((a + b) % 2 == 0)
        cout << (a + b) / 2 << endl;
    else
        cout << "IMPOSSIBLE" << endl;
    return 0;
}


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

int main() {
  int N; cin >> N;
  
  int place_of_one = N%10;
  
  if(place_of_one == 2) cout << "hon" << endl;
  if(place_of_one == 4) cout << "hon" << endl;
  if(place_of_one == 5) cout << "hon" << endl;
  if(place_of_one == 7) cout << "hon" << endl;
  if(place_of_one == 9) cout << "hon" << endl;
  
  if(place_of_one == 0) cout << "pon" << endl;
  if(place_of_one == 1) cout << "pon" << endl;
  if(place_of_one == 6) cout << "pon" << endl;
  if(place_of_one == 8) cout << "pon" << endl;
  
  if(place_of_one == 3) cout << "bon" << endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vvi ans;
ll n,m;
ll dfs(int i,int j){
    if(i>=n)return 0;
    if(ans[i][j])return ans[i][j];
    ans[i][j]=dfs(i+1,j);
    return ans[i][j];
}
ll dfs2(int i,int j){
    if(i>=n)return 0;
    if(ans[i][j])return ans[i][j];
    ans[i][j]=dfs2(i-1,j);
    return ans[i][j];
}
int main() {
    ll k;cin>>n>>m>>k;
    vector<vector<bool>> v(n,vector<bool>(m,false));
    vector<bool> s(n,false);
    rep(i,n){
        string t;cin>>t;
        rep(j,m){
            if(t[j]=='#'){
                v[i][j]=true;
                s[i]=true;
            }
        }
    }
    ans=vvi(n,vi(m));
    bool used=false;
    rep(i,n){
        if(s[i]){
            int last;
            rep(j,m){
                ans[i][j]=k;
                if(v[i][j]){
                    k--;
                    last=j;
                }
            }
            REP(j,last+1,m)ans[i][j]=k+1;
        }
    }
    rep(i,n){
        if(!s[i]){
            rep(j,m)dfs(i,j);
        }
    }
    rep(j,m)dfs2(n-1,j);
    outvv(ans);
}

Measured memory_bytes: 2176
package main

import (
	"bufio"
	"os"
	"strings"
)

const scBufSize = 1 * 1024 * 1024 // 1MB

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, scBufSize), scBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}()
var w = []string{"dream", "dreamer", "erase", "eraser"}

func main() {
	s := scans()

	if check(s) {
		os.Stdout.WriteString("YES")
		return
	}
	os.Stdout.WriteString("NO")
}

func scans() string {
	sc.Scan()
	return sc.Text()
}

func check(s string) bool {
	var b bool
	for _, v := range w {
		if v == s {
			return true
		}
		if strings.HasPrefix(s, v) {
			b = b || check(s[len(v):])
		}
	}
	return b
}


Measured memory_bytes: 9472
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string s;
  cin >> s;
  int odd=0, even=0;
  for(int i=0;i<s.size();i++){
    odd+=(s[i]-'0')^(i%2);
    even+=(s[i]-'0')^((i+1)%2);
  }
  cout << min(odd,even) << endl;
}

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

#define MAX_S 101
#define MAX_CH 100

int main(){

  int S[MAX_S];
  int top=0;
  char ch[6];
  int sum;

  while(scanf("%s",ch) != EOF){
    if(ch[0] == '+'){
      S[top-1] += S[top]; 
      top--;
    }
    else if(ch[0] == '-'){
      S[top-1] -= S[top]; 
      top--;
    }
    else if(ch[0] == '*'){
      S[top-1] *= S[top]; 
      top--;
    }
    else if(ch[0] == '/'){
      S[top-1] /= S[top]; 
      top--;
    }
    else{
      top++;
      S[top] = atoi(ch);
    }
  }

  printf("%d\n",S[1]);

  return 0;
}

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

using namespace std;
using namespace std;
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define sz(v)  v.size()


void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}


int N = 1.5 * 1e7 + 5;

ll GCD(ll a, ll b) {
    if (!b)return a;
    return GCD(b, a % b);
}

ll fastExpo(ll a, ll b) {
    if (!b)return 1;
    ll half = fastExpo(a, b / 2);
    ll ans = (half * half);
    if (b & 1)return (ans * a);
    return ans;
}

int sumofdigits(int n) {
    int t = 0;
    while (n != 0) {
        t += n % 10;
        n /= 10;
    }
    return t;
}

ll fact(int n) {
    if (n <= 1)return 1;
    return n * fact(n - 1);
}


int freq[200];


int main() {
    fast();
    int a,b,c;cin>>a>>b>>c;
    cout<<((a==b&&a!=c)||(b==c&&a!=c)||(a==c&&a!=b)?"Yes":"No");
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;


#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define sq5(x) ((x) * (x) * (x) * (x) * (x))

char s[1005];

int main(void) {
	scanf("%s", &s);
	string a = (string)s;
	if (a.back() == 's') {
		a += "es";
	}
	else {
		a += "s";
	}

	printf("%s\n", a.c_str());
}


Measured memory_bytes: 3660
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
#print(l)
ans=0
for i in range(n):
    for j in range(i+1,n):
        c=bisect.bisect_left(l,l[i]+l[j])-(j+1)
        #print(c)
        ans+=c
print(ans)



Measured memory_bytes: 3316
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define LL       long long
#define DS       pair<int, int>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int n;
    scanf("%d", &n);
    int ok = 1;
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        if (x % 2 == 0) {
            if (x % 3 == 0 || x % 5 == 0) continue;
            ok = 0;
            break;
        }
    }
    puts(ok ? "APPROVED" : "DENIED");
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;

bool ng[30010];
bool check(int j, int p) {
    for (int i = 2; i < p; i++) {
        if (j % i == 0)
            return false;
    }
    return true;
}

vector<int> calc(int p) {
    memset(ng, false, sizeof(ng));
    for (int i = p; i < 30000; i++) {
        ng[i] = check(i, p);
    }

    int d = (p == 11 ? 2*3*5*7 : 2*3*5*7*11);
    
    vector<int> res;
    int sum = 0;
    for (int i = 2; i < 30000; i++) {
        if (ng[i]) continue;
        res.push_back(i);
        sum += i;
        if ((int)res.size() == n-1) {
            i++;
            while (i <= 30000) {
                if (!ng[i] && (sum+i) % d == 0) {
                    res.push_back(i);
                    break;
                }
                i++;
            }
            break;
        }
    }
    return res;
}

void solve() {
    vector<int> res = calc(11);
    if ((int)res.size() < n) res = calc(13);

    for (int v : res) {
        cout << v << " ";
    }
    cout << endl;
}

void input() {
    cin >> n;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}


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

int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  bool p=false;
  vector<int> q(5);
  q[0]=a;
  q[1]=b;
  q[2]=c;
  q[3]=d;
  q[4]=e;
  for(int i=0;i<4;i++){
    for(int j=i+1;j<5;j++){
      if(q[j]-q[i]>k){
        p=true;
        break;
      }
    }
    if(p)
      break;
  }
  if(p)
    cout << ":(";
  else
    cout << "Yay!";
}

Measured memory_bytes: 256
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
a=n1()

def comb(n):
    if n<=1:
        return 0
    if n==2:
        return 1
    return (n*(n-1))//2

from collections import Counter
c=Counter(a)
# print(c)
d={i:comb(j) for i,j in c.items()}
# print(d)
s=sum(d.values())
# print(s)

for i in a:
    print(s-d[i]+comb(c[i]-1))

Measured memory_bytes: 32156
#include<iostream>
#include<string>
using namespace std;
int main(){
	string inp;
	int m,h;
	while(1){
	cin >> inp;
	if(inp=="-")	break;
	cin >> m;
	for(int i=0;i<m;i++){
		cin >> h;
		inp += inp.substr(0,h);
		inp.erase(0,h);
	}
	cout << inp << endl;
	}
	return 0;
}

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

int main(){
  	int N, K, cnt=0;
  	cin >> N >> K;
  	
  	while(N>=K){
    	N/=K;
      	cnt++;
      	if(N<K){
        	break;
        }
    }
  	cnt++;
  	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
program energy_drink_collector
  implicit none
  integer(8) :: n, m, ab(100000,2), i, p
  read(*,*) n, m
  ab = 0_8
  do i = 1, n
    read(*,*) ab(i,:)
  end do
  call merge_sort(n,ab(1:n,:),1_8)
  p = 0
  do i = 1, n
    if (m.le.ab(i,2)) then
      p = p + m*ab(i,1)
      exit
    else
      p = p + ab(i,2)*ab(i,1)
      m = m - ab(i,2)
    end if
  end do
  write(*,'(i0)') p
  stop
contains
  subroutine merge_sort(n,c,idx)
    implicit none
    integer(8), intent(in)    :: n, idx
    integer(8), intent(inout) :: c(n,2)
    integer(8)                :: number, length, i, ubound
    number = n
    length = 1
    do while (number .gt. 1)
      do i = 1, number/2
        ubound = min(2*i*length,n)
        call merge(c(2*(i-1)*length+1:(2*i-1)*length,:),c((2*i-1)*length+1:ubound,:),idx)
      end do
      length = 2*length
      number = (number+1)/2
    end do
    return
  end subroutine merge_sort
  subroutine merge(c1,c2,idx)
    implicit none
    integer(8), intent(inout) :: c1(:,:), c2(:,:)
    integer(8), intent(in)    :: idx
    integer(8)                :: c(size(c1(:,1))+size(c2(:,1)),size(c1(1,:)))
    integer(8)                :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(c1(:,1))
    n2 = size(c2(:,1))
    do while (i1 .le. n1 .and. i2 .le. n2)
      if (c1(i1,idx) .le. c2(i2,idx)) then
        c(i1+i2-1,:) = c1(i1,:)
        i1 = i1+1
      else
        c(i1+i2-1,:) = c2(i2,:)
        i2 = i2+1
      end if
    end do
    if (i1 .le. n1) then
      c(i1+i2-1:n1+n2,:) = c1(i1:n1,:)
    else if (i2 .le. n2) then
      c(i1+i2-1:n1+n2,:) = c2(i2:n2,:)
    end if
    c1 = c(1:n1,:)
    c2 = c(n1+1:n1+n2,:)
    return
  end subroutine merge
end program energy_drink_collector

Measured memory_bytes: 5108
#include<iostream>
using namespace std;
int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  for(int i=1; i<100; i++){
    if((a * i) % b == c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int N;
    cin>>N;
    long long int t;
    long long int ms = N-1;
    for(int i=2;i<=sqrt(N);++i){
        t=N/i;
        if(t*i==N && ms>t+i-2)ms = t+i-2;
    }
    cout<<ms;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

N, *A = map(int, open(0).read().split())

C = Counter(A)
dp = [[[.0] * (N + 2) for _ in range(N + 2)] for _ in range(N + 2)]
for i in range(C[3] + 1):
    for j in range(N - C[1] - i + 1):
        for k in range(N - i - j + 1):
            if i + j + k != 0:
                dp[i][j][k] = (
                    N +
                    i * dp[i - 1][j + 1][k] +
                    j * dp[i][j - 1][k + 1] +
                    k * dp[i][j][k - 1]
                ) / (i + j + k)

print(dp[C[3]][C[2]][C[1]])

Measured memory_bytes: 258312
import java.util.*;

class Main{
	static Scanner s=new Scanner(System.in);
	public static void main(String[] $){
		int n=s.nextInt(),t=s.nextInt(),a=s.nextInt();
		
		int index=-1;
		double eval=Double.MAX_VALUE;
		
		for(int i=0;i<n;++i) {
			double e=Math.abs(a-(t-0.006*s.nextInt()));
			if(e<eval) {
				index=i+1;
				eval=e;
			}
		}
		System.out.println(index);
	}
}

Measured memory_bytes: 23120
import java.math.BigDecimal

fun main(args: Array<String>) {
    val n = readLine()!!

    println(
            readLine()!!.split(Regex("\\s+")).map { it.toInt() }
                    .groupBy { it }
                    .mapValues { it.value.size }
                    .filterValues { it >= 2 }
                    .toList().sortedByDescending { it.first }
                    .let { l ->
                        val first = l.getOrElse(0, { i -> 0 to 0 })
                        val second = l.getOrElse(1, { i -> 0 to 0 })

                        val fvalue = BigDecimal(first.first)
                        val svalue = BigDecimal(second.first)

                        fvalue * (if (first.second >= 4) fvalue else svalue)
                    }
    )
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

vll seen;
void dfs(vvll &graph, ll v, ll ct){
  seen.at(v) = ct;
  vrep(nv, graph.at(v)) if(seen.at(nv) == 0) dfs(graph, nv, ct);
}

int main(){
  ll n, m, k;
  cin >> n >> m >> k;
  vvll follow(n);
  rep(i, 0, m){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    follow.at(a).push_back(b);
    follow.at(b).push_back(a);
  }
  ll ct = 1;
  seen.assign(n, 0);
  rep(i, 0, n) if(seen.at(i) == 0){
    dfs(follow, i, ct);
    ct++;
  } //グループ分け完了 
  vll group(n + 1);
  vrep(i, seen) group.at(i)++;
  vll ans(n, 0);
  rep(i, 0, n){
    ans.at(i) = group.at(seen.at(i)) - follow.at(i).size() - 1;
  }
  vpll block;
  rep(i, 0, k){
    ll c, d;
    cin >> c >> d;
    c--; d--;
    block.push_back(make_pair(c, d));
  }
  vrep(i, block){
    ll c = i.first, d = i.second;
    if(seen.at(c) == seen.at(d)){
      ans.at(c)--;
      ans.at(d)--;
    }
  }
  rep(i, 0, n) cout << (ans.at(i) > 0 ? ans.at(i) : 0) << (i == n - 1 ? "" : " ");
  cout << endl; 
}

Measured memory_bytes: 11892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    ll X;
    cin >> X;
    ll Y = 100;
    int ans = 0;
    while (Y < X) {
        ans++;
        Y += Y / 100;
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

const int INF = 100000;

int main(){
	int n,m;//太郎、花子のそれぞれのカードの枚数
	while(true){
		cin >> n >> m;
		if(n==0 && m==0){
			break;
		}
		int *card1 = new int[n];
		int *card2 = new int[m];
		int sum1=0;//交換する前のcard1の和
		int sum2=0;//            card2の和
		for(int i=0;i<n;i++){
			cin >> card1[i];
			sum1 += card1[i];
		}
		for(int i=0;i<m;i++){
			cin >> card2[i];
			sum2 += card2[i];
		}


		if((sum1-sum2) %2 == 1){//下コメ参照
			cout << -1 << endl;
		}
		else{
			//交換して組み合わせが等しい場合に代入。組み合わせがない場合はずっとINF
			int change1 = INF;//太郎が渡す
			int change2 = INF;//花子が渡す
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(sum1 - sum2 == 2*(card1[i] - card2[j])){//下コメ参照。交換したら等しい
						if(change1+change2 > card1[i] + card2[j]){
							//答えは交換したカードの和の最小値
							change1 = card1[i];
							change2 = card2[j];
						}
					}
				}//for(j)終わり
			}//for(i)終わり
			if(change1 == INF){//塗り替えなし、つまり見つからなかった
				cout << -1 << endl;
			}else{
				cout << change1 << ' ' << change2 << endl;
			}
		}//else終わり

		delete[] card1;
		delete[] card2;
	}//while終わり
	return 0;
}
/*
太郎が渡すカードe1
花子が渡すカードe2
交換して和が等しいとき
sum1-e1+e2 = sum2-e2+e1
つまり、sum1 - sum2 = 2*(e1 - e2)
を満たすe1、e2を探せばよい。カードの値は整数なので、sum1-sum2が奇数のとき解なし
sum1-sum2の値はO(n+m)で求まる
e1-e2の値を全探索するときO(nm)
*/

Measured memory_bytes: 1196
/*                        _
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                   ____/`---'\____
                  /  \\|     |//  \
                 / \\||| /:\ |||// \
                / _||||| -:- |||||- \
               |   | \\\ \-/ /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
            ____'. .'  /--.--\  `. .'_____
          /"" '<  `.___\_<|>_/___.' >' "" \
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` / _/
          `-.____`.___ \_____/___.-`___.-'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 JENISH MONPARA S.    IIT PATNA    I_LOVE_ADITI_GOEL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793;
const long double DEL = 1e-12;
const int mod =  1000000007;
const int LIM = 100005;


#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define deb(a) cerr << #a << ": " << a << endl
#define ftt cin>>t;for(int tt=1;tt<=t;++tt)
#define forr(i,n) for((i)=1;(i)<=(n);(i)++)
#define Rev(v) reverse(v.begin(),v.end())
#define Sort(v) sort(v.begin(),v.end())
#define mem(a,b) memset(a,b,sizeof(a))
#define umii unordered_map<int,int>
#define all(a) a.begin() , a.end()
#define vvi vector<vector<int>>
#define pq priority_queue<int>
#define sqr(a) (((a) * (a)))
#define double long double
#define dbg cout<<"\nhi\n"
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define eb emplace_back
#define vi vector<int>
#define nl cout<<"\n"
#define pb push_back
#define int long long
#define sp <<" "<<
#define ss second
#define ff first
 
int fpow(int x, int n){
    int res = 1;
    while(n){
          if(n&1){
                res = res * x % mod;
          }
          x = x * x % mod;
          n>>=1;
    }
    return res;
}
int gcd(int a,int b){
    if(b == 0)return a;
    return gcd(b,a % b);
}
void sieve(int n){
     bool prime[5*LIM];
     memset(prime, true, sizeof(prime));
      int rootn = (int)sqrt(n);
     for (int p = 2; p <= rootn; p++)
          if (prime[p] == true)
               for (int i = p*p; i <= n; i += p)
                    prime[i] = false;
     prime[1] = 0;

}

int cnt, sum, mid, mx = -1e17, mn = 1e17, a[2*LIM];
int n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;

//******************************************* CHECK CONSTRAINTS **************************************************


int32_t main()
{     fio;
      cin>>n;
      vi a(n);
      forr(i,n){
            cin>>a[i-1];
      }
      Sort(a);
      x=a.back();
      k=n/2;
      while(k--){
            sum+=2*a.back();
            a.pop_back();
      }
      if(n&1){
            sum+=a.back();
      }
      cout<<sum-x;
     
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define int long long int
#define ldouble long double

//setprecision()<<

using namespace std;

int NextP(int P,int S,int F,int C){
    int n=(P-S)/F+1;
    if(P-S<=0){
        return S+C;
    }
    if(F==1){
        return P+C;
    }
    if((P-S)%F==0){
        n--;
    }   
    return F*n+S+C;
}

signed main() {
    int N,P;
    cin>>N;
    vector<int> C(N-1);
    vector<int> S(N-1);
    vector<int> F(N-1);
    for(int i=0;i<N-1;i++){
        cin>>C.at(i)>>S.at(i)>>F.at(i);
    }

    for(int j=0;j<N-1;j++){
        for(int i=j;i<N-1;i++){
            if(i==j){
                P=S.at(i);
            }
            P=NextP(P,S.at(i),F.at(i),C.at(i));
            if(i==N-2){
                cout<<P<<endl;
            }
        }
    }
    
    cout<<0<<endl;

return 0;
}

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

bool done[60][60];
int islands[60][60];
void dfs(int vx, int vy, int w, int h)
{
    done[vx][vy] = true;
    int dx[8] = {-1, -1, 0, 1, 1, 1, 0, -1,};
    int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1,};
    rep(i, 8)
    {
        if(islands[vx + dx[i]][vy + dy[i]] == 0) continue;
        if(vx + dx[i] < 0 || vx + dx[i] >= h) continue;
        if(vy + dy[i] < 0 || vy + dy[i] >= w) continue;
        if(done[vx + dx[i]][vy + dy[i]]) continue;
        dfs(vx + dx[i], vy + dy[i], w, h);
    }
    return;
}

int main(void)
{
    while(1)
    {
        int w, h;
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        rep(i, h)rep(j, w) done[i][j] = false;
        rep(i, h)rep(j, w) cin >> islands[i][j];
        int ans = 0;
        rep(i, h)rep(j, w)
        {
            if(islands[i][j] == 0) continue;
            if(done[i][j]) continue;
            ans++;
            dfs(i, j, w, h);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 3050;
const int mod = 1e9+7;
const int INF=0x3f3f3f3f;
int r,c,k,x,y,val;
ll dp[MAX][MAX][4];
ll room[MAX][MAX];
void solve() {
    cin>>r>>c>>k;
    while(k--){
        cin>>x>>y>>val;
        room[x][y]=val;
    }
    for(int i=1;i<=r;i++){
        for(int j=1;j<=c;j++){
            for(int k=1;k<=3;k++){
                dp[i][j][k]=max(dp[i-1][j][3]+room[i][j],dp[i][j][k]);
                dp[i][j][k]=max(dp[i][j][k],room[i][j]+dp[i][j-1][k-1]);
            }
            for(int k=0;k<=3;k++){
                dp[i][j][k]=max(dp[i][j-1][k],dp[i][j][k]);
                dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][3]);
            }
        }
    }
    ll maxn=0;
    for(int i=0;i<=3;i++){
        maxn=max(maxn,dp[r][c][i]);
    }
    cout<<maxn;

}

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


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 X; cin >> X;
    i64 r = 2000;
    for (i64 i = 1; ; i++) {
        r -= 200;
        if (X >= r) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
bool S[100010];
int count[100010];
int main() {
	S[1] = true;
	for (int i = 3; i <= 100000; i += 2) {
		S[i + 1] = true;
		if (S[i])continue;
		int j = 2;
		while (i*j <= 100000) {
			S[i*j] = true;
			j++;
		}
	}
	for (int i = 1; i <= 100000; i += 2) {
		count[i] = count[i - 2];
		if ((!S[i]) && (!S[(i + 1) / 2])) {
			count[i]++;
		}
	}
	int Q;
	std::cin >> Q;
	for (int i = 0; i < Q; i++) {
		int l, r;
		std::cin >> l >> r;
		l -= 2;
		std::cout << (count[r] - count[l]) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1152
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << std::endl;
}

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> da(n*n);
    rip(i,n*n,0) {
        cin >> da[i];
        --da[i];
    }
    ll ans = 0;
    vector<vector<int>> co(n, vector<int>(n));
    vector<vector<int>> ju(n, vector<int>(n, 1));
    rip(i,n,0) {
        rip(j, n, 0) {
            co[i][j] = min({abs(i), abs(j), abs(n-i-1), abs(n-j-1)});
        }
    }
    queue<Pii> q;
    rip(i,n*n,0) {
        int xx = da[i]/n, yy = da[i]%n;
        ans += co[xx][yy];
        q.push({xx, yy});
        ju[xx][yy]--;
        while(!q.empty()) {
            auto now = q.front(); q.pop();
            int x = now.first, y = now.second;
            if(x > 0 && chmin(co[x-1][y],co[x][y]+ju[x][y])) q.push({x-1, y});
            if(x < n-1 && chmin(co[x+1][y],co[x][y]+ju[x][y])) q.push({x+1, y});
            if(y > 0 && chmin(co[x][y-1],co[x][y]+ju[x][y])) q.push({x, y-1});
            if(y < n-1 && chmin(co[x][y+1],co[x][y]+ju[x][y])) q.push({x, y+1});
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6160
using System;

public class Hello
{
    public static void Main()
    {
        string[] s = Console.ReadLine().Trim().Split(' ',',','.');
        var first = 0;
        for (int i = 0; i < s.Length; i++)
            if (s[i].Length >= 3 && s[i].Length <= 6)
                if (first == 0) { Console.Write(s[i]); first = 1; }
                else Console.Write(" {0}", s[i]);
        Console.WriteLine();
    }
}

Measured memory_bytes: 8768
#include <iostream>
#include <math.h>

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point{
public:
	double x, y;
	Point(double _x = 0, double _y = 0) :x(_x), y(_y){};

	Point operator+(const Point &p){ return Point(x + p.x, y + p.y); }
	Point operator-(const Point &p){ return Point(x - p.x, y - p.y); }
	Point operator*(const Point &p){ return Point(x * p.x, y * p.y); }
	Point operator/(const Point &p){ return Point(x / p.x, y / p.y); }

	double norm() { return x*x + y*y; }
	double abs() { return sqrt(norm()); }

	bool operator<(const Point &p) const{
		return (x != p.x) ? x < (p.x) : (y < p.y);
	}

	bool operator==(const Point &p){
		return equals(x, p.x) && equals(y, p.y);
	}
};

typedef Point Vector;

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

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

bool isOrthogonal(Vector a, Vector b){
	return equals(dot(a, b), 0.0);
}

bool isParallel(Vector a, Vector b){
	return equals(cross(a, b), 0.0);
}

int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		double x0, y0, x1, y1, x2, y2, x3, y3;
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		Vector v1(x1 - x0, y1 - y0);
		Vector v2(x3 - x2, y3 - y2);
		if (isParallel(v1, v2)) cout << 2 << endl;
		else if (isOrthogonal(v1, v2)) cout << 1 << endl;
		else cout << 0 << endl;
	}

}

Measured memory_bytes: 3228
#include<stdio.h>

int main(void){
  char S[10000000]={},T[1000000]={};
  int count =0;
  scanf("%s%s",S,T);
  
  for(int i=0;i<sizeof(T);i++){
  if(S[i]!=T[i]) count++;
    if(S[i]==0) break;
  }
  
  printf("%d",count);

return 0;
  
}

Measured memory_bytes: 12452
program modulo_matrix
  implicit none
  integer, parameter :: m = 7919, k = 500
  integer :: n, u = 0, i, j
  integer(8) :: a(k,k) = 1_8, p(2*k) = 0_8
  logical :: b(m) = .false.
  read(*,*) n
  if (n == 2) then
    write(*,'(a)') "2 9"
    write(*,'(a)') "5 4"
    stop
  end if
  b(1) = .true.
  do i = 1, m
    if (b(i)) cycle
    do j = i, m, i
      b(j) = .true.
    end do
    b(i) = .false.
  end do
  do i = 1, m
    if (b(i)) cycle
    u = u+1
    p(u) = i
  end do
  do i = 1, n
    do j = 1, n
      u = i+j
      if (mod(u,2) == 0) a(i,j) = a(i,j)*p(u/2)
      u = i-j+n-1
      if (mod(u,2) /= mod(n,2)) a(i,j) = a(i,j)*p(2*n-(u+1)/2)
    end do
  end do
  do i = 1, n
    do j = 1, n
      if (a(i,j) /= 1_8) cycle
      if (i /= 1) a(i,j) = lcm(a(i,j),a(i-1,j))
      if (i /= n) a(i,j) = lcm(a(i,j),a(i+1,j))
      if (j /= 1) a(i,j) = lcm(a(i,j),a(i,j-1))
      if (j /= n) a(i,j) = lcm(a(i,j),a(i,j+1))
      a(i,j) = a(i,j)+1_8
    end do
  end do
  do i = 1, n
    write(*,'(i0)',advance='no') a(i,1)
    do j = 2, n
      write(*,'(x,i0)',advance='no') a(i,j)
    end do
    write(*,*)
  end do
contains
  integer(8) function lcm(a,b)
    integer(8), intent(in) :: a, b
    lcm = abs(a)/gcd(a,b)*abs(b)
  end
  integer(8) function gcd(a,b)
    integer(8), intent(in) :: a, b
    integer(8) :: x, y
    x = max(abs(a),abs(b))
    y = min(abs(a),abs(b))
    do while (y > 0_8)
      gcd = y
      y = mod(x,y)
      x = gcd
    end do
  end
end program modulo_matrix

Measured memory_bytes: 5120
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 100100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

//Edge.at(i).first.first:from .first.second:to .second:coin
vector<pair<pair<int,int>,long long>> Edge;
vector<long long> score(1005,-INF);

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

    int N,M;cin >> N >> M;
    for(int i = 0;i<M;i++){
        int from,to;long long coin;cin >> from >> to >> coin;from--;to--;
        Edge.push_back(make_pair(make_pair(from,to),coin));
    }

    //Bellman-Ford
    bool infinity_loop = false;
    long long prv = -INF;
    score.at(0) = 0;
    for(int i = 0;i<N+5;i++){
        bool update = false;
        for(int j = 0;j<M;j++){
            int from = Edge.at(j).first.first,to = Edge.at(j).first.second;long long coin = Edge.at(j).second;
            if(score.at(from) == -INF) continue;
            if(score.at(from)+coin > score.at(to)){
                score.at(to) = score.at(from)+coin;
                update = true;
            }
        }
        if(!update) break;
        if(i >= N){
            if(prv != score.at(N-1))infinity_loop = true;
            break;
        }
        prv = score.at(N-1);
    }
    
    if(infinity_loop){
        cout << "inf" << endl;
        return 0;
    }

    cout << score.at(N-1) << endl;

}

Measured memory_bytes: 3572
A = input()

op = ['+', '-']

for i in range(len(op)):
    for j in range(len(op)):
        for k in range(len(op)):
            if eval(A[0]+op[i]+A[1]+op[j]+A[2]+op[k]+A[3]) == 7:
                print(A[0]+op[i]+A[1]+op[j]+A[2]+op[k]+A[3]+'=7')
                exit()


Measured memory_bytes: 3060
def solve(k, d, fl):
    if k <= 1:
        if d == 0:
            return 10 ** k
        return 0
    x = (-d) % 10
    c = 9 - x + 1 - fl
    d -= 10 ** (k - 1) * x - x
    return c * solve(k - 2, abs(d) // 10, 0)

d = int(input())

ans = 0
for i in range(1, 100):
    ans += solve(i, d, 1)
print(ans)


Measured memory_bytes: 3060
N = int(input())
vals = list(map(int, input().split()))
count = 0
is_odd = False
while True:
    for i in range(0, N):
        if vals[i] % 2 == 1:
            is_odd = True
        vals[i] /= 2
    if is_odd:
        break
    count += 1
print (count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
	int n,a,MAX=-1000000000,MIN;
	cin>>n>>a;
	MIN=a;
	for(int i=1;i<n;i++){
		cin>>a;
		MAX=max(MAX,a-MIN);
		MIN=min(MIN,a);
	}
	cout<<MAX<<endl;
	return 0;
}



Measured memory_bytes: 3096
#include<iostream>
#include<cstring>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;
#define MAX 500000
#define INF 2e9
int L[MAX/2+2],R[MAX/2+2];
long long  cnt=0;
long long merge(int A[],int n,int left,int mid,int right)
{
    long long cnt=0;
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0;i<n1;i++)
    {
        L[i]=A[left+i];
    }
    for(int i=0;i<n2;i++)
    {
        R[i]=A[mid+i];
    }
    L[n1]=INF;
    R[n2]=INF;
    int i=0,j=0;
    for(int k=left;k<right;k++)//合并
    {
     if(L[i]<=R[j])
     A[k]=L[i++];
     else
     {
     A[k]=R[j++];
     cnt=cnt+(n1-i);
}
}
return cnt;
}
long long  mergeSort(int A[],int n,int left,int right)
{
    long long v1,v2,v3;
    if(left+1<right)
    {
        int mid=(left+right)/2;
        v1=mergeSort(A,n,left,mid);
        v2=mergeSort(A,n,mid,right);
        v3=merge(A,n,left,mid,right); 
        return (v1+v2+v3); 
    }
    else
    return 0;
}
int main()
{
int A[MAX],n;
cnt=0;
cin>>n;
for(int i=0;i<n;i++)
cin>>A[i];
cnt=mergeSort(A,n,0,n);
cout<<cnt<<endl;
return 0;
 }


Measured memory_bytes: 4668
# include<iostream>
# include<cstdio>
# include<algorithm>
using namespace std;

int main(void)
{
    std::ios::sync_with_stdio(false);
    int a[200003];
    int b[200003];
    int n;
    while(cin >> n && n!=0)
    {
        int i;
        for(i = 1; i <= n; ++i)
        {
            cin >> a[i];
            b[i] = a[i];
        }
        sort(a+1, a+n+1);
        int mid = (1+n)/2;
        //cout << mid << endl;
        //for(i = 1; i <= n; ++i)
        //cout << a[i] << " ";
        //cout << endl;
        for(i = 1; i <= n; ++i)
        {
            if(b[i] > a[mid])
                cout << a[mid] << endl;
            else if(b[i] < a[mid])
                cout << a[mid+1] << endl;
            else
                cout << a[mid+1] << endl;
        }
    }
    return 0;
}


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

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    int rest_blocks = 0;
    for (int i = 0; i < N; ++i) {
        if (rest_blocks + 1 == a[i]) {
            rest_blocks++;
        }
    }
    int ans = 0;
    if (rest_blocks == 0) ans = -1;
    else ans = N - rest_blocks;
    cout << ans << endl;
}


Measured memory_bytes: 1024