akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ret = 1;
    for (int i = 1; i < n; ++i) {
        if (s[i] != s[i - 1])
            ret++;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int a,b,x;
    cin >> a >> b >> x;
    if(a == 0) cout << (b / x + 1) << '\n';
    else cout << (b / x + 1) - ((a - 1) / x + 1) << '\n';
    return 0;
}


Measured memory_bytes: 256
import numpy as np
import sys

three_cookies = list(map(int, input().split()))

three_div = [i % 2 for i in three_cookies]
if all(three_div) or any(three_div):
    print(0)
    sys.exit()

a_b_c = np.array(three_cookies)
lis = np.array([[0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]])
i = 0

while True:
    i += 1
    a_b_c = np.dot(lis, a_b_c)
    #print(a_b_c)
    for j, item in enumerate(a_b_c):
        if three_cookies == a_b_c.tolist():
            print(-1)
            sys.exit()
        if item % 2 == 1:
            print(i)
            sys.exit()

Measured memory_bytes: 12424
#include<iostream>
using namespace std;
int main()
{
    string s[110],t[110];
  	int n,m;
  	cin >> n;
  	for(int i=0;i<n;i++) cin >> s[i];
	cin >> m;
  	for(int i=0;i<m;i++) cin >> t[i];
  	int ans=0;
  	
  	for(int i=0;i<n;i++){
      int count=0;
      for(int x=0;x<n;x++)
      	if(s[i]==s[x]) count++;
      for(int y=0;y<m;y++)
        if(s[i]==t[y]) count--;
      ans=max(ans,count);
    }
  	cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int p[52] = {};

int root(int x) {return p[x] < 0 ? x : p[x] = root(p[x]);}

void mer(int x, int y) {
    if ((x = root(x)) == (y = root(y))) return;
    if (p[x] > p[y]) swap(x, y);
    p[x] += p[y];
    p[y] = x;
}

int main() {
    int n, m, u[52] = {}, v[52] = {}, z = 0;
    cin >> n >> m;
    fr(m) cin >> u[i] >> v[i];
    fr(m) {
        fr(52) p[i] = -1;
        for (int j = 0; j < m; j++) if (j != i) mer(u[j], v[j]);
        if (p[root(1)] != -n) z++;
    }
    cout << z;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a[202020],ans,l,r,k;
bool check(long long x){
	long long sum=0;
	for(int i=0;i<n;i++){
		if(a[i]==0){
			if(x>=0){
				sum+=n-1;
			}
		}
		else if(a[i]<0){
			long long mx=x/a[i];
			if(mx*a[i]>x){
				mx++;
			}
			int j=lower_bound(a,a+n,mx)-a;
			sum+=n-j;
			if(j<=i){
				sum--;
			}
		}
		else{
			long long mx=x/a[i];
			if(mx*a[i]>x){
				mx--;
			}
			int j=upper_bound(a,a+n,mx)-a-1;
			if(j<0){
				continue;
			}
			sum+=j+1;
			if(j>=i){
				sum--;
			}
		}
	}
	if(sum/2>=k){
		return 1;
	}
	else return 0;
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	l=-1e18-100;
	r=1e18+100;
	while(l<r){
		long long mid=l+(r-l)/2;
		if(check(mid)){
			r=mid;
		}
		else{
			l=mid+1;
		}
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <cxxabi.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    ((ll)1ll<60)
#define INF     ((int)1<<30)
#define EPS     (1e-9)
#define MOD     (1000000007)
template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class T,typename I=typename T::iterator>auto&operator<<(ostream&os,T t){bool b=1;for(auto s:t)os<<(abi::__cxa_demangle(typeid(decltype(*declval<I>())).name(),0,0,0)[2]=='d'||exchange(b,0)?"":" ")<<s;return os<<endl;}

int main(){
	int a,b;
	cin>>a>>b;
	vi v(999);
	iota(all(v),1);
	partial_sum(all(v),v.begin());
	cout<<v[b-a-1]-b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
#define MOD 1000000007
int facnum[1001]={};
void factors(int n){
	for(int i=2;i*i<=n;i++){
		if(n%i==0){
			while(n%i==0){
				n/=i;
				facnum[i]++;
			}
		}
	}
	facnum[n]++;
}
int main(){
	int n;
	cin >> n;
	for(int i=2;i<=n;i++){
		factors(i);
	}
	ll ans=1;
	for(int i=2;i<=n;i++){
		if(facnum[i]!=0)ans*=facnum[i]+1;
		ans%=MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	char c1,c2,c3,c4,c5,c6;
	cin >> c1 >> c2 >> c3;
	cin >> c4 >> c5 >> c6;
	if(c1 == c6 && c2 == c5 && c3 == c4) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <map>
#define LL long long
#define maxn 4005

using namespace std;

char s[maxn],p[maxn];
const int P=1007;
LL val[26],vs[maxn],vp[maxn];
map<LL,bool> mp;

int main()
{
    val[0]=1;
    for (int i=1;i<26;i++) val[i]=val[i-1]*P;

    mp.clear();
    scanf("%s",s);
    scanf("%s",p);
    int ls=strlen(s),lp=strlen(p);
    vs[0]=val[s[0]-'a']; vp[0]=val[p[0]-'a'];
    for (int i=1;i<ls;i++) vs[i]=vs[i-1]+val[s[i]-'a'];
    for (int i=1;i<lp;i++) vp[i]=vp[i-1]+val[p[i]-'a'];

    int ans=0;
    for (int len=1;len<=min(ls,lp);len++)
    {
        mp.clear();
        for (int l=0;l+len<=ls;l++) 
        {
            int r=l+len-1;
            mp[vs[r]-vs[l-1]]=1;
        }

        for (int l=0;l+len<=lp;l++)
        {
            int r=l+len-1;
            if (mp[vp[r]-vp[l-1]]) 
            {
                ans=len; break;
            }
        }
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };



int main() {

	int x, a, b;
	cin >> x >> a >> b;

	if ((b - a) <= 0) {
		cout << "delicious" << endl;
	}
	else if (x >= (b - a)) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll LINF = 6e18;

ll c2, c3, c5, c1;
map<ll, ll> mp;

ll dfs(ll n) {
  if (!mp.count(n)) {
    if (n == 0) {
      mp[n] = 0;
    } else if (n == 1) {
      mp[n] = c1;
    } else if (n == 2) {
      mp[n] = c1 + min(c1, c2);
    } else {
      ll res = LINF;
      if (n <= res / c1) res = min(res, c1 * n);
      res = min(res, dfs(n / 2) + c2 + c1 * (n % 2));
      res = min(res, dfs(n / 3) + c3 + c1 * (n % 3));
      res = min(res, dfs(n / 5) + c5 + c1 * (n % 5));
      res = min(res, dfs(1 + n / 2) + c2 + c1 * (2 - (n % 2)));
      res = min(res, dfs(1 + n / 3) + c3 + c1 * (3 - (n % 3)));
      res = min(res, dfs(1 + n / 5) + c5 + c1 * (5 - (n % 5)));
      mp[n] = res;
    }
  }
  return mp[n];
}

int main(){
  int T;
  cin >> T;
  while (T--) {
    mp = {};
    ll n;
    cin >> n;
    cin >> c2 >> c3 >> c5 >> c1;
    ll ans = dfs(n);
    cout << ans << endl;
  }
}

Measured memory_bytes: 4728
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        PrintWriter pw = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);


    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int r = 0;
    String ans = "No";
    if (a == b)
        r-=-1;
    if (b == c)
        r-=-1;
    if (c == a)
        r-=-1;
    //pw.println(r);
    if (r == 1) {
        ans = "Yes";
    }
    pw.println(ans);

        pw.close();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String file) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}




Measured memory_bytes: 21204
A,B = (int(i) for i in input().split())

import math
#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = [1]
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    factor.append(n)
    return factor

A_ = trial_division(A)
B_ = trial_division(B)
c = list(set(A_))
d = list(set(B_))

count = 0
for i in range(len(c)):
    for j in range(len(d)):
        if c[i] == d[j]:
            count += 1

print(count)


Measured memory_bytes: 3188
import math
a,b,C = [float(s) for s in input().split(' ')]

C = math.radians(C)

h = b * math.sin(C)
S = a * h * 0.5
L = a + b + math.sqrt(a**2 + b**2 - 2*a*b*math.cos(C))

print(S)
print(L)
print(h)

Measured memory_bytes: 7764
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//↑templete
int main() {
	long double a,b,x;
	cin>>a>>b>>x;
	long double maxi=a*a*b;
	cout<<setprecision(20)<<fixed;
	if(a*a*b/2.<=x){
		long double low=0., high=M_PI/2.;
		for(int i=0;i<10000;i++){
			long double theta=(low+high)/2.;
			long double y=a*a*a*tan(theta)/2;
			//cout<<theta*180./M_PI<<" "<<y<<endl;
			if(y>maxi-x)
				high=theta;
			else
				low=theta;
				
		}
		cout<<low*180./M_PI<<endl;
	}
	else{
		long double low=0., high=M_PI/2.;
		for(int i=0;i<10000;i++){
			long double theta=(low+high)/2.;
			long double y=a*b*b*tan(M_PI/2.-theta)/2;
			//cout<<theta*180./M_PI<<" "<<y<<endl;
			if(y<x)
				high=theta;
			else
				low=theta;
				
		}
		cout<<low*180./M_PI<<endl;
	}
	return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

//拡張ユークリッドの互除法
int extgcd(int a, int b, int& x, int& y) {
    int d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

// mod逆元
int mod_inverse(int a, int m) {
    int x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

// 階乗、階乗逆元テーブル
int fact[1100000], fact_inv[1100000];
int mod_fact(int n, int m) {
    fact[0] = fact_inv[0] = 1;
    for (int i = 1; i <= n; i++) {
        fact[i] = fact[i - 1] * i % m;
        fact_inv[i] = mod_inverse(fact[i], m);
    }
}

int n;
int a[110000], idx[110000];
int mod = 1e9 + 7;
signed main() {
    cin >> n;
    n++;
    mod_fact(n, mod);
    for (int i = 1; i <= n; i++)cin >> a[i];
    int x;
    for (int i = 1; i <= n; i++) {
        if (idx[a[i]] != 0)x = i - idx[a[i]] + 1;
        idx[a[i]] = i;
    }
    for (int i = 1; i <= n; i++) {
        int ans = fact[n] * fact_inv[i] % mod * fact_inv[n - i] % mod;
        if (n - x >= i - 1)ans = (ans + mod - fact[n - x] * fact_inv[i - 1] % mod * fact_inv[n - x - (i - 1)] % mod) % mod;
        cout << ans << endl;
    }

}


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

int main() {
  int N,K;
  cin >> N;
  cin >> K;
  vector<int> vec(N);
  for(int i = 0;i < N;i++) {
    cin >> vec.at(i);
  }
  int count = 0;
  for(int j = 0;j < N;j++) {
    if(vec.at(j) > K - vec.at(j)) {
      count = count + (K - vec.at(j)) * 2;
    }
    else {
      count = count + vec.at(j) * 2;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <climits>

using namespace std;


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

	const int MAXN = 1e5 + 1;

	vector<int> answer(MAXN + 1, 0);

	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		answer[a]++;
		if (a != 0) answer[a - 1]++;
		answer[a + 1]++;
	}


	cout << *(max_element(answer.begin(), answer.end())) << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int k;

 
int main(){
 
   
    int a, b;

    cin >> a >> b;
    a = a;
    b= b;

    int res_ = -1;
    rep(i, 20000){
        if(((i * 8 / 100)== a)&&((i / 10)==b)) {
            res_ = i;
            break;
        }
    }

    cout << res_;    


    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
ll n;
cin>>n;
ll ans = 0;
ll cnt = 0,num = 9;
rep(i,keta(n)-1){
    cnt += num;
    num *= 10;
}
//cout<<cnt<<endl;
for(int i = 9;i >= 0;i--){
    ll Q = i*_pow(10,keta(n)-1) + cnt;
    if(Q <= n){
        cout<<i+(keta(n)-1)*9<<endl;
return 0;
    }
}


return 0;
}


Measured memory_bytes: 3588
#N,Wを入力
H,W = map(int, input().split())

trout = []

for i in range(H):
    trout.append(list(input()))

# 配列の比較用の変数
h = H-1
w = W-1

for i in range(H):
    for j in range(W):
        
        c = 0
        # "#"だったらスルー
        if trout[i][j] == "#":
            pass
        
        else:
            # 左上
            if i>=1 and j>=1 and trout[i-1][j-1] == "#":
                c += 1
            # 真上
            if i>=1 and trout[i-1][j] == "#":
                c += 1
            # 右上
            if i>=1 and j<w and trout[i-1][j+1] == "#":
                c += 1
            # 左
            if j>=1 and trout[i][j-1] == "#":
                 c += 1
            # 右
            if j<w and trout[i][j+1] == "#":
                c += 1
            # 左下
            if i<h and j>=1 and trout[i+1][j-1] == "#":
                c += 1
            # 真下
            if i<h and trout[i+1][j] == "#":
                c += 1
            #右下
            if i<h and j<w and trout[i+1][j+1] == "#":
                c += 1
                
            trout[i][j] = str(c)
            
for i in range(H):
    print(''.join(trout[i]))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ABC072D - Derangement
  // 1, 2, 3, …, Nからなる順列p
  // 隣り合う二つの数を選んでスワップする
  // i != pとなる最小回数
  // i==pとなる数を見つけたら、i+1とスワップ
  // 最後のみ、i-1とスワップ（cnt++するだけで実際にはスワップしなくても良い）
  int N;
  cin >> N;
  vector<int> p(N+1);
  for(int i = 1; i <= N; i++){
    cin >> p.at(i);
  }
  int tmp, cnt = 0;
  for(int i =1; i < N; i++){
    if(p.at(i) == i){
      tmp = p.at(i);
      p.at(i) = p.at(i+1);
      p.at(i+1) = tmp;
      cnt++;
    }
  }
  if(p.at(N) == N){
    cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 640
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>

using namespace std;

int main() {

/*
	int H, N;
	cin >> H >> N;

	int count = 0;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		count += tmp;
	}

	if (H <= count) cout << "Yes" << endl;
	else cout << "No" << endl;
*/

	int H, A;
	cin >> H >> A;

	int ans = H / A + (H%A!=0);
	cout << ans << endl;

	return 0;
}



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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20

typedef long long ll;
using namespace std;

int r = 0,x = 0,y = 0,z = 0;
vector<int> q(3); 
int main() {
    while(cin >> q[0] >> q[1] >> q[2]){
    sort(q.begin(),q.end());

    if(q[0]+q[1]<=q[2]){
        cout << r << " " << x  << " " << y << " " << z << endl;
        return 0;
    }
    r++;
    if(q[0]*q[0]+q[1]*q[1]==q[2]*q[2]) x++;
    if(q[0]*q[0]+q[1]*q[1] >q[2]*q[2]) y++;
    if(q[0]*q[0]+q[1]*q[1] <q[2]*q[2]) z++;
    }
    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define endl '\n'
#define modulo 1000000007
//#define int int64_t
#define float double
#define PI acos(-1)
#define sinDegrees(x) sin((x) * PI / 180.0)
#define cosDegrees(x) cos((x) * PI / 180.0)
#define tanDegrees(x) tan((x) * PI / 180.0)
#define atanDegrees(x) atan(x)* 180.0 / PI
using namespace std;
int power(int x,int y,int m)
{
int temp;
if(y == 0)
return 1;
temp = (power(x, y/2,m))%m;
if (y%2 == 0)
return ((temp%m)*temp);
else
return ((x*temp%m)*temp%m)%m;
}
int inv(int x)
{
return (power(x,modulo-2,modulo))%modulo;
}
bool comp(int a,int b)
{
return a<b;
}
///Solution created by:Ahmadsm2005
int answer[200001];bool visited[200002];
int32_t main()
{
//freopen("output.txt","w", stdout);
//freopen("rect.in","r", stdin);
iostream::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,m,a,b;
cin>>n>>m;
vector<vector<int>>edges(n);
for(int i=0;i<m;i++){
cin>>a>>b;
edges[a-1].push_back(b-1),edges[b-1].push_back(a-1);
}
for(int i=0;i<n;i++)
answer[i]=-1;
queue<pair<int,int>>lol;
lol.push({0,-1});
while(lol.size()){
int top=(lol.front().first),top2=(lol.front().second);
lol.pop();
if(visited[top])
continue;
visited[top]=1;
answer[top]=top2;
for(int i=0;i<edges[top].size();i++){
if(!visited[edges[top][i]]){
lol.push({edges[top][i],top});
}
}
}
cout<<"Yes"<<endl;
for(int i=1;i<n;i++)
cout<<answer[i]+1<<endl;
return 0;
}


Measured memory_bytes: 10824
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define INFTY 10000

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

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

  ll ans1 = 0, ans2 = 0;
  for(int i = 1; i <= n+1; i++){
    ans1 += abs(a[i] - a[i-1]);
  }
  ans2 = ans1;

  for(int i = 1; i <= n; i++){
    ans1 = ans2;
    ans1 = ans1 - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) + abs(a[i+1]-a[i-1]);
    cout << ans1 << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
char s[52][52];
int pos[52];
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        sort(s[i], s[i] + strlen(s[i]));
    }
    vector<char> hoge;
    for (char c = 97; c <= 122; c++) {
        int minCount = 114514;
        for (int i = 0; i < n; i++) {
            int count = 0;
            while (true) {
                if (s[i][pos[i]] == c) {
                    count++;
                    pos[i]++;
                } else {
                    break;
                }
            }
            minCount = min(minCount, count);
        }
        for (int i = 0; i < minCount; i++) {
            hoge.push_back(c);
        }
    }
    string str(hoge.begin(), hoge.end());
    cout << str << endl;
}


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

int main()
{
    char s[6];
    scanf("%s",s);
    
    if (strncmp(&s[2],&s[3],1) == 0 && strncmp(&s[4],&s[5],1) == 0) {
    printf("Yes\n");
    }
    else {
    printf("No\n");
    }
    
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e18
#define mod 1000000007

struct edge{
  ll f,t,c;
};

ll n,m,s,t;
ll d1[101010],cnt1[101010];
ll d2[101010],cnt2[101010];
vector<P> g[101010];
vector<edge> es;
bool used[101010];

int main(){
  cin>>n>>m>>s>>t;
  s--; t--;
	rep(i,m){
    ll a,b,c;
    cin>>a>>b>>c;
    a--; b--;
    g[a].push_back(P(b,c));
    g[b].push_back(P(a,c));
    es.push_back((edge){a,b,c});
  }
  {
    rep(i,n)d1[i]=INF;
    priority_queue<P,vector<P>,greater<P> > que;
    que.push(P(0,s));
    d1[s]=0;
    cnt1[s]=1;
    while(que.size()){
      ll nd=que.top().fi,v=que.top().se; que.pop();
      if(d1[v]<nd)continue;
      for(P e : g[v]){
        ll u=e.fi,c=e.se;
        if(d1[u]==nd+c){
          (cnt1[u]+=cnt1[v])%=mod;
        }else if(d1[u]>nd+c){
          d1[u]=nd+c;
          cnt1[u]=cnt1[v];
          que.push(P(nd+c,u));
        }
      }
    }
  }
  {
    rep(i,n)d2[i]=INF;
    priority_queue<P,vector<P>,greater<P> > que;
    que.push(P(0,t));
    d2[t]=0;
    cnt2[t]=1;
    while(que.size()){
      ll nd=que.top().fi,v=que.top().se; que.pop();
      if(d2[v]<nd)continue;
      for(P e : g[v]){
        ll u=e.fi,c=e.se;
        if(d2[u]==nd+c){
          (cnt2[u]+=cnt2[v])%=mod;
        }else if(d2[u]>nd+c){
          d2[u]=nd+c;
          cnt2[u]=cnt2[v];
          que.push(P(nd+c,u));
        }
      }
    }
  }
  ll tot=d1[t];
  ll res=cnt1[t]*cnt2[s]%mod;
  rep(i,n){
    if(d1[i]*2==tot){
      ll cnt=(cnt1[i]*cnt2[i])%mod;
      res=(res-((cnt*cnt)%mod)+mod)%mod;
      //dbg(i);
    }
  }
  rep(i,es.size()){
    ll u=es[i].f,v=es[i].t,c=es[i].c;
    if(d1[u]>d1[v])swap(u,v); // d1[u] < d1[v];
    if(d1[u]*2<tot&&tot<d1[v]*2&&d1[u]+d2[v]+c==tot){
      ll cnt=(cnt1[u]*cnt2[v])%mod;
      res=(res-((cnt*cnt)%mod)+mod)%mod;
      //dbg(u); dbg(v);
      //dbg(d1[u]); dbg(d1[v]); dbg(c);
      //dbg(res);
    }
  }
  cout<<res<<endl;
	return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXN = 110;

int stu[MAXN][MAXN];
bool l[MAXN][MAXN];
bool r[MAXN][MAXN];

int main()
{
    int n;
    while(cin >> n && n)
    {
        memset(l, 0, sizeof(l));
        memset(r, 0, sizeof(r));

        rep(j,n)rep(i,n)cin >> stu[i][j];

        rep(i,n)
        {
            int s = stu[i][0];
            rep(j,n)if(s < stu[i][j]) s = stu[i][j];

            rep(j,n)if(stu[i][j] == s) r[i][j] = true;
        }

        rep(j,n)
        {
            int h = stu[0][j];
            rep(i,n)if(h > stu[i][j]) h = stu[i][j];

            rep(i,n)if(stu[i][j] == h) l[i][j] = true;
        }

        int ans = 0;

        rep(i,n)rep(j,n)if(l[i][j] && r[i][j]) ans = stu[i][j];
        cout << ans << endl;

    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <vector>
#include <string.h>

using namespace std;

int main(){

  string s;
  cin>>s;

  char ani[25] = {'a','b','c','d','e','f','g','h','i','j',
                  'k','l','m','n','o','p','q','s','t','u',
                  'v','w','x','y','z'
   };

   sort(s.begin(),s.end());

   string das = "abcdefghijklmnopqrstuvwxyz";

   if(das == s){
    cout<<"None"<<endl;
  return 0;
   }

     for(int j=0;j<=24;j++)
     {
        int flag = 0;
     char news  = '1';
      for(int i=0;i<s.length();i++)
      {
        if(s[i] == ani[j]){
            flag = 1;
          break; }
          news = ani[j];
       }
        if(flag == 0 && news!= '1'){
        cout<<news<<endl;
        return 0; }

     }

     cout<<"None"<<endl;

return 0;
}


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

int main() {
    int a, b;
    while (cin >> a >> b) {
        if (a > b) swap(a, b);
        int A = a, B = b;
        while ((a % A != 0) || (b % A != 0)) {
            --A;
        }
        while ((B % a != 0) || (B % b != 0)) {
            B += A;
        }
        cout << A << ' ' << B << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3052
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	LL N, A, B;
	cin >> N >> A >> B;

	LL C = A + B;

	cout << N / C * A + min(N % C, A) << endl;


	return 0;
}


Measured memory_bytes: 888
package main

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

type Bridge struct {
	a int
	b int
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	nIslands := scanInt(sc)
	nBridges := scanInt(sc)

	bridges := make([]Bridge, nBridges)

	for i := 0; i < nBridges; i++ {
		a, b := scanInt(sc), scanInt(sc)
		bridges[i] = Bridge{a, b}
	}

	islands := make([]int, nIslands+1)
	ranks := make([]int, nIslands+1)
	members := make([]int64, nIslands+1)
	for i := 1; i <= nIslands; i++ {
		islands[i] = i
		members[i] = 1
	}

	connectedPairs := make([]int64, nBridges+1)

	for i := nBridges - 1; i >= 0; i-- {
		bridge := bridges[i]

		ra := findRoot(islands, bridge.a)
		rb := findRoot(islands, bridge.b)
		if ra == rb {
			connectedPairs[i] = connectedPairs[i+1]
			continue
		}

		var main, sub int
		if ranks[ra] > ranks[rb] {
			main = ra
			sub = rb
		} else {
			main = rb
			sub = ra
		}

		islands[sub] = main
		if ranks[main] == ranks[sub] {
			ranks[main] += 1
		}

		nPrevPairs := countPairs(members[main]) + countPairs(members[sub])
		members[main] += members[sub]
		newConnectedPairs := countPairs(members[main]) - nPrevPairs
		connectedPairs[i] = connectedPairs[i+1] + newConnectedPairs
	}

	maxPairs := connectedPairs[0]
	w := bufio.NewWriter(os.Stdout)
	for i := 1; i <= nBridges; i++ {
		fmt.Fprintln(w, maxPairs-connectedPairs[i])
	}
	w.Flush()
}

func findRoot(islands []int, x int) int {
	if islands[x] == x {
		return x
	}
	root := findRoot(islands, islands[x])
	islands[x] = root
	return root
}

func countPairs(nIslands int64) int64 {
	return nIslands * (nIslands - 1) / 2
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


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

int main() {
    int N, M;
    std::cin >> N >> M;
    
    std::vector<int> v(N);
    int a, b;
    for (int i = 0; i < M; ++i) {
        std::cin >> a >> b;
        ++v[a - 1];
        ++v[b - 1];
    }

    for (auto x : v) {
        std::cout << x << std::endl;
    }
}


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

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, s, e) for (ll i = s; i < e; i++)
#define pb push_back
#define ll long long
#define mp make_pair
int main()
{
    ll a, b;
    cin >> a >> b;
    cout << a * b << endl;
    // your code goes here
    return 0;
}

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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair <int, int> pii;
typedef long double ld;
typedef vector <ll> vi;

const int N = 2e6 + 1;
const ll INF = 1e18 + 9;
const int B = 1e9 + 7;

int n, c, k;
int a[N];

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> c >> k;
    forn(i, 1, n)
        cin >> a[i];
    sort(a + 1, a + 1 + n);
    int ans = 0;
    forn(i, 1, n) {
        ++ans;
        int j = i;
        while (j <= i + c - 1 && j <= n && a[j] <= a[i] + k) ++j;
        i = j - 1;
    }
    cout << ans << "\n";

    return 0;
}


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

int main()
{
int n,k;
cin>>n>>k;
int arr[n];
for(int i=0;i<n;i++)
{
    cin>>arr[i];
}
vector<int>dp(k+1);

    for(int j=1;j<=k;j++)
    {  
        for(int i=1;i<=n;i++)
        {
        if((j-arr[i-1])>=0)
        {
        dp[j]=dp[j]||(!dp[j-arr[i-1]]);
        }
        }
        
    }

cout<<((dp[k])? "First":"Second")<<"\n";
}

Measured memory_bytes: 768
var
  s: string;
  t: string;
  i: integer;
begin
  readln(s);
  readln(t);
  for i := 0 to Length(s) do begin
    if s = t then begin
      writeln('Yes');
      Exit;
    end;
    s := copy(s, 2, Length(s) - 1) + s[1];
  end;
  writeln('No');
end.

Measured memory_bytes: 256
program trained;
uses math;
var
  n, i, k: integer;
  a: array [1..100000] of integer;
begin
  read(n);
  for i := 1 to n do
    read(a[i]);
  i := 1;
  for k := 1 to n do
  begin
    i := a[i];
    if i = 2 then
    begin
      writeln(k);
      halt(0);
    end;
  end;
  writeln(-1);
end.

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std; 

#define NOT_FOUND -1
#define rep(i,n) for(int i=0;i<(int)(n); i++)
/*for文のマクロ定義
rep(i,回数){
    処理
}
*/

void swap(int *a, int *b){
	*b=*a-*b;
	*a-=*b;
	*b+=*a;
}

int sosu_judge(int N){
	/*素数ならば1
	  素数でなければ0を返す
	*/
	int i,j;

	if(N==2)   return 1;
	if(N%2==0) return 0;

	for(i=3;i<N && N%i!=0;i+=2);

	if(i>=N) return 1;
	
	return 0;
}

int factorial(int N){  //Nの階乗を求める関数
	int ans=1;

	while(N--) ans*=(N+1);
	return ans;
}

//クイックソートをする関数
void q_sort(int a[], int first, int last){
    int i,j;
    int x,t;

    x = a[(first + last) / 2];
    i = first; j=last;

    while(1){
        while( a[i] < x) i++;
        while( x < a[j]) j--;
        
        if( i >= j) break;
        
        swap(&a[i],&a[j]);
        i++; j--;
    }
    if(first < i-1) q_sort(a, first,i-1 );
    if(last > j+1)  q_sort(a, j+1,  last);
}

int b_search(int target, int array[],int right, int left){
    /*二分探索を行う関数である。
      戻り値は探索したい値の格納されている位置である。
      もし値が存在しない場合、NOT_FOUND(-1)を返す
    */
    int mid;
    while(left<right){
        mid=(right+left)/2;
        if(array[mid]<target) left =mid+1;
        else                  right=mid;
    }
    if(array[mid]==target) return mid;
    return NOT_FOUND;
}

unsigned long combination(int n, int r){
    /*nCrの値を求める関数である。
      値が巨大になる可能性があるため、戻り地はunsigned longである
    */
    int i,j;
    unsigned long a[17];

    if(n-r<r) r=n-r;
    if(r==0 ) return 1;
    if(r==1 ) return n;
    if(r>17 ) return 0;
    for(i=1;i<r;i++) a[i]=i+2;
    for(i=3;i<=n-r+1;i++){
        a[0]=i;
        for(j=1;j<r;j++)a[j]+=a[j-1];
    }
    return a[r-1];
}
   
int main(){
    int N;
    cin>>N;
    vector<int> A(N);

    rep(i,N) cin>>A[i];

    vector<int> ans(N);
    rep(i,N) ans[A[i]-1]=i+1;
    rep(i,N) cout<<ans[i]<<" ";
    cout<<endl;
    return 0;
}



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

int main(){
long long int N,K,minimum=15000000000;
cin >>N>>K; long long int M[N];
for(long long int i=0;i<N;i++){
cin >> M[i];
}
sort(M,M+N);
   for(long long int i=0;i<N-K+1;i++){
      minimum=min(M[i+K-1]-M[i],minimum);
   }
   cout << minimum;
 }



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

int main(){
	int x[10],y;
	for(int i = 0 ; i < 10 ; i++){
		cin >> x[i];
	}
	for(int i = 0 ; i < 10 ; i++){
		for(int l = i + 1 ; l < 10 ; l++){
			if(x[i]<x[l]){
				y=x[i];
				x[i]=x[l];
				x[l]=y;
			}
		}
	}
	for(int i = 0 ; i <= 2 ; i++){
		cout<<x[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3120
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

#define int long

const int INF = 1000000009;
const long LINF = 1123456789012345678;

const int MOD = 1000000007;
int h, w, k;
int ans = 0;

int dp[105][10];
int pos[10];//枝の配置が隙間の数iで何通ありえますか = pos[i]

signed main(){
	scanf("%ld %ld %ld", &h, &w, &k);
	dp[0][1] = 1;
	pos[0] = pos[1] = 1;
	for(int i = 2; i < 10; i++){
		pos[i] = pos[i-1] + pos[i-2];
	}
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			//powerのとこがposでうまいこと置き換えられます
			dp[i][j] = dp[i-1][j] * pos[std::max(0l, j-1)] * pos[std::max(0l, w-j)];
			dp[i][j] %= MOD;
			if(j > 1){
				dp[i][j] += dp[i-1][j-1] * pos[std::max(0l, j-2)] * pos[std::max(0l, w-j)];
				dp[i][j] %= MOD;
			}
			if(j < w){
				dp[i][j] += dp[i-1][j+1] * pos[std::max(0l, j-1)] * pos[std::max(0l, w-j-1)];
				dp[i][j] %= MOD;
			}
		}
	}
	/*
	for(int i = 1; i <= w; i++){
		printf("%9ld ", i);
	}
	printf("\n");
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			printf("%9ld ", dp[i][j]);
		}
		printf("\n");
	}
	//*/
	printf("%ld\n", dp[h][k]);
	return 0;
}


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

const int N = 1e5 + 10;
int n, k, m;
int dp[N], h[N];

int main(){
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> h[i];
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < k; i++){
		m = 1e9;
	    for (int j = i - 1; j >= 0; j--){
	    	m = min(m , dp[j] + abs(h[i] - h[j]));
	    }
	    dp[i] = m;
	}
	for (int i = k; i < n; i++){
		m = 1e9;
		for (int j = i - 1; j >= i - k; j--){
			m = min(m , dp[j] + abs(h[i] - h[j]));
		}
		dp[i] = m;
	}
//	for (int i = 0; i < n; i++)
//		cout << dp[i] << ' ';
    cout << dp[n - 1];
}


Measured memory_bytes: 1024
import java.util.Scanner;


//Intersection of Rectangles
public class Main{

	public static final double EPS = 1e-8;

	public static class P implements Comparable<P>{
		public double x;
		public double y;
		public P(double x, double y) {
			this.x = x;
			this.y = y;
		}
		public int compareTo(P o) {
			if(equals(o))return 0;
			if(Math.abs(x-o.x)<EPS){
				return y-o.y<0?1:y-o.y>0?-1:0;
			}
			return x-o.x<0?1:x-o.x>0?-1:0;
		}
		public boolean equals(P o){
			return Math.abs(x-o.x)<EPS && Math.abs(y-o.y)<EPS;
		}
		@Override
		public String toString() {
			return "("+x+","+y+")";
		}
	}

	public static class Vec{
		public P s;
		public P t;
		public double dx;
		public double dy;
		public Vec(P t){
			this.s = new P(0, 0);
			this.t = t;
			dx = t.x-s.x;
			dy = t.y-s.y;
		}
		public Vec(P s, P t) {
			this.s = s;
			this.t = t;
			dx = t.x-s.x;
			dy = t.y-s.y;
		}
		public Vec reverse(){
			return new Vec(t, s);
		}
		public double norm(){
			return Math.sqrt(dx*dx+dy*dy);
		}
		public double dotProduct(Vec o){
			return dx*o.dx + dy*o.dy;
		}
		public double crossProduct(Vec o){
			return dx*o.dy - dy*o.dx;
		}
		public boolean isOrthogonal(Vec o){
			return dotProduct(o)==0;
		}
		public boolean isParallel(Vec o){
			return crossProduct(o)==0;
		}
		public int ccw_(P p){
			return ccw(s, t, p);
		}
		public boolean isCross(Vec o){
			return ccw_(o.s)*ccw_(o.t) < EPS && o.ccw_(s)*o.ccw_(t) < EPS ||
			ccw_(o.s)*ccw_(o.t) < EPS && o.ccw_(s)*o.ccw_(t) < EPS;
		}
		public double distanceFromPoint(P p){
			Vec o = new Vec(s, p);
			return Math.abs(crossProduct(o))/norm();
		}
		@Override
		public String toString() {
			return s+"->"+t;
		}
	}

	public static int ccw(P p1, P p2, P p3){
		Vec a = new Vec(p1, p2);
		Vec b = new Vec(p1, p3);
		if(a.crossProduct(b)<0)return 1;
		if(a.crossProduct(b)>0)return -1;
		//if program run here, three points on line because AxB = 0 shows parallel
		if(a.dotProduct(b)<0)return 2;
		if(a.norm() < b.norm())return -2;
		return 0;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			P[] p = new P[4];
			for(int i=0;i<4;i++)p[i]=new P(sc.nextDouble(),sc.nextDouble());
			Vec[] v1 = new Vec[4];
			P p1 = new P(p[1].x, p[0].y);
			P p2 = new P(p[0].x, p[1].y);
			v1[0] = new Vec(p[0], p1);
			v1[1] = new Vec(p1, p[1]);
			v1[2] = new Vec(p[1], p2);
			v1[3] = new Vec(p2, p[0]);
			Vec[] v2 = new Vec[4];
			p1 = new P(p[3].x, p[2].y);
			p2 = new P(p[2].x, p[3].y);
			v2[0] = new Vec(p[2], p1);
			v2[1] = new Vec(p1, p[3]);
			v2[2] = new Vec(p[3], p2);
			v2[3] = new Vec(p2, p[2]);
			boolean f = false;
			boolean left1 = true;
			boolean left2 = true;
			for(int i=0;i<4;i++){
				for(int j=0;j<4;j++){
					if(v1[i].isCross(v2[j]))f = true;
					if(v1[i].ccw_(v2[j].s)!=-1||v1[i].ccw_(v2[j].t)!=-1)left1 = false;
					if(v2[j].ccw_(v1[i].s)!=-1||v2[j].ccw_(v1[i].t)!=-1)left2 = false;
				}
			}
			System.out.println(f||left1||left2?"YES":"NO");
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{
    int n;
    cin >> n;
    map<char, ll> mp;
    
    mp['M'] = 0;
    mp['A'] = 0;
    mp['R'] = 0;
    mp['C'] = 0;
    mp['H'] = 0;   

    for (int i=0; i<n; ++i)
    {
        string str;
        cin >> str;
        mp[str[0]] += 1;
    }

    ll ans = 0;
    string key = "MARCH";
    for (int i=0; i<key.size(); ++i)
    {
        for (int j=i+1; j<key.size(); ++j)
        {
            for (int k=j+1; k<key.size(); ++k)
            {
                ans += mp[key[i]]*mp[key[j]]*mp[key[k]];
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string S;
int vis;
int main(){
	cin >> S;
	for(int i = 0; i < S.length(); i++){
		int n = S[i] - 'a';
		vis |= (1 << n);
	}
	int nn = 25;
	bool f = false;
	for(int i = 0; i < 26; i++){
		if(S[i] - 'a' != nn--){
			f = true;
			break;
		}
	}
	if(!f){
		puts("-1");
		return 0;
	}
	if(vis == (1 << 26) - 1){
		string ns = S;
		next_permutation(ns.begin(), ns.end());
		for(int i = 0; i < S.length(); i++){
			if(S[i] == ns[i])	cout << S[i];
			else{
				cout << ns[i] << endl;
				break;
			}
		}
	}
	else{
		int ls = 0;
		for(int i = 0; i < 26; i++)
			if(!(vis & (1 << i))){
				ls = i;
				break;
			}
		cout << S << (char)(ls + 'a') << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const double pi = 3.14159265358979323846;
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    speed;
    ll a,b,c;
    char d;
  
    cin>>a>>b;
    cin>>d>>c;
  
    b=100*b+c;
    cout<<(a*b)/100;
    
    return 0;
}

Measured memory_bytes: 3608
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;
template<typename T> using VP = vector<pair<T, T>>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

signed main()
{
    int n, k;
    cin >> n >> k;
    V<int> p(n);
    RBF(pi, p) cin >> pi;
    upsort(p);
    int ans = 0;
    REP(i, k) {
        ans += p[i];
    }
    col(ans);
    return 0;
}


Measured memory_bytes: 3620
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""
from heapq import*
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
for k in range(N):
    for i in range(N):
        for j in range(N):
            if A[i][j]>A[i][k]+A[k][j]:
                print(-1)
                exit()
res = 0
for i in range(N-1):
    for j in range(i+1, N):
        for k in range(N):
            if k==i or k == j:
                continue
            if A[i][j]==A[i][k]+A[k][j]:
                break
        else:
            res += A[i][j]
print(res)


Measured memory_bytes: 45788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
const int mod = 1000000007;

int fib(int j){
  if (j==0){return 1;}
  else if (j==1){return 1;}
  else{
    return (fib(j-1)+fib(j-2))%mod;
  }
}

int fib_inv(int j, int W){
  if (j==W){return 1;}
  else if(j==W-1){return 1;}
  else{
    return (fib_inv(j+1, W)+fib_inv(j+2, W))%mod;
  }
}


int main(){
  int H, W, K;cin>>H>>W>>K;
  vvl dp(H+1, vl (W,0));dp[0][0]=1;

  for (int i=0;i<H;++i){
    for (int j=0;j<W;++j){
      dp[i+1][j]=dp[i][j]*fib(j)*fib_inv(j+1, W);
      dp[i+1][j]%=mod;
      if (j!=0){
        dp[i+1][j]+=dp[i][j-1]*fib(j-1)*fib_inv(j+1,W);
        dp[i+1][j]%=mod;
      }
      if(j!=W-1){
        dp[i+1][j]+=dp[i][j+1]*fib(j)*fib_inv(j+2,W);
        dp[i+1][j]%=mod;
      }
    }
  }
  cout << dp[H][K-1]<< endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;

int rev(int x){
  char str[10],tmp[10];
  sprintf(str,"%d",x);
  REP(i,strlen(str)){
    tmp[strlen(str)-1-i] = str[i];
  }
  return atoi(tmp);
}

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int A,B,res=0;
  cin >> A >> B;
  for(int i = A;i<=B;i++){
    if(rev(i) == i)
      res++;
  }
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N, M;
  cin >> N >> M;
  
  int a, b;
  vector<vector<int>> vec(M, vector<int>(2));
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    vec.at(i).at(0) = a;
    vec.at(i).at(1) = b;
  }
  
  vector<int> v(M*2);
  for(int i = 0; i < M*2; i++){
    if(i%2 == 0){
      v.at(i) = vec.at(i/2).at(0);
    } else {
      v.at(i) = vec.at(i/2).at(1);    
    }
  }
  
  for(int i = 1; i <= N; i++){
    cout << count(v.begin(), v.end(), i) << "\n";  
  }
  
  
  return 0;
}

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

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

  ll a, b, k;
  cin >> a >> b >> k;

  if (k <= a) cout << a - k << " " << b << '\n';
  else if (k <= a + b) cout << 0 << " " << b - (k - a) << '\n';
  else cout << 0 << " " << 0 << '\n';

  return (0);
}

Measured memory_bytes: 3632