akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll a[n+1];
	for(ll i=0;i<=n;i++){
		cin>>a[i];
	}
	if(n==0){
		if(a[n]==1) cout<<1;
		else cout<<-1;
		return 0;
	}
	ll sum[n+1];
	sum[n]=a[n];
	for(ll i=n-1;i>=0;i--){
		sum[i] = sum[i+1]+a[i];
	}
	ll node[n+1];
	node[0]=1;
	for(ll i=1;i<=n;i++){
		node[i] = min(sum[i] , (node[i-1]-a[i-1])*2);
		if(node[i]<0){
			cout<<-1;
			return 0;
		}
	}
	if(node[n]!=a[n]) {
		cout<<"-1";
		return 0;
	}
	ll ans=0;
	for(ll i=0;i<=n;i++) ans+=node[i];
	cout<<ans;
	
 	
	
	return 0;
}

Measured memory_bytes: 5984
#include <cstdio>
#include <map>
using namespace std;

map<long long, bool> mp;
int main()
{
	int n, cnt = 0;
	long long id;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{ 
		scanf("%lld", &id);
		if (mp.find(id) == mp.end())
		{
			mp[id] = true;
			cnt++;
		}
		else
		{
			if (mp[id] == true)
			{
				mp[id] = false;
				cnt--;
			}
			else
			{
				mp[id] = true;
				cnt++;
			}
		}
	}
	printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 6528
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

const int INF = 0x7fffffff;
const int N = 2005;
int n, a[N<<1], t, dp[N][N], g[N<<1][N<<1];
char c;

int cal(int x, int b, int w){
    return g[x][b] - g[x-1][b] + g[x][w] - g[x][n] - g[x-1][w] + g[x-1][n];
}

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n << 1; i++){
        scanf("%s%d", &c, &a[i]);
        if(c == 'W')    a[i] += n;
        for(int j = 1; j < i; j++)
            g[a[j]][a[i]] = 1;
    }
    for(int i = 1; i <= n << 1; i++)
        for(int j = 1; j <= n << 1; j++)
            g[i][j] += g[i-1][j] + g[i][j-1] - g[i-1][j-1];
    memset(dp, 0x7f, sizeof dp);
    dp[0][0] = 0;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            if(!i && !j)    continue;
            dp[i][j] = min(i ? dp[i-1][j] + cal(i, i, j+n) : INF, j ? dp[i][j-1] + cal(j+n, i, j+n) : INF);
        }
    }
    printf("%d\n", dp[n][n]);
    return 0;
}


Measured memory_bytes: 78720
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/




int main() {
int N;
cin>>N;
vector<pair<ll,ll>> table(N);
map<pair<ll,ll>,int> count;
rep(i,N){
  ll x,y;
  cin>>x>>y;
  table[i]=make_pair(x,y);
}
rep(i,N){
  rep(j,N){
    if(i==j)continue;
    count[make_pair(table[i].first-table[j].first,table[i].second-table[j].second)]++;

  }
}
int max_=0;
rep(i,N){
  rep(j,N){
    if(i==j)continue;
    max_=max(max_,count[make_pair(table[i].first-table[j].first,table[i].second-table[j].second)]);

  }
}
cout<<N-max_<<endl;
return 0;
}

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

class Point implements Comparable<Point>{
    public int x,y;
    public int color;
    public static int red=0,
                      blue=1;
    
    public Point(int x, int y, int color){
    	this.x=x;
    	this.y=y;
    	this.color=color;
    }
    
    public int compareTo(Point another){
    	return this.x-another.x;
    }
    
    public boolean connectable(Point another){
    	return (this.x<another.x && this.y<another.y && this.color==red && another.color==blue)
    	     ||(this.x>another.x && this.y>another.y && this.color==blue && another.color==red);
    }
    
    public void use(){
    	color = -1;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Point[] r = new Point[N];
        for(int n=0;n<N;n++) r[n]= new Point(sc.nextInt(), sc.nextInt(), 0);
        Point[] b = new Point[N];
        for(int n=0;n<N;n++) b[n]= new Point(sc.nextInt(), sc.nextInt(), 1);
        Arrays.sort(r);
        Arrays.sort(b);
        
        int ans=0;
        
        for(Point blue:b){
        	int highest = -1;
        	for(Point red:r) if(blue.connectable(red) && red.y>highest)  highest=red.y;
        	if(highest>=0){
        	    ans++;
        	    for(Point red:r)if(red.y==highest) red.use();
        	}
        }
        
        System.out.println(ans);
        
        
        
        
    }
}

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

int a, b, c;

int main() {
  cin >> a >> b >> c;
  if (a <= c && b <= c) {
    cout << a + b << endl;
  }
  else if (c <= b && a <= b) {
    cout << a + c << endl;
  }
  else {
    cout << b + c << endl;
  }
  return 0;
}


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

int main()
{
    char a, b;
    cin >> a >> b;
    int i = 1;
    if(a == 'D') i *= -1;
    if(b == 'D') i *= -1;
    cout << (i + 1 ? 'H' : 'D') << endl;    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int most1=0,most2=0,most3=0,a[10],i;

    for(i=0; i<10; i++){
        scanf("%d",&a[i]);
        if(most1<=a[i]){
        most3=most2;
        most2=most1;
        most1=a[i];
    }else if(most2<=a[i] && most1>=a[i]){
        most3=most2;
        most2=a[i];
    }else if(most3<=a[i] && most2>=a[i] && most1>=a[i]){
        most3=a[i];
    }
    }
    printf("%d\n%d\n%d\n",most1,most2,most3);

    return 0;
}

Measured memory_bytes: 0
<?php
$input = trim(fgets(STDIN));
$S = array();

$S['SUN'] = 1;
$S['MON'] = 2;
$S['TUE'] = 3;
$S['WED'] = 4;
$S['THU'] = 5;
$S['FRI'] = 6;
$S['SAT'] = 7;

echo (7 -$S[$input] +1).PHP_EOL;



Measured memory_bytes: 4728
N = int(input())
A = input().split()
B = input().split()
C = input().split()
B2 = [int(s) for s in B]


a = sum(B2)
for i in range(N-1):
    if int(A[i])+1 == int(A[i+1]):
        b = int(A[i])-1
        a += int(C[b])
print(a)

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

int main(){
    string ans="Yay!";
    int a[5];
    for(int i=0;i<5;i++){
        cin>>a[i];
    }
    int k;
    cin>>k;

    for(int i=0;i<5;i++){
        for(int j=1;j<5;j++){
            if(a[j]-a[i]>k){
                ans=":(";
                break;
            }
        }
    }

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


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

using namespace std;
typedef long long ll;

int main()
{
	//freopen("t.txt","r",stdin);
	
	int n, a[100],count=0;
	cin>>n;
	
	for (int i=1;i<=n;i++){
		cin>>a[i];
		if (a[i]!=i){
			count ++;
		}
	}
	if (count==2||count==0){
		cout<<"YES";
	}
	else{
		cout<<"NO";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h,w,k;
    scanf("%d%d%d",&h,&w,&k);
    char grid[h][w];
    int ans[h][w];
    memset(ans,-1,sizeof(ans));
    int ct = 1;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            scanf(" %c",&grid[i][j]);
            if (grid[i][j] == '#'){
                ans[i][j] = ct++;
            }
        }
    }
    for (int i = 0; i < h;i ++){
        for (int j = 1; j < w; j++){
            if (ans[i][j] == -1) ans[i][j] = ans[i][j-1];
        }
    }
    for (int i = 0; i < h;i ++){
        for (int j = w-2; j >= 0; j--){
            if (ans[i][j] == -1) ans[i][j] = ans[i][j+1];
        }
    }
    for (int i = 1; i < h; i ++){
        for (int j = 0; j < w; j++){
            if (ans[i][j] == -1) ans[i][j] = ans[i-1][j];
        }
    }

    for (int i = h-2; i >= 0;i --){
        for (int j = 0; j < w; j++){
            if (ans[i][j] == -1) ans[i][j] = ans[i+1][j];
        }
    }
    for (int i = 0; i < h;i ++){
        for (int j = 0; j < w; j++){
            printf("%d ",ans[i][j]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int a[100];

int main(){
    int m, d;
    cin >> m >> d;
    
    int cnt = 0;
    
    for(int i = 1; i <= d; ++i){
        int d1, d2;
        int temp = i;
        d1 = temp % 10;
        temp /= 10;
        d2 = temp % 10;
        
        if(d1 < 2 || d2 < 2){
            a[i] = -1;
            continue;
        }
        
        a[i] = d1 * d2;
    }
    
    for(int i = 1; i <= m; ++i){
        for(int j = 1; j <= d; ++j){
            if(a[j] < 0)    continue;
            
            if(i == a[j])   cnt++;
        }
    }
    
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

const int MAXN = 100005;
const int MOD = 1000000007;
const ll INF = 4e18;

int n,f,g;
int la[MAXN];
int ra[MAXN];
int lb[MAXN];
int rb[MAXN];
int lazf[MAXN];
int lazg[MAXN];

ll A,B;
ll s[MAXN];

int main()
{
	scanf("%d%lld%lld",&n,&A,&B);
	for (int i = 1;i <= n;i++)
		scanf("%lld",&s[i]);
	s[0] = -INF;
	for (int i = n - 1,l = n,r = n;i >= 0;i--)
	{
		la[i] = l;
		ra[i] = r;
		if (!i)
			break;
		if (s[i + 1] - s[i] < A)
			l = (r = i) + (s[i + 1] - s[i - 1] < B);
		while (l - 1 >= i && s[l] - s[i - 1] >= B)
			l--;
	}
	for (int i = n - 1,l = n,r = n;i >= 0;i--)
	{
		lb[i] = l;
		rb[i] = r;
		if (!i)
			break;
		if (s[i + 1] - s[i] < B)
			l = (r = i) + (s[i + 1] - s[i - 1] < A);
		while (l - 1 >= i && s[l] - s[i - 1] >= A)
			l--;
	}
	lazf[0] = lazg[0] = 1;
	lazf[1] = lazg[1] = -1;
	for (int i = 0;i < n;i++)
	{
		(f += lazf[i]) %= MOD;
		(g += lazg[i]) %= MOD;
		(lazf[la[i]] += g) %= MOD;
		(lazf[ra[i] + 1] -= g) %= MOD;
		(lazg[lb[i]] += f) %= MOD;
		(lazg[rb[i] + 1] -= f) %= MOD;
	}
	(f += lazf[n]) %= MOD;
	(g += lazg[n]) %= MOD;
	printf("%d\n",((f + g) % MOD + MOD) % MOD);
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>

int selectionSort(int *, int);

int main()
{
    int i, N, count;
    int A[100];
    
    scanf("%d", &N);
    for(i=0; i < N; i++){
        scanf("%d", &A[i]);
    }
    count = selectionSort(A, N);
    for(i=0; i < N; i++){
        if(i != 0)printf(" ");
        printf("%d", A[i]);
    }
    printf("\n%d\n", count);
    
    return 0;
}

int selectionSort(int A[], int N)
{
    int i, j, str, count=0, minj;
    for(i=0; i < N-1; i++){
        minj = i;
        for(j=i; j < N; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(A[i] != A[minj]){
            str = A[i];
            A[i] = A[minj];
            A[minj] = str;
            count++;
        }
    }
    return count;
}


Measured memory_bytes: 2040
#include <iostream>
    using namespace std;
     
    int main()
    {
      int a, b;
      cin>>a>>b;
      if(1<=a and a<=9 and 1<=b and b<=9)
      {
        cout<<(a*b)<<endl;
        
      }
      else
        cout<<-1<<endl;
      return 0;
      
      
    }

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

using namespace std;

int A[100007];
int B[100007] = {0};

int main(){

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

    int temp=0;
    int result=0;

    if(N == 1){
        cout << 1 << endl;
    }else{
        for(int i=1; i<100001; i++){
            temp = B[i] + B[i-1] + B[i+1];
            if(temp > result) result = temp;
        }
        cout << result << endl;
    }
    

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm> 
#include<cstdio>
#include<cctype>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const int maxn= 2e5+5;
const double pi = acos(-1.0);
const ll mod = 1e9+7;
int main()
{
    int n;
	cin>>n;
	int tmp,cnt=0;
	for(int i=0;i<n;i++){
		cin>>tmp;
		if(i%2==0&&tmp&1){
			cnt++;
		}
	}
	cout<<cnt<<endl;
 	
    return 0;
}




Measured memory_bytes: 3628
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  int Q, H, S, D, Q8, H4, S2, Q4, H2;
  ll N;
  cin >> Q >> H >> S >> D >> N;

  Q8 = Q * 8;
  Q4 = Q * 4;
  H4 = H * 4;
  H2 = H * 2;
  S2 = S * 2;

  ll divN = N / 2;
  ll modN = N % 2;

  // cout << min(Q8, min(H4, min(S2, D))) << endl;
  // cout << min(Q4, min(H2, S)) << endl;

  ll ans = divN * min(Q8, min(H4, min(S2, D))) + modN * min(Q4, min(H2, S));

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int n, m, memo[2000][2000];
char arr[2000][2000];

#define mod 1000000007
int solve(int i, int j)
{
    if(i > n || j > m || arr[i][j] == '#')
        return 0;
    if(i == n - 1 && j == m - 1)
        return 1;
    if(memo[i][j]!=-1)return memo[i][j]%mod;

    memo[i][j]= (solve(i + 1, j) + solve(i, j + 1)) % mod;
    return memo[i][j];
}
int main()
{

    cin >> n >> m;
    memset(memo, -1,sizeof(memo));
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < m ; j++)
            cin >> arr[i][j];
    cout << solve(0, 0) % mod;
    return 0;
}



Measured memory_bytes: 19712
#include <iostream>
#include <sstream>

using namespace std;

int main(void){
    int a, b;
    cin >> a >> b;
    int result;
    if (abs(a-b) >= 2) {
        result = max(a,b)*2-1;
    }
    else {
        result = a + b;
    }
    cout << result << endl;


}

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

using namespace std;

typedef long long LL;
#define N 100

LL n,a[N],ans;

int main(){
	scanf("%lld",&n);
	for (LL i=1;i<=n;++i) scanf("%lld",a+i);
	while (1){
		bool fl=0;
		for (LL i=1;i<=n;++i)
			if (a[i]+ans>=n){
				fl=1;
				LL t=(a[i]+ans)/n;
				ans+=t;
				a[i]-=t*(n+1);
			}
		if (!fl) break;
	}
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 256
N, K = map(int, input().split())
xy = []
for _ in range(N):
    xy.append(tuple(map(int, input().split())))

xy.sort()
ans = float("inf")
for i in range(N):
    for j in range(i + 1, N):
        x = xy[j][0] - xy[i][0]
        y_list = [xy[1] for xy in xy[i:j + 1]]
        y_list.sort()
        for k in range(len(y_list)-K+1):
            y = y_list[k + K -1] - y_list[k]
            tmp = x * y
            if ans > tmp:
                ans = tmp

print(ans)


Measured memory_bytes: 3064
from itertools import combinations_with_replacement

n, m, q = map(int, input().split())

conditions = [list(map(int, input().split())) for _ in range(q)]

selections = combinations_with_replacement(range(1, m+1), n)

maximum_points = 0
for s in selections:
    for i in range(n-1):
        if s[i] > s[i+1]:
            continue
    points = 0
    for c in conditions:
        if s[c[1]-1] - s[c[0]-1] == c[2]:
            points += c[3]
    maximum_points = max(maximum_points, points)
print(maximum_points)

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

#define PI 4*atan(1)
#define INF 1e8

typedef long long ll;

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

int N;

bool mysort(pair<int, int> lhs, pair<int, int> rhs){
  return -lhs.second < -rhs.second;
}

vector<pair<int, int>> calc_point(vector<pair<int, int>> v, vector<int> r, int x){
  int rank = 0;
  v[0].first += x;
  sort(v.begin(), v.end(), greater<pair<int, int>>());
  int pre = v[0].first;
  vector<pair<int, int>> point(N);
  int same = 0;
  for(int i = 0; i < N; i++){
    if(pre != v[i].first){
      rank+=same;
      same = 1;
    }else {
      same++;
    }
    int p = r[rank];
    point[i].first = p;
    point[i].second = v[i].second;
    pre = v[i].first;
  }
  sort(point.begin(), point.end(), mysort);
  return point;
}

vector<pair<int, int>> calc_sum(vector<pair<int, int>> s_p, vector<pair<int, int>> p_p, vector<pair<int, int>> c_p){
  vector<pair<int, int>> sum_p(N);
  for(int i = 0; i < N; i++){
    int sum = s_p[i].first + p_p[i].first + c_p[i].first;
    sum_p[i].first = sum;
    sum_p[i].second = -i;
  }
  sort(sum_p.begin(), sum_p.end(), greater<pair<int, int>>());
  return sum_p;
}

bool calc_rank(vector<pair<int, int>> sum_p){
  int rank;
  for(int i = 0; i < N; i++){
    if(sum_p[i].second == 0){
      rank = i;
      break;
    }
  }
  return rank < 8;
}

int main(){
  cin >> N;
  vector<int> r(N);
  for(int i = 0; i < N; i++){
    cin >> r[i];
  }
  vector<pair<int, int>> s(N), p(N), c(N);
  int max_s = 0, max_p = 0, max_c = 0;
  for(int i = 0; i < N; i++){
    cin >> s[i].first >> p[i].first >> c[i].first;
    s[i].second = -i; p[i].second = -i; c[i].second = -i;
    max_s = max(s[i].first, max_s);
    max_p = max(p[i].first, max_p);
    max_c = max(c[i].first, max_c);
  }

  vector<pair<int, int>> s_p;
  vector<pair<int, int>> p_p;
  vector<pair<int, int>> c_p;
  vector<pair<int, int>> sum_p;

  p_p = calc_point(p, r, 0);
  c_p = calc_point(c, r, 0);

  int ans = INF;
  for(int x = 1; x <= 100; x++){
    s_p = calc_point(s, r, x);
    sum_p = calc_sum(s_p, p_p, c_p);
    // cerr << "=============================" << endl;
    // for(int i = 0; i < N; i++)cerr << "s: " << s_p[i].first << " team" << s_p[i].second << endl;
    // for(int i = 0; i < N; i++)cerr << "sum " << sum_p[i].first << " team" << sum_p[i].second << endl;
    // cerr << "=============================" << endl;

    if(calc_rank(sum_p)){
      ans = min(ans, x); 
      break;
    }
  }
  s_p = calc_point(s, r, 0);
  c_p = calc_point(c, r, 0);
  for(int x = 1; x <= 100; x++){
    p_p = calc_point(p, r, x);
    sum_p = calc_sum(s_p, p_p, c_p);
  
    if(calc_rank(sum_p)){
      ans = min(ans, x); 
      break;
    }
  }
  s_p = calc_point(s, r, 0);
  p_p = calc_point(p, r, 0);
  for(int x = 1; x <= 100; x++){
    c_p = calc_point(c, r, x);
    sum_p = calc_sum(s_p, p_p, c_p);
  
    if(calc_rank(sum_p)){
      ans = min(ans, x); 
      break;
    }
  }
  if(ans != INF)cout << ans << endl;
  else cout << "Saiko" << endl;
  // for(int i = 0; i < N; i++) cer << "point: " << s_p[i].first << " team: " << s_p[i].second << endl;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
int main(){
  int a,b,h,m;
  long double ai, bi;
  cin >> a >> b>> h >>m;
  ai = (m+h*60)*M_PI*2/(12*60);
  bi = m*M_PI*2/60;
  long double the = min(abs(ai-bi),2*M_PI-abs(ai-bi));
  long double c = sqrt(a*a + b* b - 2*cos(the)*a*b);
  
  cout << std::setprecision(20) << c << endl;
}

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

int main() {
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	vector<ll> a(x), b(y), c(z);
	rep(i, x) cin >> a[i];
	rep(i, y) cin >> b[i];
	rep(i, z) cin >> c[i];
	vector<ll> ab;
	rep(i, x)rep(j, y) ab.push_back(a[i]+b[j]);
	sort(ab.begin(), ab.end(), greater<ll>());
	//rep(i, ab.size()) cout << ab[i] << endl;
	vector<ll> abc;
	if (k < ab.size()) {
		rep(i, k)rep(j, z) abc.push_back(ab[i]+c[j]);
	} else {
		rep(i, ab.size())rep(j, z) abc.push_back(ab[i]+c[j]);
	}
	sort(abc.begin(), abc.end(), greater<ll>());
	//rep(i, abc.size()) cout << abc[i] << endl;
	rep(i, k) cout << abc[i] << endl;
	return 0;
}


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

int bitDPtab[1 << 10][10];
int mv_cost[128][128];
int cal[8];
int m, n, K, d;

const int INF = 1e9;

int bitDP(int status, int pos) {
	if(bitDPtab[status][pos] + 1)
		return bitDPtab[status][pos];

	bitDPtab[status][pos] = INF;
	for(int i = 0; i < m+2; i++) {
		if((status & (1 << i)) && i != pos) {
			bitDPtab[status][pos] = min(bitDPtab[status][pos], bitDP(status ^ (1 << pos), i) + mv_cost[i][pos]);
		}
	}
	return bitDPtab[status][pos];
}

int to_num(string s) {
	if(s[0] == 'H')
		return 0;
	if(s[0] == 'D')
		return 1;
	if(s[0] == 'C')
		return 2 + atoi(s.c_str() + 1) - 1;
	if(s[0] == 'L')
		return 2 + m + atoi(s.c_str() + 1) - 1;
	return -1;
}

int main() {
	while(cin >> m >> n >> K >> d, m||n||K||d) {
		// init
		for(int i = 0; i < (1 << 10); i++) {
			for(int j = 0; j < 10; j++) {
				bitDPtab[i][j] = -1;
			}
		}

		for(int i = 0; i < m + 2; i++) {
			bitDPtab[1 << i][i] = INF;
		}
		bitDPtab[1 << 1][1] = 0;

		for(int i = 0; i < 128; i++) {
			for(int j = 0; j < 128; j++) {
				mv_cost[i][j] = INF;
			}
			mv_cost[i][i] = 0;
		}

		// input
		for(int i = 0; i < m; i++) {
			cin >> cal[i];
		}
		for(int i = 0; i < d; i++) {
			string src, dst;
			int c;
			cin >> src >> dst >> c;
			int a, b;
			a = to_num(src);
			b = to_num(dst);
			mv_cost[a][b] = mv_cost[b][a] = c * K;
		}

		// WF
		for(int i = 0; i < 2 + m + n; i++) {
			if(i < 2 || 2 + m <= i) {
				for(int j = 0; j < 2 + m + n; j++) {
//					if(j < 2 || 2 + m <= j) {
						for(int k = 0; k < 2 + m + n; k++) {
//							if(k < 2 || 2 + m <= k) {
								mv_cost[j][k] = min(mv_cost[j][k], mv_cost[j][i] + mv_cost[i][k]);
//							}
						}
//					}
				}
			}
		}

		int res = INF;
		for(int i = 0; i < (1 << m); i++) {
			int dic = 0;
			for(int j = 0; j < m; j++) {
				if(i & (1 << j))
					dic += cal[j];
			}
			res = min(res, bitDP((i << 2) | 3, 0) - dic);
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 1324
#include "bits/stdc++.h"
using namespace std;

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

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

    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());
    int ans = p[0] / 2;
    for (int i = 1; i < N; i++) {
        ans += p[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define VE vector<int>
#define VP vector<pair<int,int> >
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
int main(){
  int M,mi,ma;
  int P[200];
  while(1){
    cin>>M>>mi>>ma;
    if(M==0){
      break;
    }
    FOR(i,0,M){
      cin>>P[i];
    }
    int cnt=0,ans;
    FOR(i,mi-1,ma){
      if(cnt<=P[i]-P[i+1]){
        cnt=P[i]-P[i+1];
        ans=i+1;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3036
import bisect


N, M = map(int, input().split())
Al = list(map(int, input().split()))
Al.sort() # 左手で握手する人のリスト
Ar = Al.copy()[::-1] # 右手で握手する人のリスト

def count_large_2(L1, L2, x):
  # L1.sort()
  # L2.sort(reverse=True)
  N1, N2 = len(L1), len(L2)
  i = j = 0
  c = 0
  while i<N1 and j<N2:
    if L1[i]+L2[j] >= x:
      c += 1
      j += 1
      if j >= N2:
        c += (N1-i-1) * N2
    else:
      i += 1
      if i>=N1:
        continue
      c += j
  return c

left = 0 # True
right = Al[-1]*2 + 1 # False
while left+1 < right:
  mid = (left + right) // 2
  if count_large_2(Al, Ar, mid) >= M:
    left = mid
  else:
    right = mid


x = left
accum_A = [Ar[0]]
for i, a in enumerate(Ar):
  if i == 0:
    continue
  accum_A.append(accum_A[-1] + a)


ans = 0
count = 0
surplus = 2*10**5
for ai in Ar:
  idx = bisect.bisect_left(Al, x-ai)
  if idx == N:
    break
  ans += (N-idx)*ai + accum_A[N-idx-1]
  count += N - idx
  surplus = min(surplus, ai+Al[idx])
 
 
print(ans - (count-M)*surplus)

Measured memory_bytes: 14020
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P2;
struct min_segtree{
private:
  vector<ll> node;
  int siz;
public:
  min_segtree(int n){
    siz=1;
    while(siz<=n) siz*=2;
    node.resize(siz*2+1,(ll)2147483647);
  }
  void upd(int pos,int x){
    pos+=siz-1;
    node[pos]=x;
    while(pos>0){
      pos=(pos-1)/2;
      node[pos]=min(node[pos*2+1],node[pos*2+2]);
    }
  }
  ll get_min(int a,int b,int pos,int l,int r){
    if(a<=l&&r<=b) return node[pos];
    if(r<=a||b<=l) return 2147483647;
    int mid=(l+r)/2;
    ll lb=get_min(a,b,pos*2+1,l,mid);
    ll rb=get_min(a,b,pos*2+2,mid,r);
    return min(lb,rb);
  }
  ll min_q(int a,int b){
    return get_min(a,b,0,0,siz);
  }
};
struct max_segtree{
private:
  vector<ll> node;
  int siz;
public:
  max_segtree(int n){
    siz=1;
    while(siz<=n) siz*=2;
    node.resize(siz*2+1,0);
  }
  void upd(int pos,int x){
    pos+=siz-1;
    node[pos]=x;
    while(pos>0){
      pos=(pos-1)/2;
      node[pos]=max(node[pos*2+1],node[pos*2+2]);
    }
  }
  ll get_max(int a,int b,int pos,int l,int r){
    if(a<=l&&r<=b) return node[pos];
    if(r<=a||b<=l) return 0;
    int mid=(l+r)/2;
    ll lb=get_max(a,b,pos*2+1,l,mid);
    ll rb=get_max(a,b,pos*2+2,mid,r);
    return max(lb,rb);
  }
  ll max_q(int a,int b){
    return get_max(a,b,0,0,siz);
  }
};

int main(){
  ll n,d;
  cin>>n>>d;
  vector<P2> vec;
  vector<ll> bright;
  for(int i=0;i<n;i++){
    ll x,y,b;
    cin>>x>>y>>b;
    bright.push_back(b);
    vec.push_back(P2(b,P(x,y)));
  }
  sort(bright.begin(),bright.end());
  sort(vec.begin(),vec.end());
  min_segtree minsegx=min_segtree(n+5),minsegy=min_segtree(n+5);
  max_segtree maxsegx=max_segtree(n+5),maxsegy=max_segtree(n+5);

  for(int i=0;i<n;i++){
    ll x=vec[i].second.first,y=vec[i].second.second;
    minsegx.upd(i,x);
    maxsegx.upd(i,x);
    minsegy.upd(i,y);
    maxsegy.upd(i,y);
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    ll jt=upper_bound(bright.begin(),bright.end(),bright[i]+d)-bright.begin();
    ll dx=maxsegx.max_q(i,jt)-minsegx.min_q(i,jt);
    ll dy=maxsegy.max_q(i,jt)-minsegy.min_q(i,jt);
    ans=max(ans,dx*dy);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 25832
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int a,b;
	cin>>a>>b;
	string s;
	cin>>s;
	for(int i=0;i<a;i++){
		if(!isdigit(s[i])){
			puts("No");
			return 0;
		}
	}
	if(s[a]!='-'){
		puts("No");
		return 0;
	}
	for(int i=a+1;i<=a+b;i++){
		if(!isdigit(s[i])){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int A(int n, int m) {
    if(n-m>0) {
        int ans1=n-m;
        return ans1;
    }
    if(n-m<0) {
        int ans2=0-(n-m);
        return ans2;
    }
    if(n-m==0) {
        int ans3=0;
        return ans3;
    }
    return 0;
}

int main() {
        
    int a, b, x=100;
    cin>>x>>a>>b;
    if(A(x,a)<A(x,b)) {
        cout<<'A'<<endl;
    }
    if(A(x,a)>A(x,b)) {
        cout<<'B'<<endl;
    }
    return 0;

}



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

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

using namespace std;

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  ll res = 0;
  int prevHeight = 0;
  for (int i = 0; i < n; ++i) {
    int already = min(prevHeight, h[i]);
    res += h[i] - already;
    prevHeight = h[i];
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  int i;
  char s[21];
  scanf("%s",s);
  i=strlen(s);
  for(i=i-1;s[i] > 0;i--){
    printf("%c",s[i]);
  }
  printf("\n");
  return (0);
}

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

int main(){
    int A = 1000005;
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> c(A, 0);
    int max = 0;
    
    for(int i=0;i<n;i++){
        cin>>a[i];
        c[a[i]] += 1;
    }


    //素数に対しO(1)の計算量
    bool pairwise = true;
    for(int i=2;i<A;i++){
        int count = 0;
        for(int j=1;j*i<A;j++){
            count += c[j*i];
        }
        if(count>1) pairwise = false;
        if(count==n){
            cout<<"not coprime"<<endl;
            return 0;
        }
    }

    if(pairwise){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }

    cout<<"setwise coprime"<<endl;
    
    return 0;

}

Measured memory_bytes: 11060
#include<iostream>

using namespace std;

int n;
long long int y;
int x = 0, y1 = 0, z = 0;

int tmp1, tmp2, tmp3;
bool judge = false;
int sum1, sum2, sum3;

int main(){
  cin >> n >> y;
  int sum = y;
  tmp1 = sum / 1000;
  //cout << tmp1 << endl;
  for(int i = 0; i <= tmp1; ++i){
    //x = i;
    sum1 = sum - i * 1000;
    //cout << sum1 << endl;
    tmp2 = sum1 / 5000;
    for(int j = 0; j <= tmp2; ++j){
      sum2 = sum1 - j * 5000;
      int k = n - i - j;
      if(sum2 - k*10000 == 0){
        x = k;
        y1 = j;
        z = i;
        judge = true;
        break;
      }
    }
  }
  if(judge == true){
    cout << x << " " << y1 << " " << z << endl;
  }else{
    cout << -1 << " " << -1 << " " << -1 << endl;
  }
}

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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int st = max(a,c);
    int en = min(b,d);
    printf("%d",max(0,en-st));
    return 0;
}


Measured memory_bytes: 256
import numpy as np
import math
n = int(input())
xy = [[int(i) for i in input().split()] for i in range(n)]
sum = 0
for i in range(n):
    for j in range(n):
        leng = ((xy[i][0]-xy[j][0])**2 + (xy[i][1]-xy[j][1])**2)**0.5
        sum += math.factorial(n-1)*leng

print(sum/math.factorial(n))


Measured memory_bytes: 21556
while True:
    data = input().split()
    h, w = int(data[0]), int(data[1])
    if h == 0 and w == 0:
        break
    elif h == 0 or w == 0:
        print()
    else:
        for i in range(h):
            for j in range(w):
                if (i%2 == 0 and j%2 == 0) or (i%2 != 0 and j%2 != 0):
                    print("#", end="")
                else:
                    print(".", end="")
            print()
        print()

Measured memory_bytes: 9008
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])

k = 0
i = 0
while i < N:
    k += 1
    c = 0
    while c < C and i + c < N and T[i + c] <= (T[i] + K):
        c += 1
    i += c
print(k)


Measured memory_bytes: 8280
/////////////////////////////
//* Code By: SANSKAR SETH *//
/////////////////////////////


/*----------HEADER FILES AND TEMPLATES----------*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define pob pop_back
#define pf pop_front()
#define puf push_front()
#define mp make_pair
#define loop(i,a,b) for(int i=a ; i<b ; ++i)
#define rloop(i,a,b) for(int i=a ; i>=b ; --i)
#define ip(a) int a; cin>>a
#define ip2(a,b) int a,b; cin>>a>>b
#define ip3(a,b,c) int a,b,c; cin>>a>>b>>c
#define ipv(v,n) vi v(n); loop(i,0,n) cin>>v[i]
#define pv(v) loop(i,0,v.size()) cout<<v[i]<<" "
#define ips(s) string s; cin>>s
#define F first
#define S second
#define si(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define coutfl(l,p) fixed << setprecision(p) << l

typedef pair<int, int> pii;
typedef unordered_set<int> usi;
typedef set<int> si;
typedef map<int, int>   mii;
typedef map<char, int>  mci;
typedef vector<int>    vi;
typedef vector<char>   vc;
typedef vector<pii>    vpii;
typedef vector<vi>     vvi;

const int mod = 1000000007;
const int N = 5e5;

/*----------SOLUTION----------*/

void solve()
{
	ip(n);
	int ans = 0, b, c = 0;

	loop(b, 1, n)
	{
		ans += ((n - 1) / b) ;
		// cout << n / b << endl;
	}

	// c = sqrt(n - 1);
	// cout << c << endl;

	cout << ans - c  << endl;

}

/*----------MAIN FUNCTION----------*/
int32_t main()
{
	fastIO;

#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif
	/*----MAIN PART----*/

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	string s;
	REP(i, 4)
	{
		char c; cin >> c;
		s += c;
	}
	sort(ALL(s));
	if (s == "1479") cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 768
from itertools import combinations, product
import bisect as bs

def tuple_int(iterable):
    return tuple(map(int, iterable.split()))

def S_with_K_plots(plots, K):
    result = []
    X, Y = sorted([x for x,y in plots]), sorted([y for x,y in plots])
    for xinf, xsup in combinations(X,2):
        for yinf in Y:
            ysup = [y for x,y in plots if xinf<=x<=xsup and y >= yinf]
            if len(ysup) < K: continue
            ysup.sort()
            result.append((xsup-xinf)*(ysup[K-1]-yinf))
    return result

if __name__ == '__main__':
    with open(0) as f:
        N, K = map(int, f.readline().split())
        plots = list(map(tuple_int, f.readlines()))
    print(min(S_with_K_plots(plots, K)))

Measured memory_bytes: 11052
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a,b,c,d;
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    printf("%lld",(a-c)*(b-d));
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    string s, ans;
    cin >> s;
    if(s[0] == s[1] & s[1] == s[2]){
        ans = "No";
    } else {
        ans = "Yes";
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import itertools
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

l = [list(map(int,input().split())) for i in range(3)]

num = l[0][0]
for i in range(1,3):
	tmp = l[i][0]-num
	for j in range(3):
		l[i][j] -= tmp
for i in range(1,3):
	tmp = l[0][i]-num
	for j in range(3):
		l[j][i] -= tmp

cnt = 0
for i in range(3):
	cnt += l[i].count(num)
if cnt == 9:
	print("Yes")
else:
	print("No")

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

constexpr int64_t MOD = 1e9 + 7;

int64_t MODpow(int64_t n, int64_t m) {
    int64_t result = 1;
    while (m) {
        if (m % 2 == 1) {
            result *= n;
            result %= MOD;
        }

        m /= 2;
        n *= n;
        n %= MOD;
    }

    return result;
}

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

    int64_t ans = MODpow(2, n);
    (ans += MOD - 1) %= MOD;

    int64_t nCa = 1, nCb = 1;
    for (int64_t i = 1; i <= a; i++) {
        (nCa *= (n + 1 - i)) %= MOD;
        (nCa *= MODpow(i, MOD - 2)) %= MOD;
    }
    for (int64_t i = 1; i <= b; i++) {
        (nCb *= (n + 1 - i)) %= MOD;
        (nCb *= MODpow(i, MOD - 2)) %= MOD;
    }

    (ans += MOD - nCa) %= MOD;
    (ans += MOD - nCb) %= MOD;
    cout << ans << endl;
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int k,x;
	cin >> k >> x;
	cout << (500*k >= x ? "Yes" : "No");
}



Measured memory_bytes: 256
;;(declaim (optimize (speed 0) (safety 3) (debug 3)))
(declaim (optimize (debug 0) (safety 0) (speed 3)))

(defvar k (read))
(defvar s (read-line))
(if (> (length s) k)
    (format t "~a..." (subseq s 0 k))
  (format t "~a" s))


Measured memory_bytes: 24428
n=int(input())
l=[int(input()) for i in range(n)]
l1=sorted(l,reverse=True)
l2=[]
for i in range(n):
  if i==0:
    l2.append(l1[i])
  else:
    if l1[i]<l1[i-1]:
      l2.append(l1[i])
print(len(l2))

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

int main() {
    int n, m, ans = 0;
    cin >> n >> m;
    vector<int> h(n);
    rep(i, n) cin >> h.at(i);
    vector<bool> cnt(n, true);
    vector<vector<int>> path(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        path.at(a - 1).push_back(b - 1);
        path.at(b - 1).push_back(a - 1);
    }
    rep(i, n) {
        rep(j, path.at(i).size()) {
            int t = path.at(i).at(j);
            if(h.at(i) <= h.at(t)) {
                cnt.at(i) = false;
                break;
            }
        }
    }
    rep(i, n) if(cnt.at(i)) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 8804
def main():
    H, W, D = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    Q = int(input())
    ans = []

    x = [0 for _ in range(90001)]
    y = [0 for _ in range(90001)]
    dp = [0 for _ in range(90001)]

    for i, row in enumerate(A):
        for j, a in enumerate(row):
            x[a] = j
            y[a] = i
    for i in range(D + 1, H * W + 1):
        dp[i] = dp[i - D] + abs(x[i] - x[i - D]) + abs(y[i] - y[i - D])

    for _ in range(Q):
        L, R = map(int, input().split())
        ans.append(dp[R] - dp[L])
    for a in ans:
        print(a)


main()


Measured memory_bytes: 17132
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define lp(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)4e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1 << (x))
using namespace std;

int main(){
	int H, W, D;
	cin >> H >> W >> D;
	vector<PII> pos(H*W);
	vector<int> sum(H*W, 0);
	REP(i, H){
		REP(j, W){
			int d;
			cin >> d;
			--d;
			pos[d]=PII(i, j);
		}
	}
	REP(i, H*W-D){
		sum[i+D] = abs(pos[i].first - pos[i+D].first) + abs(pos[i].second - pos[i+D].second) + sum[i];
	}
	int Q;
	cin >> Q;
	REP(i, Q){
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		cout << sum[b]-sum[a] << endl;
	}
	return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include <numeric>
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> X(M);
  vector<int> dist(M - 1);
  for(int i =0;i<M;i++){
    cin >> X[i];
  }
  //一番距離が遠いところに置くべき
  sort(X.begin(),X.end());
  
  for(int i = 0; i < M -1; i++){
    dist[i] = X[i+1] - X[i];
  }
  
  sort(dist.begin(),dist.end());
  
  if(N >= M){
    cout << 0 << endl;
    return 0;
  }else{
    cout << accumulate(dist.begin(), dist.end() - (N -1), 0) << endl;
    return 0;
  }
  
}


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

using namespace std;

int main(){
	int n; scanf("%d", &n);
	for(int k = 1; k * (k + 1) / 2 <= n; k++) if(k * (k + 1) / 2 == n){
		int s[500][500] = {};
		for(int i = 0, p = 1; i < k; i++) for(int j = 0; j < k - i; j++) s[i][j + i] = p++;
		for(int i = 0; i < k; i++) for(int j = 0; j < k - i; j++) s[j + i + 1][i] = s[i][j + i];
		puts("Yes");
		printf("%d\n", k + 1);
		for(int i = 0; i < k + 1; i++){
			printf("%d ", k);
			for(int j = 0; j < k; j++) printf("%d%c", s[i][j], j + 1 == k ? '\n' : ' ');
		}
		return 0;
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 2304
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let add: i32 = read();
    let s: String = read();

    for c in s.bytes() {
        print!("{}", (((c - 65 + add as u8) % 26) + 65) as char);
    }

    println!("");
    
}


Measured memory_bytes: 4352
def main():
    import sys
    input = sys.stdin.readline
    S = input().strip()
    p = ''
    c = ''
    ans = 0
    for s in S:
        c += s
        if p != c:
            ans += 1
            p = c
            c = ''
        
    print(ans)

if __name__ == '__main__':
    main()

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

int main()
{
    int N;
    int a[100] = {0};

    std::cin >> N;
    for(int i = 0; i < N; i++){ std::cin >> a[i]; }

    int aliceP = 0;
    int bobP = 0;

    std::sort(a, a + N, std::greater<int>());

    for(int i = 0; i < N; i++){
        if(i%2 == 0){
            aliceP += a[i];
        } else {
            bobP += a[i];
        }
    }
    
    std::cout << aliceP - bobP << std::endl;

    return 0;
}

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

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

    int ans=0;
    rep(i,n){
        int cnt=0;

        for(char c='a';c<='z';c++){
            bool left=false,right=false;

            rep(j,i) if(s[j]==c) left=true;
            
            for(int j=i; j<n; j++) if(s[j]==c) right=true;

            if(left && right) cnt++;
        }

        if(ans<cnt) ans=cnt;
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256