akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 using namespace std; 
 int main() {
    string s;
    cin >> s;
    bool x = false;
    bool y = false;
    if (s[0] == '1' && (s[1] == '1' || s[1] == '2' || s[1] == '0')) {
        x= true;
    }
    else if (s[0] == '0' && (int(s[1]) > 48 && int(s[1]) < 58)) {
        x = true;;
    }
    if (s[2] == '1' && (s[3] == '1' || s[3] == '2' || s[3] == '0')) {
        y = true;
    }
    else if (s[2] == '0' && (int(s[3]) > 48 && int(s[3]) < 58)) {
        y = true;
    }
    if (x == true && y == true) {
        cout << "AMBIGUOUS";
    }
    else if (x == true) {
        cout << "MMYY";
    }
    else if (y == true) {
        cout << "YYMM";
    }
    else {
        cout << "NA";
    }

 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
ll dp[100010];
ll idx[100010];

int main(){
    int n;
    scanf("%d",&n);
    int cnt=0;
    bool flag=false;
    while(n--){
        int a,b;
        scanf("%d%d",&a,&b);
        if(a==b) cnt++;
        else cnt=0;
        if(cnt>=3) flag=true;
    }
    printf("%s",flag?"Yes":"No");
    return 0;
}

Measured memory_bytes: 3860
#include<iostream>
#include<vector>
#include<algorithm>
 using namespace std;
int main()
{
    vector<int> height(10);
 
    for(int i=0;i<10;++i)
    {
        cin >> height[i];
    }
 
    sort(height.begin(),height.end());
 
    cout << height[9] << '\n';
 
    cout << height[8] << '\n';
 
    cout << height[7] << '\n';
}

Measured memory_bytes: 1212
function main()
  
  N = parse(Int, readline())
  Ls = map(x -> parse(Int, x), split(chomp(readline()), " "))
  
  sort!(Ls, rev=true)
  
  cnt = 0

  for i in 1:N-2
    for j in i+1:N-1
      for k in j+1:N
        
        if Ls[i] < Ls[j] + Ls[k] && Ls[i] > Ls[j] && Ls[i] > Ls[k] 
          if Ls[i] != Ls[j] && Ls[j] != Ls[k] && Ls[k] != Ls[i]
            cnt += 1
          end
        end
        
      end
    end
  end
  
  println(cnt)
  
end

main()

Measured memory_bytes: 176932
import math
from itertools import combinations_with_replacement

n, m, q = map(int, input().split())
ls = []
for i in range(1, m + 1):
    ls.append(i)

a = []
b = []
c = []
d = []

for i in range(q):
    aa, bb, cc, dd = map(int, input().split())
    a.append(aa)
    b.append(bb)
    c.append(cc)
    d.append(dd)

zzz = list(combinations_with_replacement(ls, n))
ans = 0

for i in zzz:
    com = list(i)
    p = 0
    for j in range(q):
        if (com[b[j] - 1] - com[a[j] - 1]) == c[j]:
            p += d[j]
    ans = max(ans, p)

print(ans)


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

int a, b, h[1000];

int main() {
    h[0] = 0;
    for (int i = 1; i <= 999; ++i)
        h[i] = h[i - 1] + i;
    while (scanf("%d%d", &a, &b) == 2) {
        int i = b - a;
        printf("%d\n", h[i - 1] - a);
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
      	int[] l = new int[m];
      	int[] r = new int[m];
      	for(int i = 0;i < m;i++)
        {
			input = Console.ReadLine().Split(' ');
			l[i] = int.Parse(input[0]);
			r[i] = int.Parse(input[1]);
        }
      	int a = r.Min()-l.Max()+1;
      	if(a <= 0)
      		Console.WriteLine(0);
     	else
          	Console.WriteLine(a);
	}
}

Measured memory_bytes: 15820
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem A

if __name__ == '__main__':
    a, b = list(map(int, input().split()))

    if (a % 3 == 0) or (b % 3 == 0) or ((a + b) % 3 == 0):
        print('Possible')
    else:
        print('Impossible')


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	static int n;
	static int a[] = new int[100];
	static int b[] = new int[100];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		for (int i = 0; i < n - 1; i++) {
			b[i] = sc.nextInt();
		}
		a[0] = b[0];
		a[1] = b[0];
		for (int i = 1; i < n - 1; i++) {
			a[i] = b[i];
			if (a[i] > b[i - 1]) {
				a[i] = b[i - 1];
			}
		}
		a[n-1] = b[n-2];

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

		System.out.println(sum);

	}

	static int max(int n1, int n2) {
		int bigger = n1 >= n2 ? n1 : n2;
		return bigger;
	}

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,k;
    cin>>n>>k;
    vector<int> l(n);
    rep(i,n) cin>>l[i];
    sort(all(l));
    int ans=0;
    rep(i,k) ans+=l[n-1-i];
    cout<<ans;
}

Measured memory_bytes: 3568
function main(input){
    var ans=1;
    var inputNum=toInt(input);
    for(var i=1;i<=input;i++){
        ans=ans*i;
    }
    console.log(ans);
}
function toInt(str){
    return parseInt(str, 10);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 15516
#include<stdio.h>
int main(){
  int a[200]={};
  int b[200]={};
  int n,i,A,B,C,D,j;
  scanf("%d",&n);
  for(i=0;i<n*(n-1)/2;i++){
    scanf("%d%d%d%d",&A,&B,&C,&D);
    if(C>D){
      a[A]+=3;
    }
    else if(C<D){
      a[B]+=3;
    }
    else{
      a[A]++;
      a[B]++;
    }
  }
  for(i=1;i<=n;i++){
    b[i]=1;
    for(j=1;j<=n;j++){
      if(i!=j)
	if(a[i]<a[j])b[i]++;
    }
  }
  for(i=1;i<=n;i++){
    printf("%d\n",b[i]);
  }
  return 0;
}
 

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

int main() {
    #define rep(i,N) for(int i=0;i<(int)N;i++)
    int N, K; std::cin >> N >> K;
    using namespace std;
    vector<int> h(N);
    rep(i,N) cin>>h[i];
    sort(h.begin(), h.end());
    int ans = 2e9;
    for (int i = 0; i + K <= N; i++) {
        
    }
    using ll = long long;
    for (int i = 0; i + K <= N; i++) {
        ans = min(ans,h[K-1+i]-h[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<cstdio>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int main()
{
	int ans = 0;
	rep( i, 10 )
	{
		int s;
		scanf( "%d", &s );
		ans += s;
	}

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

	return 0;
}

Measured memory_bytes: 1028
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false



int main()
{
	//clock_t start, end;
	//start = clock();

	int r, c;
	cin >> r >> c;
	vector<vector<int> > vec(r + 1, vector<int>(c + 1, 0));
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> vec[i][j];
		}
	}

	for (int i = 0; i < r; i++) vec[i][c] = accumulate(vec[i].begin(), vec[i].end() - 1, 0);
	for (int j = 0; j <= c; j++) {
		for (int i = 0; i < r; i++) {
			vec[r][j] += vec[i][j];
		}
	}
	
	for (int i = 0; i <= r; i++) {
		cout << vec[i][0];
		for (int j = 1; j <= c; j++) {
			cout << " " << vec[i][j];
		}
		cout << endl;
	}


	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}



Measured memory_bytes: 3156
// Aizu Vol-6 0608: Water Rate
// 2017.9.5 bal4u@uu

#include <stdio.h>

int main()
{
	int a, b, c, d, p;
	int pa, pb;

	scanf("%d%d%d%d%d", &a, &b, &c, &d, &p);
	pa = p * a;
	pb = b;	if (p > c) pb += (p-c) * d;
	printf("%d\n", pa <= pb ? pa : pb);
	return 0;
}

Measured memory_bytes: 1840
# using:utf-8

s = input()
c_list = list(s)
n = len(c_list)
min = 1000
for i in range(n-2):
    x = int(c_list[i]+c_list[i+1]+c_list[i+2])
    d = abs(x - 753)
    if d <= min:
        min = d

print(min)

Measured memory_bytes: 3060
import fractions as fr
from functools import reduce
def gcd(a):
  return reduce(fr.gcd, a)
n, k = map(int, input().split())
a = list(map(int, input().split()))
g = gcd(a)
print("POSSIBLE" if (k in a) or (max(a) >= k and (g == 1 or k%g == 0)) else "IMPOSSIBLE")

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x);1
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair	
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

using namespace std;
typedef long long ll;
typedef long double ld;	
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
	 
const ll MAX = 10000000;
const ll inf = 5e18-1;

int main() {
	fastio;
	ll n,k;
	cin>>n>>k;
	map<ll,ll> m;		
	ll d,x,cont=0;
	f(i,0,k){
		cin>>d;
		f(j,1,d+1){
			cin>>x;
			m[x]+=j;
		}
	}
	cout<<n - sz(m)<<endl;
	return 0;
	}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	map<int, int> odd_mp, even_mp;
	for(int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		
		if( i % 2 == 0 ) odd_mp[a]++;
		if( i % 2 == 1 ) even_mp[a]++;
	}
	
	vector< pair<int, int> > odd_x, even_x;
	
	for(auto& s : odd_mp) {
		odd_x.push_back(make_pair(s.second, s.first));
	}
	
	for(auto& s : even_mp) {
		even_x.push_back(make_pair(s.second, s.first));
	}
	
	sort(odd_x.rbegin(), odd_x.rend());
	sort(even_x.rbegin(), even_x.rend());
	
	int ans1 = 0, ans2 = 1e9;
	for(int i = 0; i < odd_x.size(); ++i) {
		ans1 += odd_x[i].first;
	}
		
	for(int i = 0; i < even_x.size(); ++i) {
		ans1 += even_x[i].first;
	}
	
	ans2 = ans1;
	if( odd_x[0].second == even_x[0].second ) {
		ans1 -= (odd_x[1].first + even_x[0].first);
		ans2 -= (odd_x[0].first + even_x[1].first);
	} else {
		ans1 -= even_x[0].first + odd_x[0].first;
	}
	
	int ans = min(ans1, ans2);
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 6136
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
#define ALL(a) a.begin(), a.end()
using namespace std;

#define MaxN 100005
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
template<typename T> T abs(T val){return val>0?val:-val;}
inline int max2(int a, int b) {return ((a > b)? a : b);}
inline int min2(int a, int b) {return ((a < b)? a : b);}
inline int max3(int a, int b, int c) {return max2(a, max2(b, c));}
inline int min3(int a, int b, int c) {return min2(a, min2(b, c));}
struct Edge
{
    int u,v,next;
}edge[MaxM];
int cont, head[MaxN];
void add(int u, int v)
{
    edge[cont].u = u;
    edge[cont].v = v;
    edge[cont].next = head[u];
    head[u] = cont++;
}
struct Node
{
    int id,step;
    Node(){}
    Node(int a, int b):id(a),step(b){}
};
int N;
bool vis[MaxN];
void solve()
{
    CLR(vis);
    queue<Node> Q,ans;
    Q.push(Node(1,0));
    vis[1] = true;
    bool flag = true;
    int limit = INF;
    while(!Q.empty())
    {
        Node tmp = Q.front();
        Q.pop();
        ans.push(tmp);
        int u = tmp.id;
        for(int i=head[u];i!=-1&&flag;i=edge[i].next)
        {
            int v = edge[i].v;
            if(vis[v]) continue;
            vis[v] = true;
            if(v==N)
            {
                limit = min(limit, tmp.step);
            }
            Q.push(Node(v,tmp.step+1));
        }
        if(!flag) break;
    }
    CLR(vis);
    limit = (limit+1)/2;
    //debug(limit)
    while(!ans.empty())
    {
        Node tmp = ans.front();
        ans.pop();
        if(tmp.step<=limit)
        {
            vis[tmp.id]=true;
            //debug(tmp.id);
        }
    }
    Q.push(Node(N,0));
    vis[N] = true;
    int cnt = 0;
    while(!Q.empty())
    {
        Node tmp = Q.front();
        Q.pop();
        int u = tmp.id;
        for(int i=head[u];i!=-1&&flag;i=edge[i].next)
        {
            int v = edge[i].v;
            //debug(v) debug(vis[v])
            if(vis[v]) continue;
            vis[v] = true;
            
            cnt++;
            Q.push(Node(v,tmp.step+1));
        }
    }
    int a = N-2-cnt;
    //debug(a) debug(cnt)
    if(cnt<a) puts("Fennec");
    else puts("Snuke");
}
void init()
{
    cont = 0;
    MST(head,-1);
}
int main()
{
    //std::ios::sync_with_stdio(false);
    while(~scanf("%d", &N))
    {
        init();
        int a, b;
        for(int i=1;i<N;i++)
        {
            scanf("%d%d", &a, &b);
            add(a,b);
            add(b,a);
        }
        solve();
    }
    //system("pause");
    //printf("%lld\n", (x%mod+mod)%mod );
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin>>a;
  vector<long long>v1(a);
  for(int i=0;i<a;i++){
    cin>>v1.at(i);
  }
  sort(v1.begin(),v1.end());
  int c=1,d=0;
  long long e=v1.at(0);
  for(int j=1;j<a;j++){
    if(e==v1.at(j)){
      c++;
      if(j==a-1){
        d+=c%2;
      }
    }
    else{
      e=v1.at(j);
      d+=c%2;
      c=1;
      if(j==a-1){
        d++;
      }
    }
  }
  cout<<d<<endl;
}

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


int main() {
	
	string s;
	cin >> s;
	int a=0, z=0;
	bool flg = 0;
	for (int i=0; i<s.size(); i++){
		if ( (s.at(i) == 'A') && !flg ) a = i, flg = 1;
		if ( s.at(i) == 'Z') z = i;
	}
	cout << z - a + 1 << endl;
		
	return 0;
	
}

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

#define ios                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define fr freopen("in.txt", "r", stdin)
#define ll long long
#define F first
#define S second
#define mem(v, x) memset(v, x, sizeof(v))
#define EB emplace_back
#define PB push_back
#define MP make_pair

int main()
{
    // fr;
    ios;

    string s;
    cin >> s;
    if (s[0] == s[1] && s[0] == s[2])
        cout << "No\n";
    else
        cout << "Yes\n";
}

Measured memory_bytes: 256
s=Hash.new(0)
t=Hash.new(0)
gets.to_i.times.map{s[gets.chomp]+=1}
gets.to_i.times.map{t[gets.chomp]+=1}
ans = 0
s.each do |k,v|
  a=0
  a+=v
  a-=t[k] if t[k]
  ans=[ans,a].max
end
p ans


Measured memory_bytes: 14372
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
const int INF = 10000000;

int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int n; cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int ans = 0, tmp = 0;
    for(int i = 1; i < n; ++i){
        if(h[i-1] >= h[i]){
            ++tmp;
            if(ans <= tmp) ans = tmp;
        }else{
            if(ans <= tmp){
                ans = tmp;
            }
            tmp = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            out.println(n < 1000 ? "ABC" : "ABD");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            return hasNext() ? buffer[bufPointer++] : -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public boolean hasNext() {
            if (bufPointer < bufLength)
                return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;

            boolean minus = false;
            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9')
                throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (!isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 22484
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}

void solve(){
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	int f=0;
	if((w/2.0)==x&&(h/2.0)==y)f=1;
	cout<<(w*h)/2<<" "<<f<<"\n";
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

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

using namespace std;

typedef long long int ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n;
    cin >> k;
    vector<int> a(n,0);
    for(int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }

    sort(a.begin(), a.end());

    int num = 0;
    int i;
    bool flag = false;
    for(i = 0; i < n; i++)
    {
        flag = false;
        if(k >= a.at(i))
        {
            k -= a.at(i);
            num++;
            flag = true;
        }
    }
    if(k != 0 && flag && num > 0)
    {
        num--;
    }


    cout<<num;
    return 0;
}


Measured memory_bytes: 256
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
    int l,r,d;cin>>l>>r>>d;
    cout<<(r/d)-((l-1)/d)<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//If wrong on pretest 2 means logically wrong


/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  int n, k; cin >> n >> k;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  sort(x.begin(), x.end());

  int ans = 1e9;
  rep(i, n-(k-1)) {
    int dst = x[i+(k-1)]-x[i];
    int near = min(abs(x[i+(k-1)]), abs(x[i]));
    ans = min(ans, near+dst);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int[] x = new int[5];
		int ans = 0;
		for(int i = 0; i < 5; i++) {
			x[i] = sc.nextInt();
			if(x[i] != i + 1) ans = i + 1;
		}
		System.out.println(ans);
		
		
		
	}

}


Measured memory_bytes: 35332
#include <iostream>
#include <vector>
#include <stdlib.h>

using namespace std;

int main(){
	int N;
	while (1){
		cin >> N;
		if (N == 0) break;
		int n, d;
		vector<int> nx, ny;
		nx.push_back(0); ny.push_back(0);
		int minX = 0, maxX = 0, minY = 0, maxY = 0;
		for (int i = 0; i < N-1; i++){
			cin >> n >> d;
			int dx, dy;
			switch (d){
			case 0:
				dx = nx[n] - 1;
				dy = ny[n];
				break;
			case 1:
				dx = nx[n];
				dy = ny[n] - 1;
				break;
			case 2:
				dx = nx[n] + 1;
				dy = ny[n];
				break;
			case 3:
				dx = nx[n];
				dy = ny[n] + 1;
				break;
			}
			nx.push_back(dx);
			ny.push_back(dy);
			if (minX > dx) minX = dx;
			if (maxX < dx) maxX = dx;
			if (minY > dy) minY = dy;
			if (maxY < dy) maxY = dy;
		}
		if (N == 1){ cout << 1 << " " << 1 << endl; continue; }
		int h = abs(maxY - minY) + 1;
		int w = abs(maxX - minX) + 1;
		cout << w << " " << h << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<string>
#define LL long long
#define li i<<1
#define ri i<<1|1
using namespace std;
inline LL read()
{
    char c=getchar();LL x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
LL ans;
int main()
{
	ans=read();
	string str="";
	while(ans>0){
		int m=ans%26;
		if(m==0) m=26;
		str+=(char)(m+64);
		ans=(ans-m)/26;
	}
	reverse(str.begin(),str.end());	//反序	
	int len=str.size();
	for(int i=0;i<len;++i){
		if('A'<=str[i]&&str[i]<='Z')
			printf("%c",str[i]-'A'+'a');
		else
			printf("%c",str[i]);
	}
//	cout<<str<<endl;	//	十进制转26进制 
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for (int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for (int (i) = (a) - 1; (i) >= (b); (i)--)
#define PI acos(-1.0)
#define DEBUG(C) cout<< C <<endl;
#define VI vector <int>
#define VII vector <VI>
#define VL vector <LL>
#define VLL vector <VL>
#define VD vector <double>
#define VDD vector <VD>
#define PII pair <int, int>
#define PDD pair <double, double>
#define PLL pair <LL, LL>
#define VPII vector <PII>
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MP make_pair
#define EB emplace_back
#define FORE(a, b) for (auto &&a:b)
#define FIND(s, n) (s.find(n) != s.end())

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = 1e9;
const int MOD = INF + 7;

string cc[2];

int main(void) {
    cc[0] = "..##";
    cc[1] = ".#.#";
    set <vector <string>> nai;
    int N; cin >> N;
    vector <string> S(2, ""), Sbuf(2);
    int cnt = 0;
    S[0] += cc[0][0];
    S[1] += cc[1][0];
    bool f = false;
    REP(_, 420) {
        printf("%s\n%s\n", S[0].c_str(), S[1].c_str());
        string c; cin >> c;
        if (c == "T") {
            Sbuf = S;
            cnt = 0;
            REP(i, 2) {
                S[i] += cc[i][cnt];
            }
        } else if (c == "F") {
            nai.insert(S);
            label:
            S = Sbuf;
            cnt++;
            if (cnt >= 4 || f) {
                f = true;
                REP(i, 2) {
                    S[i] = cc[i][cnt % 4] + S[i];
                }
            } else {
                REP(i, 2) {
                    S[i] += cc[i][cnt % 4];
                }
            }
            if (FIND(nai, S)) {
                goto label;
            }
        } else {
            break;
        }
    }
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll sum = 0;
  ll res = 0;
  rep(i,n) {
    sum += a[i];
    if(i % 2 == 0 ) {
      if (sum >= 0) {
        res += sum + 1;
        sum = -1;
      }
    }
    else {
      if(sum <= 0) {
        res += 1 - sum;
        sum = 1;
      }
    }
  }
  sum = 0;
  ll tmp = 0;

  rep(i,n) {
    sum += a[i];
    if (i % 2 == 0) {
      if (sum <= 0) {
        tmp += 1 - sum;
        sum = 1;
      }
    }
    else {
      if (sum >= 0) {
        tmp += sum + 1;
        sum = -1;
      }
    }
  }
  cout << min(res,tmp) << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int A = Integer.parseInt(sc.next());

    String result = N % 500 <= A ? "Yes" : "No";
    System.out.println(result);

  }
}


Measured memory_bytes: 21844
#!/usr/bin/env python3
N, x = map(int, input().split())
a = list(map(int, input().split()))

b = a[:]
ans = float('inf')
for i in range(N):
    b = [min(b[j], a[j - i]) for j in range(N)]
    ans = min(ans, i * x + sum(b))
print(ans)


Measured memory_bytes: 3188
#include <cstdio>
#include<iostream>
#include<string>
#include<set>
#define rep(i,l,p) for(int i=l;i<=p;i++)
using namespace std;
const int maxN = 110;
int h,w,n;
int a[maxN];
int m[maxN][maxN];
void input(){

	scanf("%d%d%d",&h,&w,&n);
	int x = 1, y = 1; 
	int t = 0;
	rep(i,1,n) {
		scanf("%d",&t);
		//printf("%d\n", t);
		//printf("pppp\n");
		while( t > 0 && x <= h && y <= w){
			m[x][y] = i;
			//printf("%d\n",m[x][y] );
			t--;
			if (x % 2 ==1){
				y++;
				if ( y > w ){
					y--;
					x++;
				}
			}else {
				y--;
				if( y < 1 ){
					y++;
					x++;
				}
			}

		}
	
	}

}
void output(){
	rep(i,1,h)
	{
		rep(j,1,w)
			printf("%d ", m[i][j]);
		printf("\n");
	}
}
int main()
{
	//freopen("in.txt","r",stdin);
	input();
	output();
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  set<int> s;
  for (int i = a; i < a + k && i <= b; ++i) s.emplace(i);
  for (int i = b; i > b - k && a <= i; --i) s.emplace(i);
  for (int i : s) cout << i << endl;
}



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

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

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int ans = 0;
	for(int i=0;i<S.size()/2;i++){
		if(S[i]!=S[S.size()-1-i])ans++; 
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import math

n, m = [int(w) for w in input().split()]
points = []


for i in range(n):
    points.append([int(w) for w in input().split()])

count = 0

for i in range(n):
    for j in range(i + 1, n):
        dist = sum([(x1 - y1) ** 2 for x1, y1 in zip(points[i], points[j])])
        dist = math.sqrt(dist)
        # print(dist)
        if dist.is_integer():
            count += 1


print(count)


Measured memory_bytes: 3064
import numpy as np
import sys
input = sys.stdin.readline

def main():

    list = np.array([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51])
    K = int(input())

    print(list[K-1])

if __name__ == '__main__':
    main()

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

int main() {
  vector<int> Kth = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  
  cout << Kth.at(K-1) << endl;
}


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

const ll INF = 1e16;

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

	if (s[0] != s.back())
	{
		if (s.size() % 2 == 1) cout << "First" << endl;
		else cout << "Second" << endl;
	}
	else
	{
		if (s.size() % 2 == 0) cout << "First" << endl;
		else cout << "Second" << endl;
	}
	return 0;
}

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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 < i; i--)
#define FOR(i, from, to)                                                       \
  for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to)                                               \
  for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<llv> llvv;

#define MOD (ll)1000000007

ll powmod(ll n, ll m, ll mod) {
  ll ans = 1;
  rep(_, m) {
    ans *= n;
    ans %= mod;
  }
  return ans % mod;
}

int main() {
  ll n;
  cin >> n;
  llv a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  bool flag = true;
  ll current = 1;
  ll count_MOD = 0;
  if (n % 2) {
    if (a[0] != 0)
      flag = false;
    else
      a.erase(a.begin());
  }
  rep(i, a.size()) {
    flag &= a[i] == (current * 2 - !(n % 2));
    if (i % 2) {
      current++;
    }
  }
  if (flag)
    cout << powmod(2, a.size() / 2, MOD) << endl;
  else
    cout << 0 << endl;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  double w,h,x,y;
  cin >> w >> h >> x >> y;
  double ans = w*h/2;
  cout << ans<< " ";
  if(x==w/2 && y==h/2){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int64_t>> c(n,vector<int64_t>(8));
  int64_t b=0;
  for(int i=0;i<n;i++){
    vector<int64_t> xyz(3);
    cin>>xyz.at(0)>>xyz.at(1)>>xyz.at(2);
    b+=abs(xyz.at(0))+abs(xyz.at(1))+abs(xyz.at(2));
    for(int j=0;j<8;j++){
      int k=j;
      int64_t s=0;
      for(int d=0;d<3;d++){
        s+=xyz.at(d)*(k%2==0?1:-1);
        k/=2;
      }
      c.at(i).at(j)=s;
    }
  }
  int64_t a=0;
  for(int x=0;x<8;x++){
    vector<vector<int64_t>> p(n+1,vector<int64_t>(m+1,-b));
    for(int i=0;i<=n;i++)
      p[i][0]=0;
    for(int i=1;i<=n;i++)
      for(int j=1;j<=m&&j<=i;j++)
        p[i][j]=max(p[i-1][j],p[i-1][j-1]+c.at(i-1).at(x));
    a=max(a,p[n][m]);
  }
  cout<<a<<endl;
}

Measured memory_bytes: 11228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
using ll = long long;
const ll mod = 1e9 + 7;
 
int main(){
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  for(ll i=0; i <= n-k+1; i++){
    ll s = (i*(n-i+1)+1)%mod;
    ans = (ans + s) %mod;
  }
  cout << ans << endl; 
  
  return 0;
}


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

using namespace std;

const int N=305;
vector<pair<int,int>> v[N];
int res[N][N];
int n,m,l;

struct state
{
    int num;
    int fuel;
    int id;
    state(int a,int b,int c)
    {
        tie(num,fuel,id)=make_tuple(a,b,c);
    }
};

bool comp(state a,state b)
{
    return (a.num>b.num||(a.num==b.num&&a.fuel<b.fuel));
}

void solve(int src)
{
    priority_queue<state,vector<state>,function<bool(state,state)>> q(comp);
    vector<pair<int,int>> best(n+1,{n+1,0});
    best[src]={0,l};
    q.push(state(0,l,src));
    while(!q.empty())
    {
        state now=q.top();
        q.pop();
        int a=now.id;
        if(now.num>best[a].first||(now.num==best[a].first&&now.fuel<best[a].second)) continue;
        //no fill
        for(pair<int,int> e:v[a])
        {
            int to=e.first;
            int w=e.second;
            if(w>now.fuel) continue;
            if(best[to].first>now.num||(best[to].first==now.num&&(best[to].second<now.fuel-w)))
            {
                best[to]=make_pair(now.num,now.fuel-w);
                q.push(state(now.num,now.fuel-w,to));
            }
        }
        //fill
        for(pair<int,int> e:v[a])
        {
            int to=e.first;
            int w=e.second;
            if(w>l) continue;
            if(best[to].first>now.num+1||(best[to].first==now.num+1&&(best[to].second<l-w)))
            {
                best[to]=make_pair(now.num+1,l-w);
                q.push(state(now.num+1,l-w,to));
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(best[i].first==n+1) res[src][i]=-1;
        else res[src][i]=best[i].first;
    }
}


int main()
{
    scanf("%d%d%d",&n,&m,&l);
    for(int i=0;i<m;i++)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        v[a].push_back({b,c});
        v[b].push_back({a,c});
    }
    for(int i=1;i<=n;i++) solve(i);
    int q;
    scanf("%d",&q);
    while(q--)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        printf("%d\n",res[a][b]);
    }
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define _GLIBCXX_DEBUG

signed main() {
  int N, X, Y; cin >> N >> X >> Y;
  

  vector<int> ans(N);

  rep(i, 0, N) {
    int k = 0;
    rep(j, i, N) {
      if(i == j) k = 0;
      else k = min(j-i, abs(i-X+1)+abs(j-Y+1)+1);
      ans[k]++;
    }
  }
  rep(i, 1, N) cout << ans[i] << endl;

}

Measured memory_bytes: 256
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define mmod 924844033
#define N 210000
#define M 550000
#define grt 5
#define LL long long
using namespace std;
LL jc[M],ny[M];
struct node{LL y,nex;}a[2*N];
struct NTT{
	LL a[M],b[M],c[M],bitrev[M],m,g[M],ng[M];
	LL qmod(LL a,LL b)
	{
		LL t=1;
		while(b)
		{
			if(b%2) t=1ll*t*a%mmod;
			b/=2;
			a=1ll*a*a%mmod;
		}
		return t;
	}
	void ntt_pre(LL n)
	{
		LL len=0;
		while((1<<len)<n) len++;
		len--;
		for(LL i=0;i<n;i++)
		{
			LL k=0;
			for(LL j=0;j<=len;j++) if(i&(1<<j)) k|=1<<(len-j);
			bitrev[i]=k;
		}
	}
	void ntt(LL *x,LL n,LL o)
	{
		for(LL i=0;i<n;i++) if(i>bitrev[i]) swap(x[i],x[bitrev[i]]);
		for(LL s=2;s<=n;s*=2)
		{
			if(o==1 && g[s]==0) g[s]=qmod(grt,(mmod-1)/s);
			if(o==-1 && ng[s]==0) ng[s]=qmod(grt,mmod-1-(mmod-1)/s);
			LL wn;
			if(o==1) wn=g[s];
			else wn=ng[s];
			for(LL i=0;i<n;i+=s)
			{
				LL w=1;
				for(LL j=0;j<s/2;j++)
				{
					LL t1=x[i+j],t2=1ll*w*x[i+j+s/2]%mmod;
					x[i+j]=(t1+t2)%mmod;
					x[i+j+s/2]=(t1-t2)%mmod;
					w=1ll*w*wn%mmod;
				}
			}
		}
	}
	void work()
	{
		m*=2;
		LL n=1;
		while(n-1<m) n*=2;
		ntt_pre(n);
		ntt(a,n,1);ntt(b,n,1);
		for(LL i=0;i<n;i++) c[i]=1ll*a[i]*b[i]%mmod;
		ntt(c,n,-1);
		LL ny=qmod(n,mmod-2);
		for(LL i=0;i<n;i++) c[i]=1ll*c[i]*ny%mmod;
		LL oo=1;
	}
}g;
LL fir[N],len,n,siz[N],cnt[N],ans[N];
void ins(LL x,LL y)
{
	a[++len].y=y;a[len].nex=fir[x];fir[x]=len;
}
void dfs(LL x,LL fa)
{
	siz[x]=1;
	for(LL k=fir[x];k;k=a[k].nex)
	{
		LL y=a[k].y;
		if(y==fa) continue;
		dfs(y,x);
		siz[x]+=siz[y];
		cnt[siz[y]]++;
	}
	cnt[n-siz[x]]++;
}
LL C(LL n,LL m)
{
	return 1ll*jc[n]*ny[m]%mmod*ny[n-m]%mmod;
}
int main()
{
	jc[0]=jc[1]=ny[0]=ny[1]=1;
	for(LL i=2;i<M;i++) jc[i]=1ll*jc[i-1]*i%mmod,ny[i]=1ll*(-mmod/i)*ny[mmod%i]%mmod;
	for(LL i=2;i<M;i++) ny[i]=1ll*ny[i-1]*ny[i]%mmod;
	scanf("%lld",&n);
	for(LL i=1;i<n;i++)
	{
		LL x,y;scanf("%lld%lld",&x,&y);
		ins(x,y);ins(y,x);
	}
	dfs(1,0);
	for(LL i=1;i<=n;i++) 
		g.a[i]=cnt[i]*jc[i]%mmod,g.b[i]=ny[n-i];
	g.m=n;
	g.work();
	for(LL i=1;i<=n;i++) ans[i]=1ll*n*C(n,i)%mmod;
	for(LL i=1;i<=n;i++) ans[i]=(ans[i]-(1ll*ny[i]*g.c[n+i]%mmod))%mmod;
	for(LL i=1;i<=n;i++) printf("%lld\n",(ans[i]+mmod)%mmod);
	return 0;
}

Measured memory_bytes: 57600
import math

def gosaikutu(nums):
    numbers = list(range(1, len(nums)+1))
    gosa = [0]*len(nums)
    
    for i,number in enumerate(nums):
        gosa[i] = numbers.index(number)
        numbers.remove(number)
    
    return gosa
    
def nanbanme(gosa):
    nanban = 1
    ikutu = len(gosa)
    
    for j,value in enumerate(gosa):
        keisuu = math.factorial(ikutu - j - 1)
        
        if value is not 0:
            nanban += keisuu * value
    return nanban

n = input()
nums1 = list(map(int, input().split(' ')))
nums2 = list(map(int, input().split(' ')))

banme1 = nanbanme(gosaikutu(nums2))
banme2 = nanbanme(gosaikutu(nums1))
ans = banme1 - banme2
if ans < 0:
    print(-ans)
else:
    print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
ll a[105][105];
int main(int argc, char** argv) {
	int A,B;
	cin>>A>>B;
	A--;
	B--;
	int P=min(A,B);
	rep(i,1,100)
	{
		rep(j,1,48)
		{
			if(i%2==0&&j%2==1&&A)
			{
				A--;
				a[i][j]=1;
			}
			else
			{
				a[i][j]=0;
			}
		}
	}
	rep(i,1,100)
	{
		a[i][49]=0;
	}
	rep(i,1,100)
	{
		a[i][50]=1;
	}
	rep(i,1,100)
	{
		rep(j,51,100)
		{
			if(i%2==0&&j%2==1&&B)
			{
				B--;
				a[i][j]=0;
			}
			else
			{
				a[i][j]=1;
			}
		}
	}
	cout<<100<<" "<<100<<endl;
	rep(i,1,100)
	{
		rep(j,1,100)
		{
			if(a[i][j]==0)
			printf("#");
			if(a[i][j]==1)
			printf("."); 
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
	int m,x,y;
	scanf("%d%d%d",&m,&x,&y);
	int w,z;
	if(m-x>0)
		w=m-x;
	else
		w=-(m-x);
	if(m-y>0)
		z=m-y;
	else
		z=-(m-y);
	
	
	if(w<z)
	printf("A\n");
	else
	printf("B\n");
	
	
	
	
	return 0;
}

Measured memory_bytes: 128
//
// Created by tac on 2016/10/12.
//

#include <cstdlib>
#include <iostream>

int main() {
    int n, m;

    std::cin >> n >> m;
    int* a = new int[n * m];
    int* b = new int[m];
    int * c = new int[n];

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            a[(i * m) + j] = 0;
            b[j] = 0;
            c[i] = 0;
        }
    }

    int e;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            std::cin >> e;
            a[(i * m) + j] = e;
        }
    }
    for (int j = 0; j < m; ++j) {
        std::cin >> e;
        b[j] = e;
    }

//    std::cout << "a = " << std::endl;
//    for (int i = 0; i < n; ++i) {
//        for (int j = 0; j < m; ++j) {
//            std::cout << " " << a[(i * m) + j];
//        }
//        std::cout << std::endl;
//    }
//    std::cout << " b = " << std::endl;
//    for (int j = 0; j < m; ++j) {
//        std::cout << " " << b[j];
//        std::cout << std::endl;
//    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            c[i] += a[(i * m) + j] * b[j];
        }
    }

    for (int i = 0; i < n; ++i) {
        std::cout << c[i] << std::endl;
    }

    delete[] a;
    delete[] b;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3104