akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
typedef double db;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;
int n , m;
bool flag = false;
char mp1[55][55],mp2[55][55];
bool dfs(int x , int y)
{
	bool flag1 = true;
	for(int i = x , a = 1; i <= x + m - 1; i++,a++)
		for(int j = y,b = 1 ; j <= y + m - 1; j++,b++)
			{
			if(mp1[i][j] == mp2[a][b])continue;
			else flag1 = false;
			}
	return flag1;
	}
int main()
{
	cin >> n >> m;
	for(int i = 1 ; i <= n ; i++)
		for(int j = 1; j <= n ; j++)
			cin >> mp1[i][j];
	for(int i = 1; i <= m ; i++)
		for(int j = 1 ;j <= m ; j++)
			cin >> mp2[i][j];
	for(int i = 1 ; i <= n - m + 1 ; i++)
		for(int j = 1; j <= n - m + 1; j++)
			if(mp1[i][j] == mp2[1][1])if(dfs(i,j)){flag = true;break;}
	if(flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
	}

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

using namespace std;

int a[100001];
pair<long long, long long> L[100001], R[100001];

int main() {
	int i, j, k, n, m, l;
	scanf("%d%d", &n, &m);
	R[0].first = R[0].second = n;
	for (i = 1; i <= m; i++) {
		scanf("%d", &a[i]);
		if (i & 1) {
			L[i].first = L[i - 1].first;
			L[i].second = L[i - 1].second - (a[i] - a[i - 1]);
			R[i].first = R[i - 1].first;
			R[i].second = R[i - 1].second - (a[i] - a[i - 1]);
			if (L[i].second < 0) {
				L[i].first -= L[i].second;
				L[i].second = 0;
			}
			if (R[i].second < 0) {
				R[i].first -= R[i].second;
				R[i].second = 0;
			}
		}
		else {
			L[i].first = L[i - 1].first;
			L[i].second = L[i - 1].second + (a[i] - a[i - 1]);
			R[i].first = R[i - 1].first;
			R[i].second = R[i - 1].second + (a[i] - a[i - 1]);
			if (L[i].second > n) {
				L[i].first -= L[i].second - n;
				L[i].second = n;
			}
			if (R[i].second > n) {
				R[i].first -= R[i].second - n;
				R[i].second = n;
			}
		}
		//printf("%d (%lld %lld) (%lld %lld)\n", a[i], L[i].first, L[i].second, R[i].first, R[i].second);
	}
	scanf("%d", &l);
	while (l--) {
		scanf("%d%d", &i, &j);
		k = upper_bound(a, a + m + 1, i) - a - 1;
		pair<long long, long long> tL = L[k], tR = R[k];
		if (k & 1) {
			tL.second += i - a[k];
			tR.second += i - a[k];
			if (tL.second > n) {
				tL.first -= tL.second - n;
				tL.second = n;
			}
			if (tR.second > n) {
				tR.first -= tR.second - n;
				tR.second = n;
			}
		}
		else {
			tL.second -= i - a[k];
			tR.second -= i - a[k];
			if (tL.second < 0) {
				tL.first -= tL.second;
				tL.second = 0;
			}
			if (tR.second < 0) {
				tR.first -= tR.second;
				tR.second = 0;
			}
		}
		//printf("%d %d : (%lld %lld) (%lld %lld)\n", i, j, tL.first, tL.second, tR.first, tR.second);
		if (j < tL.first) printf("%lld\n", tL.second);
		else if (j > tR.first) printf("%lld\n", tR.second);
		else printf("%lld\n", j - tL.first + tL.second);
	}
}


Measured memory_bytes: 4608
n, k = map(int, input().split())
a = list(map(int, input().split()))
f = [-1] * n
f[0] = 0
s1, s2, g1, g2 = 0, 0, 0, 0
j = a[0] - 1
jpre = 0
c = 1
i = 0
while True:
    if i >= k:
        s1, s2 = f[jpre], jpre
        g1, g2 = 0, 0
        break
    if f[j] != -1:
        s1, s2 = f[jpre], jpre
        g1, g2 = f[j], j
        break
    else:
        f[j] = c
        c += 1
        jpre = j
        j = a[j] - 1
    i += 1
ans = (k - g1) % (s1 - g1 + 1) + f[g2]
for i in range(n):
    if f[i] == ans:
        print(i + 1)
        break

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

int main(void)
{
	int W, H, x, y;
	cin >> W >> H >> x >> y;
	int judge = 0;
	double area = (double)W*H / 2;
	if (2 * x == W && 2 * y == H)judge = 1;
	cout << area << " " << judge;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979


int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	map<int, bool> check;

	rep(i, k)
	{
		if (a + i > b) break;
		check[a + i] = true;
		cout << a + i  << endl;
	}
	rep(i, k)
	{
		if (b - k + 1 +  i < a || check[b - k + 1 + i] != false) continue;
		cout << b - k + 1 + i << endl;
	}
	return 0;
}

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

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x)
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

void solve()
{
    cin >> N;
    for (int i = 1; i <= N; i++)
    {
        cin >> A[i];
        for (int j = 1; j <= A[i]; j++)
        {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for (int bits = 1; bits < (1 << N); bits++)
    {
        bool ok = true;
        for (int i = 1; i <= N; i++)
        {
            if (!(bits & (1 << (i - 1))))
                continue;
            for (int j = 1; j <= A[i]; j++)
            {
                if (((bits >> (x[i][j] - 1)) & 1) ^ y[i][j])
                    ok = false;
            }
        }
        if (ok)
            ans = max(ans, counter(bits));
    }
    cout << ans << endl;
    return;
}

int main()
{
    solve();
    return 0;
}

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

int main(){
    int n,a[200],cnt=0;
    bool even_flag=true;

    cin >> n;

    for (int i = 0; i < n; i++) cin >> a[i];

    while(even_flag){

        for (int i = 0; i < n; i++) {
            if(a[i] & 1){
                even_flag = false;
                cnt--;
                break;
            }
            a[i] /= 2;
         }

        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
string s; cin>>s; int a=0;
  rep(i,s.size()) if(s.at(i)=='x') a++;
  if(a>=8) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}

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

immutable int LEFT = 0;
immutable int DOWN = 1;
immutable int RIGHT = 2;
immutable int UP = 3;
immutable int INF = 10_0000_0000;

void set( bool[][][] canMove, int l, int dir, int[] val ) {
  switch( dir ) {
  case LEFT:
	foreach ( x; 1 .. canMove[ 0 ].length ) {
	  canMove[ l ][ x ][ dir ] = ( val[ x - 1 ] == 0 );
	}
	break;
  case DOWN:
  case UP:
	foreach ( x; 0 .. canMove[ 0 ].length ) {
	  canMove[ l ][ x ][ dir ] = ( val[ x ] == 0 );
	}
	break;
  case RIGHT:
	foreach ( x; 0 .. canMove[ 0 ].length - 1 ) {
	  canMove[ l ][ x ][ dir ] = ( val[ x ] == 0 );
	}
	break;
  default:
	break;
  }
}

struct Point {
  int y;
  int x;

  this( int y, int x ) {
	this.y = y;
	this.x = x;
  }
}

void main() {
  int count = 0;
  while ( true ) {
	count++;
  	auto wh = split( strip( readln ) );
  	immutable int w = to!int( wh[ 0 ] );
  	immutable int h = to!int( wh[ 1 ] );
  	if ( w == 0 && h == 0 ) break;
	
	int[][] turn = new int[][]( h, w );
  	bool[][][] canMove = new bool[][][]( h, w, 4 );
	foreach ( arry; canMove ) {
	  foreach ( ary; arry ) {
		ary[] = false;
	  }
	}
	foreach ( i; 0 .. h - 1 ){
	  auto tokens = array( map!( to!int )( split( strip( readln ) ) ) );
	  set( canMove, i, LEFT, tokens );
	  set( canMove, i, RIGHT, tokens );
	  tokens = array( map!( to!int )( split( strip( readln ) ) ) );
	  set( canMove, i + 1, UP, tokens );
	  set( canMove, i, DOWN, tokens );
  	}
	auto tokens = array( map!( to!int )( split( strip( readln ) ) ) );
	set( canMove, h - 1, LEFT, tokens );
	set( canMove, h - 1, RIGHT, tokens );
	
	immutable int[] dx = [ -1, 0, 1, 0 ];
  	immutable int[] dy = [ 0, 1, 0, -1 ];

	auto queue = SList!Point();
	queue.insertFront( Point( 0, 0 ) );
	foreach ( ary; turn ) {
	  ary[] = INF;
	}
	turn[ 0 ][ 0 ] = 1;
	
	while ( !queue.empty ) {
	  auto p = queue.front;
	  queue.removeFront;
	  if ( p.y == h - 1 && p.x == w - 1 ) {
		break;
	  }
	  foreach ( dir; 0 .. 4 ) {
		int ny = p.y + dy[ dir ];
		int nx = p.x + dx[ dir ];
		if ( canMove[ p.y ][ p.x ][ dir ] && turn[ ny ][ nx ] > turn[ p.y ][ p.x ] + 1 ) {
		  queue.insertAfter( queue[], Point( ny, nx ) );
		  turn[ ny ][ nx ] = min( turn[ ny ][ nx ], turn[ p.y ][ p.x ] + 1 );
		}
	  }
	}
	writeln( turn[ h - 1 ][ w - 1 ] == INF ? 0 : turn[ h - 1 ][ w - 1 ] );
  }
}

void print( int[][] turn ) {
  foreach ( ary; turn ) {
	stderr.writeln( join( array( map!( v => format( "%2d", v == INF ? 0 : v ) )( ary ) ), "," ) );
  }
}

Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  if(N % 2 == 0) cout << N/2;
  else{
    cout << N/2 + 1;
  }

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));



int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a < b and b < c) puts("Yes");
    else puts("No");
}


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

using namespace std;

int main(){
	long long n, m;
	cin >> n >> m;
	if(m < n) swap(m, n);
	long long ans = (n - 2LL) * (m - 2LL);
	if(n == 1LL){
		ans = m - 2;
	}
	if(n == m && n == 1) ans = 1;
	ans = max(ans, 0LL);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for (int i=(a); i>=(b); --i)
#define REP(i,b) for (int i=0; i<(b); ++i)
#define endl '\n'
#define sz(x) (int) x.size()
#define mod %
#define fillchar(x,y,z) memset(x,z,y)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define sqr(x) ((x)*(x))
typedef long long int64;
typedef unsigned long long qword;
using namespace std;
const int maxn=1e4+5;
const int base=1e9+7;
int n,k;
char a[maxn];
int f[maxn][105][2];
void Input()
{
    cin >> (a+1);
    n=strlen(a+1);
    cin >> k;
}
int calc(int i, int remain, int isless)
{
    if (i>n) return remain==0;
    int &res=f[i][remain][isless];
    if (res!=-1) return res;
    res=0;
    FOR(digit,0,9)
        if (isless||digit<=a[i]-'0') {
            res+=calc(i+1,(remain+digit) mod k,isless|(digit<a[i]-'0'));
            if (res>=base) res-=base;
        }
    return res;
}
void Solve()
{
    fillchar(f,sizeof(f),255);
    cout << (base-1+calc(1,0,0)) mod base << endl;
}
int main()
{
    #ifdef meomeomeooooo
        freopen("input.txt","r",stdin);
        //freopen(".out","w",stdout);
    #endif // meomeomeooooo
    iostream::sync_with_stdio(false);
    cin.tie(0);
    Input();
    Solve();
    return 0;
}


Measured memory_bytes: 9216
using System;
using System.Linq;

namespace C
{
	class Program
	{
		static void Main()
		{
			var S = Console.ReadLine();

			var counts = new int[] {0, 0};

			foreach (var c in S) {
				counts[int.Parse(c.ToString())]++;
			}

			Console.WriteLine(counts.ToList().Min() * 2);
		}
	}
}

Measured memory_bytes: 15456
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

uint64_t dp[100000];
uint16_t H[100000];

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

  for (int n=0; n<N; ++n)
    cin >> H[n];
  
  dp[0] = 0;
  dp[1] = dp[0] + abs(H[1] - H[0]);
  
  for (int n=2; n<N; ++n)
    dp[n] = min(dp[n-1]+abs(H[n]-H[n-1]), dp[n-2]+abs(H[n]-H[n-2]));

  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 1280
package main

import "fmt"

func main() {
	var n, x int
	ans := make([]int, 0)
	for {
		fmt.Scan(&n, &x)
		if n == 0 && x == 0 {
			break
		}
		cnt := 0
		for i := 1; i <= n; i++ {
			for j := i + 1; j <= n; j++ {
				for k := j + 1; k <= n; k++ {
					if i+j+k == x {
						// fmt.Printf("%d+%d+%d=%d\n", i, j, k, x)
						cnt++
					}
				}
			}
		}
		ans = append(ans, cnt)
	}
	for i := range ans {
		fmt.Println(ans[i])
	}
}



Measured memory_bytes: 1124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define cY cout << "Yes" << endl;
#define cN cout << "No" << endl;

ll f(ll x){
  if(x == 1) return 1;
  return 2*f(x/2) + 1;
}

int main() {
  ll h;
  cin >> h;
  cout << f(h) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const double PI = 3.1415926535;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する
#define NIL -1
#define MAX 2 * 100000 + 10

vector<int> num(MAX);
vector<vector<int>> child(MAX);
vector<bool> fd(MAX, false);

void add(int p){
    REP(i, child[p].size()){
        if(fd[child[p][i]]) continue;
        fd[child[p][i]] = true;
        num[child[p][i]] += num[p];
        add(child[p][i]);
    }
}


signed main(void){
    int n, q; cin >> n >> q;


    REP(i, n - 1){
        int a, b; cin >> a >> b;
        child[a - 1].push_back(b - 1);
        child[b - 1].push_back(a - 1);
    }
    REP(i, q){
        int a, b; cin >> a >> b;
        num[a - 1] += b;
    }
    
    fd[0] = true;
    add(0);
    
    REP(i, n){
        if(i != 0) cout << " ";
        cout << num[i];
    }
    cout << endl;
    
}

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

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 (b<a) { a=b; return 1; } return 0; }

using ll = long long;

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

ll g(ll k,ll x){
  if(k==0LL){
    if(x%4LL==1LL||x%4LL==2LL) return 1LL;
    else return 0LL;
  }
  else {
    ll t = x%(1LL<<(k+1));
    if(t<(1LL<<k))return 0LL;
    if(t%2LL==0LL) return 1LL;
    else return 0LL;
  }
}

int main() {
  ll A,B;
  cin>>A>>B;
  bitset<60> bi;
  for(ll i = 0LL; i < 60LL; i++) {
    ll a = g(i,A-1LL);
    ll b = g(i,B);
    if((b-a)%2LL!=0LL)bi.set(i);
  }
  cout<<bi.to_ullong()<<endl;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
ll merge_cnt(vector<int> &a)
{
    int n = a.size();
    if (n <= 1)
    {
        return 0;
    }

    ll cnt = 0;
    vector<int> b(a.begin(), a.begin() + n / 2);
    vector<int> c(a.begin() + n / 2, a.end());

    cnt += merge_cnt(b);
    cnt += merge_cnt(c);

    int ai = 0, bi = 0, ci = 0;
    // merge の処理
    while (ai < n)
    {
        if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci]))
        {
            a[ai++] = b[bi++];
        }
        else
        {
            cnt += n / 2 - bi;
            a[ai++] = c[ci++];
        }
    }
    return cnt;
}
int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    auto w = v;
    sort(ALL(v));

    map<int, int> mp;
    rep(i, n) mp[v[i]] = i;
    int ans = 0;
    rep(i, n)
    {
        a[i] = mp[w[i]];
        if ((i % 2) != (a[i] % 2))
            ans++;
    }
    cout << ans / 2 << endl;
    return 0;
}


Measured memory_bytes: 6144
#include"bits/stdc++.h"
using namespace std;
int main()
{
    int k;
    string s;
    cin>>k>>s;
    int n=s.length();
    if(n<=k) {
        cout<<s<<endl;
    }
    else {
        string g = s.substr(0,k);
        g+="...";
        cout<<g<<endl;
    }
}

Measured memory_bytes: 3628
import java.util.Scanner
import scala.collection.mutable.Queue

object Main extends App { 
  val sc = new Scanner(System.in)
  val N, L = sc.nextInt()
  val An = (for (i <- 0 until N) yield sc.nextInt()).toArray
  val que = Queue[Int]()

  def enque(i:Int):Unit = {
    if (!que.isEmpty) {
      if (que.head <= i -L) que.dequeue()
      if (!que.isEmpty && An(que.last) >= An(i)) que.dequeueAll(An(_) >= An(i))
    }
    que += i
  }

  def solver(i:Int, acc:List[Int]):List[Int] = {
    if (i == N) acc.reverse
    else {
      enque(i)
      solver(i+1, An(que.head)::acc)
    } 
  }

  for (i <- 0 until L) enque(i)
  println(solver(L, List(An(que.head))).mkString(" "))
}



Measured memory_bytes: 478844
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    ll n,k;
    cin >> n >>k;
    vl d(k+1);
    for(ll i=k;i>=1;i--){
        d[i]=rep_jijo(k/i,n);
        for(ll j=2;i*j<=k;j++){
            d[i]-=d[i*j];
            d[i]%=mod;
        }
    }
    ll ans=0;
    for(ll i=1;i<=k;i++){
        ans+=i*d[i];
        ans%=mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n;
vi v;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int b;
    cin >> b;
    v.pb(b);
  }
  sort(rng(v));
  int minv = v[0], maxv = v[n-1];
  if(maxv - minv >= 2){
    cout << "No" << endl;
    return 0;
  }
  int c = 0;
  if(maxv == minv && maxv == n-1){
    cout << "Yes" << endl;
    return 0;
  }
  if(maxv > minv){
    FOR(i, 0, n){
      if(minv < v[i]) break;
      c++;
    }
    n -= c;
    maxv -= c;
    if(minv < c){
      cout << "No" << endl;
      return 0;
    }
  }
  if(maxv <= n/2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

int main() {
  uint32_t N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  string res;
  for (uint32_t i = 0; i < N; ++i) {
    res.push_back(S[i]);
    res.push_back(T[i]);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys

def bfs(loads):
    visit = [-1] * len(loads)
    d = deque([0])
    visit[0] = 0
    
    while d:
        num = d.popleft()
        
        for l in loads[num]:
            if visit[l] != -1:
                continue
            
            d.append(l)
            visit[l] = num
        
        
    return visit

n, m = map(int, input().split())
loads = [[] for _ in range(n)]

for i in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    loads[a].append(b)
    loads[b].append(a)
    
visit = bfs(loads)

if -1 in visit:
    print('No')
    sys.exit()
    
print('Yes')
for i in range(1, n):
    print(visit[i] + 1)

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

using namespace std;

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> H(N);
    for(int i = 0;i < N;i++){
        cin >> H.at(i);
    }
    sort(H.begin(),H.end());
    long long int All_HP = 0;
    for(int i = 0;i < N - K;i++){
        All_HP += H.at(i);
    }
    cout << All_HP;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  ll h, w, n;
  cin >> h >> w >> n;
  map<pii, ll> count;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    for (int dy = -2; dy <= 0; ++dy) {
      for (int dx = -2; dx <= 0; ++dx) {
	int y = a + dy;
	int x = b + dx;
	count[pii(y, x)]++;
      }
    }
  }
  vl ans(10, 0);
  for (auto entry : count) {
    if (!in_range(entry.first.first, 1, h-1) or
	!in_range(entry.first.second, 1, w-1)) {
      continue;
    }
    ans[entry.second]++;
  }
  ans[0] = (h - 2) * (w - 2);
  for (int i = 1; i <= 9; ++i) {
    ans[0] -= ans[i];
  }
  for (int i = 0; i <= 9; ++i) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 56448
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
#define end return 0;
 
ll i,j,k,ii,jj;
ll n,m,sum,num=INF;
ll ans;
ll a,b,c,d,e;
ll x[100005],y[100005],z[100005];
ll xa[100005],ya[100005],za[100005];
char s[100005];

int main(){
	cin>>s;
	n=strlen(s);
	for(i=0;i<n-1;i++){
		if(s[i]=='A' && s[i+1]=='C'){
			p("Yes");
			end;
		}
	}
	p("No");
	end;
}

Measured memory_bytes: 5632
N, M = map(int, input().split())
a, b, c = [0] * M, [0] * M, [0] * M
INF = int(1e9)
d = [[INF] * N for i in range(N)]
for i in range(M):
    a[i], b[i], c[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1
    d[a[i]][b[i]] = c[i]
    d[b[i]][a[i]] = c[i]

for i in range(N):
    d[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min((d[i][j], d[i][k] + d[k][j]))

ans = 0
for i in range(M):
    isUsed = False
    for j in range(N):
        for k in range(j, N):
            # print("d[%d][%d]: %d, d[%d][%d] + c[%d] + d[%d][%d]: %d" % (j, k, d[j][k], j, a[i], i, b[i], k, d[j][a[i]] + c[i] + d[b[i]][k]))
            isUsed = isUsed \
                or d[j][k] == d[j][a[i]] + c[i] + d[b[i]][k] \
                or d[j][k] == d[j][b[i]] + c[i] + d[a[i]][k]
    if not isUsed:
        ans += 1
print(ans)


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

int main()
{
    ll n, y;

    cin >> n >> y;

    y /= 1000;

    for (ll _1 = 0; _1 <= n; _1++) {
        for (ll _5 = 0; _1 + _5 <= n; _5++) {
            ll _10 = n-_1-_5;
            if (_1 + _5 * 5 + _10 * 10 == y) {
                cout << _10 << ' ' << _5 << ' ' << _1 << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;



    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static FastReader input = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws IOException {

		int l = input.nextInt();
		int r = input.nextInt();
		int min = Integer.MAX_VALUE;

		int x = 1;

		for (x = 1; true; x++) {
			long y = x * 2019;
			if (y >= l && y <= r) {
				min = 0;
				break;
			}
			if (y >= 2 * (int) (1e9))
				break;

		}
		l %= 2019;
		r %= 2019;
		
		if (min != 0) {
			for (int i = l; i < r; i++) {
				for (int j = i + 1; j <= r; j++) {
					min = Math.min(min, (i * j) % 2019);
				}
			}
		}

		out.println(min);

		out.flush();
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		String nextLine() throws IOException {
			String str = "";
			str = br.readLine();
			return str;
		}
	}

	static class con {
		static int IINF = (int) 1e9;
		static int _IINF = (int) -1e9;
		static long LINF = (long) 1e15;
		static long _LINF = (long) -1e15;
		static double EPS = 1e-9;
	}

	static class Triple implements Comparable<Triple> {
		int x;
		int y;
		int z;

		Triple(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		@Override
		public int compareTo(Triple o) {
			if (x == o.x && y == o.y)
				return z - o.z;
			if (x == o.x)
				return y - o.y;
			return x - o.x;
		}
	}

	static class Pair implements Comparable<Pair> {
		int x;
		int y;

		Pair(int x, int y) {
			this.x = x;
			this.y = y;

		}

		@Override
		public int compareTo(Pair o) {
			if (x == o.x)
				return y - o.y;
			return x - o.x;
		}
	}

	static void shuffle(int[] a) {
		for (int i = 0; i < a.length; i++) {
			int r = i + (int) (Math.random() * (a.length - i));
			int tmp = a[r];
			a[r] = a[i];
			a[i] = tmp;
		}
	}

}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	char c;
	cin >> c;
	if (c >= 'a') cout << "a\n";
	else cout << "A\n";
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main(){
	int a[105],b[105];
	int n,flag=1;
	cin>>n;
	int i;
	for(i=0;i<n;i++)cin>>a[i];
	for(i=0;i<n;i++){
		if(a[i]%2==0){
			if(a[i]%3!=0&&a[i]%5!=0){
				flag=0;
				break;
			}
		}
		}
	if(flag==1)printf("APPROVED");
	else printf("DENIED");
	return 0;
}

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

using namespace std;
#define ll long long 
#define pb(a) push_back(a)
#define fi first
#define se second



int main(){

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

    string s;
    cin>>s;

    s[b-1] = tolower(s[b-1]);

    cout<<s<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1000000007; 
const int N = 200005;


int main(){
    fast;
    string s;
    cin >> s;
    if(s[s.size()-1] == '2' || s[s.size()-1] == '5' || s[s.size()-1] == '7' || s[s.size()-1] == '4' || s[s.size()-1] == '9')
        cout << "hon";
    else if(s[s.size()-1] == '0' || s[s.size()-1] == '1' || s[s.size()-1] == '6' || s[s.size() - 1] == '8')
        cout << "pon";
    else
        cout << "bon";
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int A = 0, X = 1, Z = 2, B = 3, W = 4, Y = 5;
    while(1){
        string s; cin>>s;
        if(s == "#") return 0;

        bool valid = true;
        int cv = A;
        int n = s.size();
        for(int i=0; i<n; i++){
            if(cv == A){
                if(s[i] == '0') cv = X;
                else cv = Y;
            }
            else if(cv == X){
                if(s[i] == '0') valid = false;
                else cv = Z;
            }
            else if(cv == Z){
                if(s[i] == '0') cv = W;
                else cv = B;
            }
            else if(cv == B){
                if(s[i] == '0') cv = Y;
                else cv = X;
            }
            else if(cv == W){
                if(s[i] == '0') cv = B;
                else cv = Y;
            }
            else{
                if(s[i] == '0') cv = X;
                else valid = false;
            }
        }

        if(valid && cv == B){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 3180
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1 << 32


def solve(S: str, T: str):
    print([S[i] == T[i] for i in range(len(S))].count(True))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fi first
#define se second
#define Mp make_pair
#define pb push_back
#define rep(i, j, k) for (int i = (j); i <= (k); i++)
#define per(i, j, k) for (int i = (j); i >= (k); i--)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> PII;
typedef vector<int> VI;

const int N = 1e5+3;
int n,a[N],b[N];
ll nums[N*2],s[N*2];
ll ans,tmp,sa,sb;

int main(){
    scanf("%d",&n);
    rep(i,1,n) scanf("%d %d",&a[i],&b[i]);
    rep(i,1,n) sa+=a[i],sb+=b[i];
    ans=min(sa,sb);
    rep(i,1,n) nums[i]=a[i],nums[i+n]=b[i];
    sort(nums+1,nums+1+n*2);
    rep(i,1,n) s[i]=s[i-1]+nums[i];
    rep(i,1,n){
        if(a[i]>b[i]) swap(a[i],b[i]);
        tmp=a[i]+b[i];
        tmp+=s[n-2];
        if(nums[n-2]>=a[i]) {
            tmp+=-a[i]+nums[n-1];
            if(nums[n-1]>=b[i]) tmp+=-b[i]+nums[n];
        }
        ans=min(ans,tmp);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
int abs(int n){
		if(n<0){
		return -1*n;}else
		return n;}
int main(void)
{int N,A,M,B,C,x,i,a,b,c,l,m,tmp;
	scanf("%d%d",&A,&B);
if((A+B)>=10){
	printf("error");}
	else
	printf("%d",A+B);


	return 0;
}


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

using namespace std;


void solve() {
    int a,b;
    cin >> a >> b;
    int res = b%a==0? a+b: b-a;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        String ans = "Odd";
        if (a * b % 2 == 0) {
            ans = "Even";
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 22996
A = [int(input())]
def pushBack(x):
	A.append(x)
def randomAccess(p):
	print(A[p+1])
def popBack():
	del A[-1]
while(1):
	try:
		a = input()
		if " " in a:
			b,c = [int(i) for i in a.split()]
			if b == 0:
				pushBack(c)
			else:
				randomAccess(c)
		else:
			popBack()
	except EOFError:
		break





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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;

struct edge { ll to,cost; };

vector<ll> dijkstra(int V, int s, vector<vector<edge>> &G) {
  vector<ll> d(V,LLONG_MAX);d[s]=0;
  priority_queue<P,vector<P>,greater<P>> q;q.push({0,s});
  while (!q.empty()) {
    P p = q.top();q.pop();
    int v = p.second;
    if (d[v]<p.first) continue;
    for (edge e:G[v]) {
      if (d[e.to]>d[v]+e.cost) {
        d[e.to] = d[v]+e.cost;
        q.push({d[e.to],e.to});
      }
    }
  }
  return d;
}

int main() {
  int N;cin>>N;
  vector<vector<edge>> G(N);
  REP(i,N-1) {
    int a,b,c;cin>>a>>b>>c;
    a--;b--;
    G[a].push_back({b,c});
    G[b].push_back({a,c});
  }
  int Q,K;cin>>Q>>K;

  // ワーシャルフロイトは間に合わない（ON3）
  // なので単純にKからの距離を全部出して足し合わせる
  vector<ll> ds = dijkstra(N,K-1,G);
  REP(i,Q) {
    int x,y;cin>>x>>y;
    x--;y--;
    OUT(ds[x]+ds[y]);
  }

  return 0;
}

Measured memory_bytes: 11120
//Shell Sort
#include <iostream>
#include <vector>

using namespace std;

int cnt = 0;
int m;
std::vector<int> G;

void insertionSort(int A[], int n, int g) {
    for(int i=g; i<n; i++) {
        int key = A[i];
        int j = i - g;
        while(j>=0 && A[j] > key) {
            A[j+g] = A[j];
            j-=g;
            cnt++;
        }
        A[j+g] = key;
    }
}

void shellSort(int A[], int n) {
    int h = 1;
    while(h <= n) {
        G.insert(G.begin(), h);
        h = 3 * h + 1;
    }
    m = int(G.size());

    for(int i = 0; i < m; i++) insertionSort(A, n, G[i]);
}

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

    shellSort(A, n);

    cout << m << endl;
    for(int i=0; i<m-1; i++) cout << G[i] << " ";
    cout << G[m-1] << endl;
    cout << cnt << endl;
    for(int i = 0; i < n; i++) cout << A[i] << endl;

    return 0;
}


Measured memory_bytes: 6980
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#include <bitset>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1e9+7
using namespace std;
typedef long long ll;
const double pi=acos(-1);

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int n,x,t;
    cin >> n >> x >> t;
    int time=((x-1)+n)/x;
    cout << t*time << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
# define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;



int main(){
    ll n,k;
    cin >> n >> k;
    ll num_k_times = n/k;
    if(k%2==0){
            ll num_khalf_times = n/(k/2);
        //ll num_khalf_times = floor((n+k/2)/k);
        //cout << pow(num_k_times,3) + pow(num_khalf_times,3);
        cout << (ll)pow(num_k_times,3) + (ll)pow(num_khalf_times-num_k_times,3);
    }else{
        cout << (ll)pow(num_k_times,3);
    }
}

Measured memory_bytes: 640
#include <iostream>

using namespace std; 

int main()
{
	long i,j, ret;
	long n,x,y;
	long *aret;
	
	cin>>n>>x>>y;
	
	aret = (long*)calloc(n,sizeof(long));
	
	for(i=1;i<=n-1;i++){
		for(j=i;j<=n;j++){
			ret = min(min(abs(y-i)+abs(x-j)+1, abs(j-i)), abs(x-i)+abs(y-j)+1);
			aret[ret]++;
		}
	}
		
	for(i=1;i<n;i++){
		cout << aret[i] <<endl;
	}
	
	return 0;
}

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


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int s,w;
    cin>>s>>w;
    if(w>=s)
    cout<<"unsafe"<<endl;
    else
    cout<<"safe"<<endl;
	// your code goes here
	return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int cc;
int s[100100],t[100100],c[100100];
vector<pair<int,int> >PP[33];
vector<pair<int,int> >aP[33];
int aa[100100];

int main(){
	cin>>n>>cc;
	REP(i,n){
		cin>>s[i]>>t[i]>>c[i];
		PP[c[i]].push_back(pair<int,int>(s[i],t[i]));
	}
	for(int i=1;i<=cc;i++){
		sort(PP[i].begin(),PP[i].end());
	}
	for(int i=1;i<=cc;i++){
		int t=-1;
		if(PP[i].size()==1){
			aP[i].push_back(pair<int,int>(PP[i][0].first,PP[i][0].second));
		}
		for(int j=0;j<(int)PP[i].size()-1;j++){
			if(PP[i][j].second==PP[i][j+1].first){
				if(t==-1){
					t=j;
				}
				if(j==PP[i].size()-2){
					aP[i].push_back(pair<int,int>(PP[i][t].first,PP[i][j+1].second));
				}
			}else{
				if(t!=-1){
					aP[i].push_back(pair<int,int>(PP[i][t].first,PP[i][j].second));
					t=-1;
				}else{
					aP[i].push_back(pair<int,int>(PP[i][j].first,PP[i][j].second));
				}
				if(j==PP[i].size()-2){
					aP[i].push_back(pair<int,int>(PP[i][j+1].first,PP[i][j+1].second));
				}
			}
		}
	}
	for(int i=1;i<=cc;i++){
		for(int j=0;j<aP[i].size();j++){
			//cout<<aP[i][j].first<<" "<<aP[i][j].second<<endl;
			aa[aP[i][j].first]+=1;
			aa[aP[i][j].second+1]-=1;
		}
	}
	int ans=aa[0];
	for(int i=1;i<=100000;i++){
		aa[i]+=aa[i-1];
		ans=max(ans,aa[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string S1, S2, S3, S4;
    int flag = 1;
    rep(i, abs(ty-sy)) {
        if (ty-sy < 0) {
            S1.push_back('D');
            S2.push_back('U');
        } else {
            S1.push_back('U');
            S2.push_back('D');            
        }
    }
    rep(i, abs(tx-sx)) {
        if (tx-sx < 0) {
            S1.push_back('L');
            S2.push_back('R');
        } else {
            S1.push_back('R');
            S2.push_back('L');            
        }
    }
    cout << S1 << S2;
    if (ty-sy > 0) {
        S3.push_back('D');
        S4.push_back('U');
    }
    else if (ty-sy < 0) {
        S3.push_back('U');
        S4.push_back('D');
    }
    rep(i, abs(tx-sx)+1) {
        if (tx-sx < 0) {
            S3.push_back('L');
            S4.push_back('R');
        } else {
            S3.push_back('R');
            S4.push_back('L');            
        }
    }
    rep(i, abs(ty-sy)+1) {
        if (ty-sy < 0) {
            S3.push_back('D');
            S4.push_back('U');
        } else {
            S3.push_back('U');
            S4.push_back('D');            
        }
    }
    if (tx-sx > 0) {
        S3.push_back('L');
        S4.push_back('R');
    }
    else if (tx-sx < 0) {
        S3.push_back('R');
        S4.push_back('L');
    }
    cout << S3 << S4 << endl;
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
haj=0
owa=n
for i in range(m):
  a,b=map(int,input().split())
  if(a>haj):
    haj=a
  if(b<owa):
    owa=b
if(owa-haj>=0):    
  print(owa-haj+1)
else:
  print(0)



Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};

int w,h;
vector<pair<int,PI > > G[3000];

int s2i(const string &in){
  stringstream ss(in);
  int ret;
  ss>>ret;
  return ret;
}

void solve(){
  rep(i,3000)G[i].clear();
  string tt;
  PI go;
  int maxv=0;
  rep(i,h)rep(j,w){
    cin>>tt;
    if(tt=="S")G[0].pb(mp(0,mp(i,j)));
    else if(tt==".")continue;
    else if(tt!="G"){
      int v=s2i(tt);
      maxv=max(v,maxv);
      G[v].pb(mp(1<<28,mp(i,j)));
    }else{
      go=mp(i,j);
    }
  }
  G[maxv+1].pb(mp(1<<28,go));
  for(int i=0;i<=maxv;++i){
    FOR(it1,G[i]){
      FOR(it2,G[i+1]){
        it2->F=min(it2->F,
                   it1->F+abs(it1->S.F-it2->S.F)+abs(it1->S.S-it2->S.S));
      }
    }
  }
  cout<<G[maxv+1][0].F<<endl;
}

main(){
  while(cin>>w>>h,w)solve();
}

Measured memory_bytes: 0
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func solve(b, a []int) ([]int, bool) {
	//eprintln(b, a)
	if len(b) == 0 {
		return a, true
	}
	for i := len(b) - 1; i >= 0; i-- {
		if i+1 == b[i] {
			nb := make([]int, 0, len(b)-1)
			for j := range b {
				if j != i {
					nb = append(nb, b[j])
				}
			}
			na, ok := solve(nb, append(a, b[i]))
			if ok {
				return na, true
			}
			return nil, false
		}
	}
	//eprintln("no match")
	return []int{}, false
}

func reverse(a []int) {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
}

func main() {
	defer stdout.Flush()
	n := readInt()
	b := make([]int, n)
	for i := range b {
		b[i] = readInt()
	}

	a, ok := solve(b, make([]int, 0))
	if !ok {
		println(-1)
		return
	}
	reverse(a)
	for _, v := range a {
		println(v)
	}
}

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


Measured memory_bytes: 768
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n){
        cin >> d[i];
    }
    sort(all(d));
    // showa(d);

    int a = d[n/2] - d[(n/2) -1];
   cout << a; 

}

Measured memory_bytes: 640