akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);  


int main(){
  ll n,  k;   cin >> n >> k;
  map<ll, ll> key;
  for(int i=0; i<n; i++){
    ll a, b;  cin >>a >> b;
    key[a] += b;
  }
  ll sum=0;
  for(auto x: key){
    sum += x.second;
    if(sum<k) continue;
    cout << x.first << endl;
    break; 
  }
}


Measured memory_bytes: 4224
/*input
6
*/
#include <bits/stdc++.h>

using namespace std;

const int N = 1004;

int a[] = {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
};

int main() {
  int n;
  scanf("%d", &n);
  printf("%d\n", a[n-1]);
  return 0;
}

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

int main(){
  string S,T;
  cin>>T;
  S="AKIHABARA";
  int N,e,f,ans;
N=T.size();
  e=0;
  for(int i=0;i<100;i++){
    if(i==9||i==8){
      if(e==N||(e==N-1&&T[e]=='A')){
        break;
      }
      else{
        cout<<"NO"<<endl;
        return 0;
      }
    }
    if(e==N){
      cout<<"NO"<<endl;
      return 0;
    }
  if(T[e]==S[i]){
    e++;
    continue;
  }
    else if(S[i]=='A'){
      continue;
    }
    else{
      cout<<"NO"<<endl;
      return 0;
    }
  }
      cout<<"YES"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

//#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}


int main() {
	int n;
	cin >> n;
	vector<int>vec(n);
	vecin(vec);
	sort(all(vec));
	cout << vec[n - 1] - vec[0] << endl;
}




Measured memory_bytes: 256
//#include <algorithm>
//#include <cassert>
//#include <cfloat>
//#include <cmath>
//#include <cstdio>
//#include <cstdlib>
//#include <deque>
#include <iostream>
//#include <limits>
//#include <map>
//#include <queue>
//#include <set>
//#include <stack>
//#include <string>
//#include <tuple>
//#include <unordered_map>
//#include <unordered_set>
//#include <vector>
using namespace std;

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int T[100000];
int main() {
  int N, C, K; scanf("%d%d%d", &N, &C, &K);
  for (int i{0}; i < N; ++i) scanf("%d", &T[i]);
  sort(T, T + N);

  int total{0};
  int i{0};
  while (i < N) {
    int count{1};
    int t = T[i];
    for (++i; i < N && T[i] == t; ++i) ++count;
    for (; REMAINDER(count, C) != 0 && i < N && T[i] <= t + K; ++i) ++count;
    total += DIVUP(count, C);
  }

  printf("%d\n", total);
  return 0;
}


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


int main(void){
   string S;
   cin >> S;
   
       if(S[2]==S[3]&&S[4]==S[5]) {
           cout << "Yes" << endl;
       }
       else {
           cout << "No" << endl;
       }
   
  
   
}




Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
#include<cmath>
using namespace std;
long long p  = 998244353;
//long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)
#define upper(h,val) upper_bound(h.begin(),h.end(),val)
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}
#define end_s(a) cout <<a<<endl;return 0
int reve(int n,vel &p) {
	int a = 1, b = 1;
	for (int i = 0; p[i] * p[i] * p[i] <= n; i++) {
		if (n%p[i] == 0) {
			n /= p[i];
			if (n%p[i] == 0) { b *= p[i]; n /= p[i]; }
			else { a *= p[i]; }
		}
	}
	if (n != 1) {
		int m = sqrt(n);
		rep(i, 3) {
			if ((m - 1 + i)*(m - 1 + i) == n) { b *= (m-1+i); n = 1; }
		}
	}
	a *= n;
	if (a > 1000000) { return -1; }
	return a * a*b;
}
signed main(){
	int n; cin >> n;
	vel s(n);
	rep(i, n) {
		cin >> s[i];
		for (int j = 2; j*j*j <= s[i]; j++) {
			while (s[i] % (j*j*j) == 0) {
				s[i] /= (j*j*j);
			}
		}
	}
	sor(s);
	vel t(1, s[0]);
	rep(i, n - 1) {
		if (s[i + 1] != s[i]) { t.push_back(s[i+1]); }
	}
	int sz = t.size();
	vel co(sz);
	rep(i, sz) {
		co[i] = upper(s, t[i]) - lower(s, t[i]);
	}
	vel pr;
	for (int i = 2; i <= 3000; i++) {
		bool fl = true;
		for (int j = 2; j*j <= i; j++) {
			if (i%j == 0) { fl = false; }
		}
		if (fl) { pr.push_back(i); }
	}
	int ans = n;
	if (t[0] == 1) { ans -= (co[0] - 1); }
	rep(i, sz) {
		if (t[i] != 1) {
			int re1 = reve(t[i],pr);
			int ind = lower(t, re1)-t.begin();
			if (i<ind &&ind < sz) {
				if (re1 == t[ind]) {
					ans -= min(co[i], co[ind]);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
	string str;
	int n;
	getline( cin, str );
	sscanf( str.c_str(), "%d", &n );

	for( int i=0; i<n; i++ ){
		int out = 0;
		int score = 0;
		bool first=false, second=false, third=false;

		while( out < 3 ){
			getline( cin, str );
			if( str == "HIT" ){
				if(third){ score++; third=false; }
				if(second){ third=true; second=false; }
				if(first){ second=true; first=false; }
				first = true;
			}
			else if( str == "HOMERUN" ){
				if(third){ score++; third=false; }
				if(second){ score++; second=false; }
				if(first){ score++; first=false; }
				score++;
			}
			else if( str == "OUT" ){
				out++;
			}
		}
		cout << score << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int a[26]={};
  int i;

  cin>>str;
  rep(i,str.size())
    a[str[i]-'a']++;
  rep(i,26)
    if(a[i]%2){
      cout<<"No"<<endl;
      return 0;
    }
  cout<<"Yes"<<endl;

}


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

int main(){
  long int A,B,K;
  cin >> A >> B >> K;
  int count = 1;

  for(int i = A; i <= B; i++){
   if(count <= K) cout << i << endl;
   else if(count > B - A + 1 - K) cout << i << endl;
   count++; 
  }
  return 0;
}

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

int main(){
  int N, M; cin >> N >> M;
  long long sum = 0;
  vector<int> vec;
  rep(i, N) {
    int A; cin >> A;
    sum += A;
    while (A != 0) {
      int nA = A / 2;
      vec.push_back(A - nA);
      A = nA;
    }
  }

  sort(vec.begin(), vec.end(), greater<int>());
  
  M = min(M, (int)vec.size());
  rep(i, M) sum -= vec[i];

  cout << sum << endl;
}

Measured memory_bytes: 18792
import java.text.*;
import java.math.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int kaisu = 1;
		double[] num = new double[kaisu];

		for(int i = 0; i < kaisu; i++) {
			num[i] = scan.nextDouble();
		}
		double pai = 3.14159265358979;
		double ensyu = pai * 2 * num[0];
		double menseki = num[0] * num[0] * pai;

		DecimalFormat df = new DecimalFormat();
		df.applyPattern("0");
		df.setMaximumFractionDigits(6);
		df.setMinimumFractionDigits(6);

		String e = df.format(ensyu);
		String m = df.format(menseki);
		System.out.println(m + " " + e);
	}
}

Measured memory_bytes: 18592
#include <bits/stdc++.h>
using namespace std;
#define MAX 100005

//構造体の型宣言
typedef struct pp {
	char s[100];
	int t;
} P;
//構造体と変数設定
P Q[MAX];
int head, tail, N;
//headとtailを0にしてqueueを空にする
void initialize() {
	head = 0;
	tail = 0;
	return;
}
//queueが空か調べる
bool isEmpty() {
	if (head == tail) return 1;
}
//queueが満杯か調べる
bool isFull() {
	if (head == tail % MAX) return 1;
}
//queueのtailに要素追加(直線の配列ver.)
void enqueue(P x) {
	//エラー吐くif (isFull) return;
	Q[tail] = x;
	if (tail + 1 == MAX) tail = 0;
	else tail++;
	return;
}
//queueのheadから要素抽出(直線の配列ver.)
P dequeue() {
	//エラー吐くif (isEmpty) return;
	P x = Q[head];
	if (head + 1 == MAX) head = 0;
	else head++;
	return x;
}
int main() {
	int elaps = 0;
	int q, dif;
	P u;
	scanf("%d %d", &N, &q);
	for (int i = 1; i <= N; i++) {
		scanf("%s", Q[i].s);
		scanf("%d", &Q[i].t);
	}
	head = 1; tail = N + 1; 
	while (head != tail) {
	 	u = dequeue();
	 	dif = min(q, u.t);
	 	u.t -= dif;
	 	elaps += dif;
	 	if (u.t > 0) enqueue(u);
	 	else printf("%s %d\n", u.s, elaps);
	}
	return 0;
}



Measured memory_bytes: 13364
fun main(args: Array<String>) {
    // Your code here!
    var (a,b) = readLine()!!.split(" ").map{it.toInt()}
    var str = ""

    if(a <= b){
        str = a.toString().repeat(b)
    }else{
        str = b.toString().repeat(a)
    }
    
    print(str)    
}


Measured memory_bytes: 37816
import sys
from collections import Counter
import heapq


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    Cnt = Counter(A)
    V = list(Cnt.values())
    heap = []
    for v in V:
        heapq.heappush(heap, -1 * v)
    if len(heap) == 1:
        print(1)
        return
    while heap:
        a = heapq.heappop(heap)
        if a == -1:
            print(-1 * sum(heap) + 1)
            return
        b = heapq.heappop(heap)
        heapq.heappush(heap, a + 1)
        heapq.heappush(heap, b + 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 18656
#include<stdio.h>
int main(){
  int H,W,x,y,r;
  scanf("%d %d %d %d %d",&H,&W,&x,&y,&r);
  if((x-r)>=0&&(x+r)<=H&&(y-r)>=0&&(y+r)<=W){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  int B[M];
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int ans = 0, A;
    for (int j = 0; j < M; j++) {
      cin >> A;
      ans += A*B[j];
    }
    ans += C;
    if (ans > 0) sum++;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <map>

using namespace std;

typedef long long ll;

const int maxn=1e5+10;

ll a[maxn];

int main()
{
    //freopen("/Users/qianjay/Documents/apac/in", "r", stdin);
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%lld",&a[i]);
    
    int res=1;
    int j=0;
    a[j++]=a[0];
    for(int i=1;i<n;i++)
    {
        if(a[i]==a[i-1]) continue;
        a[j++]=a[i];
    }
    n=j;
    for(int i=2;i<n;i++)
    {
        if(a[i]-a[i-1]>0&&a[i-1]-a[i-2]<0)
        {
            res++;
            i++;
        }
        else if(a[i]-a[i-1]<0&&a[i-1]-a[i-2]>0)
        {
            res++;
            i++;
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
x = []
y = []
z = []
for i in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    z.append(c)

ans = -1e18
for i in range(-1, 2, 2):
    for j in range(-1, 2, 2):
        for k in range(-1, 2, 2):
            v = []
            for l in range(n):
                v.append(x[l] * i + y[l] * j + z[l] * k)
            v.sort()
            v.reverse()
            now = 0
            for l in range(m):
                now += v[l]
            ans = max(ans, now)

print(ans)


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

int main()
{
ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
#endif

	int n;
	cin>>n;


	

	

	map<string,int> mp;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		mp[s]++;
		
	}

	int c=INT_MIN;

	for(auto i:mp)
	{
		c=max(c,i.second);
	}

	

	for(auto i:mp)
	{
		if(i.second==c)
		{
			cout<<i.first<<endl;
		}
		
	}



	return 0;
}

Measured memory_bytes: 19176
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
signed main(){
  init_io();
  ll n,a,b,c,d;
  bool can = false;
  cin >> n >> a >> b >> c >> d;
  for(int i=0;i<n;i++){
    ll left=(-d)*i+(n-1-i)*c;
    ll right=(-c)*i+(n-1-i)*d;
    if(left<=b-a&&b-a<=right){
      can = true;
      break;
    }
  }
  if(can){
    cout <<"YES\n";
  }else{
    cout <<"NO\n";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define all(x) (x).begin(), (x).end()
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007ll

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(15)
  int n;
  cin >> n;
  int countmax = 0, cnt = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a == b) cnt++;
    else {
      countmax = max(countmax, cnt);
      cnt = 0;
    }
  }
  countmax = max(countmax, cnt);
  cout << (countmax >= 3 ? "Yes" : "No") << endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int main(void){
    int K, T; cin >> K >> T;
    vi a(T); for(auto & e : a) cin >> e;

    if(T == 1){
        cout << K - 1 << endl;
        return 0;
    }

    int pi = -1;
    int res = 0;
    rep(i, K){
        int mi = max_element(_all(a)) - begin(a);
        int tmp = a[mi];
        a[mi] = -1;
        int nmi = max_element(_all(a)) - begin(a);
        a[mi] = tmp;

        if(mi == pi and a[nmi] > 0) mi = nmi;
        if(mi == pi) res++;

        a[mi]--;
        pi = mi;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)

point = 0
point += b[a[0]-1]
index = a[0]-1

(1..n-1).each do |i|
  point += b[a[i]-1]
  if a[i]-1 == index+1
    point += c[index]
  end
  index = a[i]-1
end

print point

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
#define PII pair<int, int>

void add(int &a, int b) {
    a += b;
    while(a >= MOD) {
        a -= MOD;
    }
    while(a < 0) {
        a += MOD;
    }
}

int det(PII a, PII b, PII c) {
    return a.first * b.second + b.first * c.second + c.first * a.second - b.first * a.second - c.first * b.second - a.first * c.second;    
};

int main() {
    int n; cin >> n;
    vector<pair<int, int>> p(n);
    
    for(int i = 0; i < n; ++i)
        cin >> p[i].first >> p[i].second;

    sort(p.begin(), p.end());
    
    vector<int> two(n + 1, 1);
    for(int i = 1; i <= n; ++i) {
        two[i] = 2LL * two[i - 1] % MOD;
    }
    
    int ans = two[n];
    add(ans, -1);
    add(ans, -n);
    add(ans, -(n * (n - 1) / 2));
    
    map<pair<int, int>, int> have;

    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < n; ++j) {
            int many = 0;
            
            vector<int> who;

            for(int k = 0; k < n; ++k) {
                if(det(p[i], p[j], p[k]) == 0) {
                    many += 1;
                    if(who.size() < 2) {
                        who.push_back(k);
                    }
                }
            }

            if(have[make_pair(who[0], who[1])])
                continue;
            have[make_pair(who[0], who[1])] = 1;
            
            int temp = (MOD - (two[many] - 1)) ;
            add(temp, many);
            add(temp, (many * (many - 1) / 2));
            add(ans, temp);
        }
    }

    cout << ans << "\n";
}

Measured memory_bytes: 1536
h,w=map(int,input().split())
lists=[list(input()) for i in range(h)]
visited=[[False for i in range(w)] for j in range(h)]
from collections import deque

ans=0
dif=[(-1,0),(1,0),(0,-1),(0,1)]

def solve(i,j):
    global ans 
    ans=ans
    black=0
    white=0
    if visited[i][j]==False:
        if lists[i][j]=="#":
            black+=1
        else:
            white+=1
        visited[i][j]=True
        
    d=deque()
    e=deque()
    d.append((i,j))
    while d:
        while d:
            p=d.popleft()
            x,y=p
            color=lists[x][y]
            for que in dif:
                dx,dy=que
                if 0<=dx+x<h and 0<=dy+y<w:
                    if visited[dx+x][dy+y]==False and lists[dx+x][dy+y]!=color:
                        visited[dx+x][dy+y]=True
                        e.append((dx+x,dy+y))
                        if color=="#":
                            white+=1
                        else:
                            black+=1
        if e:
            d=e
            e=deque()
    ans+=(white)*(black)
flag=True
while flag:
    sub=False
    for i in range(h):
        for j in range(w):
            if visited[i][j]==False:
                solve(i,j)
                sub=True
    if sub==False:
        flag=False
print(ans)
              


Measured memory_bytes: 82608
#include<stdio.h>
#include<stdlib.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
typedef long l;
typedef unsigned long long u;
int x(const void *a,const void *b){return *(l*)a<*(l*)b?-1:*(l*)a==*(l*)b?0:1;}
int main(void){
	l n;
	scanf("%ld",&n);
	l r[n];
	l i;
	for(i=0;i<n;i++)scanf("%ld",&r[i]);
	qsort(r,n,sizeof(l),x);
	u c[n];
	c[0]=r[0];
	for(i=1;i<n;i++)c[i]=c[i-1]+r[i];
	l a=1;
	for(i=n-2;i>=0&&c[i]*2>=(u)r[i+1];i--)a++;
	printf("%ld",a);
	return 0;
}


Measured memory_bytes: 1788
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>

using namespace std;
#define INF 100100100100

#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;
typedef pair<ll, ll> PI;

void solve(ll n) 
{
    if(n == 0) { return; }
    //cout << n%2 << endl; cout << n/-2 << endl;
    if(!(n%2)) {
        solve(n/-2);
        cout << "0";
    } else {
        solve((n-1)/-2);
        cout << "1";
    }
}


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

    if(n == 0) { cout << "0" << endl; }
    else       { solve(n); }

    return 0;
}


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

int main() {
	int cnt = 0, a , i;
	long long N;
	cin >> N;
	vector<char> x(100);

	for (int i = 0; N>0; i++)
	{
		a = N % 26;
		if (a == 0)a = 26;
		x.insert(x.begin(), 96 + a);
		if (N % 26 == 0) {
			N--;
			N /= 26;
		}
		else {
			N /= 26;
		}
		cnt++;
	}
	for (i = 0; i < cnt; i++) {
		cout << x[i];
	}

	return 0;
}

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

int main(){
  string s;
  cin >> s;
  s+='a';
  int cntzero=0;
  int cntone=0;
  
  for(int i=0; i<s.size(); i++){
    if(s.at(i)=='0') cntzero++;
    else if(s.at(i)=='1') cntone++;
  }
  if(cntzero==0 || cntone ==0) cout << 0 << endl;
  else if(cntzero>cntone) cout << cntone*2 << endl;
  else cout << cntzero*2 << endl;
  return 0;
}

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

using namespace std;

int mp[110][110],x=1,y=1,h,w;

int paint(int color,int area){
	int i;
	for(i=0; i<area; i++){
		 mp[x][y]=color;
		 if(y%2==1){
		 	x++;
		 	if(x>h){
		 		x--;
		 		y++;
		 	}
		 }else{
		 	x--;
		 	if(x<1){
		 		x++;
		 		y++;
		 	}
		 }
	}
	return 0;
}

int main(void){
	int n,i,j,a;
	fill(mp[0],mp[110],0);
	cin >> h >> w >> n;
	for(i=1; i<=n; i++){
		cin >> a;
		paint(i,a);
	}
	for(i=1; i<=h; i++){
		for(j=1; j<w; j++){
			cout << mp[i][j] << " ";
		}
		cout << mp[i][w] << endl;
	}
	return 0;
}

Measured memory_bytes: 384
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(((a*3)+b)/2);

    }
}


Measured memory_bytes: 35628
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
using namespace std;
const int MAX=1005,VMAX=10005;
int a[1005],b[1005];
int T[10005];
bool v[1005];
int main()
{
    int n;
    cin>>n;
    int s=VMAX+5,ans=0;
    for(int i=0;i<n;i++)cin>>a[i],b[i]=a[i],s=min(s,a[i]);
    sort(b,b+n);
    for(int i=0;i<n;i++)T[b[i]]=i;      //构造Cytle的必要方法
    for(int i=0;i<n;i++)
    {
        if(v[i])continue;
        int an=0;
        int sn=0;
        int m=VMAX+1;
        int cur=i;
        while(1)
        {
            v[cur]=true;
            an++;
            int V=a[cur];
            m=min(m,V);
            sn+=V;
            cur=T[V];
            if(v[cur])break;
        }
        ans+=min(sn+(an-2)*m,m+sn+(an+1)*s);
    }
    cout<<ans<<endl;
    return 0;
}
//4 3 1 2 5



Measured memory_bytes: 3176
// https://atcoder.jp/contests/abc134/tasks/abc134_d

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
// ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// ll lcm(long a, long b) { return a * b / gcd(a, b); }

inline int read() {
    int out = 0, fh = 1;
    char jp = getchar();
    while ((jp > '9' || jp < '0') && jp != '-')
        jp = getchar();
    if (jp == '-')
        fh = -1, jp = getchar();
    while (jp >= '0' && jp <= '9')
        out = out * 10 + jp - '0', jp = getchar();
    return out * fh;
}

int a[200001];
bool b[200001];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = n; i >= 1; i--) {
        int x = a[i];
        for (int j = i << 1; j <= n; j += i) {
            x ^= b[j];
        }
        b[i] = x;
        if (x)
            ans++;
    }
    printf("%d\n", ans);
    for (int i = 1; i <= n; i++) {
        if (b[i])
            printf("%d ", i);
    }

    return 0;
}


Measured memory_bytes: 1920
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
      int N = scan.nextInt();
      int K = scan.nextInt();
      int[] pn = new int[N];
      int result = 0;
      
      for(int i=0; i<N; i++){
        pn[i] = scan.nextInt();
      }
      Arrays.sort(pn);
      for(int i=0; i<K; i++)
        result += pn[i];
      System.out.println(result);
    }
}


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

using namespace std;

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<lli, lli> pi;

int main()
{
    lli pw[15];
    pw[0] = 1;
    for(int i=1; i<15; i++){
        pw[i] = pw[i-1]*10;
    }
    vector<string> v, u, w;
    vector<lli> vec;
    for(int i=1; i<10; i++){
        string s = "";
        char c = '0'+i;
        s+=c;
        v.push_back(s);
        w.push_back(s);
    }

    while(v.size() < 100010){
        for(int i=0; i<w.size(); i++){
            char c = w[i].back();
            int in = c - '0';
            for(int x=in-1; x<in+2; x++){
                if(x>=0 && x<=9){
                    c = '0'+x;
                    u.push_back(w[i]+c);
                }
            }
            if(v.size()+u.size() > 100010)
                break;
        }
        w.clear();
        for(int i=0; i<u.size(); i++){
            v.push_back(u[i]);
            w.push_back(u[i]);
        }
        u.clear();
        //cout << v.size() << endl;
    }
    for(int i=0; i<v.size(); i++){
        string s = v[i];
        reverse(s.begin(), s.end());
        lli x = 0;
        for(int j=0; j<s.size(); j++){
            lli y = s[j] - '0';
            x += y*pw[j];
        }
        vec.push_back(x);
    }
    sort(vec.begin(), vec.end());
    //cout << vec.size() << endl;


    int n;
    cin >> n;
    cout << vec[n-1] << endl;

    return 0;
}


Measured memory_bytes: 9832
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        char[] d = S.toCharArray();
        for (int i = 0; i < d.length - 1; i++) {
            if (d[i] == d[i+1]) {
                System.out.printf("%d %d\n", i+1, i+2);
                return;
            }
        }
        for (int i = 0; i < d.length - 2; i++) {
            if (d[i] == d[i+2]) {
                System.out.printf("%d %d\n", i+1, i+3);
                return;
            }
        }
        System.out.printf("%d %d\n", -1, -1);
    }
}


Measured memory_bytes: 27412
package main

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

func main() {
	var n, m int
	fmt.Scan(&n)
	fmt.Scan(&m)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	min := 0
	max := n
	for i := 0; i < m; i++ {
		scanner.Scan()
		l, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		r, _ := strconv.Atoi(scanner.Text())

		if l > min {
			min = l
		}
		if r < max {
			max = r
		}
	}

	ret := max - min + 1
	if ret < 0 {
		ret = 0
	}
	fmt.Println(ret)
}


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

ll binexp(ll a, ll b){
    ll res = 1;
    while(b){
        if(b&1){
            res = res*a;
            b--;
        }
        a = a*a;
        b/=2;
    }
    //res = res*a;
    return res;
}

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

    //good luck kittu!
    ll h, x; cin>>h;
    x = ceil(log2(h+1));
    x = binexp(2, x) - 1;
    cout<<x<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int a, b;
    a = stoi(s);
    b = a % 100;
    a = a / 100;
  
    if ( (a >= 1 && a <= 12) && (b >= 1 && b <= 12) ) {
        cout << "AMBIGUOUS";
    } else if (a >= 1 && a <= 12) {
        cout << "MMYY";
    } else if (b >= 1 && b <= 12) {
        cout << "YYMM";
    } else {
        cout << "NA";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
#define ESP 1e-10
int main(void){
  double x1,x2,x3,x4;
  double y1,y2,y3,y4;
  while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4){
    cout << (abs((x2-x1) * (x4-x3) + (y2-y1) * (y4-y3))<ESP?"YES":"NO")<<endl;
  } 
  return 0;
}

Measured memory_bytes: 1216
A, B, C, X = 4.times.map{gets.to_i}
ans = 0
0.upto(A){|a| 0.upto(B){|b| 0.upto(C){|c|
    ans += 1 if a * 500 + b * 100 + c * 50 == X
    }}}
puts ans

Measured memory_bytes: 1788
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #
    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    ans=0
    for i in range(1,n):
        diff = arr[i-1]-arr[i]
        if diff > 0:
            ans+=diff
            arr[i]+=diff
    print(ans)
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 40284
import java.util.*;

public class Main {
	static Map<Long, Long> map = new TreeMap<Long, Long>(); // key:金額,val:本数

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		for (int i = 0; i < N; i++) {
			long a = sc.nextInt();
			long b = sc.nextInt();
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + b);
			} else {
				map.put(a, b);
			}
		}
		sc.close();

		long ans = 0;
		int cnt = 0;

		for (Map.Entry<Long, Long> en : map.entrySet()) {
			long price = en.getKey();
			long num = en.getValue();

			for (int i = 0; i < num; i++) {
				if (cnt < M) {
					ans += price;
					cnt++;
				} else {
					break;
				}
				}
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 68160
# -*- coding: utf-8 -*-

import sys
import subprocess
import json
import time
import math
import re
import sqlite3

N, M = map(int, input().split())
l = []
for i in range(N):
    l.append(0)

for i in range(M):
    a, b = map(int, input().split())
    a -= 1; b -= 1;
    l[a] += 1
    l[b] += 1

for i in range(N):
    print(l[i])




Measured memory_bytes: 4680
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    int a[1005];
    int b[1005];
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    int sum=0;
    for(int i=0; i<n; i++)
    {
        sum+=a[i];
        b[i]=sum;
    }
    int  k=100005;
    for(int i=0; i<n; i++)
    {
       k=min(k,abs(sum-b[i]-b[i]));
    }
    printf("%d\n",k);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const long long inf=1e18+1;
int n,k;
int a[200001];
bool judge(long long x)
{
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]<0)
		{
			int tmp=x/a[i];
			if(x>0&&abs(x)%a[i]!=0)
				tmp--;
			int sum=n-max(i,(long long)(upper_bound(a+1,a+n+1,tmp-(abs(x)%abs(a[i])==0))-a-1));
			ans+=max(0ll,sum);
		}
		else if(a[i]>0)
		{
			int tmp=x/a[i];
			if(x<0&&abs(x)%a[i]!=0)
				tmp--;
			int sum=upper_bound(a+1,a+n+1,tmp)-a-1;
			ans+=max(0ll,sum-i);
		}
		else if(a[i]==0)
		{
			if(x>=0)
				ans+=n-i;
		}
	}
	return ans>=k;
}
signed main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	long long l=-inf-1,r=inf+1;
	while(l+1<r)
	{
		long long mid=(l+r)/2;
		if(judge(mid))
			r=mid;
		else
			l=mid;
	}
	printf("%lld",r);
	return 0;
}
/*
4 6
-1 0 1 2
*/

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1 << 29;
/****** define constant end ********/
/****** define variable start ******/
ll n;
/******* define variable end *******/
int solve() {
	cin >> n;
	ll ans = 0;
	REP(i, n+1){
		if(i % 3 != 0 && i % 5 != 0){
			ans += i;
		}
	}
	cout << ans << endl;
	return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


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

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



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

int main(){
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    for(ll m=0; m<=N-1; m++){
        if(C*(N-1-m)-D*m <= B-A && B-A <= -C*m+(N-1-m)*D){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}



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

int main() {
    double x1, y1, x2, y2;
    scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
    printf("%.8lf\n", hypot(x1 - x2, y1 - y2));
    return 0;
}


Measured memory_bytes: 2104
S = list(input())
S_after = []
for i in S:
    if i == '1':
        S_after.append('1')
    elif i == '0':
        S_after.append('0')
    elif i == 'B':
        if S_after == []:
            pass
        else:
            S_after.pop()
print(''.join(S_after))

Measured memory_bytes: 8736
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){

    int s,k;
    cin >> k >> s;

    int cnt = 0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            int m = s-i-j;
            if(0<=m && m<=k) cnt++;
        }
    }

    cout << cnt << endl;

   return 0;
}

Measured memory_bytes: 256
n,x=map(int,input().split())
a=[]
for i in range(n):
    m=int(input())
    a.append(m)
count=0
if x>=sum(a):
    count+=n
    x-=sum(a)
while x>=min(a):
    count+=1
    x-=min(a)
print(count)

Measured memory_bytes: 3064
#include <iostream>

int main(){
	int x,j=0;
	std::cin>>x;
	for(int i=1;i<=x;i++){
		x-=i;
		j++;
	}
	if(x==0)
	std::cout<<j<<std::endl;
	else 
	std::cout<<j+1<<std::endl;
	return 0;
}

Measured memory_bytes: 256
tem = []
for i in range(5):
    tem.append(int(input()))
    
t = 0
if (tem[0]<0):
    t += (0-tem[0])*(tem[2])
    t += tem[3]
    t += tem[1]*(tem[4])
elif (tem[0]>0):
    t += (tem[1] - tem[0])*(tem[4])
print(t)


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>

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

typedef long long ll;

using namespace std;

int main() {
    
    vector<int> s(3);
    
    FOR(i, 0, 3){
        cin >> s[i];
    }
    
    int k;
    cin >> k;
    
    sort(s.begin(),s.end());
    
    int ans = s[0] + s[1] + pow(2,k) * s[2];
    
    cout << ans << endl;
    
    
    return 0;
}


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

int main()
{
  int H, W;
  vector<vector<int>> a(50, vector<int>(50, 0));
  vector<string> s(50);

  cin >> H >> W;
  for (int i = 0; i < H; i++)
  {
    cin >> s[i];
    for (int j = 0; j < W; j++)
    {
      if (s[i][j] == '#')
      {
        if (i != 0)
        {
          if (j != 0)
            a[i - 1][j - 1]++;
          a[i - 1][j]++;
          if (j != W - 1)
            a[i - 1][j + 1]++;
        }
        if (j != 0)
          a[i][j - 1]++;
        if (j != W - 1)
          a[i][j + 1]++;
        if (i != H - 1)
        {
          if (j != 0)
            a[i + 1][j - 1]++;
          a[i + 1][j]++;
          if (j != W - 1)
            a[i + 1][j + 1]++;
        }
      }
    }
  }
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (s[i][j] == '#')
        cout << '#';
      else
        cout << a[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
program ABC108B
    implicit none
    integer(8)::x1,x2,x3,x4,y1,y2,y3,y4,x_diff,y_diff

    read(5,*)x1,y1,x2,y2

    x_diff=x2-x1
    y_diff=y2-y1

    x3=x2-y_diff
    y3=y2+x_diff
    x4=x3-x_diff
    y4=y3-y_diff

    print'(i0,1x,i0,1x,i0,1x,i0)',x3,y3,x4,y4
    
end program ABC108B

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}
bool comp(pair<ll,ll>a,pair<ll,ll>b)
{
    if(a.fi==b.fi)return a.se>b.se;
    return a.fi>b.fi;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll n,m,x; cin>>n>>m>>x;
vvi g(n,vi(m));
vi arr(n);
ll ans = 1e18;
rep(i,0,n)
{
    cin>>arr[i];
    rep(j,0,m)cin>>g[i][j];
}
rep(i,0,(1<<n))
{
    vi res(m,0);
    ll cost = 0;
    rep(j,0,n)
    {
        if((1<<j)&i)
        {
            cost+=arr[j];
            rep(k,0,m)res[k]+=g[j][k];
        }
    }
    bool flag = true;
    rep(i,0,m)if(res[i]<x)flag = false;
    if(flag)ans = min(ans,cost);
}
if(ans==1e18)cout<<-1<<endl;
else cout<<ans<<endl;
return 0;
}


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

int main(){
    string s, t, ans;
    cin >> s >> t;
    vector<int> v;
    for(int i=0; i<(int) s.size() - (int) t.size() + 1; i++){
        for(int j=0; j<(int) t.size(); j++){
            if(s[i+j] != '?' && s[i+j] != t[j]){
                break;
            }
            if(j == (int) t.size() - 1){
                v.push_back(i);
            }
        }
    }

    if(v.empty()){
        cout << "UNRESTORABLE\n";
    }else{
        string array[v.size()];
        
        for(int i=0; i<(int) v.size(); i++){
            array[i] = s;
            for(int j=0; j<(int) t.size(); j++){
                array[i][v[i]+j] = t[j];
            }

            for(int j=0; j<(int) s.size(); j++){
                if(array[i][j] == '?'){
                    array[i][j] = 'a';
                }
            }
        }

        ans = array[0];
        for(int i=0; i<(int) v.size(); i++){
            if(ans > array[i]){
                ans = array[i];
            }
        }

        cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int A,B,C,D;
    cin>>A>>B>>C>>D;
    while(A !=0 || C != 0)
    {
       C = C - B;
       if(C <= 0)
       { 
         cout<<"Yes";
         break;
       }
       A = A - D;
       if(A <= 0)
       { 
         cout<<"No";
         break;
       }
    } 
    return 0;
}

Measured memory_bytes: 3636
n = gets.to_i
a_array = gets.split(" ").map(&:to_i).sort.reverse
alice = []
bob = []

a_array.each.with_index(1) do |a, i|
  if i.odd?
    alice << a
  else
    bob << a
  end
end

p alice.inject(&:+) - bob.inject(&:+)

Measured memory_bytes: 1788
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,K = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))
uf = UnionFind(N)
ans = -10**9
for i in range(N):
    uf.union(i,P[i]-1)
for group in uf.all_group_members().values():
    size = len(group)
    SUM = 0
    for i in group:
        SUM += C[i]
    if SUM < 0:
        SUM = 0
    for i in group:
        cur = i
        current_sum = 0
        remain = K
        for _ in range(size):
            cur = P[cur]-1
            current_sum += C[cur]
            remain -= 1
            if remain < 0:
                break
            ans = max(ans,current_sum+SUM*(remain//size))
print(ans)

Measured memory_bytes: 75392
import numpy as np

N,D = map(int, input().split())
P = []
for i in range(N):
  *X, = map(int, input().split())
  P.append(np.array(X))

ans = 0
for j in range(1,N):
  for i in range(j):
    tmp = (P[i] - P[j])
    tmp2 = np.sqrt(np.dot(tmp,tmp))
    #print(tmp2, tmp2.is_integer())
    if (tmp2.is_integer()):
      ans += 1
print(ans)


Measured memory_bytes: 21500
#include <stdio.h>

const int mod = 1000000007;
long long int dp[2][3];

int main(){
  int i, j;
  long long int n;
  scanf("%lld", &n);

  dp[0][0] = 1;
  for(i = 0; n; n >>= 1, i^=1){
    int z = (n & 0x1) << 1;

    dp[i^1][0^z] = dp[i][0^z];
    dp[i^1][1] = 2*(dp[i][0^z] + dp[i][1]) + dp[i][2^z];
    dp[i^1][2^z] = dp[i][1] + 2*dp[i][2^z];

    dp[i^1][0] %= mod;
    dp[i^1][1] %= mod;
    dp[i^1][2] %= mod;
  }
  printf("%lld\n", dp[i][0]);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>//
#define ll long long
using namespace std;
int main()
{
   ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long n,k,len;
    string s;
    cin>>k>>s;
    len=s.length();
    if(k>=len)
        cout<<s<<endl;
    else{
    for(int i=0;i<k;i++)
        cout<<s[i];
        cout<<"..."<<endl;

    }

    return 0;
}




Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <regex>

using namespace std;

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

    bool ok = true;
    int c_cnt = 0;

    for(int i=0; i<S.size(); i++) {
        if(i==0) {
            if ( S[i] != 'A') {
                ok = false;
            }
        } else if(i >= 2 && i <= S.size()-2) {
            if (S[i] == 'C') {
                c_cnt ++;
            } else if ( (S[i] < 'a') || (S[i] > 'z') ) {
                ok = false;
            }
        } else {
            if ( (S[i] < 'a') || (S[i] > 'z') ) {
                ok = false;
            }
        }
    }

    if(c_cnt != 1) {
        ok = false;
    }

    cout << (ok ? "AC" : "WA") << endl;
}


Measured memory_bytes: 256
#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>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;
int main(){
    int n,ans=0;cin>>n;
    multiset<ll> s;
    vi v(n);
    rep(i,n)cin>>v[i];
    rep(i,n){
        auto it=s.lower_bound(v[i]);
        if(it==s.begin())ans++;
      else {
        it--;
        s.erase(it++);
      }
      s.insert(v[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5760