akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    if(A+B <= C*2){
        cout << A*X + B*Y << endl;
    }else{
        int res1, res2;
        if(X > Y){
            res1 = C*min(X, Y)*2 + (X-Y)*A;
        }else{
            res1 = C*min(X, Y)*2 + (Y-X)*B;
        }
        res2 = C*max(X, Y)*2;
        cout << min(res1, res2) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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; }
ll MOD = 1000000007;

void solve()
{	
	int n; cin >> n;
	string s, t; cin >> s >> t;
	rep(i, n)
	{
		bool mat = true;
		for (int j = 0; i + j < n; j++)
		{
			if(s[i + j] != t[j]) 
			{
				mat = false;
				break;
			}
		}
		if(mat)
		{
			cout << n + i << endl;
			return;
		}
	}
	cout << 2*n << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		long ans = 1;
		for (int i = 0; i < N; i++) {
			long a = sc.nextLong();
			if (a == 0) {
				System.out.println(0);
				return;
			}
			A[i] = a;
		}
		for (int i = 0; i < N; i++) {
			if (1000000000000000000L / ans < A[i]) {
				System.out.println("-1");
				return;
			}
			ans *= A[i];
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 61320
import itertools
n, m = map(int, input().split())
to = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    to[a-1].append(b-1)
    to[b-1].append(a-1)

count = 0
seq = list(range(1,n))
permutation = itertools.permutations(seq)
for l in permutation:
    t = 0
    flag = 0
    for i in l:
        c = to[i].count(t)
        if c == 0:
            flag = 1
            break
        t = i
    if flag == 0:
        count += 1
    flag = 0

print(count)

Measured memory_bytes: 3064
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll N;
ll K;
ll C;
vint point;
vint after;
vint before;

int main(){


    
    cin >> N;
    cin >> K;
    cin >> C;

    string S;
    cin >> S;


    //o か x
    int point_x;
    int bef_index=0;
    int point_i;
    point_i=0;
    rep(ni,N){
        if(S.substr(ni,1)=="o"){
            point_x = ni + 1;
            point.push_back(point_x);
            after.push_back(0);
            before.push_back(0);
            while(point_x > point[bef_index] + C){
                after[bef_index]=point_i;
                bef_index++;
            }
            point_i++;
        }
    }

    int last_index = point.size()-1;
    int aft_index= last_index;
    for( int index = last_index ; index >=0 ; index-- ){
        point_x = point[index];
        while(point_x + C < point[aft_index]){
            before[aft_index]=index;
            aft_index--;
        }
    }

    //rep(ni,point.size()){
        //cout << ni << " : " << point[ni]  << "/" << after[ni]<< "/"<< before[ni] << endl;
    //}

    ll load_front[K];
    ll load_back[K];

    point_i=0;
    point_x = point[point_i];
    load_front[0]=(point_x);
    for( int index = 1 ; index <=K-1 ; index++ ){
        point_i = after[point_i];
        point_x = point[point_i];
        load_front[index]=point_x;
    }

    //cout << "back" << endl;
    point_i = last_index;
    point_x = point[point_i];
    load_back[K-1]=(point_x);
    for( int index = K-2 ; index >=0 ; index-- ){
        point_i = before[point_i];
        point_x = point[point_i];
        load_back[index]=point_x;
    }
    //cout << "vs" << endl;
    rep(index,K){
        //cout << load_front[index] << " vs " << load_back[index] << endl;
        if(load_front[index]==load_back[index]) cout << load_front[index] << endl;
    }


}

Measured memory_bytes: 7396
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

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;
}

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}


void Main()
{
    int n,a,b;
    cin>>n>>a>>b;

    LL result = modpow(2,n)-1;
    //LL ca = COM(n,a);
    //LL cb = COM(n,b);

    LL ca=1;
    REP(i,a){
        ca *= (n-i);
        ca %= MOD;
    }
    REP(i,a){
        ca *= modinv(i+1, MOD) % MOD ;
        ca %= MOD;
    }

    LL cb=1;
    REP(i,b){
        cb *= (n-i);
        cb %= MOD;
    }
    REP(i,b){
        cb *= modinv(i+1, MOD) % MOD ;
        cb %= MOD;
    }

    //dump(result)
    //dump(ca)
    //dump(cb)

    result = mod((result%MOD) - (ca%MOD), MOD);
    result = mod((result%MOD) - (cb%MOD), MOD);

    cout << result << endl;


	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
_max = (n-1)*(n-2)//2
if k > _max:
    print(-1)
    exit()

ans = []
for i in range(1, n):
    ans.append((1, i+1))
reduce = _max - k
f = 1
t = 2
while reduce:
    ans.append((f+1, t+1))
    reduce -= 1
    if t+1 == n:
        f += 1
        t = f + 1
    else:
        t += 1

print(len(ans))
for a, b in ans:
    print(a, b)


Measured memory_bytes: 3992
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 100000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int N;
    cin >> N;
    vector<string> W(N);
    REP(i, N) cin >> W[i];

    //同じ単語がないか探索
    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            if(W[i] == W[j]){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    /*string A = W[0];
    string B = W[1];
    cout << A << " " << B << endl;
    cout << A[0] << endl;
    cout << B[B.size()-1] << endl;*/

    //しりとりになっているか探索
    for(int i=0; i<N-1; i++){
        if(W[i][W[i].size()-1] != W[i+1][0]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  int x = 800 * N;
  int y = 200 * (N / 15);

  cout << x - y << endl;

  return 0;
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N; cin >> N;
    int C[N+1] = {}; rep(i, N) cin >> C[i+1];
    ll dp[N+1][2];
    int prev_c[200001] = {}; //prev_c[i]: 色iが一番最近に現れた場所

    dp[0][0] = 0; dp[0][1] = 0; dp[1][0] = 1; dp[1][1] = 0; prev_c[C[1]] = 1;
    for(int i = 2; i <= N; i++){
        
        //dp[i][0] = (dp[i-1][0] + dp[i-1][1]) % mod;
        //dp[i][1] = (dp[prev_c[C[i]]][0] + dp[prev_c[C[i]]][1]) % mod;
        //基本はこの遷移でいいけど、隣接してる時が危ない -> 1個前をそのままコピーすればいい
        if(C[i] == C[i-1]){
            dp[i][0] = dp[i-1][0];
            dp[i][1] = dp[i-1][1];
        }
        else{
            dp[i][0] = (dp[i-1][0] + dp[i-1][1]) % mod;
            dp[i][1] = (dp[prev_c[C[i]]][0] + dp[prev_c[C[i]]][1]) % mod;
        }
        
        prev_c[C[i]] = i;
    }
    cout << (dp[N][0] + dp[N][1]) % mod << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 4992
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <functional>

using namespace std;
typedef pair<int,int> mp;
int mins(int p,int q){
  if(p==-1)return q;
  else if(q==-1 || p<q)return p;
  else return q;
}
int max(int p,int q){
  if(p<q)return q;
  else return p;
}

int md[3000][3000];
int mm[3000];
int dt[3000];
bool ch[3000];
int m,n,k;

int main(void){
  memset(md,-1,sizeof(md));
  memset(dt,-1,sizeof(dt));
  scanf("%d%d%d",&n,&m,&k);
  int i,j;
  int a,b,c;
  for(i=0;i<m;i++){
    scanf("%d%d%d",&a,&b,&c);
    md[a-1][b-1]=c;
    md[b-1][a-1]=c;
  }
  for(i=0;i<k;i++){
    scanf("%d",&a);
    mm[i]=a-1;
  }
  int st,no,kyo,mk;
  mp pa;
  int ans=0;
  priority_queue <mp,vector<mp>,greater<mp> > que;
  for(i=0;i<k;i++){
    st=mm[i];
    dt[st]=0;
  }
  memset(ch,false,sizeof(ch));
  //ch[st]=true;
  que.push(make_pair(0,st));
  while(!que.empty()){
    pa=que.top();
    que.pop();
    kyo=pa.first;
    no=pa.second;
    if(ch[no]==false){
      for(j=0;j<n;j++){
	if(md[no][j]!=-1 && ch[j]==false){
	  mk=md[no][j];
	  dt[j]=mins(dt[j],kyo+mk);
	  que.push(make_pair(dt[j],j));
	}
      }
      ch[no]=true;
    }
  }
  for(i=0;i<n;i++){
    ans=max(ans,dt[i]);
    //printf("%d\n",dt[i]);
  }
  //printf("\n");
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(md[i][j]!=-1){
	ans=max(ans,(int)((dt[i]+dt[j]+md[i][j]+1)/2));
	//printf("%d %d %d\n",i+1,j+1,(int)((dt[i]+dt[j]+md[i][j]+1)/2));
      }
    }
  }

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

Measured memory_bytes: 36696
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100000+10;
int n,h[maxn],dp[maxn];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>h[i];
	memset(dp,0x3f3f3f3f,sizeof(dp));
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
		dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 4420
using System;
class Program{
  public static void Main(){
    int A, B;
    var line = Console.ReadLine().Split(' ');
    A = int.Parse(line[0]);
    B = int.Parse(line[1]);
    if (B % A == 0){
      Console.WriteLine(B + A);
    }
    else{
      Console.WriteLine(B - A);
    }
  }
}

Measured memory_bytes: 13140
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iomanip>

using namespace std;
#define INF 1e9
#define MAX 100005
#define MOD 1000000007
#define Q queue
#define PQ priority_queue
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define FOR( i, L, U ) for(int i=(int)L ; i<(int)U ; i++ )
#define FORD( i, U, L ) for(int i=(int)U ; i>=(int)L ; i-- )
#define wa cout<<"Wa"<<endl
#define READ(filename)  freopen(filename, "r", stdin);
#define WRITE(filename)  freopen(filename, "w", stdout);

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef map<int , vector<int> > mvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

void base(){
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
}


int main(){
	base();
	int n,arr[MAX];
	cin>>n;
	FOR(i,1,n+1){
		cin>>arr[i];
	}
	Q<int> q;
	q.push(1);
	int ans=0;
	while(!q.empty()){
		int now = q.front();
		q.pop();
		if (now==2){
			cout<<ans<<endl;
			return 0;
		}
		ans++;
		if (ans>MAX){
			cout<<-1<<endl;
			return 0;
		}
		q.push(arr[now]);
	}
	return 0;
}



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

using namespace std;

const int N = 20;
int n;
int a[N];
int b[N];
int c[N];

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

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

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += b[i];
    }


    for (int i = 0; i + 1 < n; i++)
    {
        if (a[i + 1] == a[i] + 1)
        {
            ans += c[a[i] - 1];
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
  
main(){
  int i,j,m[N][N],n,l,u,s;
  scanf("%d",&u);
  for(i=0;i<u;i++){
    for(j=0;j<u;j++){
      m[i][j]=0;
    }
  }
  
  for(i=0;i<u;i++){
    scanf("%d %d",&n,&l);
    n--;
    for(j=0;j<l;j++){
      scanf("%d",&s);
      s--;
      m[n][s]=1;
    }
  }
  for(i=0;i<u;i++){
    for(j=0;j<u-1;j++){
      printf("%d ",m[i][j]);
    }
    printf("%d",m[i][u-1]);
    printf("\n");
  }
    
    
 return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

int main()
{
	int n;
	cin>>n;
	vector<int>h(n);
	rep(i,n)cin>>h[i];
	int now=h[0];
	int cnt=0;
	int ans=0;
	FOR(i,1,n){
		if(now>=h[i]){
			cnt++;
		}else{
			ans=max(ans,cnt);
			cnt=0;
		}
		now=h[i];
		//cout<<cnt<<endl;
	}
	ans=max(ans,cnt);
	cout<<ans<<endl;
}


Measured memory_bytes: 640
import java.io.*;
import java.util.StringTokenizer;

public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        StringTokenizer st =new StringTokenizer(br.readLine());
        int N = Integer.parseInt(st.nextToken());
        int Q = Integer.parseInt(st.nextToken());
        char[] arr = br.readLine().toCharArray();
        int[] num = new int[N];
        num[0] = 0;
        for(int i=1;i<N;++i)
        {
            num[i] = num[i-1] + (arr[i-1]=='A'&&arr[i]=='C'?1:0);
        }
        for(int i=0;i<Q;++i)
        {
            st = new StringTokenizer(br.readLine());
            int start = Integer.parseInt(st.nextToken());
            int end = Integer.parseInt(st.nextToken());
            bw.write((num[end-1] - num[start-1]) +"\n");
        }
        bw.close();

    }
}


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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int a,b;cin>>a>>b;
    vector<string> res(100,"");
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            res[i]+=".";
        }
    }  
    for(int i=1;i<100;i++){
        for(int j=0;j<100;j++){
            if(j==99) res[i][j]='#';
            if(i%2 && j!=0) res[i][j]='#';
            if(i==99) res[i][j]='#';
        }
    }
    int cnt=1;
    for(int i=0;i<99;i+=2){
        //cout<<i<<" "<<cnt<<endl;
        if(cnt>=a) break;
        for(int j=1;j<=97;j+=2){
            if(cnt>=a) break;
            res[i][j]='#';
            cnt++;
        }
    }
    cnt=1;
    for(int i=99;i>=1;i-=2){
        if(cnt>=b) break;
        for(int j=98;j>=2;j-=2){
            if(cnt>=b) break;
            res[i][j]='.';
            cnt++;
        }
    }
    cout<<100<<" "<<100<<endl;
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            cout<<res[i][j];
        }
        cout<<endl;
    }
}


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

using namespace std;
bool isPalindrome(int n){
	bool ans = true;
	string s = to_string(n);
	n = s.size();
	for(int i =0; i<n/2; i++){
		if(s[i]!= s[n-1-i]){
			ans = false;
			break;
			}
		}
	return ans;
	}
int main(){
	int a, b;
	int count = 0;
	cin>>a>>b;
	for(int i = a; i<b+1; i++){
		
		if(isPalindrome(i)) count++;
		}
	cout<<count;
	
	return 0;
	}


Measured memory_bytes: 256
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::collections::BinaryHeap;

fn f(s: usize, n: usize, edges: &mut Vec<Vec<usize>>, cnt: &mut Vec<u32>) {
    let mut dis: Vec<usize> = vec![n; n];

    let mut bh: BinaryHeap<i32> = BinaryHeap::new();

    let tmp = 0 * 10000 + s as i32;
    bh.push(-tmp);

    while let Some(tmp) = bh.pop() {
        let tmp = (-tmp) as usize;
        let d = tmp / 10000;
        let u = tmp % 10000;
        if d < dis[u] {
            dis[u] = d;
        } else {
            continue;
        }
        for &v in &edges[u] {
            let tmp = ((d + 1) * 10000 + v) as i32;
            bh.push(-tmp);
        }
    }

    for i in 0..n {
        cnt[dis[i]] += 1;
    }
}

fn main() {
    let nxy: Vec<usize> = read_vec();
    let n = nxy[0];
    let x = nxy[1] - 1;
    let y = nxy[2] - 1;

    let mut edges: Vec<Vec<usize>> = vec![vec![]; n];

    for i in 0..n - 1 {
        edges[i].push(i + 1);
        edges[i + 1].push(i);
    }
    edges[x].push(y);
    edges[y].push(x);

    let mut cnt: Vec<u32> = vec![0; n];

    for i in 0..n {
        f(i, n, &mut edges, &mut cnt);
    }

    for i in 1..n {
        println!("{}", cnt[i] / 2);
    }
}


Measured memory_bytes: 4352
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        new Magatro().Solve();
    }
}

public class Scanner
{
    private StreamReader Sr;

    private string[] S;
    private int Index;
    private const char Separator = ' ';

    public Scanner(Stream source)
    {
        Index = 0;
        S = new string[0];
        Sr = new StreamReader(source);
    }

    private string[] Line()
    {
        return Sr.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public decimal NextDecimal()
    {
        return decimal.Parse(Next());
    }
    public string[] StringArray(int index = 0)
    {
        Next();
        Index = S.Length;
        return S.Skip(index).ToArray();
    }
    public int[] IntArray(int index = 0)
    {
        return StringArray(index).Select(int.Parse).ToArray();
    }
    public long[] LongArray(int index = 0)
    {
        return StringArray(index).Select(long.Parse).ToArray();
    }
    public bool EndOfStream
    {
        get { return Sr.EndOfStream; }
    }
}

public class Magatro
{
    private Scanner Cin;
    private int A, B;

    private void Scan()
    {
        Cin = new Scanner(Console.OpenStandardInput());
        A = Cin.NextInt();
        B = Cin.NextInt();
    }

    public void Solve()
    {
        Scan();
        Console.WriteLine(Compare(A, B));
    }

    private string Compare(int a,int b)
    {
        if (a == b) return "Draw";
        if (a == 1)
        {
            return "Alice";
        }
        if (b == 1)
        {
            return "Bob";
        }
        if (a > b)
        {
            return "Alice";
        }
        else
        {
            return "Bob";
        }
    }
}





Measured memory_bytes: 11092
#include <iostream>
#include <string>
using namespace std;
int main() {
  int H, W;
  string S[100];
  ios::sync_with_stdio(false);
  cin >> H >> W;
  for (int i=0; i<H; i++) {
    cin >> S[i];
  }
  int r[100], c[100];
  for (int i=0; i<H; i++) {
    r[i] = 0;
    for (int j=0; j<W; j++) {
      if (S[i][j] == '#') {
        r[i] = 1;
        break;
      }
    }
  }
  for (int j=0; j<W; j++) {
    c[j] = 0;
    for (int i=0; i<H; i++) {
      if (S[i][j] == '#') {
        c[j] = 1;
        break;
      }
    }
  }
  for (int i=0; i<H; i++) {
    if (!r[i]) continue;
    for (int j=0; j<W; j++) {
      if (!c[j]) continue;
      cout << S[i][j];
    }
    cout << '\n';
  }
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

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

  vector<string> v1 = {"a"};
  vector<string> v2 = {"aa", "ab"};
  vector<string> v3 = {"aaa", "aab", "aba", "abb", "abc"};
  vector<string> v4;
  vector<string> v5;
  vector<string> v6;
  vector<string> v7;
  vector<string> v8;
  vector<string> v9;
  vector<string> v10;

  REP(i, v3.size()) {
    string s = v3[i];
    char M = 'a';
    REP(j, s.size()) {
      char ch = s[j];
      M = max(ch, M);
    }
    FOR(ch, 'a', M + 1) {
      string p = s + char(ch);
      v4.push_back(p);
    }
  }

  REP(i, v4.size()) {
    string s = v4[i];
    char M = 'a';
    REP(j, s.size()) {
      char ch = s[j];
      M = max(ch, M);
    }
    FOR(ch, 'a', M + 1) {
      string p = s + char(ch);
      v5.push_back(p);
    }
  }

  REP(i, v5.size()) {
    string s = v5[i];
    char M = 'a';
    REP(j, s.size()) {
      char ch = s[j];
      M = max(ch, M);
    }
    FOR(ch, 'a', M + 1) {
      string p = s + char(ch);
      v6.push_back(p);
    }
  }

  REP(i, v6.size()) {
    string s = v6[i];
    char M = 'a';
    REP(j, s.size()) {
      char ch = s[j];
      M = max(ch, M);
    }
    FOR(ch, 'a', M + 1) {
      string p = s + char(ch);
      v7.push_back(p);
    }
  }

  REP(i, v7.size()) {
    string s = v7[i];
    char M = 'a';
    REP(j, s.size()) {
      char ch = s[j];
      M = max(ch, M);
    }
    FOR(ch, 'a', M + 1) {
      string p = s + char(ch);
      v8.push_back(p);
    }
  }

  REP(i, v8.size()) {
    string s = v8[i];
    char M = 'a';
    REP(j, s.size()) {
      char ch = s[j];
      M = max(ch, M);
    }
    FOR(ch, 'a', M + 1) {
      string p = s + char(ch);
      v9.push_back(p);
    }
  }

  REP(i, v9.size()) {
    string s = v9[i];
    char M = 'a';
    REP(j, s.size()) {
      char ch = s[j];
      M = max(ch, M);
    }
    FOR(ch, 'a', M + 1) {
      string p = s + char(ch);
      v10.push_back(p);
    }
  }

  vector<vector<string>> v;
  v.push_back(v1);
  v.push_back(v2);
  v.push_back(v3);
  v.push_back(v4);
  v.push_back(v5);
  v.push_back(v6);
  v.push_back(v7);
  v.push_back(v8);
  v.push_back(v9);
  v.push_back(v10);

  REP(i, v[n - 1].size()) {
    ANS(v[n - 1][i]);
  }
  return 0;
}


Measured memory_bytes: 12532
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        if (num < 1200){
            System.out.print("ABC");
        }else if (num < 2800){
            System.out.print("ARC");
        }else {
            System.out.print("AGC");
        }
    }
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

std::string tables[100][100];

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

    int H, W;
    std::cin >> H >> W;

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

            if(s == "snuke"){
                std::cout << (char)('A' + j) << (i + 1) << std::endl;
                return 0;
            }
        }
    }
}


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

#define BUF_SIZE 200

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
#ifdef BUF_SIZE
    char line[BUF_SIZE];
    char *tmpbuf = line;
    int i;
    if(!fgets(line, BUF_SIZE, stdin)) return -1;
    for(i = 0; i < size; i++) {
        char *tmp = strtok(tmpbuf, " ");
        arr[i] = strtol(tmp, NULL, 10);
        tmpbuf = NULL;
    }
#else
#error
#endif
    return 0;
}

#define KINDS_MAX 20
#define NUM_MAX 50000
#define min(a,b) ((a) > (b) ? (b) : (a))

int asc(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int main(void) {
    int cost, kinds;
    int dp[NUM_MAX+1];
    
    get_int2(&cost, &kinds);

    int coins[KINDS_MAX];
    int i, j;
    fget_array(coins, kinds);
    qsort(coins, kinds, sizeof(int), asc);

    // assume that coins[0] = 1;
    for(i = 0; i <= cost; i++) {
        dp[i] = i;
    }

    for(i = 2; i <= kinds; i++) {
        int c = coins[i-1];
        for(j = c; j <= cost; j++) {
            // how many coin you can use!
            dp[j] = min(dp[j],dp[j-c]+1);
        }
    }

    printf("%d\n", dp[cost]);
    return 0;
}



Measured memory_bytes: 2112
while 1:
	H,W = map(int,raw_input().split())
	if H == 0: break
	M = [raw_input() for i in range(H)]
	A = [[0]*W for i in range(H)]
	B = [[0]*W for i in range(H)]
	ans = 0
	for h in range(H):
		L = 0
		for w in range(W):
			if M[h][w] == ".":
				L += 1
			else:
				L = 0
			A[h][w] = L
			B[h][w] = (B[h-1][w] if h > 0 else 0) + 1 if L > 0 else 0
			if L*B[h][w] > ans:
				a = L
				for hi in range(B[h][w]):
					a = min(a,A[h-hi][w])
					if a*B[h][w] <= ans:
						break
					ans = max(ans,a*(hi+1))
	print ans

Measured memory_bytes: 10308
from math import ceil
a,b,c=map(int,input().split())
l=[]
l.append(a)
l.append(b)
l.append(c)
l.sort()

val=2*l[-1]-l[0]-l[1]
if l[0]%2==l[1]%2:
    print(int(val/2))
else:
    print(ceil(val/2)+1)


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

int main(){

  int a, b;
  int temp;
  int i=0;
  int n;

  while( cin >> a >> b ) {
    n=0;
    temp = a+b;
    while(temp!=0){
      n++;
      temp = temp/10;
    }
    cout << n <<"\n";
    i++;

  }

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

bool is_prime(int num) {
    for (int i = 2; i < num; i++) {
        if (num % i == 0) {
            return false;
        }
    }
    return true;
}

int main(void) {
    int N;
    cin >> N;
    int c = 0;

    for (int i = 2; i <= 55555 && c < N; i++) {
        if (is_prime(i) && i % 5 == 1) {
            cout << i << endl;
            c++;
        }
    }

    return 0;
}

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

using namespace std;

const bool debug = true;
#define dbg(...) if(debug) printf(__VA_ARGS__)
#define print(var) if (debug) cout << #var << " = " << var << endl

namespace {
    /** output whole vector. ex) vector<int>{1, 2, 3} -> '1 2 3'. */
    template<typename T>
    ostream& operator<<(ostream& os, const vector<T>& xs) {
       if (xs.empty()) return os;
       os << xs[0];
       for (auto i = 1; i < xs.size(); i++) os << ' ' << xs[i];
       return os;
    }

    string S;
    int K;
    void input() {
        cin >> S >> K;
    }

    void normalize(vector<int>& xs) {
        if (xs.empty()) return;
        if (xs[0] == 1) {
            for (auto& x : xs) x = !x;
        }
    }

    void solve() {
        int N = S.size();
        vector<int> s[2];
        auto map_int = [&](char c) {
            return int(c == 'R' || c == 'U');
        };
        for (int i = 0; i < N; i++) {
            char c = S[i];
            s[int(c == 'R' || c == 'L')].push_back(map_int(c));
        }
        normalize(s[0]); normalize(s[1]);
        static int cache[2][2][2002][2002];
        const int INF = 1<<28;
        for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) for (int k = 0; k < 2002; k++) for (int l = 0; l < 2002; l++) cache[i][j][k][l] = -INF;
        function<int(int, int, int, int)> f = [&](int w, int flip, int i, int k) {
            auto& t = s[w];
            auto& ans = cache[w][flip][i][k];
            if (k < 0) return -INF;
            if (i == t.size()) return 0;
            if (ans >= 0) return ans;
            return ans = max(f(w, !flip, i + 1, k - 1) + (t[i] == !flip ? +1 : -1),
                             f(w, flip, i + 1, k) + (t[i] == flip ? +1 : -1));
        };
        int ans = -INF;
        for (int k = 0; k <= K; k++) {
            for (int p = 0; p <= 1; p++) {
                for (int q = 0; q <= 1; q++) {
                    ans = max(ans, f(0, p, 0, k) + f(1, q, 0, K - k));
                }
            }
        }
        cout << ans << endl;
    }
}

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




Measured memory_bytes: 65892
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a), _end_ = (b); i < _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

map<LL, int> ma;
multiset<LL, greater<LL> > se;
int n; LL t;
int main()
{
#ifdef ANONYM
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    int rtime = clock();
#endif

    scanf("%d", &n);
    REP(i, 0, n) {
        scanf("%lld", &t);
        ma[t]++;
        if(ma[t] > 1) {
            se.insert(t);
            ma[t] -= 2;
        }
    }
    multiset<LL>::iterator it = se.begin();
    if(se.size() < 2) puts("0");
    else printf("%lld\n",  (*it) * (*(++it)));

#ifdef ANONYM
    debug("time: %d\n",int(clock() - rtime));
#endif
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

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

    string s;
    while(N){
        if(N%2){
            s.insert(s.begin(),'1');
            N=(N-1)/(-2);
        }
        else{
            s.insert(s.begin(),'0');
            N/=-2;
        }
    }
    if(s=="") 
        cout<<"0"<<endl;
    else
        cout<<s<<endl;
}


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


using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int d;
	d = 100 * a + 10 * b + c;
	if (d % 4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;




	return 0;
}


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

int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(c-b==b-a) {
        puts("YES");
    } else {
        puts("NO");
    }
    return 0;
}


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

int main(){
    int R;
    cin >> R;
    string ans;

    if(R<1200){
        ans="ABC";
    }
    else if(R<2800){
        ans="ARC";
    }
    else{
        ans="AGC";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  long a, b;
  cin >> a;
  for(int i = 0; i < N - 1; i++){
    cin >> b;
    a ^= b;
  }
  cout << (a == 0?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
lists=[]
n=int(input())
for i in range(n):
  a=int(input())
  lists.append(a)
import collections
dicdic=collections.Counter(lists)
dicdic=dict(dicdic)
ans=0
for i in dicdic.values():
  if i%2!=0:
    ans+=1
print(ans)

Measured memory_bytes: 19728
#include<bits/stdc++.h>
using namespace std;
int dp[100005];
int solve(int a[],int k1,int j){
//base case
  if(j==0)
    return 0;
  
  if(dp[j]!=-1){
    return dp[j]; 
  }
  int ans=INT_MAX;
  for(int k=1;k<=k1;k++){
    if(j-k>=0)
    ans=min(ans,abs(a[j]-a[j-k])+solve(a,k1,j-k));
  }
  return dp[j]=ans;
    
 }
  
int main(){
   memset(dp, -1, sizeof(dp)); 
  int n,k1;
  cin>>n>>k1;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];

  cout<<solve(a,k1,n-1);

  return 0;
  
}


Measured memory_bytes: 13716
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, int> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll a[310];
ll x;

map<T, ll> memo;

ll calc(ll p, ll q, int i) {
    const T t = make_tuple(p, q, i);
    if (memo.count(t) == 0) {
        if (p == 0 && q == 0) {
            memo[t] = ((x>>i)==0LL ? 0LL : (ll)1e18);
        } else {
            if (((p&1)^(q&1)) != ((x>>i)&1)) {
                memo[t] = (ll)1e18;
            } else {
                ll v0 = calc(p/2, q/2, i+1);
                ll v1 = calc((p-1)/2, (q+1)/2, i+1) + (1LL<<i);
                memo[t] = min(v0, v1);
            }
        }
    }
    return memo[t];
}

ll solve() {
    x = 0;
    for (int i = 2; i < n; i++) {
        x ^= a[i];
    }

    ll ret =  calc(a[0], a[1], 0);
    return ((ret >= 1e18 || ret == a[0]) ? -1 : ret);
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int W;
int a[100010];
int goalL[100010], goalR[100010];
int wallL[100010], wallR[100010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> W;
  for (int i = 0; i < W; i++) {
    cin >> a[i];
    goalL[i] = goalR[i] = -1;
    wallL[i] = wallR[i] = -1;
  }
  for (int i = 0; i < W; i++) {
    if (i == 0) {
      goalL[i] = a[i] == 0 ? i : -1;
      wallL[i] = a[i] < 0 ? i : -1;
    } else {
      if (a[i] > 0) {
        goalL[i] = goalL[i - 1];
        wallL[i] = wallL[i - 1];
      } else if (a[i] < 0) {
        goalL[i] = goalL[i - 1];
        wallL[i] = wallL[i - 1] < 0 || a[i] > a[wallL[i - 1]] + i - wallL[i - 1] ? i : wallL[i - 1];
      } else {
        goalL[i] = i;
        wallL[i] = -1;
      }
    }
  }
  for (int i = W - 1; i >= 0; i--) {
    if (i + 1 == W) {
      goalR[i] = a[i] == 0 ? i : -1;
      wallR[i] = a[i] < 0 ? i : -1;
    } else {
      if (a[i] > 0) {
        goalR[i] = goalR[i + 1];
        wallR[i] = wallR[i + 1];
      } else if (a[i] < 0) {
        goalR[i] = goalR[i + 1];
        wallR[i] = wallR[i + 1] < 0 || a[i] > a[wallR[i + 1]] + wallR[i + 1] - i ? i : wallR[i + 1];
      } else {
        goalR[i] = i;
        wallR[i] = -1;
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < W; i++) {
    if (a[i] <= 0) continue;
    int tmpL = goalL[i] < 0 ? 0 : min(a[i], wallL[i] < 0 ? a[i] : -a[wallL[i]] - (i - wallL[i]));
    int tmpR = goalR[i] < 0 ? 0 : min(a[i], wallR[i] < 0 ? a[i] : -a[wallR[i]] - (wallR[i] - i));
    ans += max({0, tmpL, tmpR});
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5128
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
preorder=(x for x in A)
postorder=[]

def recontruction(l,r):
    if l>=r:
        return None
    c=next(preorder)
    m=B.index(c)
    recontruction(l,m)
    recontruction(m+1,r)
    postorder.append(c)
    

recontruction(0,n)
print(*postorder)


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll n, a, b; cin >> n >> a >> b;
  ll result = 1;
  ll d2 = 1, p2 = 2;
  while(d2<=n) { 
    if (d2&n) result = result*p2%MOD;
    d2*=2; 
    p2=p2*p2%MOD; 
  }
  result--;

  ll ca = 1; rep(i,a) { ca *= (n-i) * inv(a-i) % MOD; ca %= MOD; }
  ll cb = 1; rep(i,b) { cb *= (n-i) * inv(b-i) % MOD; cb %= MOD; }
  // cout << ca << " " << cb << endl;

  result -= ca + cb; result = (result%MOD+MOD)%MOD; 
  cout << result << endl;
  return 0;
}

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

mod = 10**9 + 7
d = {}

for i in range(2,n+1):
	x = i
	for j in range(2,x+1):
		while x % j == 0:
			x = x // j
			d[j] = d.get(j, 0) + 1

ret = 1
for v in d.values():
	ret *= v+1

print(ret % mod)


Measured memory_bytes: 40048
def factorization(n):
    res = []
    tmp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i== 0:
                cnt += 1
                tmp //= i
            res.append([i, cnt])
    if tmp != 1:
        res.append([tmp, 1])
    if not res:
        res.append([n, 1])
    return res

a, b = map(int,input().split())
a_list = [x[0] for x in factorization(a)]
b_list = [x[0] for x in factorization(b)]
ans = set(a_list) & set(b_list) | {1}
print(len(ans))


Measured memory_bytes: 3188
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    N = int(input())
    print(N//3)

main()


Measured memory_bytes: 5056
#include<bits/stdc++.h>
using namespace std;
#define int long long
long long X[200200];
signed main()
{
  int Ans=0;
  int N,M,K;
  cin>>N>>M>>K;
  for(int i=1;i<=N;i++)
  {
    cin>>X[i];
    X[i]+=X[i-1];
  }
  Ans=lower_bound(X+1,X+N+1,K+1)-X-1;
  for(int i=1;i<=M;i++)
  {
    int Y;
    cin>>Y;
    K-=Y;
    if(K<0)
    {
    	for(int j=i+1;j<=M;j++)
    		cin>>Y;
    	break;
	}
    Ans=max(Ans,(int)(lower_bound(X+1,X+N+1,K+1)-X+i-1));
  }
  cout<<Ans<<endl;
  return 0;
}


Measured memory_bytes: 5192
local S = io.read().."X"

local length = 0
local counter = 0

for i = 1, #S do
    local PS = string.sub(S,i,i)
    if PS == "A" or PS == "C" or PS == "G" or PS == "T" then
        counter = counter + 1
    else
        length = math.max(counter, length)
        counter = 0
    end
end

print(length)

Measured memory_bytes: 884
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_145
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            double[][] xys = new double[n][];
            for(int i = 0; i < n; i++)
            {
                xys[i] = ReadDoubles();
            }
            double k = 1;
            for (int i = 0; i < n - 1; i++) k *= (i + 1);
            double res = 0;
            for(int i = 0; i < n; i++)
            {
                for(int j = 0; j < n; j++)
                {
                    res += k * Sqrt((xys[i][0] - xys[j][0]) * (xys[i][0] - xys[j][0])
                        + (xys[i][1] - xys[j][1]) * (xys[i][1] - xys[j][1]));
                }
            }
            res /= k * n;
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13268
import sys
input = sys.stdin.readline

N,M = map(int,input().split())
AB = [tuple(int(x) for x in input().split()) for _ in range(M)]

graph = [set() for _ in range(N+1)]
for a,b in AB:
    graph[a].add(b)
    graph[b].add(a)

deg = [len(x) for x in graph]

def solve():
    # そもそもeulerグラフでない場合
    if any(x&1 for x in deg):
        return False
    cycle = 0
    # まず次数2の頂点を全部縮約する
    # 自己ループは取り去っちゃってよい
    V2 = set(i for i,x in enumerate(deg) if x == 2)
    V = set(range(1,N+1))
    while V2:
        v = V2.pop()
        a = graph[v].pop()
        b = graph[v].pop()
        deg[v] = 0
        graph[a].remove(v)
        graph[b].remove(v)
        if b in graph[a]:
            cycle += 1
            graph[a].remove(b)
            graph[b].remove(a)
            deg[a] -= 2
            deg[b] -= 2
            if deg[a] == 2:
                V2.add(a)
            if deg[b] == 2:
                V2.add(b)
            if deg[a] == 0:
                V2.remove(a)
                V.remove(a)
            if deg[b] == 0:
                V2.remove(b)
                V.remove(b)
        else:
            graph[a].add(b)
            graph[b].add(a)
        V.remove(v)
    n = len(V)
    return cycle >= 3 or n >= 3

answer = 'Yes' if solve() else 'No'
print(answer)



Measured memory_bytes: 57572
#include <bits/stdc++.h>
#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)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    rep(i,n) cin >> v[i];
    rep(i,n) cin >> c[i];

    int ans = 0;
    for(int bit = 0; bit < (1<<n); bit++){
        int x = 0;
        int y = 0;
        rep(i,n){
            if(bit&(1<<i)){
                x+=v[i];
                y+=c[i];
            }
        }
        ans = max(ans,x-y);
    }

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

Measured memory_bytes: 256
s = input()
t = "AKIHABARA"
idx = 0
ng = 0
for i in range(len(t)):
    if t[i] == s[idx]:
        idx += 1
    elif t[i] != "A":
        ng = 1
        break
    if idx == len(s):
        if i < len(t) - 2:
            ng = 1

        break

if idx != len(s):
    ng = 1

if ng:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 61920
#include<bits/stdc++.h>
long long a,b,k;
main(){
    scanf("%lld%lld%lld",&k,&a,&b);
    if(k<=a)return puts("1"),0; 
    else if(a<=b)return puts("-1"),0;   
    else printf("%lld\n",((k-a)/(a-b)+bool((k-a)%(a-b)))<<1|1);
}

Measured memory_bytes: 256