akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;

int point(int C[]){
	
	int e = 0;

	
	//??£???
	for (int i = 0; i < 9; i++){
		if (C[i] == 10)break;
		int f = 0;
		int p = C[i];
		int acc[3];
		acc[0] = i;
		for (int j = i + 1; j < 9; j++){
			if (C[j] == 10)break;

			if (C[j] == p + 1){
				f++;
				p++;
				acc[f] = j;
			}
			if (f == 2)break;
		}

		if (f == 2){
			e++;
			C[acc[0]] = 0; C[acc[1]] = 0; C[acc[2]] = 0;

		}
		
	}


	int l=0;
	int n = 0;

	/*printf("%d\n", e);
	for (int i = 0; i < 9; i++) printf("%d", C[i]);
	printf("\n");*/

	sort(C, C + 9);

	for (int i = 0; i < 9; i++) {
		if (C[i] != 0 && C[i] != 10){
			l = i;
			n++;
			break;
		}
	}

	if (e == 3 || n==0)return e;
	
	

	//???
	int p = 0;
	int d = 0;
	for (int i = l; i < 9; i++){
		if (C[i] == 10)break;
		if (p == 0 && C[i] != 0){
			p = C[i];
			continue;
		}
		if (C[i]>p){
			d = 0;
			p = C[i];
			continue;
		}
		else if (C[i] == p){
			d++;
		}
		
		if (d == 2){
			e++;
			p = C[i + 1];
			d = 0;
			i ++;
		}
	}

	return e;

}

int main(){

	

	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		int n[9];
		char c[9];
		int R[9];
		int G[9];
		int B[9];
		int r = 0, g = 0, b = 0;
		//?????????
		for (int j = 0; j < 9; j++){
			c[j] = 0;
			n[j] = 0;
			R[j] = 10;
			G[j] = 10;
			B[j] = 10;
		}

		//????????????	
		for (int j = 0; j < 9; j++){
			cin >> n[j];
		}
		for (int j = 0; j < 9; j++){
			cin >> c[j];
		}


		//?????????
		for (int j = 0; j < 9; j++){
			if (c[j] == 'R'){
				R[r] = n[j];
				r++;
			}
			else if (c[j] == 'G'){
				G[g] = n[j];
				g++;
			}
			else if (c[j] == 'B'){
				B[b] = n[j];
				b++;
			}
		}
		sort(R, R + 9);
		sort(G, G + 9);
		sort(B, B + 9);
		//??????
		int e = 0;
		
		//R
		if (R[0] != 10){
			e += point(R);
			
		}
		//G
		if (e < 3 && G[0] != 10){
			e += point(G);
			
		}
		//B
		if (e < 3 && B[0] != 10){
			e += point(B);
			
		}
		//printf("%d %d",i+1, e);
		if (e == 3){
			cout << 1 << endl;
			//printf(" 1\n");
		}
		else{
			cout << 0 << endl;
			//printf(" 0\n");
		}
		//break;
	}

	return 0;

}

Measured memory_bytes: 1180
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;
#define ll long long
#define pb push_back
#define pp pair<long long,long long>
#define ppp pair<long long, pair<long long,long long> >
#define f first	
#define s second
#define pd pair<double,long long>
void solveTestCase() {
	ll n,i,j,k,l;
	cin>>n;
	vector<pp> arr(n);
	for (i=0;i<n;i++)
		cin>>arr[i].f>>arr[i].s;
	bool flag=false;
	for (i=0;i<n-2;i++) {
		if (arr[i].f==arr[i].s && arr[i+1].f==arr[i+1].s && arr[i+2].f==arr[i+2].s)
			flag=true;
	}
	if (flag)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}
int main() {
	ll t,n,i,j,k,l,m;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll p;
	t=1;
	//cin>>t;
	for (ll T=1;T<=t;T++) {
		solveTestCase();
	}
	return 0;
}

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

int main(){
  int n,a,b,sum=0;
  cin>>n>>a>>b;
  for(int i=1;i<=n;i++){
    int z=i,t=0;
    while(z>0){
      t+=z%10;
      z/=10;
    }
    if(a<=t && t<=b) sum+=i;
  }

  cout<<sum<<endl;
}


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

int main() {
	// your code goes here
	int n,m;
	cin>>n>>m;
	int a[n],sum=0;
	for(int i=0;i<n;i++){
	    cin>>a[i];
	    sum+=a[i];
	}
	
	
	int c=0;
	int pro=4*m;
	for(int i=0;i<n;i++){
	    if(1ll*a[i]*pro>=sum) c++;
	}
	cout<<((c>=m)?"Yes":"No")<<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)
typedef long long ll;
typedef pair<int, int> P;

P getNum(int x){
    int a = x%10;
    int b = 0;
    while(x) {
        b = x;
        x/=10;
    }
    return P(a, b);
}

int main(){
    int n;
    cin >> n;
    map<P, int> mp;
    for(int i = 1; i <= n; i++){
        P p = getNum(i);
        mp[p]++;//存在しなとこにアクセスすると0値が入る
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        P p = getNum(i);
        P q(p.second, p.first);
        ans += mp[q];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, M;
    cin >> N >> M;

    vector<vector<bool>> light(M, vector<bool>(N, 0));

    rep(i, M) {
        int k;
        cin >> k;
        rep(j, k) {
            int s;
            cin >> s;
            light[i][s - 1] = true;
        }
    }

    vector<int> p(M);
    rep(i, M) cin >> p[i];
    int ans = 0;
    rep(bit, 1 << N) {
        vector<int> sw(N);
        rep(i, N) {
            sw[i] = ((bit >> i) & 1); 
        }
        bool flag = true;
        rep(i, M) {
            int cnt = 0;
            rep(j, N) {
                if (!light[i][j]) continue;
                cnt += sw[j];
            }
            if (cnt % 2 != p[i]) flag = false;
        }
        if (flag) ans++;
    }

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

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

from collections import deque
from pprint import pprint
moves=[(0,1),(1,0),(0,-1),(-1,0)]
pp=pprint
# INF=float("inf")

h,w,k=map(int,input().split())
x1,y1,x2,y2=map(lambda x:int(x)-1,input().split())
maze=[list(input()) for _ in range(h)]
cost=[[-1]*w for _ in range(h)]

todo=deque()
todo.append((x1,y1))
cost[x1][y1]=0

while todo:
    x,y=todo.popleft()
    for vx,vy in moves:
        for kk in range(1,k+1):
            nx=x+vx*kk
            ny=y+vy*kk
            if not(0<=nx<h) or not(0<=ny<w):
                break
                # 更に伸ばす必要はない
            if maze[nx][ny]=="@":
                break
                # 蓮の向こうにはいけない
            if cost[nx][ny]!=-1 and cost[nx][ny]<=cost[x][y]:
                # 更新を1回以上受けていて、更に良くならない場合はbreak
                break
            if cost[nx][ny]==-1:
                cost[nx][ny]=cost[x][y]+1
                todo.append((nx,ny))


# pp(cost)
ans=cost[x2][y2]
print(ans)

Measured memory_bytes: 138944
def gcd(x,y):
	x, y = max(x,y), min(x,y)
	while(y):
		x, y = y, x%y
	return x
A,B,C,D = map(int,input().split())
A -= 1
CD = C*D // gcd(C,D)
a = A - (A//C + A//D - A//CD)
b = B - (B//C + B//D - B//CD)
print(b-a)

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

int main(){
  string str,com,rep;
  char work;
  int n,a,b;

  cin >> str;
  cin >> n;

  for(int i=0; i<n; ++i){
    cin >> com >> a >> b;
    
    if(com == "replace"){
      cin >> rep;
      for(int k=a; k<=b; ++k){
	str[k] = rep[k - a];
      }
    }else if(com == "reverse"){
      string str2 = str;
      int l = b - a + 1;
      int counter = 0;
      for(int k = a; k<=b; ++k){
	str[k] = str2[b-counter];

	++counter;
      }
    }else{
      for(int k = a; k<=b; ++k){
        cout << str[k];
      }
      cout << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
using ll = long long;

int main(){
    ll H, W; std::cin >> H >> W;
    std::string temp(W+2,'.');
    std::vector<std::string> s(H+2, temp);

    for(int i=0; i<H; i++){
        std::string b; std::cin >> b;
        for(int j=0; j<W; j++){
            s[i+1][j+1] = b[j];
        }
    }

    for(int i=1; i<=H; i++){
        for(int j=1; j<=W; j++){
            if(s[i][j]=='#'){
                if(s[i][j+1]=='#'){
                    ;
                }else if(s[i][j-1]=='#'){
                    ;
                }else if(s[i+1][j]=='#'){
                    ;
                }else if(s[i-1][j]=='#'){
                    ;
                }else{
                    std::cout << "No";
                    return 0;
                }
            }
        }
    }

    std::cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) ((int)(v).size())
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1);



int main(void) {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << (60 * h2 + m2) - k - (60 * h1 + m1) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(){
    int a,b;
	scanf("%d%d",&a,&b);
	while(a!=0&&b!=0){
		for(int i=0;i<a;++i){
			for(int j=0;j<b;++j)
				printf("#");
			printf("\n");}
	printf("\n");
	scanf("%d%d",&a,&b);}
	
	return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int bns (int a[], int l, int r, int key) {
    int mid, pos = l - 1;
    while(l<=r) {
        mid=(l+r) / 2;
        if(a[mid]<key) {
            l = mid + 1;
            pos = mid;
        } else
            r = mid - 1;
    }
    return pos;
}
int main() {
    int n;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    int cnt=0;
    for(int i=0; i<n-2; i++) {
        for(int j=i+1; j<n-1; j++) {
            cnt += bns(a,j+1,n-1,a[i] + a[j]) - j;
        }
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 256
import std.container;
import std.range;
import std.algorithm;
import std.array;
import std.string;
import std.conv;
import std.stdio;
import std.container;

void main() {
	auto s = readln.chomp;
	auto c = s.count!(x => x == 'R');

	if (c == 2 && s[1] != 'R') {
		writeln(1);
	} else {
		writeln(c);
	}
}


Measured memory_bytes: 2600
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
 
    String[] inputHeader = scanner.nextLine().split(" ");
    
    int N = Integer.parseInt(inputHeader[0]);
    int K = Integer.parseInt(inputHeader[1]);
    
    String[] inputData = scanner.nextLine().split(" ");

    int[] array = new int[200000+1];
    
    for(int i =0;i <N;i++){
        array[Integer.parseInt(inputData[i])]++;
    }

    Arrays.sort(array);
    
    int result = 0;
    for(int i = 0;i < array.length-K;i++){
        result += array[i];
    }
    
    System.out.println(result);
    scanner.close();
  }
}

Measured memory_bytes: 57016
def make_divisors(n:int):
    upper_div = []
    lowwer_div = []
    i = 1
    while i*i <= n:
        if n%i == 0:
            lowwer_div.append(i)
            if n//i != i:
                upper_div.append(n//i)
        i+=1
    return lowwer_div + upper_div[::-1]

def main():
    a,b,c = [int(i) for i in input().strip().split()]
    ans = 0
    divs = make_divisors(c)
    
    for d in divs:
        if a <= d  and d <= b:
            ans += 1
    
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5600
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  string S;
  cin>>N>>S;
  for(int i=0;i<S.size();++i) {
    if(S[i]+N>'Z') S[i] = S[i]+N-'Z'+'A'-1;
    else S[i] += N;
  }
  cout<<S<<endl;
}



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


int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false);
    int n; std::cin >> n;
    std::vector<int> A(n); for(int i = 0; i < n; ++i) std::cin >> A[i];
    int res = 0;
    for(int i = 0; i < n; ++i) for(int j = i + 1; j < n; ++j) if(A[i] != A[j]){
        const int e1 = (A[i] < A[j]) ? A[j] - A[i] : A[i] - A[j];
        const int e2 = A[i] + A[j];
        for(int k = j + 1; k < n; ++k) if(A[i] != A[k] and A[j] != A[k]){
            if(e1 < A[k] and A[k] < e2) ++res;
        }
    }
    std::cout << res << '\n';
    return 0;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//最大公約数
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}

//複数個の最大公約数
ll ngcd(vector<ll> a)
{
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size() && res != 1; i++)
  {
    res = gcd(a[i], res);
  }
  return res;
}

//最小公倍数
ll lcm(ll a, ll b)
{
  return a / gcd(a, b) * b;
}

//素因数分解
map<ll, ll> prime_factor(ll n)
{
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

//複数個の最小公倍数
ll nlcm(vector<ll> numbers)
{
  ll res;
  res = numbers[0];
  for (ll i = 1; i < numbers.size(); i++)
  {
    res = lcm(res, numbers[i]);
  }
  return res;
}

void Main()
{
  ll n; cin >> n;
  ll flag = 0;
  vll a(n); rep(i, n) cin >> a[i];
  ll B = 1;
  if(a[0] == 1)
  {
    flag++;
    B = 0;
  }
  for(ll i = 1;i < n;i++)
  {
    if(B == 0&&a[i] == i + 1)
    {
      B = 1;
      continue;
    }
    if(a[i] == i + 1)
    {
      B = 0;
      flag++;
    }
    else
    {
      B = 1;
    }
  }
  fin(flag);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


Measured memory_bytes: 1024
W,H,N = map(int,input().split())
zero = [0,0]
X = [W,H]
ans = True
for i in range(N):
    x,y,a = map(int,input().split())
    if(a == 1):
        if zero[0] < x < X[0]:
            zero[0] = x
        elif X[0] <= x:
            ans = False
            break
    elif(a == 2):
        if zero[0] < x < X[0]:
            X[0] = x
        elif zero[0] >= x:
            ans = False
            break
    elif(a == 3):
        if zero[1] < y < X[1]:
            zero[1] = y
        elif X[1] <= y:
            ans = False
            break
    elif(a == 4):
        if zero[1] < y < X[1]:
            X[1] = y
        elif zero[1] >= y:
            ans = False
            break
if(ans):
    S = (X[1] - zero[1]) * (X[0] - zero[0])
    print(S)
else:
    print(0)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
ll MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}
ll modpow(ll x, ll y, ll m) {
    if (y == 0) return 1;
    ll res = modpow(x, y / 2, m);
    return res * res % m * (y & 1 ? x : 1) % m;
}
ll modinv(ll x) { return modpow(x, MOD - 2, MOD); }

int main(){
    string S,T,U; ll A,B; cin >> S >> T >> A >> B >> U;
    if(S == U) cout << A-1 << " " << B;
    else cout << A << " " << B-1;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 20;
const ll INF = (1LL<<60);
int N; ll A[MAXN + 5];
ll dfs(int l, int r, int cntl, int cntr) {
	if( l + 1 == r ) return 0;
	ll ret = dfs(l, l+1, cntl, cntl+cntr) + dfs(l+1, r, cntl+cntr, cntr) + (cntl+cntr)*A[l+1];
	for(int i=l+2;i<=r-1;i++)
		ret = min(ret, dfs(l, i, cntl, cntl+cntr) + dfs(i, r, cntl+cntr, cntr) + (cntl+cntr)*A[i]);
	return ret;
}
int main() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++)
		scanf("%lld", &A[i]);
	printf("%lld\n", dfs(1, N, 1, 1) + A[1] + A[N]);
}

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

#define MAXN 100
#define WHITE 0
#define BLACK 1

using namespace std;

int D[MAXN][MAXN];

bool judge ( int color, int i, int j)
{
  if ( i-1 >= 0 && j-1 >= 0 && D[i-1][j-1] == color ) return false;
  if ( i-1 >= 0 && D[i-1][j] == color ) return false;
  if ( i-1 >= 0 && j+1 < MAXN && D[i-1][j+1] == color ) return false;
  if ( i+1 < MAXN && j-1 >= 0 && D[i+1][j-1] == color ) return false;
  if ( i+1 < MAXN && D[i+1][j] == color ) return false;
  if ( i+1 < MAXN && j+1 < MAXN && D[i+1][j+1] == color ) return false;
  if ( j-1 >= 0 && D[i][j-1] == color ) return false;
  if ( j+1 < MAXN && D[i][j+1] == color ) return false;

  return true;
}

int main()
{
  int A,B;
  int cnt;

  cin >> A >>B;

  for ( int i = 0; i < 50; ++i ) {
    for ( int j = 0; j < MAXN; ++j ) D[i][j] = BLACK;
  }

  cnt = 1;
  for ( int i = 0; i < 49; ++i ) {
    for ( int j = 0; j < MAXN; ++j ) {
      if ( cnt == A ) break;
      if ( judge(WHITE, i,j) ) {
        D[i][j] = WHITE;
        ++cnt;
      }
    }
  }

  cnt = 1;
  for ( int i = 51; i < MAXN; ++i ) {
    for ( int j = 0; j < MAXN; ++j ) {
      if ( cnt == B ) break;
      if ( judge(1, i, j) ) {
        D[i][j] = 1;
        ++cnt;
      }
    }
  }


  cout << " " << MAXN << " " << MAXN <<"\n";
  for ( int i = 0; i < MAXN; ++i ) {
    for ( int j = 0; j < MAXN; ++j ) {
      if ( D[i][j] ) cout << '#';
      else cout << '.';
    }
    cout << "\n";
  }
}


Measured memory_bytes: 256
package main


import "fmt"


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


func main () {
  var n int
  fmt.Scanf("%d", &n)

  h := make([]int, n)
  for i := 0; i<n; i++ {
    fmt.Scanf("%d", &h[i])
  }

  var ans int = 1
  var cur int = h[0]

  for i := 1; i<n; i++ {
    if cur <= h[i] {
      cur = h[i]
      ans++
    }
  }

  fmt.Println(ans)
}




Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
int n,m;
vector<int> g[100001];
int dis1[100001],dis2[100001];
int sum1,sum2;
void dfs1(int fa,int x){
	for(int i=0;i<g[x].size();i++){
		if(g[x][i]!=fa){
			dis1[g[x][i]]=dis1[x]+1;
			dfs1(x,g[x][i]);
		}
	}
}
void dfs2(int fa,int x){
	for(int i=0;i<g[x].size();i++){
		if(g[x][i]!=fa){
			dis2[g[x][i]]=dis2[x]+1;
			dfs2(x,g[x][i]);
		}
	}
}
int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	m=n-1;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--,b--;
		g[a].push_back(b);
		g[b].push_back(a); 
	}
	dfs1(0,0);
	dfs2(m,m);
	sum1=sum2=0;
	for(int i=0;i<n;i++){
		if(dis1[i]<=dis2[i]) sum1++;
		else sum2++;
	}
	if(sum1>sum2) cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
    return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

//#define int long long

/*************** using variables ***************/
string s;
/**********************************************/

signed main(){
    while(getline(cin, s), s != "."){
        stack<char> st;
        st.push('.');
        auto itr = s.begin();
        bool flag = true;
        while(*itr != '.'){
            if(*itr == '['  || *itr == '(') st.push(*itr);
            if(*itr == ']'){
                if(st.top() != '['){
                    flag = false;
                    break;
                }else{
                    st.pop();
                }
            }
            if(*itr == ')'){
                if(st.top() != '('){
                    flag = false;
                    break;
                }else{
                    st.pop();
                }
            }
            ++itr;
        }
        cout << (flag && '.' == st.top() ? "yes":"no") << endl;
        s = "";
    }
}



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

int main() {
    
    int n,i;
    double s;
    s=0;
    cin>>n;
    double a[n];
    string u[n];
    for(i=0;i<=n-1;i++){
        cin>>a[i]>>u[i];
        if(u[i]=="JPY"){
            s=s+a[i];
        }else if(u[i]=="BTC"){
            s=s+a[i]*380000;
        }
    }
    cout<<s<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
$n=<>;
@a=glob<>;
@b=glob<>;
@c=glob<>;
for$i(0..$n-1){
	$ans+=$b[$a[$i]-1];
	if($i&&$a[$i-1]+1==$a[$i]){
		$ans+=$c[$a[$i-1]-1];
	}
}
print$ans

Measured memory_bytes: 5276
class Dice
  @north = 5
  @south = 2
  @east = 3
  @west = 4
  @top = 1
  @bottom = 6

  def initialize(input_t, input_s, input_e, input_w, input_n, input_b)
    @north = input_n
    @south = input_s
    @east = input_e
    @west = input_w
    @top = input_t
    @bottom = input_b
  end

  def move(order_array)
    length = order_array.length
    for i in 0..(length-1)
      if order_array[i] == "N"
        move_north
      elsif order_array[i] == "S"
        move_south
      elsif order_array[i] == "E"
        move_east
      else
        move_west
      end
    end
    return @top
  end

  def move_north
    tmp = []
    tmp.push(@north)
    tmp.push(@south)
    tmp.push(@top)
    tmp.push(@bottom)
    @bottom = tmp[0]
    @top = tmp[1]
    @north = tmp[2]
    @south = tmp[3]
  end

  def move_south
    tmp = []
    tmp.push(@north)
    tmp.push(@south)
    tmp.push(@top)
    tmp.push(@bottom)
    @top = tmp[0]
    @bottom = tmp[1]
    @south = tmp[2]
    @north = tmp[3]

  end

  def move_east
    tmp = []
    tmp.push(@east)
    tmp.push(@west)
    tmp.push(@top)
    tmp.push(@bottom)
    @bottom = tmp[0]
    @top = tmp[1]
    @east = tmp[2]
    @west = tmp[3]
  end

  def move_west
    tmp = []
    tmp.push(@east)
    tmp.push(@west)
    tmp.push(@top)
    tmp.push(@bottom)
    @top = tmp[0]
    @west = tmp[2]
    @bottom = tmp[1]
    @east = tmp[3]
  end

end

dice_numbers = gets.chomp.split.map(&:to_i)
dice_order = gets.chomp
input_t = dice_numbers[0]
input_s = dice_numbers[1]
input_e = dice_numbers[2]
input_w = dice_numbers[3]
input_n = dice_numbers[4]
input_b = dice_numbers[5]
dice = Dice.new(input_t, input_s, input_e, input_w, input_n, input_b)
puts dice.move(dice_order)

Measured memory_bytes: 8656
#include<bits/stdc++.h>    
using namespace std;  
  
int dp[2][3][10][500][500];  
string s;  
int M;  
  
int rec(int idx, int mod, bool free, int pre, int pre_up){  
  if(idx == s.size()) return mod == 0;  
  if(~dp[free][pre_up][pre][idx][mod]) return dp[free][pre_up][pre][idx][mod];  
  int ret = 0, end = free ? 9 : s[idx] - '0';  
  
  for(int i = 0; i <= end; i++){  
  
#define next(l)  rec( idx + 1, (mod * 10 + i) % M, free|(i != end), i, l)  
  
    if(pre_up == 1 && pre <= i) continue;  
    if(pre_up == 2 && pre >= i) continue;   
  
    if(pre_up == 0){
      if(pre && pre == i) continue;
      if(pre == 0) ret += next(0);  
      else if(pre < i) ret += next(1);  
      else if(pre > i) ret += next(2);  
    } else if(pre_up == 1){  
      ret += next(2);
    } else {
      ret += next(1);
    }
  }  
  return dp[free][pre_up][pre][idx][mod] = ret % 10000;  
}  
  
int get_value(string str){  
  s = str;  
  fill_n( ****dp, 500 * 500 * 10 * 2 * 3, -1);  
  return rec( 0, 0, false, 0, 0);  
}  
  
string sub(string s){  
  for(int i = s.size() - 1; i >= 0; i--){  
    if(s[i] == '0') s[i] = '9';  
    else{ s[i]--; break; }  
  }  
  return s;  
}  
int main(){  
  string a, b;  
  cin >> a >> b;  
  cin >> M;  
  cout << (get_value(b) - get_value(sub(a)) + 10000) % 10000 << endl;  
}  

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

#define rep(i,a,b)                for(ll i=a;i<b;i++)
#define re(i,b)                for(ll i=0;i<b;i++)
#define repr(i,n)                for(ll i=n-1;i>=0;i--)
#define ll long long
#define ld long double
#define llu long long unsigned
#define vll std::vector<ll>
#define mll std::map<ll, ll>
#define pll std::pair<ll, ll>
#define mpll std::map<pair<ll,ll>, ll>
#define sll std::set<ll>
#define fi first
#define se second
#define msll std::multiset<ll>
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define srt(x) sort(all(x))
#define rsrt(x) sort(allr(x))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define s(yy) ll yy;cin>>yy
#define mod 1000000007
#define maxlong 9223372036854775808


/*
###################################################### 
#                                                    #
#                     @author                        #
#                  Parth Lathiya                     #
#      https://www.cse.iitb.ac.in/~parthiitb/        #
#                                                    #
###################################################### 
*/

// vll primes;
// vll primefac[10000001];

// void sieve(ll n)
// {
// 	rep(i,2,n+1)
// 	{
// 		if(primefac[i].empty())
// 		{	
// 			primes.pb(i);
// 			for(ll j=i;j<=n;j+=i)
// 				primefac[j].pb(i);
// 		}
// 	}
// }


int main()
{

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

	#ifdef PARTH_LATHIYA_HOME

		freopen("D_in.txt","r",stdin);
	
		ll ttt,bkkk;
		cin>>ttt;
		bkkk=ttt;
		while(ttt--) {
			cout<<"Testcase - "<<bkkk-ttt<<"\n";
	#endif

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

	s(n);
	string s;
	cin>>s;
	
	stack<char> ss;
	re(i,n){
		if(!ss.empty() && ss.top()=='(' && s[i]==')')
			ss.pop();
		else
			ss.push(s[i]);
	}

	ll o=0;
	ll c=0;

	while(!ss.empty() && ss.top()=='('){ss.pop();o++;}
	while(!ss.empty() && ss.top()==')'){ss.pop();c++;}

	re(i,c)
		cout<<'(';
	re(i,n)
		cout<<s[i];
	re(i,o)
		cout<<')';
		
//--------------------------------------------------------------------------------------
	
	#ifdef PARTH_LATHIYA_HOME
		cout<<"\n"; }
	#endif

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int solve(int, int);

int n, A[2000];

int main(){
  int q, m[2000], i;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  scanf("%d", &q);
  for(i=0; i<q; i++) scanf("%d", &m[i]);

  for(i=0; i<q; i++){
    if(solve(0, m[i]) == 1) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}

int solve(int i, int m){
  if(m == 0) return 1;
  if(i >= n) return 0;
  return ( solve(i+1, m) || solve(i+1, m-A[i]) );
}

Measured memory_bytes: 588
#include <stdio.h>
int main()
{
	int a=0,b=0,c=0,k=0;
	int total=0;
	scanf("%d %d %d",&a,&b,&c);
	scanf("%d",&k);
	
	for(int i=0;i<k;i++)
	{
	if(a>b)
	{
		if(a>c)
		{
			a=2*a;
		}
		else
		{
			c=2*c;
		}
	}
	
	else
	{
		if(b>c)
		{
			b=2*b;
		}
		
		else
		{
			c=2*c;
		}
	}
	}
	
	total=a+b+c;
	printf("%d",total);
	return 0;
}

Measured memory_bytes: 128
/*
     去年の本選はこの程度の問題をバグらせていたとは壊れるなあ
 */

#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

int m, n;
int p[10000];
int _psum[10001];
int *psum = _psum+1;
int c[500];
int e[500];
int dp[501][10001]; // dp[n][m]
int ans;

int main() {
    fill((char*)dp, (char*)(dp)+sizeof(dp), -1);

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

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

    sort(p, p+m, greater<int>());
    for (int i=0; i<m; i++) {
        psum[i] = psum[i-1] + p[i];
    }

    dp[0][0] = 0;
    for (int i=0; i<n; i++) {
        for (int j=0; j<=m; j++) {
            int to = j+c[i];
            int diff;
            
            if (dp[i][j] == -1) continue;
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if (to > m) to = m;
            diff = psum[to-1] - psum[j-1] - e[i];
            dp[i+1][to] = max(dp[i+1][to], dp[i][j]+diff);
        }
    }

    for (int i=0; i<=m; i++) {
        ans = max(ans, dp[n][i]);
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 20692
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn solve(a: i64, b: i64, c: i64, d: i64) -> bool {
    // c < a + bx + dy < b
    // c-a < bx + dy < b-a
    if a < b || d < b {
        false
    } else if c >= b {
        true
    } else {
        let lower = c - a;
        let upper = b - a;
        assert!(lower < upper);

        let g = gcd(b, d);
        if upper <= 0 {
            let (lower, upper) = (-upper, -lower);
            let next_g = (lower + g) / g * g;
            assert!(next_g > lower);
            assert!(next_g - g <= lower);
            if upper > next_g {
                false
            } else {
                true
            }
        } else if lower >= 0 {
            let next_g = (lower + g) / g * g;
            assert!(next_g > lower);
            assert!(next_g - g <= lower);
            if upper > next_g {
                false
            } else {
                true
            }
        } else {
            assert!(lower < 0);
            assert!(upper > 0);
            false
        }
    }
}

fn main() {
    input!(t: usize, abcd: [(i64, i64, i64, i64); t]);
    for &(a, b, c, d) in abcd.iter() {
        if solve(a, b, c, d) {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 4352
from collections import deque
n = int(input())
a = list(map(int, input().split()))

ans = deque([])
t = 0
for i in a:
  if t == 0: ans.append(i)
  else: ans.appendleft(i)
  t = 1 - t

if t == 0: print(*ans)
else: print(*reversed(ans))

Measured memory_bytes: 32412
using System;
using System.Linq;
public class Test
{ 
    public static void Main()
    { int ans=0;
           
        while(true){
            string str=Console.ReadLine();
            if(str==null){break;}
            string bef="";
            for(int i=0;i<str.Length;i++){
                char u=str[i];
                if(u=='0'||u=='1'||u=='2'||u=='3'||u=='4'||u=='5'||u=='6'||u=='7'||u=='8'||u=='9')
                {bef+=u;}
                else if(bef!=""){
                    ans+=int.Parse(bef);
                    bef="";
                }
                   
            }
            if(bef!=""){
            ans+=int.Parse(bef);
            bef="";
            	
            }
        }    
        Console.WriteLine(ans);
             
             
        
        // your code goes here
    }
}


Measured memory_bytes: 9036
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

int p[100000];

struct UF
{
    vector<int> r, p;
    UF(int n) : r(n, 0), p(n, 0)
    {
        iota(p.begin(), p.end(), 0);
    }
	
    int f(int x)
    {
        return (p[x] == x ? x : p[x] = f(p[x]));
    }
	
    void u(int i, int j)
    {
        int x = f(i), y = f(j);
        if (x == y)
            return;

        if (r[x] >= r[y])
        {
            p[y] = x;
            if (r[x] == r[y])
                r[x]++;
        }
        else
            p[x] = y;
    }

    bool s(int i, int j)
    {
        return f(i) == f(j);
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
        cin >> p[i], p[i]--;

    UF uf(n);
    for (int i = 0; i < m; ++i)
    {
        int x, y;
        cin >> x >> y;
        x--; y--;
        uf.u(x, y);
    }
    vector<vector<int>> a(n), b(n);
    for (int i = 0; i < n; ++i)
    {
        a[uf.f(i)].push_back(i);
        b[uf.f(i)].push_back(p[i]);
    }
    int sol = 0;
    for (int i = 0; i < n; ++i)
    {
        sort(all(a[i]));
        sort(all(b[i]));
        vector<int> c(a[i].size());
        c.resize(set_intersection(all(a[i]), all(b[i]), c.begin()) - c.begin());
        sol += c.size();
    }
    cout << sol;
}


Measured memory_bytes: 12288
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

const int MAX_N = 100005;

int n;
pair<int, int> a[MAX_N];

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

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(a, a + n);

	for (int i = 0; i < n; i++)
		cout << (a[i].second + 1) << " ";
	cout << endl;

	return 0;
}

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

const double PI=acos(-1.0);

int main() {
    int a[4];
    string s;
    cin >> s;
    rep(i, 4) {
        a[i] = s[i] - '0';
    }
    
    int sum = 0;
    char op[3];
    rep(i, 8) {
        sum = a[0];
        rep(j, 3) {
            if(i & (1 << j)) {
                op[j] = '+';
                sum += a[j + 1];
            } else {
                op[j] = '-';
                sum -= a[j + 1];
            }
        }
        if(sum == 7) {
            break;
        }
    }

    rep(i, 3) {
        cout << a[i] << op[i];
    }
    cout << a[3] << "=7" << 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 P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
int64_t N,M,i;

vector<int64_t> ediv(int64_t n){
  vector<int64_t> ret;
  for(i=1;i*i<=n;i++){
    if(n%i == 0){
      ret.push_back(i);
      if(i!=1 && i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  ret.push_back(n);
  return ret;
}
int64_t mn=LINF;
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

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

  cin>>N>>M;
  for(auto i: ediv(M)){
    if(i>=N){
      mn=min(mn, i);
    }
  }
  cout<<M/mn<<endl;
  return 0;
}


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

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

    int N;
    cin >> N;
    string s;
    cin >> s;

    vector<int> w(N + 1, 0);
    vector<int> b(N + 1, 0);
    rep(i, N) {
        if (s[i] == '#')
            b[i + 1] = 1;
    }
    reverse(all(s));
    rep(i, N) {
        if (s[i] == '.')
            w[i + 1] = 1;
    }

    rep(i, N) { b[i + 1] += b[i]; }
    rep(i, N) { w[i + 1] += w[i]; }
    reverse(all(w));

    ll ans = INF;
    rep(i, N + 1) {
        ll tmp = b[i] + w[i];
        ans = min(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 5196
l=[0]*120
s="#"*20
n=input()
while n:n-=1;b,f,r,v=map(int,raw_input().split());l[b*30+f*10+r-41]+=v
print"",
while 1:
 n+=1;print l[n-1],
 if n==120:break
 if n%30==0:print;print s,
 if n%10==0:print;print"",

Measured memory_bytes: 4216
def submit():
    n = int(input())
    h = list(map(int, input().split()))

    d = [0 for _ in range(n)]
    d[1] = abs(h[1] - h[0])

    for i in range(2, n):
        d[i] = min(
            abs(h[i] - h[i - 1]) + d[i - 1],  # i-1から
            abs(h[i] - h[i - 2]) + d[i - 2]   # i-2から
        ) 

    print(d[n - 1])


submit()

Measured memory_bytes: 13924
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int V, x, y;
    cin >> V >> x >> y;
    --x; --y;
    vector<int> ans(V);
    for(int i = 0; i < V - 1; ++i){
        for(int j = i + 1; j < V; ++j){
            if(!(j < x || i > y)){
                int d1 = abs(x - i) + 1 + abs(j - y);
                int d2 = abs(x - j) + 1 + abs(i - y);
                int d3 = j-i;
                int d = min(min(d1, d2), d3);
                ans[d]++;
            }
            else{
                int dist = j - i;
                ans[dist]++;
            }
        }
    }
    for(int i = 1; i < V; ++i){
        cout << ans[i] << endl;
    }

}
int main(int argv, char **argc){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


Measured memory_bytes: 3660
def get_root(s):
    if s != root[s]:
        root[s] = get_root(root[s])
        return root[s]
    return s

def unite(s, t):
    root_s = get_root(s)
    root_t = get_root(t)
    if not root_s == root_t:
        if rank[s] == rank[t]:
            root[root_t] = root_s
            rank[root_s] += 1
            union_count[root_s] += union_count[root_t]
        elif rank[s] > rank[t]:
            root[root_t] = root_s
            union_count[root_s] += union_count[root_t]
        else:
            root[root_s] = root_t
            union_count[root_t] += union_count[root_s]

def same(s, t):
    if get_root(s) == get_root(t):
        return True
    else:
        return False

n, m, k = map(int, input().split())
root = [i for i in range(n)]
rank = [1 for _ in range(n)]
union_count = [1 for _ in range(n)]
friend_count = [0] * n
for _ in range(m):
    a, b = map(int, input().split())
    unite(a - 1, b - 1)
    friend_count[a - 1] += 1
    friend_count[b - 1] += 1
ans = [-1] * n
for _ in range(k):
    c, d = map(int, input().split())
    if same(c - 1, d - 1):
        ans[c - 1] -= 1
        ans[d - 1] -= 1
for i in range(n):
    r = get_root(i)
    ans[i] += union_count[r] - friend_count[i]
print(" ".join(map(str, ans)))

Measured memory_bytes: 20280
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define INF 1000000009
#define LINF 1000000000000000009
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }
ll mod = 1000000007;

ll fac[2000010];

ll modinv(ll a) {
	ll b = mod, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}

void modfac() {
	fac[0] = 1;
	for (ll i = 1; i < 2000010; i++) {
		fac[i] = (fac[i - 1] * i) % mod;
	}
}

ll modperm(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	else return (fac[n] * modinv(fac[n - k])) % mod;
}

ll modcomb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	else return ((fac[n] * modinv(fac[k])) % mod*modinv(fac[n - k])) % mod;
}

int main() {
	ll r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	modfac();
	ll ans = 0;
	for (ll i = r1; i <= r2; i++) {
		ans += modcomb(c2 + i + 1, i + 1);
		ans -= modcomb(c1 + i, i + 1);
		if (ans < 0) ans += mod;
		if (ans >= mod) ans -= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 15872
# coding: utf-8
# Your code here!

n=int(input())
l=list(map(int,input().split()))
flg=0
l.sort()
if n%2!=0:
    flg=1
ans=l[n//2]-l[n//2-1]
if flg==0:
    print(ans)
else:
    print(0)


Measured memory_bytes: 14428
n,k = map(int,input().split())
v = list(map(int,input().split()))
import bisect

ans=0
minnk = min(n,k)
for r in range(minnk+1):
    for l in range(minnk+1-r):
        sute = k-(r+l)
        
        temoti = sorted(v[:l] +v[n-r:])
        n_nega = bisect.bisect(temoti,0)
        score = sum(temoti[min(n_nega,sute):])

        if ans<score:
            ans=score
print(ans)   

Measured memory_bytes: 42088
#include <algorithm>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#ifdef __APPLE__
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...)
#endif

const int N = (int)1e6 + 123;
const int MOD = (int)1e9 + 7;
const int inf = (int)5e8;
const long long infll = (long long)1e17;

void solve() {
    long long a, b, c;
    scanf("%lld %lld %lld", &a, &b, &c);
    int ans = 0;
    set<vector<long long>> was;
    while ((a % 2 + b % 2 + c % 2) == 0) {
        if (was.count({a, b, c})) {
            printf("-1\n");
            return;
        }
        was.insert({a, b, c});
        long long add[3] = {a / 2, b / 2, c / 2};
        a = add[1] + add[2];
        b = add[0] + add[2];
        c = add[0] + add[1];
        ++ans;
    }
    printf("%d\n", ans);
}

int main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
count =0
s = list(map(int, input()))
s1 = s[:2]
if s1 >= [0, 1] and s1 <= [1, 2]:
    count += 1
s1 = s[2:]
if s1 >= [0, 1] and s1 <= [1, 2]:
    count += 2

if count == 0:
    print("NA")
elif count == 1:
    print("MMYY")
elif count == 2:
    print("YYMM")
elif count == 3:
    print("AMBIGUOUS")

Measured memory_bytes: 3064
n = int(input())
connect_list = [[] for i in range(n)]
for i in range(n-1):
    a, b, c = [ int(v)-1 for v in input().split() ]
    c += 1
    connect_list[a].append((b,c))
    connect_list[b].append((a,c))


q, k = [ int(v) for v in input().split() ]
k -= 1

shortest_list = [-1 for i in range(n)]
shortest_list[k] = 0

searching_list = [k]

while searching_list != []:

    new_search_list = []
    for i in searching_list:
        for j in connect_list[i]:
            x, y = j
            if shortest_list[x] == -1:
                shortest_list[x] = y + shortest_list[i]
                new_search_list.append(x)
    searching_list = new_search_list


for i in range(q):
    a, b = [ int(v)-1 for v in input().split() ]
    print(shortest_list[a] + shortest_list[b])


Measured memory_bytes: 83152
while True:
  ans=[]
  a=int(input())
  if a ==0: break
  ans.append(a)
  for i in range(4):
    b=int(input())
    ans.append(b)
  if 1 in ans and 2 in ans and 3 in ans:
    for i in range(5): print "3"
  elif 1 in ans and 2 in ans and 3 not in ans:
    for i in range(5):
      if ans[i] == 1: print 1
      else: print 2
  elif 2 in ans and 3 in ans and 1 not in ans:
    for i in range(5):
      if ans[i] == 2: print 1
      else: print 2
  elif 3 in ans and 1 in ans and 2 not in ans:
    for i in range(5):
      if ans[i] == 3: print 1
      else: print 2
  else:
    for i in range(5): print "3"

Measured memory_bytes: 4272
#include <cstdio>
#include <cstring>

int n,k;

int main()
{
	scanf("%d %d",&n,&k);
	int now=(n-1)*(n-2)/2,tot=n-1,con=0;
	if(k>now)
	{
		printf("-1");
		return 0;
	}
	if(k<n-2)
	{
		k=n-2-k;
		printf("%d\n",n-1+(n-3+1+n-k-2+1)*k/2);
		for(int i=1;i<n;i++)
		printf("%d %d\n",i,i+1);
		for(int i=1;i<=k;i++)
		for(int j=i+2;j<=n;j++)
		printf("%d %d\n",i,j);
		return 0;
	}
	while(now>k)
	{
		now--;
		if(con<tot-3)con++;
		else tot--,con=0;
	}
	printf("%d\n",n-1+con);
	for(int i=2;i<=1+tot;i++)
	printf("%d %d\n",1,i);
	for(int i=3;i<=2+con;i++)
	printf("%d %d\n",2,i);
	for(int i=1+tot;i<n;i++)
	printf("%d %d\n",i,i+1);
}

Measured memory_bytes: 128
n  =int(input())

arr =[int(x) for x in input().split()]
summ = sum(arr)
q = int(input())
from collections import *
count = Counter(arr)
while q:
     q-= 1
    #  print(count)
     b,c = [int(x) for x in input().split()]
     summ += count[b]*c - count[b]*b
    #  temp = count[b] + 0
     count[c] += count[b]
     count[b] = 0
     print(summ)

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

typedef unsigned long ul;
typedef long long int ll;
typedef pair<ll, ll> P;
#define pb push_back
#define mp make_pair
#define REP(i,n) REPN(i,0,n)
#define REPN(i,m,n) for(int i=m; i<(n); i++)
#define dump(x) cout << #x << " = " << (x) << endl

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

    int n;
    char a[100], b[100], c[100];
    cin >> n >> a >> b >> c;

    ll ans = 0;

    REP(i, n) {
        if (a[i] == b[i] || b[i] == c[i] || a[i] == c[i]) {
            ans++;
        } else {
            ans += 2;
        }
        if (a[i] == b[i] && b[i] == c[i]) {
            ans--;
        }
    }

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


Measured memory_bytes: 256