akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int h,w,n,k;
  cin>>h>>w>>n>>k;
  auto ask=
    [&](Int y,Int x){
      cout<<"? "<<y<<" "<<x<<" "<<y<<" "<<x<<endl;
      Int p;
      cin>>p;
      for(Int i=0;i<(y*w+x);i++) p=p*2%k;
      return p;
    };
  Int ans=0;
  for(Int i=0;i<h;i++)
    for(Int j=0;j<w;j++)
      ans+=ask(i,j);
  ans%=k;
  cout<<"! "<<ans<<endl;
  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C ++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()

//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD (int)(1e9+7)
#define INF 0x3f3f3f3f
#define MAXN (int)(1e5+1)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
//DEBUG
#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }

int main()
{
	fastio;
	ll n;cin>>n;
	vector<vll >a(n+1,vll(n+1));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>a[i][j];
		}
	}
	vector<vll >dp(n+1,vll(1<<n,0));
	dp[0][0]=1;
	ll lim=1ll<<n;
	for(int i=1;i<=n;i++){
		for(ll mask=0;mask<lim;mask++){
			
			if(dp[i-1][mask]==0)continue;
			for(int j=1;j<=n;j++){
				if(a[i][j] && !(mask>>(j-1)&1)){
					ll x=1ll<<(j-1);
					dp[i][mask^(x)]=addmod(dp[i][mask^(x)],dp[i-1][mask]);
				}
			}
		}
	} 
	cout<<dp[n][lim-1]<<endl;
}


Measured memory_bytes: 377216
/*
* Author : MaxSally
*/
/********   All Required Header Files ********/
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (ll i = j ; i <= k ; ++i)
#define rrep(i, j, k) for (int i = j; i >= k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

const int N = 0;
ll cnt = 0, n;
set<ll> s;

void solve(ll i){
    ll m = n;
    s.insert(i);
    if(i == 1) return;
    while(m > 1 && m % i == 0){
        m /= i;
    }
    if(m % i == 1){
        cnt++;
    }
}

int main(){
    io;
    //freopen("input.txt","r",stdin);
    cin >> n;

    for(ll i = 1; i * i <= n; i++){
        if(n % i != 0){
            continue;
        }
        solve(i);
        if(i * i != n){
            solve(n/i);
        }
    }
    for(ll i = 1; i * i <= n - 1; i++){
        if((n - 1) % i == 0){
            if(i * i != (n - 1)){
                if(s.find((n - 1)/i) == s.end()){
                    cnt++;
                }
            }
            if(s.find(i) == s.end()){
                cnt++;
            }
        }
    }
    cout << cnt;
    return 0;
}


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

int main()
{
    ll x, sum = 0, ans = 0;
    cin >> x;
    sum += x / 11;

    if (x % 11 != 0)
    {
        if (x % 11 >= 7)
        {
            ans = sum * 2 + 2;
        } else {
            ans = sum * 2 + 1;
        }
    } else {
        ans = sum * 2;
    }

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 10000
int parent(int i)
{
    return i / 2;
}
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }

int main()
{
    int H, i, A[MAX];

    cin >> H;
    for (i = 1; i <= H; i++)
        cin >> A[i];

    for (i = 1; i <= H; i++)
    {
        cout << "node " << i << ": key = " << A[i] << ", ";
        if (parent(i) >= 1)
            cout << "parent key = " << A[parent(i)] << ", ";
        if (left(i) <= H)
            cout << "left key = " << A[left(i)] << ", ";
        if (right(i) <= H)
            cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cassert>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
double ans,d[500],x[500],cx;
int n;
int main() {
  cin >> n;
  ans = 0;
  rep(i,n){
    cin >> d[i];
    x[i] = d[i];
    rep(j,i){
      cx = x[j]+sqrt((d[i]+d[j])*(d[i]+d[j])-(d[i]-d[j])*(d[i]-d[j]));
      if(x[i]<cx) x[i] = cx;
    }
    if(ans < x[i]+d[i]) ans = x[i]+d[i];
  }
  printf("%.8lf\n",ans);
  return 0;
}

Measured memory_bytes: 3208
from itertools import zip_longest

S = input()
T = input()

N = len(S)
Tn = len(T)

ans = []
for i in range(N-Tn+1):
    K = S[i:i+Tn]

    for k, t in zip_longest(K, T, fillvalue=""):
        if (k != "?") and (k != t):
            break
    else:
        tmp = S[:i] + T + S[i+Tn:]
        ans.append(tmp.replace("?", "a"))

ans.sort()
if ans:
    print(ans[0])
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;

int main() {
  int n; cin >> n;
  vector<int> a(n); for (int& x : a) cin >> x;
  int ans = 0;
  for (int i = 1; i < n; i++)
    for (int j = 0; j < i; j++)
      ans += a[i] * a[j];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    static public void main(String[] av) {
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int s = a*b;
	int l = a*2+b*2;

	System.out.println(s+" "+l);
    }
}



Measured memory_bytes: 26144
n = int(input())
x = [list(map(int, input().split())) for i in range(n)]

y = [[0 for j in i] for i in x]


for i in range(len(x)):
    if i - 1 < 0:
        y[i] = [k for k in x[i]]    
        continue

    for j in range(len(x[i])):
        x_1 = max([y[i - 1][k] for k in range(len(x[i - 1])) if k != j])
        y[i][j] = x[i][j] + x_1

print(max(y[n - 1]))

Measured memory_bytes: 47384
from sys import stdin
import math

def main():

    input = stdin.readline

    a,b,c = map(int,input().split())

    sqrt = c - (a + b)

    if sqrt <= 0:
        print("No")
    elif sqrt ** 2 > 4 * a * b:
        print("Yes")
    else:
        print("No")
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

void solve(int tc)
{
	ll m, k;
	cin >> m >> k;
	ll lim = (1ll << m);
	if (k >= lim)
	{
		cout << -1 << ln;
		return;
	}
	if (m == 0)
		cout << "0 0" << ln;
	else if (m == 1)
	{
		if (k == 0)
			cout << "0 0 1 1" << ln;
		else
			cout << -1 << ln;
	}
	else
	{
		if (k == 0)
		{
			for (int i = 0; i < (1ll << m); i++)
				cout << i << ' ' << i << ' ';
			cout << ln;
			return;
		}
		s64 elt;
		for (ll i = 0; i < (1ll << m); i++)
			elt.insert(i);
		v64 ans;
		//each time build two segments of length four
		while (sz(elt))
		{
			ll e = *elt.begin();
			elt.erase(e);
			ll e_ = k ^ e;
			elt.erase(e_);
			ll z = *elt.begin();
			elt.erase(z);
			ans.push_back(z);
			ans.push_back(e);
			ans.push_back(e_);
			ans.push_back(z);
			ll z_ = z ^ k;
			elt.erase(z_);
			ans.push_back(z_);
			ans.push_back(e_);
			ans.push_back(e);
			ans.push_back(z_);
		}
		for (ll x : ans)
			cout << x << ' ';
		cout << ln;
	}
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 10108
/*
*
* author: ian macleod
*
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef vector<long long int> vll;

#define IO                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
 
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b) for(ll i=a;i>=b;i--)

ll power(ll x, ll y) {
    ll res = 1;     // Initialize result
    x = x ;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0) {
        if (y & 1)
            res = (res*x);
        y = y>>1; // y = y/2
        x = (x*x);  // Change x to x^2
    }
    return res;
}


void solve() {
    
    ll k;
    cin >> k;
    string s;
    cin >> s;
    if (s.length() > k) {
        cout << s.substr(0,k) << "..." << endl;
    }
    else {
        cout << s << endl;
    }
    return ;
}



int main() {
    solve();
}



Measured memory_bytes: 3488
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
    string X;
    cin >> X;

    int output = 0;
    int t = 0;
    int s = 0;
    for (int i = 0; i < X.size(); i++) {
        if (X[i] == 'S') s++;
        if (X[i] == 'T') {
            if (s == 0)
                output++;
            else
                s--;
        }
    }

    cout << output + s << endl;

    return 0;
}


Measured memory_bytes: 3728
import java.util.*

fun main(args:Array<String>){
    val (a,b,c,d) = readLine()!!.split(" ").map{it.toLong()}
    val k = b / c + b / d - b / lcm(c,d) - ((a - 1) / c + (a - 1) / d - (a - 1) / lcm(c,d))
    println(b - a + 1 - k)
}

fun gcd(a : Long, b : Long) : Long{
    if(a % b == 0L) return b
    return gcd(b, a % b)
}

fun lcm(a : Long, b : Long) : Long{
    return a / gcd(a, b) * b
}

Measured memory_bytes: 37904
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	int sum = 0, ab = INF, x = INF;
	for (int i = 0; i < N; i++) {
		int n = L + i;
		sum += n;
		int m = abs(n);
		if (m < ab) {
			ab = m;
			x = n;
		}
	}

	cout << sum - x << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<math.h>
#include<iomanip>
int main(){
	double r;
	std::cin>>r;
	double s = M_PI*r*r;
	double l = M_PI*2.0*r;
	std::cout.setf(std::ios::showpoint);
	std::cout<<std::fixed<<std::setprecision(6)<<s<<' '<<l<<std::endl;
}

Measured memory_bytes: 1284
//
// Created by Myabu on 2020/01/01.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;


int main(void){
    int N, X;
    cin>>N>>X;

    int L[110];
    for (int i = 0; i < N; ++i) {
        cin>>L[i];
    }

    int D = 0;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if(D<=X){
            ans++;
        }
        D += L[i];
    }

    if(D<=X){
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
f::(Int,Int)->Int
f (x,y)=x*y

f2::String->[Int]->Int
f2 xs ys=let zs=zip (map read (words xs)::[Int]) ys
         in sum (map f zs)

main = do
       e1<-getLine
       e2<-getLine
       es<-getContents
       let xs=lines es
           ys=map read (words e2)::[Int]
           (_:_:c:[])=map read (words e1)::[Int]
       print $ length [1|e<-xs,(f2 e ys)+c>0]

Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
 
int main() {
	char a,b;
	cin >> a >> b;
	 if (a == 'H') {cout << b << endl;}
	 else {
		if(b == 'H')cout << 'D' << endl;
		else cout << 'H' << endl;
	}
}


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

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

Measured memory_bytes: 3640
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  int times[101];
  int times_sum=0;
  for(int i=1;i<=n;i++)cin>>times[i];
  for(int i=1;i<=n;i++){
    times_sum+=times[i];
  }
  int m;cin>>m;
  for(int i=1;i<=m;i++){
    int p,x;cin>>p>>x;
    P(times_sum-times[p]+x);
  }
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#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 eb emplace_back
#define pb push_back
#define lb(v,k) lower_bound(all(v),k)-v.begin()
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
ll inf=100100100100;
const int mod=1000000007;
int dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
int main(){
   int h,w,count=0;cin>>h>>w;
   vvc v(h+2,vc(w+2));
   rep(i,h+2){
      v[i][0]='#';
      v[i][w+1]='#';
   }
   rep(i,w+2){
      v[0][i]='#';
      v[h+1][i]='#';
   }
   rep(i,h){
     string s;cin>>s;
     rep(j,w){
         v[i+1][j+1]=s[j];
         if(v[i+1][j+1]=='.')count++;
      }
   }
   vvi dis(h+2,vi(w+2,inf));
   dis[1][1]=1;
   queue<P> q;
   q.push(P(1,1));
   while(!q.empty()){
      auto p=q.front();
     q.pop();
      rep(i,4){
         if(v[p.first+dx[i]][p.second+dy[i]]=='.'){
            if(dis[p.first+dx[i]][p.second+dy[i]]!=inf)continue;
            dis[p.first+dx[i]][p.second+dy[i]]=dis[p.first][p.second]+1;
            q.push(P(p.first+dx[i],p.second+dy[i]));
            if(p.first+dx[i]==h&&p.second+dy[i]==w){
               cout<<count-dis[h][w]<<endl;
               return 0;
            }
         }
      }
   }
  cout<<-1<<endl;
}

Measured memory_bytes: 256
//
// Created by PIIMUU on 8/22/2020.
//
#include <bits/stdc++.h>
using namespace  std;

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

Measured memory_bytes: 4040
#include <bits/stdc++.h>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// typedef vector<vector<ll>> matrix;
// const ll PRIME = 1e9 + 7;
// typedef pair<int,pair<int,int> >  ppi;

void solve()
{
    int n;
    cin >> n;
    int a[n + 1];
    memset(a, 0, sizeof(a));
    for (int y = 6; y <= n; y++)
    {
        bool flag = 0;
        for (int i = 1; i * i <= y; i++)
        {
            for (int j = 1; j * j <= y; j++)
            {
                for (int k = 1; k * k <= y; k++)
                {
                    if (i * i + j * j + k * k + i * j + i * k + j * k == y)
                    {
                        a[y]++;
                    }
                    if (i * i + j * j + k * k + i * j + i * k + j * k >= y)
                    {
                        flag = 1;
                        break;
                    }
                }
               
            }
            
        }
    }
    frf(i, 1, n)
    {
        cout << a[i] << "\n";
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;
    // cin >> t
    t = 1;
    while (t--)
    {
        solve();
    }
}

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

#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 VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

const int mod = 1e9 + 7;
int n;
int t[25][25];


int main () {
	read(n);
	FOR(i,0,n) {
		FOR(j,0,n) {
			make(a); t[i][j] = a;
		}
	}
	int ans = 0 ;
	FOR(i,1,1<<n) {
		int loc = 1;
		int sz = 0;	
		FOR(j,0,n) {
			if ((1<<j) & i) sz++;
			int sum = 0;
			FOR(k,0,n) {
				if (i & (1<<k)) {
					sum += t[j][k];
					sum %= mod;
				}
			}
			loc = (loc * 1LL * sum) % mod;
		}
		sz += n;
		if (sz%2) ans = (ans + mod - loc) % mod;
		else ans = (ans + loc) % mod;
	}
	printf("%d\n", ans);
}	





Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから

void solve(){
  int n;
  cin>>n;
  vector<int>l(n);
  rep(i,n)cin>>l[i];
  sort(l.begin(),l.end());
  int sum=0;
  rep(i,n-1)sum+=l[i];
  if(sum>l.back())cout<<"Yes";
  else cout<<"No";
}

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


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

int main(){
  int N,count = 1;
  cin >> N;
  vector<int> d(N);
  
  for(int i = 0;i < N;i++){
    cin >> d.at(i);
  }
  
  sort(d.begin(), d.end(), greater<int>());
  
  for(int i = 1;i < N;i++){
	if(d.at(i) < d.at(i - 1)){
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import numpy as np
#import operator
#import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#scipy.sparse import csr_matrix
#scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
    s=input().rstrip().decode('utf-8')
    s0=s[::2]
    s1=s[1::2]
    print(s1.count("g")-s0.count("p"))



if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////

	
int main() {

	ll a, b;
	cin >> a >> b;
	if (a >= 13) { cout << b; }
	else if (a >= 6) { cout << b / 2; }
	else { cout << 0; }
	
	

	
	system("PAUSE");
}

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

using namespace std;

int main(){
    int k;
    cin >> k;
    int M=32;
    int term[M]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << term[k-1];
    return 0;
}


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

int main() {
    long long  a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<long long> v {a*c, a*d, b*c, b*d};
    sort(v.begin(), v.end());
    cout << v[3];
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N, A;
    cin >> N;
    int times = 0;
    int answer = 30;
    
    for (int i=0; i < N; i++) {
        cin >> A;
        
        while (A % 2 == 0) {
            times +=1;
            A /=2;
        }
        
        if (times <= answer) answer = times;
        
        times = 0;
    }
    
    cout << answer << endl;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a + b + c >= 22) {
    cout << "bust" << endl;
  }
  else {
    cout << "win" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;
//using namespace boost::multiprecision;


int main(){

    int n;
    cin >> n;

    vector<ll> one(60);
    vector<ll> zero(60);

    rep(i, n){
        ll a;
        cin >> a;



        rep(j,60){
            ll mask = ((ll)1 << j);
            if(a & mask){
                one[j] = (one[j] + 1) % MODN;
            }else{
                zero[j] = (zero[j] + 1) % MODN;
            }
        }
    }

    rep(i,60){
        //cerr << digit[i] << " ";
    }
    cerr << endl;

    vector<ll> pow2(60, 1);

    for(int i = 1; i < 60; i++){
        pow2[i] = pow2[i - 1] * 2 % MODN;
    }

    ll ans = 0;

    for(int i = 0; i < 60; i++){

        ll tmp = one[i] * zero[i] % MODN;
        tmp = tmp * pow2[i] % MODN;
        ans = (ans + tmp) % MODN;
    }

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

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

int main(){
  string S,T;
  cin>>S>>T;
  int count=0;
  for(int i=0; i<S.size(); i++){
    if(S.at(i)!=T.at(i)){
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3860
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main(){
	int n,m;
	while( cin >> n >> m , n||m ){
		int t[1001][101]={0};
		vector<int> p;
		map<int,vector<int> > f;
		
		for(int j=0 ; j<n ; j++ ){
			for(int i=0 ; i<m ; i++ ){
				cin >> t[j][i];
			}
		}
		for(int i=0 ; i<m ; i++ ){
			int cnt=0;
			for(int j=0 ; j<n ; j++ ){
				cnt += t[j][i];
			}
			if( !count(p.begin(),p.end(),cnt) ) p.push_back( cnt );
			f[cnt].push_back( i+1 );
		}
		
		sort( p.begin() , p.end() );
		reverse( p.begin() , p.end() );

		for(int i=0 ; i<(int)p.size() ; i++ ){
			sort( f[ p[i] ].begin() , f[ p[i] ].end() );
		}
		for(int i=0 ; i<(int)p.size() ; i++ ){
			for(int j=0 ; j < (int)f[ p[i] ].size() ; j++ ){
				cout << f[ p[i] ][j];
				if( i == (int)p.size()-1 && j == (int)f[ p[i] ].size()-1 )
					cout << endl;
				else
					cout << " ";
			}
		}
	}
}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  int count;
  cin >> s >>t;
  count = 0;
    
  for (int i; i<3 ; i+=1){
    if ( s[i] == t[i]){
      count +=1;
    }
    else{
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(ll)(n);i++)
typedef pair<int,long long> pint;
typedef long long ll;
const ll mod= 1e9+7;
const int inf=1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int cnt[2][4040][2020],dp[2020][2020],a[2][2020];

int rec(int b,int w){
  if(dp[b][w]!=-1)return dp[b][w];
  if(b==0&&w==0)return 0;
  int ret=inf;
  if(b>0)ret=min(ret,rec(b-1,w)+a[0][b]+cnt[0][a[0][b]][b-1]+cnt[1][a[0][b]][w]-b-w);
  if(w>0)ret=min(ret,rec(b,w-1)+a[1][w]+cnt[0][a[1][w]][b]+cnt[1][a[1][w]][w-1]-b-w);
  return dp[b][w]=ret;
  }

int main(){
  int n;cin>>n;
  rep(i,2*n){
    string s;cin>>s;
    int x;cin>>x;
    if(s=="W")a[1][x]=i+1;
    else a[0][x]=i+1;
    }
  rep(i,n+1)rep(j,n+1)dp[i][j]=-1;
  rep(i,2*n)rep(j,n){
    if(i+1<a[0][j+1])cnt[0][i+1][j+1]++;
    if(i+1<a[1][j+1])cnt[1][i+1][j+1]++;
    }
  rep(i,2*n)rep(j,n-1){
    cnt[0][i+1][j+2]+=cnt[0][i+1][j+1];
    cnt[1][i+1][j+2]+=cnt[1][i+1][j+1];
    }
  cout<<rec(n,n)<<endl;
  return 0;
  }

Measured memory_bytes: 79872
#include <cassert>
#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <deque>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

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

    int n = min(a, b);
    for (int i = 0; i < max(a, b); i++) {
        cout << n;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;
 
#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())
 
ll inf = 1e9;
ll INF = inf * 1ll * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

void mod_add(ll &a, ll b) {
  a += b;
  if(a > mod) a -= mod;
}
void mod_sub(ll &a, ll b) {
  a -= b;
  if(a < 0) a += mod;
}

//only for variables and vectors; 
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

/*...................................................*/

main()
{
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);

  ll t, n, m, i, j, k, q, u, v;
  // cin >> t;
  // ll tc = t;
  t = 1;
  while (t--)
  {
    cin >> n; 
    vii a(n);
    for(i = 0; i < n; i++) {
      cin >> a[i].first;
      a[i].second = i;
    }
    sort(all(a));
    for(i = 0; i < n; i++) {
      cout << a[i].second + 1 << ' ';
    }
    // cout << "Case #" << tc - t << ": ";

    cout << '\n';
  }
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
const int MAX=210000;
const long long MOD=1000000007;

typedef long long ll;

ll fac[MAX],finv[MAX],inv[MAX];

ll mod_pow(ll x, ll n){ //べき乗
    ll ans=1;
    while(n!=0){
        if(n&1) ans=ans*x%MOD;
        x=x*x%MOD;
        n=n>>1;
    }
    return ans;
}

void com_init(){ //初期化
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        //inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        //finv[i]=finv[i-1]*inv[i]%MOD;
        finv[i]=finv[i-1]*mod_pow(i,MOD-2)%MOD;//フェルマーの小定理より
    }
}

ll comb(ll n, ll k){ //nCk
    if(n<k) return 0;
    if(n<0||k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
    ll N,K; cin >> N >> K;
    ll ans=0;
    com_init();
    for(int i=0;i<min(K+1,N);i++){
        ans+=(comb(N,i)*comb(N-1,N-i-1))%MOD;
        ans%=MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
using p = pair<ll, ll>;
const int mod = pow(10, 9) + 7;

ll binpow(int x, int y);

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

    ll ans = 0, n = 1, m;
    vector<p> table;
    table.push_back(p(1, 1));
    for(int i = 0; i < h + w - 2; i++){
        n *= (i + 1) % mod; /*need long long*/
        n %= mod;
        m = binpow(n, mod - 2);
        table.push_back(p(n, m));
    }

    for(int i = 0; i < w - b; i++){
        ll tmp = 1;
        tmp *= table[b + h - a + i - 1].first;
        tmp *= table[h - a - 1].second;
        tmp %= mod;
        tmp *= table[b + i].second;
        tmp %= mod;
        tmp *= table[a - b + w - i - 2].first;
        tmp %= mod;
        tmp *= table[a - 1].second;
        tmp %= mod;
        tmp *= table[w - b - i - 1].second;
        tmp %= mod;

        ans += tmp;
        ans %= mod;
    }
    cout << ans << endl;
}

ll binpow(int x, int y){
    ll re = 1, seed = x % mod;
    while(y > 0){
        if(y%2 != 0){
            re *= seed;
            re %= mod;
        }
        seed *= seed;
        seed %= mod;
        y >>= 1;
    }
    return re;
}

Measured memory_bytes: 7400
fun main(args: Array<String>) {
    val (a, b, c, d) = readLongList()

    println(b - b / c - b / d + b / lcm(c, d) - (a - 1 - (a - 1) / c - (a - 1) / d + (a - 1) / lcm(c, d)))
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

// 最大公約数
fun gcd(p: Long, q: Long): Long = if (p % q == 0L) q else gcd(q, p % q)

// 最小公倍数
fun lcm(p: Long, q: Long): Long = p / gcd(p, q) * q

Measured memory_bytes: 36340
#include <iostream>
#include<algorithm>
#include<vector> //動的配列
#include<string> 
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>


//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

typedef long long ll;


using namespace std;

typedef pair<int, int> P;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int n;


int main(){
    cin>>n;
    vector<int> vec; 
    
    int c;
    for (int i=0;i<n;i++){
        cin>>c;
        vec.push_back(c);
    }
    int cnt=0;
    bool check=true;
    for (int i=1;i<n;i++){
        if (vec[i]==vec[i-1] && check==true){
            cnt++;
            check=false;
        } else {
            check=true;
        }
    }
    cout<<cnt<<endl;
}

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

int main()
{
    int n = 0;
    int k = 0;
    std::cin >> n >> k;
    std::vector<int> scaffoldCost(n);
    int inputCost = 0;
    for(int i = 0; i < n; ++i)
    {
        std::cin >> inputCost;
        scaffoldCost.at(i) = inputCost;
    }
    
    std::vector<long long> minCosts(n);
    long long tempMinCost = 0;
    
    for(int index = 1; index < n; ++index)
    {
        tempMinCost = 1000000000;
        for(int diff = 0; diff < k; ++diff)
        {
            if(index - diff < 1)
            {
                break;
            }
            tempMinCost = std::min(tempMinCost,
                minCosts.at(index - diff - 1) 
                + std::abs(scaffoldCost.at(index) - scaffoldCost.at(index - diff - 1))
                );
        }
        minCosts.at(index) = tempMinCost;
    }
    std::cout << minCosts.back() << std::endl;
}

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

int N;
vector<int> P;
vector<int> A, B;
int offset = 500000000;

int main() {
    scanf("%d", &N);
    P.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%d", &P[i]);
        P[i]--;
    }

    A.resize(N);
    B.resize(N);
    for(int i = 0; i < N; i++) {
        A[ P[i] ] = offset + 20000*P[i] + i;
        B[ P[i] ] = offset - 20000*P[i];
    }
    for(int i = 0; i < N; i++) {
        printf("%d ", A[i]);
    }
    printf("\n");
    for(int i = 0; i < N; i++) {
        printf("%d ", B[i]);
    }
}


Measured memory_bytes: 896
#include<stdio.h>
#include<algorithm>
#include<set>
using namespace std;
int UF[40000];
int BF[40000];
int SCOOT=200;
int chg[400000];
int siz;
int FIND(int a){
	if(UF[a]<0)return a;
	return FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);
	b=FIND(b);
	if(a==b)return;
	if(UF[a]>UF[b])swap(a,b);
	chg[siz++]=a;
	chg[siz++]=b;
	UF[a]+=UF[b];
	UF[b]=a;
}
int x[40000];
int y[40000];
int z[40000];
set<pair<int,int> >S;
set<pair<int,int> >T;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		scanf("%d%d%d",x+i,y+i,z+i);
	}
	for(int i=0;i<a;i++)UF[i]=BF[i]=-1;
	for(int i=0;i<b;i++){
		if(i%SCOOT==0){
			T.clear();
			for(int j=0;j<SCOOT&&i+j<b;j++){
				if(x[i+j]!=3){
					T.insert(make_pair(y[i+j],z[i+j]));
					if(x[i+j]==1)S.insert(make_pair(y[i+j],z[i+j]));
					if(x[i+j]==2)S.erase(make_pair(y[i+j],z[i+j]));
				}
			}
			for(int j=0;j<a;j++)UF[j]=BF[j]=-1;
			siz=0;
			set<pair<int,int> >::iterator it=S.begin();
			while(it!=S.end()){
				pair<int,int>W=*it;
	//			if(i==9000){
	//				printf("%d %d\n",W.first,W.second);
	//				fflush(stdout);
	//			}
				if(!T.count(W))UNION(W.first,W.second);
				it++;
			}
			for(int j=0;j<a;j++)BF[j]=UF[j];
		}
		if(x[i]==3){
			set<pair<int,int> >U;
			int n=i/SCOOT*SCOOT;
			for(int j=0;j<i%SCOOT;j++){
				if(x[n+j]==1)U.insert(make_pair(y[n+j],z[n+j]));
				if(x[n+j]==2)U.erase(make_pair(y[n+j],z[n+j]));
			}
			for(int j=min(SCOOT-1,b-n-1);j>i%SCOOT;j--){
				if(x[n+j]==2)U.insert(make_pair(y[n+j],z[n+j]));
				if(x[n+j]==1)U.erase(make_pair(y[n+j],z[n+j]));
			}
			set<pair<int,int> >::iterator it=U.begin();
			siz=0;
			while(it!=U.end()){
				pair<int,int>W=*it;
				UNION(W.first,W.second);
				it++;
			}
			if(FIND(y[i])==FIND(z[i]))printf("YES\n");
			else printf("NO\n");
			for(int j=0;j<siz;j++)UF[chg[j]]=BF[chg[j]];
		}
	}
}

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

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long) (1e9+7);
	static long cf = 998244353;
    static final long MAX = (long) 1e15;
   // public static List<Integer>[] edges;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		long n = sc.nextLong();
		long ans = n;
		for(int i=1;i<=Math.sqrt(n);++i) {
			if(n%i == 0) {
				ans = Math.min(ans,i + n/i - 2);
			}
		}
		out.print(ans);
		out.close();
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    int n,m; cin >> n >> m;
    int array[n];
    for(int i = 0;i < n;i++){
        array[i] = 0;
    }
    int a,b;
    for(int i = 0;i < m;i++){
        cin >> a >> b;
        array[a-1]++;
        array[b-1]++;
    }
    for(int i = 0;i < n;i++){
        cout << array[i] << endl;
    }
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            string inputbuf1 = Console.ReadLine();
            //string inputbuf2 = Console.ReadLine();
            //string inputbuf1 = "2510";
            //string inputbuf2 = "ABCAB";
            string[] inputstring = inputbuf1.Split(' ');
            int N = Convert.ToInt32(inputstring[0]);
            int K = Convert.ToInt32(inputstring[1]);


            long conN = 1;
            long score = 0;
            double pbuf = 0;
            double ptotal=0;
            while (conN<=N)
            {
                score = conN;
                pbuf = Convert.ToDouble(1) / Convert.ToDouble(N);

                while (score<K)
                {
                    score = score * 2;
                    pbuf = pbuf / 2;
                }
                ptotal = ptotal + pbuf;
               conN++;
                score = 0;
            }
                Console.WriteLine(ptotal);
            
            
            //Console.ReadKey();

        }
    }
}


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

vector<int> par;
vector<int> RA;
int root(int a){
  if(a==par[a]){
    return a;
  }
  else{
    return par[a]=root(par[a]);
  }
}
void UN(int a,int b){
  a=root(a);
  b=root(b);
  if(a==b){
    return;
  }
  else if(RA[a]<RA[b]){
    par[a]=b;
  }
  else{
    par[b]=a;
  }
  if(RA[a]==RA[b]){
    RA[a]++;
  }
}
bool same(int a,int b){
  if(root(a)==root(b)){
    return true;
  }
  else{
    return false;
  }
}


int main() {
  int N,M;
  cin>>N>>M;
  par.resize(N);
  RA.resize(N);
  for(int i=0;i<N;i++){
    par[i]=i;
  }
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    UN(a,b);
  }
  vector<int> p(N);
  for(int i=0;i<N ;i++){
    p[root(i)]++;
  }
  int Z=0;
  for(int i=0;i<N;i++){
    Z=max(Z,p[i]);
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 5632
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    int n;
    cin >> n;
    set<string> st;
    rep(i, n) {
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 19204
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}







/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  ll n;
  cin>>n;
  ll ans=0;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  map<ll,ll> mp;
  vector<ll> sum(n+1,0);
  sum[0]=0;
  rep(i,n) sum[i+1]=sum[i]+v[i];
  rep(i,n+1){
    mp[sum[i]]++;
  }
  for(auto c:mp) ans+=c.second*(c.second-1)/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 15872
import itertools,math
n = int(input())
points = [list(map(int,input().split())) for _ in range(n)]
roots = list(itertools.permutations(points))
ans = 0
for root in roots:
    for i in range(n-1):
        ans += math.sqrt(pow(root[i+1][0] - root[i][0],2) + pow(root[i+1][1] - root[i][1],2))
ans /= len(roots)
print(ans)

Measured memory_bytes: 13864