akhauriyash/Code-Regression huggingface dataset:
//#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <cstdlib>      // srand,rand


using namespace std;
#define modd 1000000007



typedef pair<long long, long long> pl;



typedef string::const_iterator State;
class ParseError {};




#define ll long long




class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


class SegmentTree {
private:
	int n;
	vector <ll> node;

public:
	// 元の配列　v をセグメントツリーで表現する。
	SegmentTree(vector<ll> v) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく。
		//セグ木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1; 
		while (n < sz)n *= 2;

	}

};




long long N, M, K, a, b, c, d, e, H, W, L,T;
ll A[300005] = {};
ll B[300005] = {};
ll C[100][3005] = {};
bool f, ff;
string S,SS;
set <long long>sll;
pl bufpl;
vector <long long>vl[600005];
vector <long long>vll;
vector <pl>vpl;
vector <string> vs;
set<ll> llset[50];
multiset<ll> llmset;
queue<ll> ql;


struct ST
{
	ll first;
	ll second;
	ll kaisuu;
	

	bool operator<(const ST& another) const
	{
		return first < another.first;//比較
	};

};



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;
double ansa;

ll zettai(ll aa) {

	if (aa < 0) {
		aa *= -1;
	}
	return aa;

}



double ab[20000];

bool fa[200009] = {};

ll amari[15] = {};
ll ama[7][10] = {};

int main() {
	cin >> N;

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

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

		if (A[i] <= B[i]) {
			a += A[i];
			B[i] -= A[i];
		}
		else {
			a += B[i];
			continue;
		}

		if (A[i + 1] <= B[i]) {
			a += A[i + 1];
			A[i + 1] = 0;
		}
		else {
			a += B[i];
			A[i + 1] -= B[i];
		}

	}

	cout << a << endl;

	//cout << fixed << setprecision(10) << ansa << endl;
	return 0;


	
}


Measured memory_bytes: 20352
#include<iostream>
using namespace std;
int main(){
    int a,b;
    char op;
    cin >>a>>op>>b;
    while(op !='?'){
        int c;
        if(op == '+') c = a+b;
        if(op == '-') c = a-b;
        if(op == '*') c= a*b;
        if(op == '/') c= a/b;
        cout <<c<<endl;
        cin >> a >>op>>b;
    }
    
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using Int = long long;
using namespace std;
const Int mod = 1e9 + 7;
int main(){
    int N;
    cin >> N;
    vector<Int>A(N);
    for(auto& e : A) cin >> e;
    auto csum = A;
    for(int i = 1; i < csum.size(); ++i)
        csum[i] += csum[i - 1];
    Int ans = 0;
    for(int i = 0; i < N; ++i){
        Int prev =  csum[i];
        ans += ((csum.back() - prev) % mod) * A[i];
        ans %= mod;
    }
    cout << ans << endl;
}



Measured memory_bytes: 6332
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;


class Main
{
	

	public static void main(String args[]) throws IOException
	{
		FastScanner fs = new FastScanner();
		int M = 1000000007;
		int n =fs.nextInt();
		int arr[] = fs.arrayIn(n);
		long sum=0;
		long suffixSum[] = new long[n+1];

		for(int i=n-1; i>0; i--)
		{
			suffixSum[i] = (suffixSum[i+1]+arr[i])%M;
		}
		
		for(int i=1; i<n; i++)
		{
			sum += (arr[i-1]*suffixSum[i])%M;
		}
		System.out.println(sum%M);
	}

	static final Random random = new Random();
	
	static void ruffleSort(int arr[])
	{
		int n = arr.length;
		for(int i=0; i<n; i++)
		{
			int j = random.nextInt(n),temp = arr[j];
			arr[j] = arr[i];
			arr[i] = temp;
			
		}
		Arrays.sort(arr);
	}
	

	static class Pairs implements Comparable<Pairs>
	{
		int value,index;
		Pairs(int value, int index)
		{
			this.value = value;
			this.index = index;
		}
		public int compareTo(Pairs p)
		{
			return Integer.compare(value,p.value);
		}
	}
}
class FastScanner
{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer str = new StringTokenizer("");
	
	String next() throws IOException
	{
		while(!str.hasMoreTokens())
			str = new StringTokenizer(br.readLine());
		
		return str.nextToken();
	}
	
	char nextChar() throws IOException {
		return next().charAt(0);
	}

	int nextInt() throws IOException
	{
		return Integer.parseInt(next());
	}
	
	float nextfloat() throws IOException
	{
		return Float.parseFloat(next());
	}
	
	double nextDouble() throws IOException
	{
		return Double.parseDouble(next());
	}
	long nextLong() throws IOException
	{
		return Long.parseLong(next());
	}
	byte nextByte() throws IOException 
	{
		return Byte.parseByte(next());
	}
	int [] arrayIn(int n) throws IOException
	{
		int  arr[] = new int[n];
		for(int i=0; i<n; i++)
		{
			arr[i] = nextInt();
		}
		return arr;
	}
}



	


Measured memory_bytes: 55176
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }





int main() {
    ll n;
    cin >> n;
    ll sum = 0, h = 0;
    bool ok = false;
    REP(i, 10000){
        sum += (i + 1);
        if(sum == n){
            ok = true;
            h = i + 2;
            break;
        }
    }
    
    if(!ok){
        cout << "No" << endl;
        return 0;
    }
    
    ll w = h - 1;
    vector<vector<ll>> ans(h, vector<ll>(w));
    ll v = 1;
    REP(i, w){
        for(ll j = i; j < w; j++){
            ans[i][j] = v;
            ans[j + 1][i] = v;
            v++;
        }
    }
    
    cout << "Yes" << '\n';
    cout << h << '\n';
    REP(i, h){
        cout << ans[i].size() << ' ';
        REP(j, w){
            cout << ans[i][j] << ' ';
        }
        cout << '\n';
    }
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int cnt[3];

signed main()
{
    string s; cin>>s;
    REP(i,s.size()) cnt[s[i]-'a']++;
    
    sort(cnt,cnt+3);
    if(cnt[2]-cnt[0]<=1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}


Measured memory_bytes: 512
#include <stdio.h>

int ar[1005][1005];

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

int main(void)
{
	int i, j;
	int m, w;
	int p[1005], t[1005];
	int ans;
	int ca = 1;
	
	while (1){
		scanf("%d", &w);
		
		if (w == 0){
			break;
		}
		
		scanf("%d", &m);
		
		for (i = 0; i < m; i++){
			scanf("%d,%d", &p[i], &t[i]);
		}
		
		for (i = 0; i <= m; i++){
			for (j = 0; j <= w; j++){
				ar[i][j] = 0;
			}
		}
		
		for (i = 1; i <= m; i++){
			for (j = 1; j <= w; j++){
				
				if (j - t[i - 1] >= 0 && ar[i - 1][j - t[i - 1]] + p[i - 1] > ar[i - 1][j]){
					ar[i][j] = ar[i - 1][j - t[i - 1]] + p[i - 1];
				}
				ar[i][j] = max(ar[i][j] ,max(ar[i - 1][j], ar[i][j - 1]));
				
			}
		}
		
		ans = ar[m][w];
	
		while (ar[m][w] == ans){
			w--;
		}
		
		printf("Case %d:\n", ca++);
		printf("%d\n%d\n", ans, w + 1);
		
		
	}
	
	return (0);
}
					
		

Measured memory_bytes: 4532
#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_popcountll

#define INF 1e16
#define mod 1000000007

ll N,K;
ll X[200010];

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

  cin>>N>>K;
  rep(i,N)cin>>X[i];

  ll res=INF;
  rep(i,N-K+1){
    if(X[i]*X[i+K-1]<0){
      minch(res,-X[i]+X[i+K-1]+min(-X[i],X[i+K-1]));
    }else{
      minch(res,max(abs(X[i]),abs(X[i+K-1])));
    }
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;


int main(){
    int n;
    vector<ll> a;
    ll ans = 1;
    int flag = 0;
    cin >> n;

    a.resize(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] == 0){
            flag = 1;
        }else if(a[i] > 1000000000000000000){
            flag = 2;
        }
    }
    if(flag != 1 && flag != 2){
        for(int i = 0; i < n; i++){

            if(a[i]*ans >= ans){
                ans *= a[i];
            }else{
                flag = 2;
                break;
            }
            if(ans > 1000000000000000000){
                flag = 2;
                break;
            }
            //cout << ans << endl;

        }

    }

    if(flag == 2){
        cout <<"-1" << endl;
    }else if(flag == 1){
        cout << "0" << endl;
    }else{
        cout << ans << endl;
    }
    

    
    return 0;
}

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

using namespace std;

int main(){
    int n,ans = 0;
    bool flag = false;
    cin >> n;
    vector<int>v(n);

    for(int i = 0;i < n;i++){
        cin >> v[i];
        if(v[i] % 2 != 0)flag = true;
    }

    while(1){
        if(!flag){
            for(auto &i:v){
                i = i/2;
                if(i%2 != 0)flag = true;
            }
        }else break;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

def partition(A,p,r):
    i = p-1
    for j in range(p,r):
        if A[j][1]<=A[r][1]:
            i += 1
            A[i],A[j] = A[j],A[i]
    A[i+1],A[r] = A[r],A[i+1]
    return i+1

def QuickSort(A,p,r):
    if p < r:
        q = partition(A,p,r)
        QuickSort(A,p,q-1)
        QuickSort(A,q+1,r)

def isStable(A):
    for i in range(1,len(A)):
        if A[i-1][1] == A[i][1]:
            if A[i-1][2] > A[i][2]:
                return 'Not stable'
    return 'Stable'

n = int(input())
A = []
for i in range(n):
    suit,num = sys.stdin.readline().split()
    A += [[suit,int(num),i]]
QuickSort(A,0,n-1)
print(isStable(A))
for i in A:
    print(i[0],i[1])



Measured memory_bytes: 23380
/*input
4 4
*/
/**
    Author: Kristopher Paul
    Date Created: 23-11-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int a,b;
    cin >> a >> b;
    int val = 0;
    if(a <= 3){
        val += (3-a+1)*100000;
    }
    if(b <= 3){
        val += (3-b+1)*100000;
    }
    if(a == b && a == 1){
        val += 400000;
    }
    cout << val << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


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

int main(){
    int n;
    cin>>n;
    for(int i=0;4*i<=n;i++){
        for(int j=0;7*j<=n;j++){
            if(4*i+7*j == n){
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	float hei;
	int cla[6] = {0};
	int i, j;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%f", &hei);
		if (hei < 165.0){
			cla[0]++;
		}
		else if (hei >= 165.0 && hei < 170.0){
			cla[1]++;
		}
		else if (hei >= 170.0 && hei < 175.0){
			cla[2]++;
		}
		else if (hei >= 175.0 && hei < 180.0){
			cla[3]++;
		}
		else if (hei >= 180.0 && hei < 185.0){
			cla[4]++;
		}
		else if (hei >= 185.0){
			cla[5]++;
		}
	}
	
	for (i = 0; i < 6; i++){
		printf("%d:", i + 1);
		for (j = 0; j < cla[i]; j++){
			printf("*");
		}
		printf("\n");
	}
	
	return (0);
}

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


//  https://atcoder.jp/contests/abc150/tasks/abc150_b

int main() {
    int N;
    string s;
    cin >> N >> s;
    int count;
    for (int i = 0; i < N-2; ++i) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
            ++count;
        }
    }
    cout << count;
}


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

int main()
{
    while (true) {
        int h, w;
        cin >> h >> w;
        
        if (!h && !w) break;
        
        string s(w, '#');
        
        for (int i = 0; i < h; i++)
            cout << s << "\n";
            
        cout << "\n";
    }
    
}

Measured memory_bytes: 1156
#include<stdio.h>
#define N 100

int n, time;
int A[N][N], color[N], d[N], f[N]; 

void visit(int u){
  int v;
  color[u] = 1;
  d[u] = ++time;
  for(v = 0; v < n; v++){
    if(A[u][v] == 0){
      continue;
    }
    
    if(color[v] == 0){
      visit(v);
    }
  }
  color[u] = 1;
  f[u] = ++time;
}

void dfs(){
  int u;
  for(u = 0; u < n; u++){
    color[u] = 0;
    time = 0;
  }
  
  for(u = 0; u < n; u++){
    if(color[u] == 0){
      visit(u);
    }
  }
  
  for(u = 0; u < n; u++){
    printf("%d %d %d\n", u+1, d[u], f[u]);
  }
}

int main(){
  int i, j, u, v, k;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      A[i][j] = 0;
    }
  }
  
  for(i = 0; i < n; i++){
    scanf("%d %d", &u, &k);
    
    for(j = 0; j < k; j++){
      scanf("%d", &v);
      A[u-1][v-1] = 1;
    }
  }
  
  dfs();
  return 0;
}



Measured memory_bytes: 2048
#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 <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
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<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;
//ここまでテンプレ
//↓10進数でi桁目の数を取り出すセット
unsigned long long deci[20]={1};
//iは0-indexedなので注意！
int deciBit(long long N,int i){
	N/=deci[i];
	return (int)(N%10);
}
int main(){
	for(int i=1;i<20;i++){
		deci[i]=deci[i-1]*10;
	}
	int N;
	cin>>N;
	int S=0;
	for(int i=0;i<10;i++)
		S+=deciBit(N,i);
	cout<<(N%S==0?"Yes":"No")<<endl;
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
ll n, c;
ll x[N], v[N];
ll ans;
ll r[N], l[N], rb[N], lb[N];

int main() {
    cin >> n >> c;
    for (int i = 1; i <= n; ++i) {
        cin >> x[i] >> v[i];
    }
    ll sum = 0;
    ll dist = 0;
    for (int i = 1; i <= n; ++i) {
        dist += x[i] - x[i - 1];
        sum += v[i];
        ll g = sum - dist;
        ll bg = sum - dist * 2;
        ans = max(ans, g);
        l[i] = max(g, l[i - 1]);
        lb[i] = max(bg, lb[i - 1]);
    }
    sum = dist = 0;
    for (int i = n; i > 0; --i) {
        if (i == n)
            dist += c - x[i];
        else
            dist += x[i + 1] - x[i];
        sum += v[i];
        ll g = sum - dist;
        ll bg = sum - dist * 2;
        ans = max(ans, g);
        r[n - i + 1] = max(g, r[n - i]);
        rb[n - i + 1] = max(bg, rb[n - i]);
    }
    for (int i = 1; i < n; ++i) {
        ll case1 = l[i] + rb[n - i];
        ll case2 = lb[i] + r[n - i];
        ans = max(ans, case1);
        ans = max(ans, case2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8332
A, B = map(int, input().split())

count = 0
for x in range(1, 10010):
    if A/0.08 <= x and B/0.1 <= x and x < (A+1)/0.08 and x < (B+1)/0.1:
        print(x)
        count += 1
        break

if count == 0:
    print("-1")


Measured memory_bytes: 2940
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
#define int long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 1e5 + 1;
int n , m;
int a[N];
string s;
int get(int x){
	int res = 0;
	rep(i , 1 , n)
		res += (a[i] - x)*(a[i] - x);
	return res;
}
main(){
	cin >> n;
	rep(i , 1 , n)
		cin >> a[i];
	int ans = 1e18;
	rep(i , -101 , 101)
		ans = min(ans , get(i));
	cout << ans;
}

Measured memory_bytes: 256
package main

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

func main() {
	S, T := readS(), readS()

	d := make([]int, len(S)-len(T)+1)
	for i := 0; i < len(S)-len(T)+1; i++ {
		d[i] = diff(S[i:i+len(T)], T)
	}
	fmt.Println(min(d))
}

func diff(a, b string) int {
	c := 0
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			c++
		}
	}
	return c
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

/*-----------Utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}


Measured memory_bytes: 1796
#include <vector>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <math.h>
#include <list>
using namespace std;

int main()
{
  int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx , dy = ty - sy;
  
  cout << string(dy , 'U') << string(dx , 'R');
  
  cout << string(dy , 'D') << string(dx , 'L');
  
  cout << 'L' << string(dy + 1 , 'U') << string(dx + 1 , 'R') << 'D';
  
  cout << 'R' << string(dy + 1 , 'D') << string(dx + 1 , 'L') << 'U';
  
  cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int x,y,a,b,c,i;
    scanf("%d%d", &x, &y);
    a = x-1;
    b = y+a;
    c = y-a;
    for(i=c;i<=b;i++)
    {
        printf("%d ", i);
    }
}

Measured memory_bytes: 128
#![allow(non_snake_case)]
#![allow(unused_macros)]

use proconio::input;
use proconio::marker::Usize1;

macro_rules! echo {
  {$x:expr} => {println!("{}", $x)}
}

macro_rules! chmax {
  {$x:expr, $y:expr} => {
    $x = std::cmp::max($x, $y)
  }
}

macro_rules! chmin {
  {$x:expr, $y:expr} => {
    $x = std::cmp::min($x, $y)
  }
}

fn main() {
  input! {
    R: usize,
    C: usize,
    K: usize,
  }
  let mut field = vec![vec![None; C]; R];
  for _ in 0..K {
    input! {
      r: Usize1,
      c: Usize1,
      v: usize,
    }
    field[r][c] = Some(v);
  }
  let mut dp = vec![vec![vec![0usize; 4]; C + 1]; R + 1];
  for i in 1..=R {
    for k in 1..=C {
      for num in 0..=3 {
        chmax!(dp[i][k][num], dp[i][k - 1][num]);
        chmax!(dp[i][k][0], dp[i - 1][k][num]);
      }
      if let Some(v) = field[i - 1][k - 1] {
        for num in (0..3).rev() {
          chmax!(dp[i][k][num + 1], dp[i][k][num] + v);
        }
      }
    }
  }
  echo!(dp[R][C].iter().max().unwrap());
}


Measured memory_bytes: 779204
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

//AOJ 302

int main(void) {
	ll n, d;
	cin >> n >> d;
	vector<tuple<ll, ll, ll>> stars = vector<tuple<ll, ll, ll>>(n);
	rep(i, 0, n) {
		ll x, y, b;
		cin >> x >> y >> b;
		stars[i] = make_tuple(b, x, y);
	}
	sort(stars.begin(), stars.end());
	priority_queue<tuple<ll,ll>> xl, xr, yt, yu;
	xl.push(make_tuple(get<1>(stars[0]), (ll)0));
	xr.push(make_tuple(-1*get<1>(stars[0]), (ll)0));
	yt.push(make_tuple(-1*get<2>(stars[0]), (ll)0));
	yu.push(make_tuple(get<2>(stars[0]), (ll)0));
	ll ans = 0;
	ll il = 0;
	rep(ir, 1, n) {
		auto sN = stars[ir], sB = stars[il];
		if (abs(get<0>(sN) - get<0>(sB) ) <= d) {
			xl.push(make_tuple(get<1>(sN),ir));
			xr.push(make_tuple(-1*get<1>(sN), ir));
			yu.push(make_tuple(get<2>(sN), ir));
			yt.push(make_tuple(-1*get<2>(sN), ir));
		}

		if (ir == n - 1 || abs(get<0>(sN) - get<0>(sB)) > d) {
			ans = max(ans, (get<0>(xl.top()) + get<0>(xr.top())) * (get<0>(yt.top()) + get<0>(yu.top())));
			while (il < ir && abs(get<0>(sN) - get<0>(stars[il])) > d) il++;
			if (ir < n - 1) {
				while (xl.size() > 0 && get<1>(xl.top()) < il) xl.pop();
				while (xr.size() > 0 && get<1>(xr.top()) < il) xr.pop();
				while (yu.size() > 0 && get<1>(yu.top()) < il) yu.pop();
				while (yt.size() > 0 && get<1>(yt.top()) < il) yt.pop();

				xl.push(make_tuple(get<1>(sN), ir));
				xr.push(make_tuple(-1 * get<1>(sN), ir));
				yu.push(make_tuple(get<2>(sN), ir));
				yt.push(make_tuple(-1 * get<2>(sN), ir));
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 20108
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println(((sc.nextLong() - sc.nextLong()) + sc.nextLong() * 0) * (sc.nextLong() % 2 == 1 ? -1 : 1));
	}
}

Measured memory_bytes: 23380
//#include<iostream>
#include<cstdio>
using namespace std;

int main() {
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

    if (x + r > W || y + r > H) {
        printf("No");
    } else if (x - r < 0 || y - r < 0) {
        printf("No");
    } else {
        printf("Yes");
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 1016
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n, r = map(int, input().split())
    if n>= 10:
        print(r)
    else:
        # r = 100 * (10-n)
        print(r+ 100*(10-n))
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 5048
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=200000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

class Point{
public:
	long long x;
	long long y;
	long long dis;
	Point(long long _x,long long _y,long long _dis){
		x=_x;
		y=_y;
		dis=_dis;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long n;
	cin>>n;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			if(i*j==n){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
}


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


int main(void) {
    int k, sum = 0, count = 0;
    cin >> k;
    if (k % 2 == 0 || k % 5 == 0) cout << -1 << endl;
    else {
        while(1) {
            sum = 10 * sum + 7;
            count++;
            sum %= k;
            if(!sum) {
                cout<<count<<"\n";
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

string divide[4] = { "dream","dreamer","erase","eraser" };
int main()
{
	int N,C,K;
	cin >> N;
	vector<int> T(N);
	for (int i = 0; i < N; i++)
	{
		cin >> T.at(i);
	}
	long sum = 0;
	long cnt1 = 0;
	for (int i = 0; i < N; i++)
	{
		sum += T.at(i);
		if (i % 2 == 0)
		{
			if (sum <= 0)
			{
				cnt1 += -sum + 1;
				sum = 1;
			}
		}
	else {
			if (sum >= 0)
			{
				cnt1 += sum + 1;
				sum = -1;
			}
		}
	}

	long cnt2 = 0;
	sum = 0;
	for (int i = 0; i < N; i++)
	{
		sum += T.at(i);
		if (i % 2 == 1)
		{
			if (sum <= 0)
			{
				cnt2 += -sum + 1;
				sum = 1;
			}
		}
		else {
			if (sum >= 0)
			{
				cnt2 += sum + 1;
				sum = -1;
			}
		}
	}

	cout << min(cnt1,cnt2) << endl;
	return 0;


	
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	int num = 10 * g + b;
	if (num % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
 
using namespace std;
#define LOCAL  1
#define UPLOAD 2
#define ll long long
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  long long N = input(); 
  long long K = input(); 
  vector<long long> P;

  vector<long long> sumVec = {0};

  long long sum = 0;
  for(long long i=0;i<N;i++){
    long long p = input();
    sum += p;
    sumVec.push_back(sum);
    P.push_back(p);
  }

  int index = 0;

  long long currentMax = 0;
  long long maxIndex = 0;
  for(long long i=0;i<N-K+1;i++){
    long long tempSum = sumVec[i + K]-sumVec[i];
    if(tempSum > currentMax){
      maxIndex = i;
      currentMax = tempSum;
    }
  }

  long double answer = 0;
  for(long long i=0;i<K;i++){
    long long index = maxIndex + i;
    long long sum = (P[index]+1)*P[index]/2;
    answer += (long double)sum / P[index];
  }
  std::cout << std::setprecision(1000) << answer << endl;
 
  return 0;
}

Measured memory_bytes: 3564
#pragma GCC optimize("O3")

#include <iostream>
#include <math.h>
#include <vector>
#include <fstream>
#include <iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <queue>
#include <stack>
#include <string.h>
#include <unordered_map>
#include <random>
#include <cassert>

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pi acos(-1.0)
#define uniq(v) (v).erase(unique((v).begin(),(v).end()),(v).end())
#define fcin(a) ifstream cin(a);
#define fcout(a) ofstream cout(a);
#define inf (long long)(4e10)
#define MOD 1000000007

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    cout << b << a;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,a1,a2;
  int st[100001]={};
  int go[100001]={};
  long long miti[100001]={};
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> a2;
    if(i != 0){
      st[min(a1,a2)]++;
      go[max(a1,a2)]++;
    }   
    a1 = a2;
  }
  long long a,b,c;
  long long ans = 0;
  for(int i=1;i<n;i++){
    miti[i] += miti[i-1];
    miti[i] += st[i];
    miti[i] -= go[i];
    cin >> a >> b >> c;
    ans += min(a*miti[i],b*miti[i]+c);
  }
  cout << ans << endl;
  return (0);
}

Measured memory_bytes: 4656
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)


const int MAX_N = 100;
int N;
string W[MAX_N];

void solve() {
    REP(i, N) {
        REP(j, N) {
            if (i != j && W[i] == W[j]) {
                cout << "No" << endl;
                return;
            }
        }
    }
    char before = ' ';
    REP(i, N) {
        if (i != 0) {
            if (W[i][0] != before) {
                cout << "No" << endl;
                return;
            }
            before = W[i][W[i].length() - 1];
        } else {
            before = W[i][W[i].length() - 1];
        }
    }
    cout << "Yes" << endl;
}

int main() {
    cin >> N;
    REP(i, N) cin >> W[i];
    solve();
    return 0;
}

Measured memory_bytes: 256
from math import sqrt

#def area########################################

def Manhattan(x,y):
	D=0.0
	for i in range(n):
		D+=abs(x[i]-y[i])
	return D

def Euclid(x,y):
	D=0.0
	for i in range(n):
		D+=(x[i]-y[i])**2
	D=sqrt(D)
	return D

def Noname(x,y):
	D=0.0
	for i in range(n):
		D+=abs((x[i]-y[i])**3)
	D**=1.0/3
	return D

def Infinity(x,y):
	L=list()
	for i in range(n):
		L.append(abs(x[i]-y[i]))			
	return max(L)

#################################################


n=int(input())
x=map(float,raw_input().split(" "))
y=map(float,raw_input().split(" "))

print Manhattan(x,y)
print Euclid(x,y)
print Noname(x,y)
print Infinity(x,y)

Measured memory_bytes: 6644
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <climits>
#include <queue>

using namespace std;

const int V = 10001;
vector<int> adj[V];
bool marked[V];
int degree[V];
vector<int> ans;

void bfs(int s) {
    queue<int> q;
    q.push(s);

    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int i = 0; i < adj[u].size(); ++i) {
            degree[adj[u][i]]--;
            if (degree[adj[u][i]] == 0) {
                q.push(adj[u][i]);
            }
        }

        marked[u] = true;
        ans.push_back(u);
    }
}

int main() {
    int v, e;
    cin >> v >> e;
    for (int i = 0; i < e; ++i) {
        int s, t;
        cin >> s >> t;
        adj[s].push_back(t);
        degree[t]++;
    }

    for (int i = 0; i < v; ++i) {
        if (!marked[i] && degree[i] == 0) {
            bfs(i);
        }
    }

    for (int i = 0; i < ans.size(); ++i) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3924
def main():
    N = input()
    in_value = [float(i) for i in input().split(' ')]

    sort_value = sorted(in_value)

    if(N != 1):
        while(len(sort_value) != 1):
            sort_value = [(sort_value.pop(0) + sort_value.pop(0)) / 2] + sort_value
                       
    print(sort_value[0])


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
a,b,c,d=map(int,input().split())
arr=[0]*101

arr[a]+=1
arr[b]+=-1
arr[c]+=1
arr[d]+=-1
ans=0


for x in range(1,100):
    arr[x]+=arr[x-1]


for x in arr:
    if x==2:
        ans+=1
print(ans)
    


Measured memory_bytes: 3060
#include <stdio.h>
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))

int main()
{
    int n, m, x, y;
    int temp;
    int i, j;

    scanf("%d %d %d %d", &n, &m, &x, &y);

    for (i = 0; i < n; i++) {
        scanf("%d", &temp);

        x = max(x, temp);
    }

    for (i = 0; i < m; i++) {
        scanf("%d", &temp);
        y = min(y, temp);
    }

    if (x < y) {
        printf("No War\n");
    } else {
        printf("War\n");
    }

    return 0;
}


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

int main()
{
	int x = 0;

	string S;
	int N;
	cin >> N;
	cin >> S;
	int max = 0;

	for (int n = 0; n < N; n++) {
		if (S[n] == 'I') { x++; }
		if (S[n] == 'D') { x--; }
		if (max < x)max = x;
	}
	cout << max;
	cin >> S;//提出時にここは消す

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  lint N,K;
  cin>>N>>K;
  lint ans=0;
  if(K==0){
    cout<<N*N<<endl;
    return 0;
  }
  FOR(b,K+1,N+1){
    ans+=(N/b)*(b-K)+max(0LL,N%b-K+1);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
 
    }
}


Measured memory_bytes: 26204
INF = 1 << 60

N = int(input())
c = [i for i in input()]

left_w = 0
right_r = c.count("R")

ans = INF

for i in range(N + 1):
    now = min(left_w, right_r) + abs(left_w - right_r)
    ans = min(now, ans)
    if i < N:
        if c[i] == "W":
            left_w += 1
        else:
            right_r -= 1

print(ans)

Measured memory_bytes: 11028
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define LL long long
using namespace std;
const int inf=0x3f3f3f3f;
const int N=310;
const int mod=1e9+7; 
int n,map[N][N];
bool f[N][N];
LL ans;
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			map[i][j]=read();
	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
			{
				if(k==i||k==j)continue;
				if(map[i][k]+map[k][j]<map[i][j]){printf("-1");return 0;}
				else if(map[i][k]+map[k][j]==map[i][j])f[i][j]=true;
			}
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(!f[i][j])ans+=map[i][j];
	printf("%lld",ans/2);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double fb;
int n;
struct node {
	fb x, y;
}e[50];
bool vis[50];
fb ans;fb cnt;
fb dis(int a, int b) {
	return sqrt((e[a].x - e[b].x) * (e[a].x - e[b].x) + (e[a].y - e[b].y) * (e[a].y - e[b].y));
}
fb an;
void dfs(int x, int las) {
	int i;//cout << x << " " << ans << endl;
	if(x == n + 1) return;
	for(i = 1; i <= n; ++i) {
		if(vis[i]) continue;
		vis[i] = 1;
		if(las) ans += dis(i, las);
		if(x == n) an += ans;
	//	cout << ans << " ";
		dfs(x + 1, i);
		if(las) ans -= dis(i, las);
	//	cout << ans << endl;
		vis[i] = 0;
	}
}
int main() {
	cin >> n;
	int i;
	memset(vis, 0 , sizeof(vis));
	for(i = 1; i <= n; ++i) {
		cin >> e[i].x >> e[i].y;
	}
	ans = 0;
	an = 0;	
	//las = 0;
	dfs(1, 0);//cout << cnt << endl;
	//cout << ans << " " << cnt << endl;
//	ans /= cnt;
	//ans *= 3;
	//cout << ans  << endl;
	int j;
	//for(i = 1; i <= n; ++i)
	 //for(j = i + 1; j <= n; ++j)
	  //	cout << i << " " << j << " " << (e[i].x - e[j].x) << " " << (e[i].y - e[j].y) << " " << dis(i, j) << endl;
	for(i = 1; i <= n; ++i) an /= (fb)i;
	printf("%.6f", an);
	return 0;
}//15656
//19 * 103 * 

Measured memory_bytes: 256
import java.io.*;
import java.util.HashSet;
import java.util.StringTokenizer;

class Main {
    static final PrintWriter sysOut = new PrintWriter(System.out);
    
    static class Dictionary {
        HashSet<String> hashSet = new HashSet<>();
        
        void insert (String string) {
            hashSet.add(string);
        }
        
        boolean find(String string) {
            return hashSet.contains(string);
        }
    }
    
    public static void main(String[] args) {
        BufferedReader br_dict = new BufferedReader(new InputStreamReader(System.in));
        
        try {
            String line = "";
            while((line = br_dict.readLine()) != null && !line.isEmpty()) {
                int n_dict = Integer.parseInt(line);
                Dictionary dictionary = new Dictionary();
                
                for(int i = 0; i < n_dict; i++) {
                    StringTokenizer tokenizer = new StringTokenizer(br_dict.readLine());
                    String operation = tokenizer.nextToken();
                    String string    = tokenizer.nextToken();
                    
                    if(operation.equals("insert")) {
                        dictionary.insert(string);
                    } else {
                        if(dictionary.find(string)) sysOut.print("yes\n");
                        else sysOut.print("no\n");
                    }
                }
            }
            sysOut.flush();
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 128296
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	long long int N,i;
	cin >> N;
	i = (long long int)sqrt(N);
	while (N % i != 0) {
		i--;
	}
	cout << i + (N / i) - 2 << endl;
	return 0;
}

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

#pragma warning(disable:4996)

#define MAX_N 100
#define MAX_LEN 10

struct Data {
	int id;
	std::string city;
	int point;
};

bool compare(Data& l, Data& r) {
	if (l.city == r.city) {
		return l.point > r.point;
	}
	return l.city < r.city;
}
int main(void) {
	int n;
	scanf("%d", &n);
	std::vector<Data> da;
	char name[MAX_LEN + 1];
	int id = 1;
	for (int i = 0; i < n; ++i) {
		int p;
		scanf("%s %d", &name[0], &p);
		Data data;
		data.id = id++;
		data.city = name;
		data.point = p;
		da.push_back(data);
	}
	std::sort(da.begin(), da.end(), compare);
	for (int i = 0; i < da.size(); ++i) {
		printf("%d\n", da[i].id);
	}
	return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import collections

def solve(N,A) -> None:
    total = 0
    for a in A:
        total ^= a
    for a in A:
        print(total ^ a,end=" ")
    print()

def main():
    N = int(input())
    A = list(map(int,input().split()))
    # solve()
    solve(N,A)

if __name__ == "__main__":
    main()


Measured memory_bytes: 31888
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>

using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define ll long long

#define MAX_V 300

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

	int res = n * n - a;

	cout << res << endl;
	


	return (0);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

constexpr int DMAX = 20;
ll nl[DMAX][10];

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

  int cnt{};

  for (int i = 0; i != 10; ++i) {
    nl[0][i] = 1;
    if (i) cnt += nl[0][i];
    if (cnt == k) {
      cout << i << endl;
      return 0;
    }
  }

  int d, i;
  for (d = 1; cnt < k; ++d) {
    for (i = 0; i != 10; ++i) {
      nl[d][i] = nl[d - 1][i];
      if (i != 9) nl[d][i] += nl[d - 1][i + 1];
      if (i) {
        nl[d][i] += nl[d - 1][i - 1];
        cnt += nl[d][i];
      }
      if (cnt >= k) break;
    }
  }

  ll ans = 0;
  int newcnt;

  while(d) {
    --d;
    ans*=10;

    if (i != 9) {
      newcnt = cnt - nl[d][i+1];
      if (newcnt < k) { 
        i = i+1;
        ans += i;
        continue;
      }
      cnt = newcnt;
    }

    newcnt = cnt - nl[d][i];
    if (newcnt < k) {
      ans += i;
      continue;
    }
    cnt = newcnt;

    if (i) {
      newcnt = cnt - nl[d][i-1];
      if (newcnt < k) {
        i = i-1;
        ans += i;
        continue;
      }
      cnt = newcnt;
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
from_1 = set()
to_N = set()
for i in range(M):
  a, b = map(int, input().split())
  if a == 1:
    from_1.add(b)
  if b == N:
    to_N.add(a)

if len(from_1 & to_N) >= 1:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 18936
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 100000000

int dp[2][51][51][5001];

int main() {
	
	int N,K;
	cin>>N>>K;
	
	dp[0][0][0][2500] = 1;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<=N;j++){
			for(int k=0;k<=N;k++){
				for(int v=0;v<=5000;v++){
					if(dp[0][j][k][v]==0)continue;
					
					dp[1][j][k][v] = mod(dp[0][j][k][v] + dp[1][j][k][v]);
					
					if(j!=N&&k!=N){
						dp[1][j+1][k+1][v-2*(i+1)] = mod(dp[1][j+1][k+1][v-2*(i+1)] + dp[0][j][k][v]);
					}
					
					if(j!=0&&k!=0){
						dp[1][j-1][k-1][v+2*(i+1)] = mod(dp[1][j-1][k-1][v+2*(i+1)] + mod(j*k*dp[0][j][k][v]));
					}
					
					dp[1][j][k][v] = mod(dp[1][j][k][v] + mod(dp[0][j][k][v] * j));
					dp[1][j][k][v] = mod(dp[1][j][k][v] + mod(dp[0][j][k][v] * k));
 				}
			}
		}
		swap(dp[0],dp[1]);
		for(int j=0;j<=N;j++){
			for(int k=0;k<=N;k++){
				for(int v=0;v<=5000;v++){
					dp[1][j][k][v]=0;
				}
			}
		}
	}
	
	cout<<dp[0][0][0][K+2500]<<endl;
	
    return 0;
}


Measured memory_bytes: 101888
N,M,Q=map(int,input().split())
table=[[0]*(N+1) for i in range(N+1)]
ans=[]
for i in range(M):
    l,m=map(int,input().split())
    table[l][m]+=1
for i in range(Q):
    l,m=map(int,input().split())
    ans.append((l,m))

for i in range(N+1):
    for j in range(N):
        table[i][j+1]+=table[i][j]

for i in range(N+1):
    for j in range(N):
        table[j+1][i]+=table[j][i]

for l,m in ans:
    print(table[m][m]-table[l-1][m]-table[m][l-1]+table[l-1][l-1])

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

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

// 行列aの中身を半角スペース区切りで出力
template<typename T>
void outputMatrix(const std::vector<std::vector<T>>& a) {
	for (size_t i = 0; i < a.size(); ++i) {
		for (size_t j = 0; j < a[0].size(); ++j) {
			std::cout << a[i][j] << " ";
		}
		std::cout << std::endl;
	}
}

signed main() {
	int H, W, h, w;
	std::cin >> H >> W >> h >> w;

	// 割り切れるときはNo
	if (H%h == 0 && W%w == 0) {
		std::cout << "No" << std::endl;
		return 0;
	}

	// そうでなければYes, 実際に構成していく
	std::cout << "Yes" << std::endl;

	std::vector<std::vector<int>> a(H, std::vector<int>(W, 1)); // 1で埋める
	REP(i, H) {
		if (i % h != h - 1) continue;
		REP(j, W) {
			if (j % w != w - 1) continue;
			a[i][j] = -w*h; // 右下だけに-whを配置
		}
	}

	int S = 0; // 操作前の行列全体の和
	REP(i, H) REP(j, W) S += a[i][j];

	// 元の和が正なら操作を行う必要がないため出力しておわり
	if (S > 0) {
		outputMatrix(a);
		return 0;
	}

	// 操作を行う
	if (W%w != 0) {
		int i = h - 1;
		REP(j, W) {
			if (j%w == 0) a[i][j] += 1-S;
			if (j%w == w - 1) a[i][j] -= 1-S;
		}
	}
	else if (H%h != 0) {
		int j = w - 1;
		REP(i, H) {
			if (i%h == 0) a[i][j] += 1-S;
			if (i%h == h - 1) a[i][j] -= 1-S;
		}
	}

	// 出力しておわり
	outputMatrix(a);

	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define N 200010
#define MAX 1000000000000000000
#define MOD 1000000007

#include <stdio.h>

int main (void) {
    int h, a;

    scanf("%d %d", &h, &a);

    printf("%d", (h + a - 1) / a);

    return 0;
}



Measured memory_bytes: 1736