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

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 


int count(int minPos, int maxPos, int len) 
{
    int n = len - minPos;
    int m = len - maxPos - 1;
    return (n * (n+1) / 2) - (m * (m+1) / 2);
}

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

    map<int, int> ord;  //! Number -> Index map

    for (int i = 1; i <= N; ++i) {
        int P;
        cin >> P;
        ord[P] = i;
    }

    LL ans = 0;
    set<int> s; //! set of index of numbers gte i
    for (int i = N; 1 <= i; --i) {
        int curr = ord[i];
        // cout << "i = " << i << ", curr = " << curr << endl;
        auto ret = s.insert(curr);
        int p = -1;
        int pp = -1;
        if (ret.first != s.begin()) {
            auto it = ret.first;
            --it;
            p = *it;
            if (it != s.begin()) {
                --it;
                pp = *it;
            }
        }
        int n = -1;
        int nn = -1;
        auto it = ret.first;
        ++it;
        if (it != s.end()) {
            n = *it;
            ++it;
            if (it != s.end()) {
                nn = *it;
            }
        }
        // cout << pp << ' ' << p << ' ' << curr << ' ' << n << ' ' << nn << endl;

        LL count = 0;
        if (0 < p) {
            //! have a bigger number on left
            int lv = ((0 < pp) ? (p - pp) : p);
            int rv = ((0 < n) ? (n - curr) : (N-curr+1));
            count +=  lv * rv;
        }
        if (0 < n) {
            //! have a bigger number on right
            int lv = ((0 < p) ? (curr-p) : (curr));
            int rv = ((0 < nn) ? (nn - n) : (N-n+1));
            count +=  lv * rv;
        }
        ans += i * count;
    }

    cout << ans << endl;

    return 0;
}


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

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


def solve(N: int, S: str):
    if len(S)%2 == 1:
        print(NO)
    else:
        if S[:len(S)//2] == S[len(S)//2:]:
            print(YES)
        else:
            print(NO)


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N;
	cin >> N;
	vector<double> cur(N + 1, 0);
	cur[0] = 1;
	repeq(i, 1, N) {
		vector<double> next(N + 1);
		double p;
		cin >> p;
		rep(j, 0, i) {
			next[j + 1] += cur[j] * p;
			next[j] += cur[j] * (1.0 - p);
		}
		cur = move(next);
	}

	double ans = 0;
	repeq(i, N / 2 + 1, N) {
		ans += cur[i];
	}
	cout << fixed << setprecision(15) << ans << endl;
	return 0;

}


Measured memory_bytes: 3864
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
      	int N[] = new int[6];
      	int cnt[] = new int[4];
      	for(int i=0;i<6;i++){
        	N[i] = sc.nextInt();
        }
      	Arrays.sort(N);
      	for(int i=1;i<5;i++){
          	int c = 0;
          	for(int j=0;j<6;j++){
            	if(N[j]==i){
                	c++;	
                }
            	cnt[i-1] =c;
            }
        }
      	Arrays.sort(cnt);
      	if(cnt[0] ==1 && cnt[1] == 1 && cnt[2] == 2 && cnt[3] == 2){
        	System.out.println("YES");
        }else{
        	System.out.println("NO");
        }		
    }
}

Measured memory_bytes: 21844
import collections
N = int(input())
a = list(map(int, input().split()))
a = collections.Counter(a)
a_key = list(a.keys())
a_value = list(a.values())
cnt = 0
for i in range(len(a)):
    x = int(a_value[i])-int(a_key[i])
    if  x >= 0:
        cnt += x
    else:
        cnt += a_value[i]
print(cnt)

Measured memory_bytes: 69032
#include <stdio.h>

void selectionSort(int A[], int N) {
   int i, j;
   int tmp, minj;
   int c = 0;
   for (i = 0; i < N; i++) {
       minj = i;
       for (j = i; j < N; j++) {
           if (A[j] < A[minj])
               minj = j;
       }

       if (i != minj) {
           tmp = A[i];
           A[i] = A[minj];
           A[minj] = tmp;
           c++;
       }
   }
   for (i = 0; i < N; i++) {
       printf("%d", A[i]);
       printf((i == N-1) ? "\n%d\n" : " ", c);
   }
}

int main()
{
   int i;
   int N, A[101];

   scanf("%d", &N);

   for (i = 0; i < N; i++) {
       scanf("%d", &A[i]);
   }

   selectionSort(A, N);

   return 0;
}

Measured memory_bytes: 1828
#include<cmath>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<iomanip>
#include<string>
using namespace std;
 
int main()
{
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int e=0;e<n;e++)
	{
		cin>>arr[e];
	}
    for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n-i-1; ++j)
		{
			if (arr[j] > arr[j+1])
			{
				arr[j] = arr[j]+arr[j+1];
				arr[j+1] = arr[j]-arr[j + 1];
				arr[j] = arr[j]-arr[j + 1];
			}
		}
	}	
	int st=n-k;
	int sum=0;
    for(int w=st;w<n;w++)
    {
    	sum=sum+arr[w];
	}
    cout<<sum<<endl;
	return 0;
}

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

int compare_string(const void *a, const void *b) {
    return strcmp(*(const char **)a, *(const char **)b);
}

int main() {
    string s, t; cin >>s >>t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    cout << ((s < t) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<queue>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

int main() {
	while (true) {
		int n = 0;
		cin >> n;
		if (n == 0) {
			break;
		}

		int a = 0;
		int b = 0;
		for (int i = 0; i < n; ++i) {
			int s, t;
			cin >> s >> t;
			if (s > t) {
				a += s + t;
			} else if (s < t) {
				b += s + t;
			} else {
				a += s;
				b += t;
			}
		}

		cout << a << " " << b << endl;

	}
	return 0;
}

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

using namespace std;

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

    int a, b;
    cin >> a >> b;
    cout << (b * 2 >= a ? 0 : a - (b * 2)) << "\n";

    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
ans=0
for b in range(k+1, n+1):
    q=n//b
    r=n%b
    if r<k:
        ans+=(q-1)*(b-k)
    else:
        ans+=(q-1)*(b-k)+(r-k+1)
if k>0:
    ans+=(n-k+1)*(n-k)//2
else:
    ans+=n*(n-1)//2
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdlib.h>
#include<set>

using namespace std;


void Quick(int a[], int pl, int pr)
{
    int left=pl;
    int right=pr;
    int x=a[(pl+pr)/2];
    do{
        while(a[pl]<x){
            pl++;
        }
        while(a[pr]>x){
            pr--;
        }
        if(pl<=pr){
            int temp;
            temp=a[pl];
            a[pl]=a[pr];
            a[pr]=temp;
            pl++;
            pr--;
        }
    }while(pl<=pr);
    
    if(left<pr){
        Quick(a,left,pr);
    }
    if(right>pl){
        Quick(a,pl,right);
    }
}

int main(void)
{
    int N;
    cin>>N;
    int a[N];
    
    
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    Quick(a,0,N-1);
    
    cout<<a[N/2]-a[N/2-1]<<endl;
    
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
    int x;
    cin>>x;
    int s=1000*(x/500)+5*((x%500)/5);
    cout<<s<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {

    public static void main(String[] args) {
        
        try {
            InputStreamReader is = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(is);
            int i = Integer.parseInt(br.readLine());
            double c =Math.PI*2*i;
            System.out.println(c);
        }catch (Exception e){
            e.printStackTrace();
        }
        
    }
}
    


Measured memory_bytes: 33140
#include<stdio.h>

typedef struct {
	int No;//通しナンバー
	int P;
	int Y;
	int ans;//得たい値である県ごとの順番
}CITY;

int Comp1(const void* pElem1, const void* pElem2)
{
	// データが扱いやすいので一旦変数に入れておく
	const CITY* pmem1 = (const CITY*)pElem1;
	const CITY* pmem2 = (const CITY*)pElem2;
	int nDiff;  // 両要素の差
	nDiff = pmem1->P - pmem2->P;
	if (nDiff != 0)
		return nDiff;
	nDiff = pmem1->Y - pmem2->Y;
	if (nDiff != 0)
		return nDiff;
}

int Comp2(const void* pElem1, const void* pElem2)
{
	// データが扱いやすいので一旦変数に入れておく
	const CITY* pmem1 = (const CITY*)pElem1;
	const CITY* pmem2 = (const CITY*)pElem2;
	int nDiff;  // 両要素の差
	nDiff = pmem1->No - pmem2->No;
	if (nDiff != 0)
		return nDiff;
}

//CITY city[10002];//構造体配列を宣言

int main() {
	int N, M;
	scanf("%d%d", &N, &M);
	CITY city[524288];//構造体配列を宣言
	for (int i = 0; i < M; i++)
	{
		city[i].No = i;
		scanf("%d%d", &city[i].P, &city[i].Y);
		//得たい値である県ごとの市の順番
		//-1の場合		:まだ未確定(初期化)
		//0以上の場合	:確定
		city[i].ans = -1;
	}

	//県順誕生年順にソートする
	qsort(city, M, sizeof(CITY), Comp1);

	for (int i = 0; i < M; i++) {
		if (i == 0) {
			city[i].ans = 1;
		}
		else if (i > 0 && city[i].P != city[i - 1].P) {
			city[i].ans = 1;
		}
		else {
			city[i].ans = city[i - 1].ans + 1;
		}
	}

	//通しナンバー順にソートする
	qsort(city, M, sizeof(CITY), Comp2);

	//printf("ソート結果\n");
	//for (int i = 0; i < M; i++) {
	//	printf("%d %d %d %d\n", city[i].No, city[i].P, city[i].Y, city[i].ans);
	//}
	for (int i = 0; i < M; i++) {
		printf("%06d%06d\n", city[i].P, city[i].ans);
	}
	return 0;
}

Measured memory_bytes: 6496
n,m = map(int, input().split())
a = [list(input().split()) for i in range(m)]
b=[[0,0] for i in range(n)]
AC=0
WA=0

for i in range(m):
    if b[int(a[i][0])-1][0]==0 and a[i][1]=='AC':
        b[int(a[i][0]) - 1][0]+=1
    elif b[int(a[i][0])-1][0]==1 and a[i][1]=='AC':
        continue
    elif b[int(a[i][0])-1][0]==0 and a[i][1]=='WA':
        b[int(a[i][0]) - 1][1] +=1
    elif b[int(a[i][0])-1][0]==1 and a[i][1]=='WA':
        continue

for i in range(n):
    if b[i][0]>=1:
        AC+=1
    if b[i][0]>=1 and b[i][1]>=1:
        WA+=b[i][1]
print(AC,WA)

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

#define ll long long
const int MAXN = 112345;

ll dp[MAXN][3];
int activity[MAXN][3];

int main () {

    int n;
    cin >> n;

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

    dp[0][0] = activity[0][0];
    dp[0][1] = activity[0][1];
    dp[0][2] = activity[0][2];

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

        dp[i][0] = activity[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = activity[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = activity[i][2] + max(dp[i-1][0], dp[i-1][1]);

    }

    cout << max(dp[n-1][0], max(dp[n-1][1],dp[n-1][2])) << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N, M, R; scanf("%d %d %d", &N, &M, &R);
  vector<int> cities(R);
  for (int i = 0; i < R; ++i) {
    scanf("%d", &cities[i]);
  }
  vector<vector<int> > d(N + 5, vector<int>(N + 5, INF));
  for (int i = 0; i < M; ++i) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    d[a][b] = d[b][a] = c;
  }
  for (int k = 1; k <= N; ++k) {
    for (int i = 1; i <= N; ++i) {
      for (int j = 1; j <= N; ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  int ans = INF;
  sort(cities.begin(), cities.end());
  do {
    int cost = 0;
    for (int i = 1; i < R; ++i) {
      cost += d[cities[i - 1]][cities[i]];
    }
    ans = min(ans, cost);
  } while (next_permutation(cities.begin(), cities.end()));

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


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

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    auto calc = [&](int mask) {
        long long sum = 0;
        for (int j = 0; j < n; j++) if ((a[j] | mask) == mask) sum += b[j];
        return sum;
    };
    long long ans = calc(k);
    for (int i = 0; i < 31; i++) if (k >> i & 1) {
        int mask = (k ^ (1 << i)) | ((1 << i) - 1);
        ans = max(ans, calc(mask));
    }
    cout << ans << endl;
    return 0;
}


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

class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int r = Integer.parseInt(br.readLine());
		int area = 3 * (r * r);
		System.out.println(area);

	}

}

Measured memory_bytes: 21332
points = input()
points = points.split(" ")
a = int(points[0])
b = int(points[1])
c = int(points[2])

if (a < b) and (a < c) and (c < b):
    print("Yes")
elif (a > b) and (a > c) and (c > b):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<stdio.h>

bool osenbei[10][10001];

int h,w;
int ans=0;

void disp(bool ob[][10001])
{
	printf("--->\n");
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			printf("%d",ob[i][j]?1:0);
		}
		printf("\n");
	}
}


void calc(bool osenbei[][10001])
{

	//disp(osenbei);

	static bool temp[10][10001];

	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			temp[i][j]=osenbei[i][j];

	for(int j=0;j<w;j++)
	{
		int count=0;
		for(int i=0;i<h;i++)
			if(temp[i][j])
				count++;
		if(count >h/2)
			for(int i=0;i<h;i++)
				temp[i][j] = temp[i][j]?false:true;
	}
	//disp(temp);

	int cnt=0;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
			if(!temp[i][j])
				cnt++;
	}
	if(cnt > ans)
		ans=cnt;
}

int solve(bool osenbei[][10001],int num)
{
	static bool temp[10][10001];
	if(num==h)
		return true;

	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			temp[i][j]=osenbei[i][j];

	calc(temp);
	solve(temp,num+1);

	for(int i=0;i<w;i++)
		temp[num][i]=osenbei[num][i]?false:true;

	calc(temp);
	solve(temp,num+1);

	return 0;
}

int main()
{
	while(1)
	{
		scanf("%d %d",&h,&w);
		if(h==0 && w == 0)
			break;
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
				scanf("%d",&osenbei[i][j]);

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

Measured memory_bytes: 1056
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int n; cin >> n; long ans = 0;
  v1li a(n+1, 1), b(n+1, 1), c(n+1, 1);
  rep(i, n){
    a[i+1] = a[i] * 10; a[i+1] %= mod1;
    b[i+1] = b[i] * 9; b[i+1] %= mod1;
    c[i+1] = c[i] * 8; c[i+1] %= mod1;
  }
  if(n > 1){
    ans += a[n] + c[n] - b[n] - b[n] + mod1 + mod1; ans %= mod1;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 26660
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF 10000000000LL
using namespace std;
typedef long long ll;
 
ll X, K, R[200000], Q, T[200000], A[200000];
 
int main(void) {
  cin >> X >> K;
  R[0] = 0;
  REP(i, 1, K + 1) cin >> R[i];
  R[K + 1] = INF;
  cin >> Q;
  REP(i, 0, Q) cin >> T[i] >> A[i];
 
  ll lower = 0;
  ll upper = X;
 
  ll sum = 0;
  ll k = 0;
  REP(i, 0, K + 1) {
    if(i > 0) {
      lower = X - max(lower - (R[i] - R[i - 1]), 0LL);
      upper = X - max(upper - (R[i] - R[i - 1]), 0LL);
      swap(lower, upper);
    }
    sum += (i % 2 == 0 ? 1 : -1) * (R[i] - R[i - 1]);
 
    while(k < Q && R[i] <= T[k] && T[k] <= R[i + 1]) {
      ll a = i % 2 == 0 ? A[k] + sum : X - A[k] - sum;
      if(a <= lower) a = lower;
      if(a >= upper) a = upper;
      cout << (i % 2 == 0 ? max(a - (T[k] - R[i]), 0LL) : X - max(a - (T[k] - R[i]), 0LL)) << endl;
      k++;
    }
  }
}


Measured memory_bytes: 4480
#pragma GCC optimize("Ofast")
#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 ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int dist[101010][3];

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i,M) {
        int u,v; cin >> u >> v;
        --u; --v;
        G[u].emplace_back(v);
    }
    int S,T; cin >> S >> T;
    --S; --T;

    rep(i,N) rep(j,3) dist[i][j] = -1;
    dist[S][0] = 0;
    queue<pii> que;
    que.emplace(S,0);
    while (!que.empty()) {
        int v,c;
        tie(v,c) = que.front(); que.pop();
        for (auto nv : G[v]) {
            if (dist[nv][(c+1)%3] != -1) continue;
            dist[nv][(c+1)%3] = dist[v][c] + 1;
            que.emplace(nv,(c+1)%3);
        }
    }

    cout << (dist[T][0] == -1 ? -1 : dist[T][0]/3) << ln;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=3003,INF=1<<30;

ll rui[MAX][MAX];

void make(ll mo){
    for(int i=0;i<mo;i++){
        rui[i][0]=1;
        for(int j=1;j<mo;j++){
            rui[i][j]=rui[i][j-1]*i;
            if(rui[i][j]>=mo) rui[i][j]%=mo;
        }
    }
}

int main(){
    
    int P;cin>>P;
    make(P);
    
    vector<ll> A(P),C(P),S(P+1,0),mae(P+1,0);//cは係数,Sは累積和,maeは(x-xi)の累積積
    mae[0]=1;
    for(int i=0;i<P;i++) cin>>A[i];
    
    for(int i=0;i<P;i++){
        int div=1,sum=0;
        for(int j=0;j<i;j++){
            div*=(i-j);
            div%=P;
        }
        for(int j=0;j<=P;j++){
            sum+=S[j]*rui[i][j];
            sum%=P;
        }
        
        C[i]=(A[i]+P-sum)*rui[div][P-2]%P;
        
        vector<ll> save(P+1,0);//変えるようの配列
        
        if(i){
            for(int j=0;j<P;j++){
                save[j]+=(P-(i-1))%P*mae[j];
                save[j+1]+=mae[j];
                
                save[j]%=P;
                save[j+1]%=P;
            }
            
            for(int j=0;j<P+1;j++){
                mae[j]=save[j];
            }
        }
        
        for(int j=0;j<P+1;j++){
            S[j]+=mae[j]*C[i];
            S[j]%=P;
        }
        
    }
    
    //バラすパート
    
    vector<ll> ans(P+1,0);
    for(int i=0;i<P+1;i++) mae[i]=0;
    mae[0]=1;
    
    for(int i=0;i<P;i++){
        for(int j=0;j<P+1;j++){
            ans[j]+=mae[j]*C[i];
            ans[j]%=P;
        }
        
        vector<ll> save(P+1,0);//変えるようの配列
        
        for(int j=0;j<P;j++){
            save[j]+=(P-i)%P*mae[j];
            save[j+1]+=mae[j];
            
            save[j]%=P;
            save[j+1]%=P;
        }
        
        for(int j=0;j<P+1;j++){
            mae[j]=save[j];
        }
        
    }
    
    for(int i=0;i<P;i++){
        if(i) cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;
}



Measured memory_bytes: 70784
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    while(true){
        ll n,ans=1;
        cin>>n;
        if(n==0) break;
        double x[310],y[310];
        rep(i,n){
            cin>>x[i]>>y[i];
        }
        rep(i,n){
            rep(j,n){
                if(i==j) continue;
                double dx=x[i]-x[j],dy=y[i]-y[j];
                double d=sqrt(dx*dx+dy*dy);
                if(d>2+eps) continue;
                double s=sqrt((1.0-d*d/4));
                double vx=-dy/d*s;
                double vy=dx/d*s;
                double ox=(x[i]+x[j])/2+vx;
                double oy=(y[i]+y[j])/2+vy;
                ll cnt=0;
                rep(k,n){
                    if((x[k]-ox)*(x[k]-ox)+(y[k]-oy)*(y[k]-oy)<1.0+eps)cnt++;
                }
                ans=max(ans,cnt);
            }   
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3180
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

void clear(queue<int> &que) {
    queue<int> empty;
    swap(que, empty);
}

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    vector<vi> data(N + 1);
    for (int i = 1; i <= N; i++) {
        if (i != 1) {
            data[i].push_back(i - 1);
        }
        if (i != N) {
            data[i].push_back(i + 1);
        }
        if (X == i) {
            data[i].push_back(Y);
        }
        else if (Y == i) {
            data[i].push_back(X);
        }
    }
    vi ans(N, 0);
    for (int i = 1; i <= N; i++) {
        vi dist(N + 1, -1);
        queue<int> que, que2;
        dist[i] = 0;
        que2.push(i);
        int count = 0;
        while (!que2.empty()) {
            count++;
            que = que2;
            clear(que2);
            while (!que.empty()) {
                int v = que.front();
                que.pop();
                for (int x : data[v]) {
                    if (dist[x] != -1) {
                        continue;
                    }
                    dist[x] = count;
                    que2.push(x);
                }
            }
        }
        for (int j = 1; j <= N; j++) {
            ans[dist[j]]++;
        }
    }
    for (int i = 1; i < N; i++) {
        cout << ans[i] / 2 << endl;
    }
}


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

int x[1000],y[1000];

double dist(int i, int j) {
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return pow(dx*dx+dy*dy, 0.5);
}

int main() {
  int n; cin >> n;
  rep(i,n) cin >> x[i] >> y[i];

  std::vector<int> v(n);
  rep(i,n) v[i] = i;

  double total = 0;
  do {
    rep(i,n-1) total += dist(v[i],v[i+1]);
  } while (next_permutation(v.begin(), v.end()));

  int f = 1;
  for (int i = 2; i <= n; i++) f *= i;
  cout << fixed << setprecision(10) << total / f << endl;
}


Measured memory_bytes: 4228
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>
#include<thread>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;

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

	int ans = 0;
	for (int i = 0; i < 3; ++i)
	{
		ans += S[i] == R[i];
	}

	cout << ans << endl;

	return 0;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    string str;
    cin >> str;
    set<char> st;
    for(const auto &it: str) {
        st.insert(it);
    }

    bool w = st.count('W');
    bool e = st.count('E');
    bool s = st.count('S');
    bool n = st.count('N');


    if((w!=e) || (s!=n)) cout << "No";
    else cout << "Yes";
    cout << endl;

}

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


Measured memory_bytes: 256
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#include <bits/stdc++.h>
#define f first
#define s second
#define ms(a, b) memset(a,b,sizeof(a))
typedef long long ll;

using namespace std;

char _;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);

    string a,b;

    cin >> a >> b;

    string c = b.substr(0, b.length()-1);

    if(a==c) cout << "Yes" << "\n";
    else cout << "No" << "\n";

    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>

int main() {
	int r, c, s[101][101], plus[101], row[101], row2=0;

	for (int i = 0; i < 101; i++) {
		for (int k = 0; k < 101; k++) {
			s[i][k] = 0;
		}
		plus[i] = 0;
		row[i] = 0;
	}
	scanf("%d %d", &r, &c);
	for (int i = 0; i < r; i++) {
		for (int k = 0; k < c; k++) {
			scanf("%d", &s[i][k]);
			plus[i] += s[i][k];
			s[r][k] += s[i][k];
		}
		s[i][c] = plus[i];
		s[r][c] += s[i][c];
	}
	

	for (int i = 0; i <= r; i++) {
		for (int k = 0; k <= c; k++) {
			if (k <c) {
				printf("%d ", s[i][k]);
			}
			else {
				printf("%d\n", s[i][k]);
			}
		}
	}

}



Measured memory_bytes: 2048
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000

const ll MOD=998244353;

main(){
    int n=in();
    ll ans=0;
    vector<pll> v;
    rep(i,n){
        ll a,b;cin>>a>>b;
        v.pb({a,b});
    }
    reverse(all(v));
    rep(i,n){
        ll a=v[i].first,b=v[i].second;
        a+=ans;
        ll c=(a+b-1)/b * b;
        ans+=c-a;
    }
    cout<<ans;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string tar; 
    cin>>tar;
    vector<string> text;
    string s;
    while(cin>>s){
        if (s=="END_OF_TEXT") break;
        transform(s.begin(),s.end(),s.begin(),::tolower);
        text.emplace_back(s);
    }
    int ans=0;
    for(int i=0; i<text.size(); i++){
        if(text[i]==tar) ans++;
    }
    cout<<ans<<endl;
    return 0;
}



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

public class Main {

    public static void main(String[] args)throws Exception {
        InputReader in = new InputReader (System.in);
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
        // Code starts from here //
        long start = in.nextLong();
        long end = in.nextLong();
        long x = in.nextLong();
        long ans = countDivisors(start, end, x);
        if(start % x == 0) pw.println((ans + 1));
        else pw.println(ans);
        pw.close();
    }
    
    static long countDivisors(long a, long b, long x) {
        return (b / x) - (a / x);
    }
    





    /****************************************
     ******* IO STUFF STARTS FROM HERE ******
     ****************************************/

    static void debug(Object...obj) {
        System.err.println(Arrays.deepToString
                (obj));
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new
                    InputStreamReader(stream));
            tokenizer = null;
        }

        //InputReader in = new InputReader(new FileReader("File_Name"));
        public InputReader(FileReader file) {
            reader = new BufferedReader(file);
            tokenizer = null;
        }

        public String next() {

            try {
                while (tokenizer == null || !
                        tokenizer.hasMoreTokens())
                    tokenizer = new StringTokenizer
                            (reader.readLine());
            } catch (IOException e) {
                return null;
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            String line = null;
            try {
                tokenizer = null;
                line =  reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public boolean hasNext(){
            try {
                while (tokenizer == null || !
                        tokenizer.hasMoreTokens())
                    tokenizer = new StringTokenizer
                            (reader.readLine());
            }
            catch (Exception e) {
                return false;
            }
            return true;
        }
    }
}

Measured memory_bytes: 25400
#include <bits/stdc++.h>
#include<algorithm>
#include<cmath>
#define ll long long
#define pb push_back
#define vi vector<int>
#define si set<int>
#define msi multiset<int>
#define vll vector<ll>
#define ff first
#define ss second
#define pii pair<int,int>
#define mp make_pair
#define all(a) a.begin(),a.end()
#define f(i,x,n) for(int i=x;i<n;i++)
#define fd(i,n,x) for (int i=n;i>=x;i--)
#define itr :: iterator it
#define endl '\n'
#define INF 1e9
#define mod 1e9+7

using namespace std;
int step(int i,int j,int n,int a[],int b[],int c[],vector<vector<int> >&dp)
{
    if(i==n||j>3)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
        if(j==0)
        {
            int x=a[i]+step(i+1,1,n,a,b,c,dp);
            int y=b[i]+step(i+1,2,n,a,b,c,dp);
            int z=c[i]+step(i+1,3,n,a,b,c,dp);
            return dp[i][j]=max(x,max(y,z));
        }

        if(j==1)
            {
                int y=b[i]+step(i+1,2,n,a,b,c,dp);
                int z=c[i]+step(i+1,3,n,a,b,c,dp);
                return dp[i][j]=max(y,z);
            }
        if(j==2)
        {
                int x=a[i]+step(i+1,1,n,a,b,c,dp);
                int z=c[i]+step(i+1,3,n,a,b,c,dp);
                return dp[i][j]=max(x,z);
        }
        if(j==3)
        {
                int x=a[i]+step(i+1,1,n,a,b,c,dp);
                int y=b[i]+step(i+1,2,n,a,b,c,dp);
                return dp[i][j]=max(x,y);
        }

}
int main()
{
    int n;
    cin>>n;
    int a[100005],b[100005],c[100005];
    vector<vector<int> >dp(n,vector<int>(4,-1));
    for(int k=0;k<n;k++)
    {
        cin>>a[k]>>b[k]>>c[k];
    }
    cout<<step(0,0,n,a,b,c,dp);
}


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

int main() {
	long long H, N, INF = 1000000000;
	vector<long long> A, B;
	cin >> H >> N;
	A.resize(N), B.resize(N);
	for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
	vector<long long> DP(H + 1, INF);
	DP[0] = 0;
	for (int i = 0; i < N; i++) {
		long long X = A[i], Y = B[i];
		do {
			for (int j = 0; j <= H; j++) {
				DP[min(H, j + X)] = min(DP[min(H, j + X)], DP[j] + Y);
			}
			X *= 2, Y *= 2;
		} while (X <= H * 2);
	}
	cout << DP[H] << endl;
}

Measured memory_bytes: 512
# 宿泊代の合計金額を求める。

days_of_stay = int(input())
days_of_original_price = int(input())
original_price = int(input())
discount_price = int(input())


# if文の上が、割引適用なし。下が割引適用。
if days_of_stay <= days_of_original_price:
    total_fee = days_of_stay * original_price
    print(total_fee)
elif days_of_stay > days_of_original_price:
    total_fee = original_price * days_of_original_price + (days_of_stay - days_of_original_price) * discount_price
    print(total_fee)

Measured memory_bytes: 9068
from sys import stdin
import math
import itertools

N = int(stdin.readline())
max_i = int(math.sqrt(N))
count = [0]*10000

# i1=i2=i3 *1
c = itertools.combinations_with_replacement(list(range(1, max_i+1)), 3)
for v in c:
    i1 = v[0]
    i2 = v[1]
    i3 = v[2]
    if i1==i2 and i2 == i3:
        num = i1*i1*6
        if num <=N:
            count[num-1] += 1
    elif i1 != i2 and i1 != i3 and i2 != i3:
        num = i1*i1+i2*i2+i3*i3 + i1*i2+ i2*i3+ i3*i1
        if num <= N:
            count[num-1] += 6
    else:
        num = i1*i1+i2*i2+i3*i3 + i1*i2+ i2*i3+ i3*i1
        if num <= N:
            count[num-1] += 3

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

Measured memory_bytes: 9332
#include <stdio.h>

int main(void){
  char str[21];
  char ans[21];
  
  int num;
  int i;
  
  for( i = 0; i < 21; i++ ){
    ans[i] = '\0';
    str[i] = '\0';
  }
  
  scanf("%s", str);  
    
  for( i = 0; i < 21; i++ ){
    if( str[i] != '\0' ) num = i;
  }
  
  for( i = 0; i <= num; i++ ){
    ans[i] = str[num-i];
  }
  
  printf("%s\n", ans);
  
  return 0;
}

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

int main(){
  int n,k=0,d1,d2;
  bool ans=false;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> d1 >> d2;
    if(d1==d2) k++;
    else k=0;
    if(k==3){
      ans=true;
      break;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3620
// Aizu Vol0 0009: Prime Number
// 2017.7.30

#include <stdio.h>
#include <stdlib.h>

char *gets(char *);

#define MAX  999999
#define SQRT 999     // sqrt(MAX)

char prime[MAX + 5], *p, *q, *pmax;
int table[MAX + 5], *t;

int main()
{
	int n, k;
	char buf[100];

	pmax = prime + MAX;
	for (k = 3, p = prime+3; k <= SQRT; k+=2, p+=2) {
		if (!*p) {
			for (q = p + k; q <= pmax; q += k) *q = 1;
		}
	}
	table[2] = k = 1, t = table + 3;
	for (p = prime + 3; p <= pmax; p += 2) {
		if (!*p) k++;
		*t++ = k, *t++ = k;
	}
#if 0
	for (k = 1; k <= 100; k++) printf("[%d]=%d\n", k, table[k]);
#endif

	while (gets(buf) != NULL) {
		n = atoi(buf);
		printf("%d\n", table[n]);
	}
	return 0;
}

Measured memory_bytes: 5404
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007
int main(){
	fast;
	ll h,w,n,cnt=0;
	cin>>h>>w>>n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	vector<int> v;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<arr[i];j++)
			v.push_back(i+1);
	}
	int mat[h][w];
	for(int i=0;i<h;i++)
	{
		if(i%2==0)
		{
			for(int j=0;j<w;j++)
				mat[i][j]=v[cnt],cnt++;
		}
		else
		{
			for(int j=w-1;j>=0;j--)
				mat[i][j]=v[cnt],cnt++;
		}
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
			cout<<mat[i][j]<<" ";
		cout<<endl;
	}
	return 0;
}



Measured memory_bytes: 3672
#include <iostream>

int main()
{
  long long noperations, biscuit_to_yen, yen_to_biscuit;
  std::cin >> noperations >> biscuit_to_yen >> yen_to_biscuit;
  if (yen_to_biscuit <= biscuit_to_yen) {
    std::cout << 1 + noperations << '\n';
    return 0;
  }
  long long rest_noperations = noperations - biscuit_to_yen + 1;
  long long result = biscuit_to_yen;
  result += (yen_to_biscuit - biscuit_to_yen) * (rest_noperations / 2);
  if (rest_noperations % 2 == 1) {
    result += 1;
  }
  std::cout << std::max(result, 1+noperations) << '\n';
  return 0;
}


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

int main() {
  int x[5];
  cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
  for (int i = 0; i < 5; i++) {
    if (x[i] == 0) {
      cout << i + 1 << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3472
#include<stdio.h>

int min(int x,int y){
    if(x>y){
        return y;
    }else{
        return x;
    }
}

int main(){
    int n,x,y;
    scanf("%d %d %d",&n,&x,&y);
    int ans[n];
    for(int i=0;i<n+1;i++){
        ans[i]=0;
    }
    for(int i=1;i<n+1;i++){
        for(int j=i+1;j<n+1;j++){
            if(i<=x && x<=j && i<=y && y<=j){
                ans[x-i+1+j-y]++;
            }else if(i<=x && x<=j){
                ans[min(j-i,x-i+1+y-j)]++;
            }else if(i<=y && y<=j){
                ans[min(j-i,i-x+1+j-y)]++;
            }else if(j < x){
                ans[j-i]++;
            }else if(y < i){
                ans[j-i]++;
            }else{
                ans[min(j-i,i-x+1+y-j)]++;
            }
        }
    }
    for(int i=1;i<n;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(c) (c).begin(), (c).end()
#define REP(i, n) for(ll i = 0; i < (n); ++i)

template<class T> class Dinic{
public:
    T max_capacity() { return numeric_limits<T>::max()/8; }
    Dinic(size_t n) : n(n), g(n) {}
    void add_edge(size_t from, size_t to, T c){
        if(from == to) return;
        g[from].push_back({to, g[to].size(),       c});
        g[to].push_back({from, g[from].size() - 1, 0});
    }
    void add_undirected_edge(size_t from, size_t to, T c){
        if(from == to) return;
        g[from].push_back({to, g[to].size(),       c});
        g[to].push_back({from, g[from].size() - 1, c});
    }
    T max_flow(size_t source, size_t sink){
        vector<size_t> dist(n);
        auto bfs = [&](){
            fill(ALL(dist), 0);
            dist[source] = 1;
            queue<size_t> q; q.push(source);
            while (!q.empty()){
                auto cur = q.front(); q.pop();
                for(auto&& e : g[cur]) if(e.cap > 0 && dist[e.to] == 0) {
                    dist[e.to] = dist[cur] + 1;
                    q.push(e.to);
                }
            }
            return dist[sink] > 0;
        };
        vector<size_t> ptr(n); // ????????????????????????????????§??¢?´¢??????????????????
        function<T(size_t, T)> dfs = [&](size_t cur, T lim) {
            if(source == cur || lim == 0) return lim;
            T sum_f = 0;
            for(auto &i = ptr[cur]; i < g[cur].size(); ++i){
                auto &e = g[cur][i], &rev_e = g[e.to][e.rev_edge_index];
                if(dist[e.to] >= dist[cur] || rev_e.cap <= 0) continue;
                T f = dfs(e.to, min(lim - sum_f, rev_e.cap));
                if(f <= 0) continue;
                rev_e.cap -= f; e.cap += f;
                sum_f += f;
                if(sum_f == lim) break;
            }
            return sum_f;
        };
        T sum_f = 0;
        while(bfs()){
            ptr.assign(n, 0);
            sum_f += dfs(sink, max_capacity());
        }
        return sum_f;
    }
private:
    struct Edge{ size_t to, rev_edge_index; T cap; };
    size_t n;
    vector<vector<Edge>> g;
};

int main() {
    int v, e;
    cin >> v >> e;
    Dinic<int> g(v);
    REP(i, e) {
        int u, v, c; cin >> u >> v >> c;
        g.add_edge(u, v, c);
    }
    cout << g.max_flow(0, v - 1) << endl;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define FOR(x,n) for(int x = 0; x < n; x++)
#define Aint(a) (a).begin(), (a).finish()
#define SZ(a) ((int)(a).size())
#define FIN ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define CLR(a) memset((a),0,sizeof(a))
using namespace std;

const int MXV = 20001;

struct Edge {
  int u, v;
  int cap, flow;
  Edge() {}
  Edge(int u, int v, int cap): u(u), v(v), cap(cap), flow(0) {}
};

struct Dinic {
  int N;
  vector<Edge> E;
  vector<vector<int>> g;
  vector<int> d, pt;
  
  Dinic(int N): N(N), E(0), g(N), d(N), pt(N) {}

  void add_edge(int u, int v, int cap) {
    if (u != v) {
      E.emplace_back(Edge(u, v, cap));
      g[u].emplace_back(E.size() - 1);
      E.emplace_back(Edge(v, u, 0));
      g[v].emplace_back(E.size() - 1);
    }
  }

  bool BFS(int S, int T) {
    queue<int> q({S});
    fill(d.begin(), d.end(), N + 1);
    d[S] = 0;
    while(!q.empty()) {
      int u = q.front(); q.pop();
      if (u == T) break;
      for (int k: g[u]) {
        Edge &e = E[k];
        if (e.flow < e.cap && d[e.v] > d[e.u] + 1) {
          d[e.v] = d[e.u] + 1;
          q.emplace(e.v);
        }
      }
    }
    return d[T] != N + 1;
  }

  int DFS(int u, int T, int flow = -1) {
    if (u == T || flow == 0) return flow;
    for (int &i = pt[u]; i < (int)g[u].size(); ++i) {
      Edge &e = E[g[u][i]];
      Edge &oe = E[g[u][i]^1];
      if (d[e.v] == d[e.u] + 1) {
        int amt = e.cap - e.flow;
        if (flow != -1 && amt > flow) amt = flow;
        if (int pushed = DFS(e.v, T, amt)) {
          e.flow += pushed;
          oe.flow -= pushed;
          return pushed;
        }
      }
    }
    return 0;
  }

  int get_mf(int S, int T) {
    int total = 0;
    while (BFS(S, T)) {
      fill(pt.begin(), pt.end(), 0);
      while (int flow = DFS(S, T))
        total += flow;
    }
    return total;
  }
};

const int MXH = 100, MXW = 100;
int H, W, grid[MXH][MXW];
pair<int,int> start, finish;

int main() { FIN;
  cin >> H >> W;
  FOR(x,H) FOR(y,W){
    char c; cin >> c;
    if(c == 'S')
      start = {x,y};
    else if(c =='T')
      finish = {x,y};
    grid[x][y] = c != '.';
  }

  if(start.first == finish.first || finish.second == start.second){
    cout << "-1\n";
    return 0;
  }

  Dinic d = Dinic(2* W * H);
  
  FOR(x,H) FOR(y,W) if(grid[x][y]){
    d.add_edge(2*(x*W+y), 2*(x*W+y)+1, 1);
    FOR(z,H)
      if(grid[z][y])
        d.add_edge(2*(x*W+y)+1, 2*(z*W+y), 1e9);
    FOR(z,W)
      if(grid[x][z])
        d.add_edge(2*(x*W+y)+1, 2*(x*W+z), 1);
  }
  cout << d.get_mf(2 * (start.first * W + start.second)+1, 2*(finish.first * W + finish.second)) << "\n";
}

Measured memory_bytes: 86236
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

        public static long d(long sx,long sy,long gx,long gy)
        {
            return Math.Abs(gx - sx) + Math.Abs(gy - sy);
        }
      



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var txy = new long[n][];
            for (int i = 0; i <n; i++)
            {
                txy[i] = Reads();
            }

            bool f = true;
            long dis = d(0, 0, txy[0][1], txy[0][2]);
            bool f1 = dis % 2 != txy[0][0] % 2;
            bool f2 = dis > txy[0][0];
            if (f1||f2) f = false;
            for (int i = 0; i < n-1; i++)
            {
                dis = d(txy[i][1], txy[i][2], txy[i + 1][1], txy[i + 1][2]);
                f1 = dis % 2 != (txy[i + 1][0] - txy[i][0]) % 2;
                f2 = dis > txy[i + 1][0] - txy[i][0];
                if (f1||f2) f = false;
            }
            Console.WriteLine(f ? "Yes" : "No");


            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 23480