akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  F
//
//  Created by 曾憲揚 on 2020/9/7.
//  Copyright © 2020 曾憲揚. All rights reserved.
//

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

const int N = 1e5+5;
typedef long long ll;
ll a[N];

ll umin(ll a, ll b){
    return a<b? a:b;
}
ll umax(ll a, ll b){
    return a>b? a:b;
}

ll maxor(int n){
    int rank=0;
    
    int j;
    for(int i=59; i>=0; i--){
        for(j=rank; j<n; j++){
            if(a[j]& (1LL<<i)) break;
        }
        if(j==n) continue;
        
        if(j>rank) a[rank]^=a[j];
        
        for(j=rank+1; j<n; j++){
            a[j]=umin(a[j], a[j]^a[rank]);
        }
        
        rank++;
    }
    ll ans=0;
    for(int i=0; i<n; i++)
        ans=umax(ans, ans^a[i]);
    
    return ans;
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int n; cin>>n;
    
    ll all=0;
    for(int i=0; i<n; i++){
        cin >>a[i];
        all^=a[i];
    }
    for(int i=0; i<n; i++){
        a[i] &= (~all);
    }
    
        
    ll ans = all+2*maxor(n);;
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4388
n = int(input())
count = 0
ans=0

for i in range(1, n+1):
  if i % 2 != 0:
    for j in range(1, i + 1):
      if i % j == 0:
        count += 1
    else:
      if count == 8:
        ans += 1
      count=0
print(ans)

Measured memory_bytes: 3060
h, w = gets.to_s.split.map{|t| t.to_i }

# p ".#".bytes #=> [46, 35]
blacks = []
a = Array.new(h) do |i| 
  s = gets.to_s.chomp.bytes
  s.each_with_index do |c, j|
    blacks << [i, j] if c == 35
  end
  s    
end

dxy = [[1, 0], [0, 1], [-1, 0], [0, -1]]

ans = -1
while blacks.any?
  
  ns = []
  ans += 1
  
  blacks.each do |x, y|
    dxy.each do |dx, dy| 
      nx = x + dx
      ny = y + dy
      if ( 0 <= nx && nx < h && 0 <= ny && ny < w && a[nx][ny] == 46 )
        a[nx][ny] = 35
        ns << [nx, ny]
      end
    end
  end
  blacks = ns.dup
end

puts ans

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/12/04  Problem: codefestival2017_team_relay E / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----

sigma (100-P)*w(i) + b(i) >= P*(ALL(b))

----解説ここまで---- */




LL N,P;

LL ans = 0LL;

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

	cin >> N >> P;
	VL w(N,0);
	VL b(N,0);
	LL bsum = 0;
	FOR(i,0,N){
		cin>> w[i] >> b[i];
		bsum += b[i];
	}
	
	VL a(N,0);
	FOR(i,0,N){
		a[i] = (100-P)*w[i] + P*b[i];	
	}
	RSORT(a);
	LL ret = 0; int id=0;
	while(ret< P*bsum){
		ret += a[id];
		id++;
	}
	
	ans = id;
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

typedef pair<int, int> ii;
typedef long long int64;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
	cin >> v[i];
    }
    int last = v[0];
    vector<int> bd;
    for (int i = 1; i < n; ++i) {
	if (v[i] < last) {
	    if (bd.size()) {
		bd.push_back(i);
	    } else {
		bd.push_back(i - 1);
	    }
	}
	last = v[i];
    }
    if (bd.size() == 1) {
	cout << "NO" << endl;
	return 0;
    }
    if (bd.size() == 2) {
	swap(v[bd[0]], v[bd[1]]);
	last = v[0];
	for (int i = 1; i < n; ++i) {
	    if (v[i] < last) {
		cout << "NO" << endl;
		return 0;
	    }
	}
	cout << "YES" << endl;
	return 0;
    }
    if (!bd.size()) {
	cout << "YES" << endl;
	return 0;
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;

using namespace std;

int main()
{
  ull N;
  cin >> N;
  vector<ull> vs(N);

  const static uint n = 100001;
  uint codd[n] = {};
  uint ceven[n] = {};

  for (auto i = 0; i < N; i++) {
    cin >> vs[i];
    if (i % 2 == 0) {
      ceven[vs[i]]++;
    } else {
      codd[vs[i]]++;
    }
  }

  vector<pair<uint, uint>> fodd, feven;
  for (auto i = 0; i < n; i++) {
    if (ceven[i] > 0) feven.push_back(make_pair(ceven[i], i));
    if (codd[i] > 0) fodd.push_back(make_pair(codd[i], i));
  }
  feven.push_back(make_pair(0, n));
  fodd.push_back(make_pair(0, n));
  sort(feven.begin(), feven.end());
  sort(fodd.begin(), fodd.end());

  uint res = 0;
  if (feven.back().second == fodd.back().second) {
    res = min(N - feven.back().first - fodd[fodd.size()-2].first,
        N - feven[feven.size()-2].first - fodd.back().first);
    } else {
    res = N - feven.back().first - fodd.back().first;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 2812
#include <iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    int n = s.length();
    bool iskaibun = true;
    for (int i = 0; i < (n-1)/2; i++) {
        if (s[i] != s[n-1-i]) {
            iskaibun = false;
            break;
        }
    }
    if (iskaibun) {
        for (int i = 0; i < (n-1)/4+1; i++) {
            if (s[i] != s[(n-1)/2-1-i]) {
                iskaibun = false;
                break;
            }
        }
    }
    if (iskaibun) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int n;
int a[101][101];

int solve() {
  int d[n][n];
  memset(d,0,sizeof(d));
  int ans=-1000000001;
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      for(int k=i; k<n; k++) {
	int x=0;
	for(int l=j; l<n; l++) {
	  x+=a[k][l];
	  if(k==i) d[k][l]=x;
	  else d[k][l]=d[k-1][l]+x;
	  ans=max(ans,d[k][l]);
	}
      }
    }
  }
  return ans;
}

int main() {
  cin >> n;
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) cin >> a[i][j];
  }
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 1244
///*Bismillahir Rahmanir Rahim***///
///**Author Thasin Sheikh**///
/*    #include <regex>
    ...
    std::string string("hello $name");
    string = std::regex_replace(string, std::regex("\\$name"), "Somename");
    */
#include<bits/stdc++.h>
using namespace std;
vector<int>primes;
#define MAX 35000
#define makefast__  ios_base::sync_with_stdio(false);
using ll=long long int  ;
using dl =double;
ll aarray[100000+10];
ll magic[501][501];
ll ar[200000+10];
ll vi[40000+10];
ll  a,b;
int main()
{
    makefast__
    string ptr,str;
    ll m1,m2,m3,m4,i,j,n,k,m5,l,m,r,ta,t,ans,flag,g,nmpo=INT_MAX,hariken=INT_MAX;
    ll w1,w2,w3,w4,w5;
    vector<ll>dvi;
    bool primes[1000007];
    memset(primes,true,sizeof(primes));
    primes[0]=primes[1]=false;
    set<ll>sl;
    for(i=2; i<=100001; i++)
    {
        if(primes[i])
        {
            for(j=i; i*j<=1000001; j++)
            {
                primes[i*j]=false;
            }
        }
    }
    cin>>n;
    if(primes[n]){
        cout<<n<<endl;
    return 0;}
    for(i=n+1;;i++)
    {
        if(primes[i])
        {
            cout<<i<<endl;
            return 0;
        }
    }


}

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

int main(void){
    long long int x, cnt=0;
    cin >> x;
    cnt = x/11*2;
    x %= 11;
    if(x == 0){
        cout << cnt << endl;
    }else if(x <= 6){
        cout << cnt+1 << endl;
    }else{
        cout << cnt+2 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

ll s[3003][3003];
ll dp[3003][3003][4]; // dp[a][b][c]:= (a,b)で同じ行でc個拾った時の最大の価値

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int h,w,k;
    cin >> h >> w >> k;
    rep(i,k){
        int a,b,c;
        cin >> a >> b >> c;
        s[a][b] = c;
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            // マス目(i,j)を拾った場合
            for(int k=0;k<3;k++){
                chmax(dp[i][j][1],dp[i-1][j][k] + s[i][j]);
                chmax(dp[i][j][k+1],dp[i][j-1][k] + s[i][j]);
            }
            chmax(dp[i][j][1],dp[i-1][j][3] + s[i][j]);
            // 拾わない場合
            for(int k=0;k<=3;k++){
                chmax(dp[i][j][k],dp[i][j-1][k]);
                chmax(dp[i][j][0],dp[i-1][j][k]);
            }
        }
    }
    ll ans = 0;
    rep(i,4)chmax(ans,dp[h][w][i]);
    cout << ans << endl;
}

Measured memory_bytes: 355528
#include<bits/stdc++.h>
using namespace std;
int t[200];
int main(){
    int n, m, sum=0;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>t[i]; sum+=t[i];
    }
    cin>>m;
    for(int i=0; i<m; i++){
        int p, x;
        cin>>p>>x;
        cout<<sum-t[p-1]+x<<endl;
    }

    return 0;
}

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

typedef struct Node{
	int key;
	struct Node *next;
	struct Node *prev;
}Node;

Node *nil, *x;

Node* listSearch(int key){
	Node *c = nil->next;
	while(c != nil && c->key != key){
		c = c->next;
	}
	return c;
}

void insert(int key){
  x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

void init(){
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList(){
	Node *c = nil->next;
	int i = 0;
	while(1){
		if(c == nil){
			break;
		}
		else if(i++ > 0){
			printf(" ");
		}
		printf("%d" ,c->key);
		c = c->next;
	}
	printf("\n");
}

void deleteNode(Node *t){
	if(t == nil){
		return;
	}
	else{
		t->prev->next = t->next;
		t->next->prev = t->prev;
		free(t);
	}
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void deleteKey(int key){
	deleteNode(listSearch(key));
}

int main()
{
	int key, n, i;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d" ,&n);
	init();
	for(i = 0; i < n; i++){
		scanf("%s%d", com, &key);
		if(com[0] == 'i'){
			insert(key);
			np++;
		}
		else if(com[0] == 'd'){
			if(strlen(com) > 6){
				if(com[6] == 'F'){
					deleteFirst();
				}
				else if(com[6] == 'L'){
					deleteLast();
				}
			}
			else{
				deleteKey(key);
				nd++;
			}
		}
	}
	printList();
	return 0;
	
}



Measured memory_bytes: 33024
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

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

	if (a < 10 && b < 10) {
		cout << a * b << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;

}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n - 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < n - 1; i++) {
        cin >> c[i];
    }

    int prv = -2;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += b[a[i]];
        if (prv + 1 == a[i]) ans += c[prv];
        prv = a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

uint64_t gcd(uint64_t x, uint64_t y) {
    // assuming x > y
    auto rem = x%y;
    if (rem == 0) return y;
    return gcd(y, rem);
}

int
main(int argc, char** argv) {
    uint64_t x, y; cin >> x >> y;
    if (x > y) {
        cout << gcd(x, y) << endl;
    } else {
        cout << gcd(y, x) << endl;
    }
}


Measured memory_bytes: 3116
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  
  int n, m; rd(n, m);
  auto g=new int[][](n, 0);
  foreach(_; 0..m){
    int a, b; rd(a, b);
    a--; b--;
    g[a]~=b; g[b]~=a;
  }

  auto c=new int[](n);
  fill(c, -1);
  bool dfs(int i, int w, int p=-1){
    c[i]=w;
    bool ret=true;
    foreach(j; g[i])if(j!=p){
      if(c[j]==-1) ret&=dfs(j, w^1, i);
      else if((c[j]^w)==0) ret=false; 
    }
    return ret;
  }

  if(dfs(0, 0)){
    long w=0;
    foreach(e; c)if(e==0) w++;
    writeln(w*(long(n)-w)-m);
  }else{
    writeln(long(n)*(n-1)/2-m);
  }

}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 14588
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int ans = 0;
    int n;
    int isIncrase = 1;

    scanf("%d", &n);
    long long int h, max = 0;

    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &h);
        if (h > max)
            max = h;
        if (h <= max - 2)
        {
            isIncrase = 0;
            break;
        }
    }

    if (isIncrase)
        puts("Yes");
    else
        puts("No");

    return 0;
}

Measured memory_bytes: 1632
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <cmath>
#include <cstring>
#include <cstdio>

using namespace std;

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

int main() {
    int A, B;
    cin >> A >> B;
    int x, y, z;
    x = A + B;
    y = A - B;
    z = A * B;
    cout << max(max(x, y), z) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main()
{
   int  n,t;

    while(scanf("%d%d",&n,&t)!=EOF&&n!=0)
    {
        int sum=0;
        int f[200]={0};
        for(int i=0;i<n;i++)
        {
            int x,y;
            scanf("%d%d",&x,&y);
           f[x]=max(f[x],y);
        }
        for(int i=1;i<=t;i++)
            sum+=f[i];
        printf("%d\n",sum);
    }
    return 0;
}








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

int main(){
	int n, m, sum=0;
	cin >> n >> m;
	int a[m+1][n+1], b[m+1], c[m+1];
	for(int i=1; i<=m; i++){
		cin >>c[i];
		for(int j=1; j<=c[i]; j++)
			cin >> a[i][j];
	}
	for(int i=1; i<=m; i++)
		cin >> b[i];
	int d[n+1]={0}, j=n;
	while(d[0]==0){
		j=n;
		int f=1;
		while(d[j]!=0){
			d[j]=0;
			j--;
		}
		d[j]=1;
		for(int i=1; i<=m; i++){
			int s=0;
			for(int k=1; k<=c[i]; k++){
				if(d[a[i][k]]==1)s++;
			}
			if(s%2!=b[i])f=0;
		}
		if(f==1)sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

//----------------------------------------



int main(void)
{

	int n,x;
	cin >> n >> x;

	vector<int> l(n);

	int ans = 1;

	rep(i, n) cin >> l[i];

	int now = 0;
	rep(i, n) {
		now += l[i];
		if (now <= x) ans++;

	}

	cout << ans << endl;

}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(X: int, Y: int):
    foot = 4 * X
    for _ in range(X + 1):
        if foot == Y:
            print(YES)
            return
        
        elif foot > Y:
            foot -= 2
        
        else:
            break
    
    print(NO)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9216
n=int(input())
a=sorted(list(map(int,input().split())))
c=[0]*8
k=n
for i in range(n):
    if a[i]<400:
        c[0]=1
    elif a[i]<800:
        c[1]=1
    elif a[i]<1200:
        c[2]=1
    elif a[i]<1600:
        c[3]=1
    elif a[i]<2000:
        c[4]=1
    elif a[i]<2400:
        c[5]=1
    elif a[i]<2800:
        c[6]=1
    elif a[i]<3200:
        c[7]=1
    else:
        k=i
        break

d=0
for i in range(8):
    if c[i]==1:
        d+=1
if d==0:
    print(1, end=" ")
else:
    print(d, end=" ")


#問題文を完全に読み違えた
print(d+(n-k))


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int cmp(char s1[4],char s2[4]){
    int answer = 0;
    for(int i = 0;i < 4;i++){
        if(s1[i] == s2[i]){
            answer++;
        }
    }
    if(answer >= 3){
        return 1;
    }else{
        return 0;
    }
}

int main()
{
    char S[4] = "DAY";
    scanf("%s", S);
    if(cmp(S,"SUN")){
        printf("%d",7);
    }else if(cmp(S,"SAT")){
        printf("%d",1);
    }else if(cmp(S,"MON")){
        printf("%d",6);
    }else if(cmp(S,"TUE")){
        printf("%d",5);
    }else if(cmp(S,"WED")){
        printf("%d",4);
    }else if(cmp(S,"THU")){
        printf("%d",3);
    }else if(cmp(S,"FRI")){
        printf("%d",2);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define     PI                       acos(-1)
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=2000+9;
ll arr[N],ans[N];
void add(int a,int b,int val){

  for(int i=a;i<=b;i++) ans[i]+=val;
}
int main(){
    GO();
    ll n,x,y;
    cin>>n>>x>>y;

    for(int i=1;i<=n;i++){

        for(int j=i+1;j<=n;j++){
            if(i<=x){
            if(j<x){
                ans[j-i]++;
            }
            else if(j>=y){
                ans[(x-i+1)+(j-y)]++;
            }
            else{
                int p1= (x-i)+(j-x);
                int p2= (x-i)+(1+(y-j));
                ans[min(p1,p2)]++;
            }
            }
            else if(i>=y){
                ans[j-i]++;
            }
            else{
                if(j<=y){
                    int p1= (i-x+1)+(y-j);
                    int p2= (j-i);
                    ans[min(p1,p2)]++;
                }
                else{
                    int p1= (i-x+1);
                    int p2= (y-i);
                    ans[min(p1,p2)+(j-y)]++;
                }
            }
        }
    }
    for(int i=1;i<=n-1;i++) cout<<ans[i]<<endl;
}











































































































Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    int firstA = line.indexOf("A");
    int lastZ = line.lastIndexOf("Z");
    line = line.substring(firstA, lastZ + 1);
    System.out.println(line.length());
    
  }
}

Measured memory_bytes: 26312
#include<stdio.h>
#include<string.h>
int main(){
 	int a,b,c,i;	
  	int ans = 99999;
  	int tmp = 0;
  char s[9999];
  char t[9999];
 	int sl,tl;
  
  scanf("%s",s);
  scanf("%s",t);
  
  sl = strlen(s);
  tl = strlen(t);
  
  for(i=0;i<sl-tl+1;i++){
    b=0;
    for(a=0;a<tl;a++){
      if(s[i+a]!=t[a]){
       b++; 
      }
    }
    if(b<=ans){
      ans=b;
    }
  }
  
  printf("%d",ans);
  return 0;
}



Measured memory_bytes: 1736
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a[] = new int[3];
        for (int i=0;i<3;i++){
            a[i]=sc.nextInt();
        }
        if (a[0]==1&&a[1]==1||a[2]==1){
            System.out.println("Open");
        }else{
            System.out.println("Close");
        }
    }
}

Measured memory_bytes: 17320
N,M=map(int, input().split())
a=N//2
b=a+1
if N&1:
    for i in range(M):
        print(a,b)
        a-=1
        b+=1
else:
    for i in range(M):
        print(a,b)
        a-=1
        b+=1
        if 2+N//2>b-a>=N//2: b+=1


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

vector<ll> compress(vector<ll> &X) {
    vector<ll> vals = X;
    sort(vals.begin(), vals.end());
    vals.erase(unique(vals.begin(), vals.end()), vals.end());
    for (int i = 0; i < (int)X.size(); i++) {
        X[i] = lower_bound(vals.begin(), vals.end(), X[i]) - vals.begin();
    }
    return vals;
}

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

int main(){
    int n, m; cin >> n >> m;
    vector<ll> x, y;
    vector<ll> a(n), b(n), c(n), d(m), e(m), f(m);

    rep(i,n){
        cin >> a[i] >> b[i] >> c[i];
        x.push_back(a[i]);
        x.push_back(b[i]);
        y.push_back(c[i]);
    }
    rep(i,m){
        cin >> d[i] >> e[i] >> f[i];
        x.push_back(d[i]);
        y.push_back(e[i]);
        y.push_back(f[i]);
    }
    x.push_back(1001001001ll);
    x.push_back(-1001001001ll);
    x.push_back(0ll);
    y.push_back(1001001001ll);
    y.push_back(-1001001001ll);
    y.push_back(0ll);
  
    auto xx = compress(x);
    auto yy = compress(y);
    vector<ll> nx, ny;
    rep(i,(int)xx.size()) rep(j,2) nx.push_back(xx[i]);
    rep(i,(int)yy.size()) rep(j,2) ny.push_back(yy[i]);
  
    vector<vector<pair<ll,ll>>> data((int)nx.size()-1,vector<pair<ll,ll>>((int)ny.size()-1,make_pair(1,0)));
    rep(i,(int)xx.size()-1) rep(j,(int)yy.size()-1) {
        data[i*2+1][j*2+1].second = (xx[i+1] - xx[i]) * (yy[j+1] - yy[j]);
    }
    rep(i,n){
        int id = lower_bound(all(yy),c[i]) - yy.begin();
        int from = lower_bound(all(xx),a[i]) - xx.begin();
        int to = lower_bound(all(xx),b[i]) - xx.begin();
        for(int j = from * 2; j <= to * 2; j++) data[j][id*2].first = 0;
    }
    rep(i,m){
        int id = lower_bound(all(xx),d[i]) - xx.begin();
        int from = lower_bound(all(yy),e[i]) - yy.begin();
        int to = lower_bound(all(yy),f[i]) - yy.begin();
        for(int j = from * 2; j <= to * 2; j++) data[id*2][j].first = 0;
    }
    int sx = (lower_bound(all(xx),0ll) - xx.begin()) * 2;
    int sy = (lower_bound(all(yy),0ll) - yy.begin()) * 2;

    queue<pair<int,int>> que;
    que.push(make_pair(sx,sy));
    ll ans = 0;
    while(!que.empty()){
        auto p = que.front();
        que.pop();
        rep(i,4){
            int nnx = p.first + dx[i], nny = p.second + dy[i];
            if(0 <= nnx && nnx < (int)nx.size()-1 && 0 <= nny && nny < (int)ny.size()-1){
                if(!data[nnx][nny].first) continue;
                if(nnx == 0 || nnx == (int)nx.size()-1 || nny == 0 || nny == (int)ny.size()-1){
                    cout << "INF" << endl;
                    return 0;
                }
                else{
                    data[nnx][nny].first = 0;
                    ans += data[nnx][nny].second;
                    que.push(make_pair(nnx,nny));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 567340
#include <iostream>
#include <cmath>
#include <cstdlib>

using namespace std;

#define MAXN 100005

#define OFFSET 2

const int inf = (int)2e9+10;

int arr[MAXN];
int dp[MAXN];

int main(){

    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);

    int n;cin>>n;
    //arr[0] = arr[1] = arr[2] = inf;
    for(int i=0;i<=OFFSET;i++)arr[i]=inf; //offset macro compatibility xd 
    cin>>arr[1+OFFSET];
    for(int i=1+OFFSET+1;i<=n+OFFSET;i++){
        cin>>arr[i];
        dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
    }
    
    cout<<dp[n+OFFSET]<<endl;
#ifdef NOTINAIR
    for(int i=1+OFFSET;i<=n+OFFSET;i++)cerr<<dp[i]<<' ';
    cerr<<endl;
#endif
}


Measured memory_bytes: 1024
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>
#include <unordered_map>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること

    ll n = inp1;
    vector<ll> a = inp(n);

    sort(ALL_OF(a), greater<ll>());


    REP(i, 1) {
        auto jtr = lower_bound(a.begin() + i+1, a.end(), a[i]/2, greater<ll>());
        ll c1 = jtr == a.begin()+1 ? *(jtr) : *(jtr - 1);
        ll c2 = jtr == a.end()     ? *(jtr - 1) : *(jtr);
        ll c = abs(a[i] - c1 * 2) < abs(a[i] - c2 * 2) ? c1 : c2;
        cout << a[i] << " " << c << endl;
    }

}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
const ll mod = 1000000007;

int dist[3][100005],n,m;
bool used[3][100005];
vector<int>edge[100005];

int main(){
	scanf("%d%d",&n,&m);
	rep(i,m){
		int a,b; scanf("%d%d",&a,&b);
		edge[a].pb(b);
	}
	rep(i,3)rep(j,100005)dist[i][j]=INF;
	int s,t; scanf("%d%d",&s,&t);
	queue<P>que;
	dist[0][s] = 0; que.push(mp(0,s));
	
	while(!que.empty()){
		P p = que.front(); que.pop();
		if(used[p.fi][p.sc]) continue;
		used[p.fi][p.sc] = 1;
		rep(i,edge[p.sc].size()){
			int x = (p.fi+1)%3;
			int y = edge[p.sc][i];
			dist[x][y] = min(dist[x][y],dist[p.fi][p.sc]+1);
			if(!used[x][y]) que.push(P(x,y));
		}
	}
	if(dist[0][t] > INF/2) dist[0][t] = -3;
	cout << dist[0][t]/3 << endl;
}

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

struct UnionFind{
    vector<int> par;
    UnionFind(int N) : par(N){
        for(int i = 0; i < N; i++){
            par[i] = -1;
        }
    }
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        else{
            if(par[rx] > par[ry]) swap(rx, ry);
            par[rx] += par[ry];
            par[ry] = rx;
       }
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    void check(){
        for(auto x : par){
            cout << x << " ";
        }
        cout << endl;
    }
};

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

    int n, m;
    cin >> n >> m;

    vector<int> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
        A[i]--;
    }

    UnionFind uf(n);

    while(m--){
        int x, y;
        cin >> x >> y;
        x--; y--;
        uf.unite(x, y);
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(uf.same(i, A[i])) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3952
#include<stdio.h>
#include<string.h>
int main(){

  char n[500];
  int i,m,count,len,sum,shift;

  while(1){
    
    scanf("%s", n);

    if ( n[0] == '-' ) break;
    
    scanf("%d", &m);
    
    sum = 0;
    for ( i = 0 ; i < m ; i++ ){
      scanf("%d", &count);
      sum = sum + count;
    }

    len = strlen(n);

    for ( i = 0 ; i < len ; i++ ){
      n[ i + len ] = n[i];
    }

    shift = sum % len;

    for ( i = 0 ; i < len ; i++ ){
      printf("%c", n[ i + shift ] );
    }

    printf("\n");
    
  }

  return 0;

}

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

int main(){
    int n;cin>>n;
    map<int,int>a;
    set<int>b;
    for(int i=2;i<=n;++i){
        int m=i;
        for(int j=2;j*j<=m;++j){
            if(m%j==0){
                b.insert(j);
                while(m%j==0){
                    m/=j;
                    a[j]++;
                }
            }
        }
        if(m!=1){a[m]++;b.insert(m);}
    }
    int c74=0,c24=0,c14=0,c4=0,c2=0;
    for(auto x:b){
        if(a[x]>=74)c74++;
        else if(24<=a[x])c24++;
        else if(14<=a[x])c14++;
        else if(4<=a[x])c4++;
        else if(2<=a[x])c2++;
    }
    int ans=0;
    ans+=c74;
    ans+=(c74+c24)*((c74+c24)-1)+(c74+c24)*(c14+c4+c2);
    ans+=(c74+c24+c14)*(c74+c24+c14-1)+(c74+c24+c14)*c4;
    ans+=(c74+c24+c14+c4)*(c74+c24+c14+c4-1)*(c74+c24+c14+c4-2)/2+(c74+c24+c14+c4)*(c74+c24+c14+c4-1)/2*c2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n = int(input())
x = list(map(int,input().split()))
x_vi = [(v,i) for i,v in enumerate(x)]
x_vi.sort()
medl = x_vi[n//2-1][0]
medr = x_vi[n//2][0]
ret_median = [0 for _ in range(n)]
for sort_idx,vi in enumerate(x_vi):
    if sort_idx < n//2:
        ret_median[vi[1]]=medr
    else:
        ret_median[vi[1]]=medl
for i in ret_median:
    print(i)

Measured memory_bytes: 35120
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

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

int main()
{
        int dx[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
        int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
        int H, W;
        cin >> H >> W;
        vector<string> S(H);
        rep(i, H) cin >> S[i];

        rep(i, H)
        {
                rep(j, W)
                {
                        if (S[i][j] == '#')
                                continue;
                        int bomb = 0;
                        rep(k, 8)
                        {
                                int x = i + dx[k];
                                int y = j + dy[k];
                                if (x < 0 || H - 1 < x)
                                        continue;
                                if (y < 0 || W - 1 < y)
                                        continue;
                                if (S[x][y] == '#')
                                        bomb++;
                        }
                        S[i][j] = char(bomb + '0');
                }
        }
        rep(i, H) cout << S[i] << endl;

        return 0;
}


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

int main() {
	int R;
	cin >> R;
	if (R < 1200) cout << "ABC" << endl;
	else if (R < 2800) cout << "ARC" << endl;
	else cout << "AGC" << 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>;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

int main(){
    int n, m;
    cin >> n >> m;
    if(abs(n - m) > 1){
        cout << 0 << endl;
        return 0;
    }
    mint nkaijo = 1, mkaijo = 1;
    rep(i, n){
        nkaijo *= mint(i + 1);
    }
    rep(i, m){
        mkaijo *= mint(i + 1);
    }
    mint ans;
    ans = nkaijo * mkaijo;
    if(n == m)ans *= mint(2);
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 256
n,s = open(0).read().split()

imp_close = 0
imp_open = 0

for char in s:
    if char == '(':
        imp_open += 1
    else:
        if imp_open:
            imp_open -= 1
        else:
            imp_close += 1

print('('*imp_close + s + ')'*imp_open)

Measured memory_bytes: 9028
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{

    public static void main(String[] args)  throws IOException {
        // write your code here

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        //int t = Integer.parseInt(reader.readLine());

        String s = reader.readLine();
        String[] inp = s.split(" ");

        int a = Integer.parseInt(inp[0]);
        int b = Integer.parseInt(inp[1]);
        int c = Integer.parseInt(inp[2]);

        int tr = a-b;

        int x = tr-c;

        if(x>=0)
        {
            System.out.println("0");
        }
        else
        {
            System.out.println(c-tr);
        }
    }
}


Measured memory_bytes: 22612
@$_=$_ for@p=0..<>;map{unshift@a,$#p*~-$#p/2-$%;/ /;@{$B=$p[$']}>@{$A=$p[$`]}or$A^=$B^=$A^=$B;$%+=$B-$A&&@$B*map$p[$$B[@$B]=$_]=$B,@$A}reverse<>;print"@a"

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n, x, y;
  cin >> n >> x >> y;

  x--;
  y--;

  vector<int> d(n, 0);
  rep(i, n) REP(j, i + 1, n) {
    int tmp = j - i;

    if (i <= x && y <= j) {
      tmp = min(j - i, x - i + 1 + j - y);
    } else if (x <= i && y <= j) {
      tmp = min(j - i, i - x + 1 + j - y);
    } else if (i <= x && j <= y) {
      tmp = min(j - i, x - i + 1 + y - j);
    } else {
      tmp = min(j - i, i - x + 1 + y - j);
    }
    d[tmp]++;
  }

  REP(i, 1, n) cout << d[i] << endl;
}


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

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

using namespace std;

int main(){
  int a,b;cin>>a>>b;
  if(a>b) rep(i,a)cout<<b;
  else rep(i,b)cout<<a;
  return 0;
}

Measured memory_bytes: 256
const lines=readlines(open("/dev/fd/0"))
input()=shift!(lines)
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
intLine()=map(intSub,split(input()))
function main()
    H,W=intLine()
    h,w=intLine()
    println((H-h)*(W-w))
end
main()

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

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

    int P[N + 1];
    int minNum = 200000;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        cin >> P[i];
        if (minNum >= P[i]) {
            minNum = P[i];
            ans++;
        }
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,K;
  cin >> N >> K;
  vector<pair<int,int>> xy(N);
  for(int i=0;i<N;i++){
    int x,y;
    cin >> x >> y;
    xy.at(i)=m_p(x,y);
  }

  vector<ll> px(N);
  vector<ll> py(N);
  for(int i=0;i<N;i++){
    px.at(i)=xy.at(i).fi;
    py.at(i)=xy.at(i).se;
  }
  sort(all(px));
  sort(all(py));

  ll ans=6e18;
  for(int px_i=0;px_i<N;px_i++){
    for(int px_j=px_i;px_j<N;px_j++){
      for(int py_i=0;py_i<N;py_i++){
        for(int py_j=py_i;py_j<N;py_j++){
          int cnt=0;
          ll lx=px.at(px_i);
          ll rx=px.at(px_j);
          ll ly=py.at(py_i);
          ll ry=py.at(py_j);
          for(int i=0;i<N;i++){
            int x=xy.at(i).fi;
            int y=xy.at(i).se;
            if(lx<=x && x<=rx && ly<=y && y<=ry) cnt++;
          }
          if(cnt>=K)  chmin(ans,(rx-lx)*(ry-ly));
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}

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

int n;
int field[1000][1000];
int total;

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;

    total = 0;
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
        scanf("%d", &field[i][j]);
        total += field[i][j];
      }
    }

    for (int i=0; i<n; i++) {
      int sum = 0;
      for (int j=0; j<n; j++) {
        sum += field[i][j];
      }
      field[i][n] = sum;
    }
    field[n][n] = total;

    for (int j=0; j<n; j++) {
      int sum = 0;
      for (int i=0; i<n; i++) {
        sum += field[i][j];
      }
      field[n][j] = sum;
    }

    for (int i=0; i<n+1; i++) {
      printf("%5d", field[i][0]);
      for (int j=1; j<n+1; j++) {
        printf("%5d", field[i][j]);
      }
      puts("");
    }
  }
}

Measured memory_bytes: 2788
import sys
# ポイント: a ^ a = 0 より (全aのxor) = A とすると (自分以外のaのxor) = A xor 自分a
# 拡張して、 a xor a xor a ... xor aについて,aが偶数個のとき 0


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
a = LI()
# sum(a) = (A xor A xor A xor A xor A xor A) xor (a1 xor a1 xor ... xor a6)
# = 0 xor (a1 xor a1 xor ... xor a6)
# = (a1 xor a1 xor ... xor a6)
# = A これでAが求められる
# よって (自分以外のaのxor) xor A = 自分a
A = 0
for elem in a:
    A ^= elem
print(*list(map(lambda elem: elem ^ A, a)))


Measured memory_bytes: 31504
n, k = input().split()
n, k=int(n),int(k)
#print(n)
#print(k)
stick=input().split()
#print(stick)

#リストのstrをintに変換
for i in range(len(stick)):
	stick[i]=int(stick[i])
#print(stick)
#変換ここまで

#大きいうちからk本の棒の合計を求めるため、ソートする。
stick=sorted(stick,reverse= True)
#print(stick)

#ソートしたリストの大きい側からk個の数値を足し合わせる
a=0
a=int(a)
for i in range(k):
	a=a+stick[i]
print(a)

Measured memory_bytes: 3060
/* ex2_1_3
Acro */

#include <stdio.h> 
int main(void){
    int n,n_1;
    scanf("%d",&n);
    /* 1の位を抽出 */
    n_1 = n % 10;
    /* 条件分岐、改行忘れずに */
    if(n_1 == 3)
    {
        printf("bon\n");
    }
    else if (n_1 == 0 || n_1 == 1 || n_1 == 6 || n_1 == 8)
    {
        printf("pon\n");
    }
    else
    {
        printf("hon\n");
    }
    
    return 0;
}

Measured memory_bytes: 1636
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if((a==b)&& (b== c) ||((a!= b) && (a!= c) && (b!=c)))
       cout<<"\nNo";
  else
    cout<<"Yes\n";
  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
#define ll long long

int main(){
    ll N,t;
    double K;
    cin >> N >> K;
    double p=1.0/(double) N;
    double ans=0.0;
    while(N>=1){
        t=max((ll)0,(ll)(N-ceil(K)+1));
        ans+=t*p;
        N=N-t;
        K=K/2.0;
        p=p/2.0;
    }
    cout<< setprecision(15) <<ans <<endl;
    return 0;
}


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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define pb push_back


// string size = str.size()

// stack <int> s; 
// queue <int> gquiz; 
// __gcd(m, n) 

// ll arr[10e5 + 5];
// char arr[10e5 + 5];


bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}


int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll a,b,c,k;
    cin >> a>>b>>c>>k;
    ll cnt = 0;
    if(k>0)
    {
        if(k <=a)
        {
            cnt += k;
            k = 0;
        }
        else
        {
            cnt += a; 
            k -= a;
        }
    }
    // cout << "k is " << k << endl;
    // cout << "cnt is "<<cnt << endl;
    if(k > 0)
    {
        if(k<=b)
        {
            k = 0;
        }
        else
        {
            k -= b; 
        }  
    }
    // cout << "k is " << k << endl;
    // cout << "cnt is "<<cnt << endl;


    if(k > 0)
    {
        if(k<=c)
        {
            cnt += k*(-1);
            k = 0;
        }
        else
        {
            cnt+= c*(-1);
        }
    }
    // cout << "k is " << k << endl;
    // cout << "cnt is "<<cnt << endl;

    cout << cnt << endl;
    return 0;
}   

Measured memory_bytes: 3652