akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1'000'000'007;
constexpr ll mod = 998244353;
const double PI = 3.14159265358;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> A(N);
  priority_queue<P> que;
  for(int i=0; i<N; i++){
    cin >> A[i];
    que.emplace(A[i],i);
  }
  que.emplace(0,inf);
  vector<ll> cnt(N,0);
  int mn = inf;
  for(int i=0; i<N; i++){
    int now,cost;
    tie(cost,now) = que.top();
    que.pop();
    chmin(mn,now);
    cnt[mn] += (ll)(cost - que.top().first) * (i+1);
  }
  for(int i=0; i<N; i++){
    cout << cnt[i] << "\n";
  }
  return 0;
}

Measured memory_bytes: 5456
use proconio::*;

fn solve(n: u64) {
    if n > 26 {
        solve((n - 1) / 26);
    }

    print!("{}", ((('a' as u64) + (n - 1) % 26) as u8) as char);
}

fn main() {
    input! {
        n: u64
    }

    solve(n);
}


Measured memory_bytes: 2148
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

struct C{
	int tx,ty,kx,ky;
	C(int tx,int ty,int kx,int ky):
	tx(tx),ty(ty),kx(kx),ky(ky) {}
};

int X,Y,sxl,syl,gxl,gyl,sxr,syr,gxr,gyr,dx[]={1,0,-1,0},dy[]={0,1,0,-1},d[51][51][51][51];
char l[51][51],r[51][51];

int bfs(int tx,int ty,int kx,int ky){
	queue<C> q;
	rep(i,X)rep(j,Y)rep(k,X)rep(l,Y)d[i][j][k][l]=INF;
	q.push(C(tx,ty,kx,ky));
	d[tx][ty][kx][ky]=0;
	while(!q.empty()){
		C c=q.front();q.pop();
		if(c.tx==gxl&&c.ty==gyl&&c.kx==gxr&&c.ky==gyr)return d[c.tx][c.ty][c.kx][c.ky];
		rep(i,4){
			int ntx=c.tx+dx[i],nty=c.ty+dy[i],nkx=c.kx-dx[i],nky=c.ky+dy[i];
			if((ntx==gxl&&nty==gyl)^(nkx==gxr&&nky==gyr))continue;
			if(ntx<0||ntx>=X||nty<0||nty>=Y||l[nty][ntx]=='#'){ntx=c.tx;nty=c.ty;}
			if(nkx<0||nkx>=X||nky<0||nky>=Y||r[nky][nkx]=='#'){nkx=c.kx;nky=c.ky;}
			if(d[ntx][nty][nkx][nky]==INF){
				q.push(C(ntx,nty,nkx,nky));
				d[ntx][nty][nkx][nky]=d[c.tx][c.ty][c.kx][c.ky]+1;
			}
		}
	}
	return 0;
}

int main(){
	while(cin>>X>>Y&&X){
		rep(i,Y){
			rep(j,X){
				cin>>l[i][j];
				if(l[i][j]=='%'){gxl=j;gyl=i;}
				if(l[i][j]=='L'){sxl=j;syl=i;}
			}
			rep(j,X){
				cin>>r[i][j];
				if(r[i][j]=='%'){gxr=j;gyr=i;}
				if(r[i][j]=='R'){sxr=j;syr=i;}
			}
		}
		int ans=bfs(sxl,syl,sxr,syr);
		cout<<(bfs(sxl,syl,sxr,syr)?"Yes":"No")<<endl;
	}
}

Measured memory_bytes: 26000
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

long long gcd(long long x, long long y) {
	long long m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

int A, B, C, D;
int f(int x) {
	ll ans = x;
	ans -= (x / C + x / D);
	ans += x / (lcm(C,D));
	return ans;
}

void solve() {
	cin >> A >> B >> C >> D;
	print(f(B) - f(A - 1));
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::vector<ll> vll;
typedef std::vector<vll> vvll;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int a, b;
  scan(a, b);
  if (b % a == 0) {
    print(a + b);
  } else {
    print(b - a);
  }

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}




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

  string ss = s + s;

  bool ans = false;;
  string ansstirng = "";



// DPでいけそう
  //12
  //○○  → SSS , WSW　→ 3つ目はどちらも可能
  //○○  → WWS , SWW


  //○×  → SSW , WWW  → 3つ目はW
  //○×  → SWS , WSS




  string f[4];
  f[0] = "SS";
  f[1] = "SW";
  f[2] = "WS";
  f[3] = "WW";

  string p = "";

  for (int i = 0; i < 4; ++i){
    p = f[i];
    bool iscomplete = false;
    for (int j = 2; j <=n+1 ; ++j){
      char a[2];
      a[0] = ss[j-2];
      a[1] = ss[j-1];
      string mes(a,2);

      char b[2];
      b[0] = p[j-1];
      b[1] = p[j-2];
      string mes2(b,2);
      
      if (mes == "oo"){
        if (mes2 == "WW")p+="S";
        if (mes2 == "WS")p+="W";
        if (mes2 == "SW")p+="W";
        if (mes2 == "SS")p+="S";
      }

      if (mes == "ox"){
        if (mes2 == "WW")p+="W";
        if (mes2 == "WS")p+="S";
        if (mes2 == "SW")p+="S";
        if (mes2 == "SS")p+="W";
      }

      if (mes == "xo"){
        if (mes2 == "WW")p+="S";
        if (mes2 == "WS")p+="W";
        if (mes2 == "SW")p+="W";
        if (mes2 == "SS")p+="S";
      }

      if (mes == "xx"){
        if (mes2 == "WW")p+="W";
        if (mes2 == "WS")p+="S";
        if (mes2 == "SW")p+="S";
        if (mes2 == "SS")p+="W";
      }
    }
    cerr << p <<endl;

    if (p[0] == p[n]  && p[1] == p[n+1]){
      ans = true;
      break;
    }


  }

  p.pop_back();
  p.pop_back();
  if (ans){
    cout << p << endl;
  }else{
    cout << -1 << endl;
  }
 




}




















Measured memory_bytes: 944
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const int INF = 1 << 29;
const ll LINF = 1l << 61;
const ld PI = abs(acos(-1));
#define pq priotity_queue
#define mp make_pair
#define P pair
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rrep(i, a, b) for (ll i = a; i >= b; i--)
#define cbuf(buf, init) memset(buf, init, sizeof(buf))
#define modp(x, y) (((y) + (x) % (y)) % (y))
#define divd(x, y) (static_cast<double>(x) / static_cast<double>(y))

ll a, b, c;

int main()
{
    //
    cin >> a >> b >> c;
    ll s = a + b;
    s = min(s, a + c);
    s = min(s, b + c);
    cout << s << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int a, b;
    cin >> a >> b;
    if(abs(a - b) % 2 == 0)
        cout<<a - (a - b) / 2<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;
    // end

    return 0;
}


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

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

using namespace std;
using ll = long long;
using P = pair<int,int>;


void calc_primefactorization(long long in, vector<vector<long long> >& out){
	
	long long N = in, Ntmp;
	long long p,e,p_init = 2;
	vector<long long> out_tmp(2);
	
	if( in == 1 ){
		out_tmp[0] = 1;
		out_tmp[1] = 1;
	}
	else{
		while( 1 ){

			Ntmp = N;
				
			p = N;
			e = 1;

			for(long long i = p_init;i * i <= N;i++){
						
				if( Ntmp % i == 0 ){
					e = 0;
					while( 1 ){
						if( Ntmp % i != 0 ){
							break;
						}
						else{
							Ntmp = Ntmp / i;
							e++;
						}
					}
					p = i;
					break;
				}
				
			}
			
			out_tmp[0] = p;
			out_tmp[1] = e;
			out.push_back(out_tmp);
			
			for(int i = 0;i < e;i++){
				N = N / p;
			}
			
			if( N == 1 ){
				break;
			}
			
		}
	}
	
}

int bitmask(int n){
	
	int a = 1;
	
	return ( a << (n - 1) );
	
}


int main(){
	
	
	int X, s = 8;
	
	cin >> X;
	
	for( int i = 6;i <= 20;i = i + 2 ){
		if( X <= (i * 100 - 1) ){
			cout << s;
			break;
		}
		else{
			s--;
		}
	}
	
	
	return 0;
	
}


Measured memory_bytes: 3624
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int x_1 = sc.nextInt();
		int y_1 = sc.nextInt();
		int x_2 = sc.nextInt();
      	int y_2 = sc.nextInt();
		int x_3 = y_1-y_2+x_2;
      	int y_3 = x_2-x_1+y_2;
      	int x_4 = y_1-y_2+x_1;
      	int y_4 = x_2-x_1+y_1;
		// 出力
		System.out.println(x_3 + " " + y_3 + " " + x_4 + " " + y_4);
	}
}

Measured memory_bytes: 25172
N=int(input())
X=list(map(int,input().split()))
XX=[]
for i in range(N):
    XX.append([X[i],i])
XX=sorted(XX,key=lambda x:x[0])

for i in range(N):
    if i<=N//2-1:
        XX[i].append(XX[N//2][0])
    else:
        XX[i].append(XX[N//2-1][0])

XX=sorted(XX,key=lambda x:x[1])

for i in range(N):
    print(XX[i][2])

Measured memory_bytes: 51392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pl;


int main(){
  int a,b;
  cin>>a>>b;

  int ans=0;
  for(int i=0;i<=20;i++){
    if(a*i-(i-1)>=b)
    break;
    else
    ans++;
  }

  cout<<ans<<endl;

}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import static java.util.stream.Collectors.joining;

class Main {
  final static int k = 10001;
  static int[] C = new int[k];

  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int size = sc.nextInt();
    int current = 0;
    int[] A = new int[size];
    int[] B = new int[size];

    for (int i = 0; i < size; i++) C[A[i] = Integer.parseInt(sc.next())]++;
    for (int i = 1; i < k; i++) C[i] += C[i - 1];
    for (int i = size - 1; i >= 0; i--) B[--C[A[i]]] = A[i];
    System.out.println(Arrays.stream(B).boxed().map(n -> n.toString()).collect(joining(" ")));
  }
}



Measured memory_bytes: 328296
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<typename Num>
        constexpr Num mypow(Num a, long long b) {
            if(b==0)return 1;
            if (a==0)return 0;
            Num x = 1;
              while (b > 0) {
                if(b & 1)x*=a;
                a*=a;
                b >>= 1;
              }
              return x;
        }

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll a;
        cin>>a;
        ll x=0;
        rep(i,3)x+=mypow(a,i+1);
        cout<<x<<endl;
    }

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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = 1;
    sort(a, a + n);
    for (int i = 0; i < n; i++) {
        if (a[i] && ans > INF / a[i]) {
            ans = -1;
            break;
        } else {
            ans *= a[i];
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4456
using System;
//using System.Text.RegularExpressions;
namespace Atcoder
{
    class Program
    //ABC126 B - YYMM or MMYY
    {
        private static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var pre = s.Substring(0,2);
            var post = s.Substring(2, 2);
            var sum = 0;
            var ans = "";

            sum += Check(pre);
            sum += Check(post) * 2;

            switch (sum)
            {
                case 0:
                    ans = "AMBIGUOUS";
                    break;
                case 1:
                    ans = "YYMM";
                    break;
                case 2:
                    ans = "MMYY";
                    break;
                case 3:
                    ans = "NA";
                    break;
            }
            Console.WriteLine(ans);
        }

        static int Check(string s)
        {
            if (1 <= int.Parse(s) && int.Parse(s) <= 12)
            {
                return 0;
            }
            return 1;
        }

    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<stdio.h>
using namespace std;
typedef unsigned long long ll;
ll mod = (10e+8)+ 7;

int main(){
	int P, Q, R;
	cin>>P>>Q>>R;
	int PQ, PR, RQ;
	PQ = P + Q;
	PR = P + R;
	RQ = R + Q;
	int ans = min(PQ, min(PR, RQ));
	
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int h,w;cin>>h>>w;
    vector<vector<char>> c(h,vector<char>(w));
    rep(i,h)rep(j,w)cin>>c[i][j];
    rep(i,h){
        rep(j,w){
            if(j!=w-1)cout<<c[i][j];
            else cout<<c[i][j]<<endl;
        }
        rep(j,w){
            if(j!=w-1)cout<<c[i][j];
            else cout<<c[i][j]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;


int main(){
	DRII(n,m);
	VI s(m+1,-1);
	s[0]=0;
	VPII c;
	REP(i,n){
		DRII(a,b);
		c.PB({a,b});
	}
	priority_queue<int> q;
	sort(c.begin(),c.end());
	int dl=0;
	auto it=c.begin();
	LL res=0;
	while (dl<=m){
		if (it!=c.end() and it->F==dl){
			while (it!=c.end() and it->F==dl){
	//			cout<<"push "<<it->F<<" "<<it->S<<endl;
				q.push(it->S);
				it++;
			}
		}
	//	cout<<dl<<" "<<q.empty()<<" "<<it->F<<endl;
		if (q.empty()) {if (it!=c.end()) {dl=it->F; continue;} else {break;}}
		else{
			res+=q.top();
			q.pop();
		}
		dl++;
	}
	printf("%lld\n",res);
}


Measured memory_bytes: 2292
n,m,l=map(int,input().split())

A = [[0] * m for i in range(n)]
B = [[0] * l for i in range(m)]
C = [[0] * l for i in range(n)]

for an in range(n):
    ar = list(map(int, input().split()))
    for am in range(m):
        A[an][am] = ar[am]

for bm in range(m):
    br = list(map(int, input().split()))
    for bl in range(l):
        B[bm][bl] = br[bl]

for nnn in range(n):
    for lll in range(l):
        for mmm in range(m):
            C[nnn][lll] += A[nnn][mmm] * B[mmm][lll]

for abc in range(n):
    print(*C[abc])


Measured memory_bytes: 7044
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	string s;
	cin >> s;
	int ans = 0;
	for(int i=0;i<s.size()/2;i++){
		if(s.at(i) != s.at(s.size()-1-i)){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int S; cin >> S;
    int h = S / (60 * 60);
    int m = (S - (h * 60 * 60 )) / 60;
    int s = S - ((h * 60 * 60) + (m * 60)); 
    cout << h << ":" << m << ":" << s << endl;
}

Measured memory_bytes: 3080
import java.util.Scanner;

class Main {
    public static Boolean PrimeCheck(int x){
	for(int i=2; i<=Math.sqrt(x);i++){
	    if(x%i==0){
		return false;
	    }
	}
	return true;
    }
     public static void main(String[] args) {
	 Scanner sc = new Scanner(System.in);
	 int n = sc.nextInt();
	 int count = 0;
	 for(int i=0;i<n;i++){
	     int x = sc.nextInt();
	     if(PrimeCheck(x)){
		 count++;
	     }
	 }
	 System.out.println(count);
     }
    
}



Measured memory_bytes: 42160
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
int main() {
	int n;
	cin >> n;

	n++;
	vector<int> t(n), x(n), y(n);

	t[0] = 0;
	x[0] = 0;
	y[0] = 0;

	for (int i = 1; i < n; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}

	for (int i = 1; i < n; i++) {
		int dt = t[i] - t[i-1];
		int dxy = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);

		if (dxy > dt || (dt - dxy) % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}

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


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;

#define INF 1000000000000000000LL

int main() {
    ll N, M; cin >> N >> M;
    vector<vector<Pll>> G(N+1);
    for (int i = 0; i < M; ++i) {
        ll a, b, c; cin >> a >> b >> c;
        G[a].emplace_back(Pll(b, c));
    }
    vector<ll> cost(N+1, -INF);
    cost[1] = 0;
    bool f = false;
    for (int i = 0; i < N; ++i) {
        f = false;
        for (int j = 1; j <= N; ++j) {
            for (Pll x : G[j]) {
                ll b, c; tie(b, c) = x;
                if (cost[j] + c > cost[b]) {
                    if (b == N) f = true;
                    cost[b] = cost[j] + c;
                }
            }
        }
    }
    if (f) {
        cout << "inf" << endl;
    } else {
        cout << cost[N] << endl;
    }
}


Measured memory_bytes: 3668
import sys

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())

    if N >= M // 2:
        ans = M // 2
        #N -= M // 2

        #ans += N // 2

        return ans

    else:
        ans = N
        M -= 2 * N

        ans += M // 4

        return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;




namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var strs = str.Split(' ');
            var a = int.Parse(strs[0]);
            var b = int.Parse(strs[1]);

            var area = a * b;
            var circuit = 2 * a + 2 * b;
            Console.WriteLine("{0} {1}", area, circuit);

        }  
    }
}

Measured memory_bytes: 5632
def merge(A, left, mid, right):
    global count
    # count += (right - left)
    L = A[left:mid] + [int(1e9)]
    R = A[mid:right] + [int(1e9)]
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            count += (mid-left-i)

def merge_sort(A, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)

if __name__ == "__main__":
    n = int(input())
    A = list(map(int, input().strip().split()))
    count = 0
    merge_sort(A, 0, n)
    print(count)

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
  int64_t n, m;
  cin >> n >> m;

  vector<vector<int64_t>> links(n);
  for (auto _ : irange(0L, m)) {
    int64_t a, b;
    cin >> a >> b;
    --a;
    --b;
    links[a].push_back(b);
    links[b].push_back(a);
  }

  vector<vector<int64_t>> dp(1u << n, vector<int64_t>(n));
  dp[1][0] = 1;
  int64_t ans = 0;
  for (auto s : irange(1uL, 1uL << n)) {
    bitset<8> bs(s);

    for (auto i : irange(0L, n)) {
      if (!bs[i]) {
        continue;
      }

      for (auto j : links[i]) {
        if (bs[j]) {
          continue;
        }

        dp[s | (1uL << j)][j] += dp[s][i];
      }

      if (s == (1uL << n) - 1) {
        ans += dp[s][i];
      }
    }
  }

  cout << ans << endl;
}

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

int main(int argc, char const* argv[])
{
	long double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	long double ans = sqrtl((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
	cout << fixed << setprecision(5) << ans << endl;
	return 0;
}


Measured memory_bytes: 1288
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define rei(n) for(int i=0;i<(int)n;i++)
#define rel(n) for(int l=0;l<(int)n;l++)
#define al(s) s.begin(),s.end()

typedef pair<int, int> pi;
typedef pair<pi, pi> ppi;
typedef pair<int, ppi> pipp;
int a(double w)
{
	if (w >= 1.1)return 0;
	if (w >= 0.6)return 1;
	if (w >= 0.2)return 2;
	return 3;
}

int main()
{
	int R[4] = {};
	int L[4] = {};
	double r, l;
	while (cin >> r >> l)
	{
		R[a(r)]++;
		L[a(l)]++;
	}
	rei(4)
	{
		cout << R[i] << " " << L[i] << endl;
	}
}

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

const int N = 1e5 + 11;
char s[33];
int n, m, AC, WA, tong[N];
bool mark[N];
int main(){
    cin>>n>>m;
    int pi;
    for(int i = 1;i <= m; i++){
        scanf("%d%s", &pi, s + 1);
        if(s[1] == 'A'){
            if(!mark[pi]){
                mark[pi] = 1;
            }
        }
        else{
            if(!mark[pi]){
                tong[pi]++;
            }
        }
    }
    for(int i = 1;i <= n; i++){
        if(mark[i]){
            AC++;
            WA += tong[i];
        }
    }
    printf("%d %d\n", AC, WA);
    return 0;
}


Measured memory_bytes: 768
import math
def main():
  s = input()
  t = input()
  flg=0
  for i in range(0,len(s)):
    s=s[len(s)-1:]+s[:len(s)-1]
    if s==t:
      flg=1
      break
  if flg==1:
    print("Yes")
  else:
    print("No")
main()


Measured memory_bytes: 8980
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


int n, a[102], ans=0;

void solve()
{
    cin >> n;
    for (int i=0; i<n; i++) cin >> a[i];
    for (int i=0; i<n; i+=2) if (a[i]%2) ans++;
    nout(ans);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3580
n = gets.to_i
sum = 1 * n * (n + 1) / 2
fizz = 3 * (n/3) * ((n/3) + 1) / 2
buzz = 5 * (n/5) * ((n/5) + 1) / 2
fizzbuzz = 15 * (n/15) * ((n/15) + 1) / 2
puts sum - fizz - buzz + fizzbuzz


Measured memory_bytes: 14276
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<stack>

using namespace std;

int main()
{
	int n;
	vector<long long> arr;

	scanf("%d", &n);

	long long acc = 0;
	long long lmin = 999999999999999999;

	for (int i = 0; i < n; i++)
	{
		long long input;

		scanf("%lld", &input);

		acc += input;

		arr.push_back(acc);
	}

	for (int i = 0; i < n - 1; i++)
	{
		if (abs(arr[i] - (arr[n - 1] - arr[i])) < lmin)
		{
			lmin = abs(arr[i] - (arr[n - 1] - arr[i]));
		}
	}

	printf("%lld\n", lmin);

	return 0;
}


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

int main()
{
  int a,b;cin>>a>>b;
  int c=max(a,b);
  for (int k=0;k<c;k++)
  {
    if (abs(a-k)==abs(b-k))
    {  
      cout<<k<<endl;
      return (0);
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 256
#![allow(unused_imports, non_snake_case)]
use proconio::{
    input, fastout,
    marker::{Chars, Bytes, Usize1}
};

#[fastout]
fn main() {
    input! {
        n:usize,
        a:[usize; n]
    }
    let mut tot = 0;
    for &x in &a {
        tot ^= x;
    }
    let mut a = a;
    for i in 0..n {
        a[i] ^= tot;
    }
    println!("{}", a.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(" "));
}

Measured memory_bytes: 19412
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#define rep(i, n) for(ll i = 0; i < (n); i++)
#define forn(i, n, m) for (ll i = (n); i<=(m); i++)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

ll mul(ll a, ll b) {
	ll val = a * b - (ll)((ld)a * b / mod) * mod;
	if (val < 0) val += mod;
	if (val >= mod) val -= mod;
	return val;
}
ll poww(ll a, ll b) {
	ll val = 1;
	a %= mod;
	while (b > 0) {
		if (b % 2) val = mul(a, val);
		a = mul(a, a);
		b >>= 1;
	}
	return val % mod;
}
ll inv(ll a) {
		return poww(a, mod - 2);
}


ll const maxn = 2e5 + 5;

vector<ll>kek[26];
ll ptr[26];

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	string s, t; cin >> s >> t;
	for (ll i = 0; i < s.size(); i++) {
		kek[s[i] - 'a'].push_back(i);
	}
	ll cnt = 0;
	for (char c : t) {
		if (kek[c - 'a'].size() == 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	ll k = 0;
	ll mx = -1;
	for (char c : t) {
		k++;
		ll id = upper_bound(all(kek[c - 'a']), mx) - begin(kek[c - 'a']);
		if (id < kek[c - 'a'].size()) {
			mx = kek[c - 'a'][id];
		}
		else {
			cnt++;
			mx = kek[c - 'a'][0];
		}
		if (k == t.size()) {
			cout << cnt * (s.size()) + mx + 1 << endl;
			return 0;
		}
	}
	return 0;
}
/*

*/

Measured memory_bytes: 1736
import Data.Char

countElem :: Eq a => a -> [a] -> Int
countElem _ [] = 0
countElem x (x':xs) = (if x == x' then 1 else 0) + (countElem x xs)

getUntil :: String -> IO [String]
getUntil eot = do
  let loop list = do
        ws <- fmap words getLine
        if ws == [eot] then return list
        else loop (list ++ ws)
  loop []

main :: IO ()
main = do
  w <- fmap (map toLower) getLine
  t <- fmap (map (map toLower)) $ getUntil "END_OF_TEXT"
  print $ countElem w t

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    //cin.tie(nullptr);
    //ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,m; cin >> n >> m;
    vint p(m),y(m);
    vvint t(1e5+1);
    rep(i,m){
        cin >> p[i] >> y[i]; p[i]--;
        t[p[i]].pb(y[i]);
    }
    rep(i,n) sort(all(t[i]));
    rep(i,m){
        printf("%06lld",p[i]+1);
        printf("%06lld\n",(lower_bound(all(t[p[i]]),y[i])-t[p[i]].begin())+1);
    }
}

Measured memory_bytes: 10324
#include <cstdio>
#define abs(x) (x>0?x:-x)
using namespace std;
int xx=0,yy=0,tt=0,x,y,t,n;
bool flag=1;
int main(){
	scanf("%d",&n);
	while(n--){
		scanf("%d%d%d",&t,&x,&y);
		int d=abs(x-xx)+abs(y-yy);
		if(t<tt+d||(t-tt-d)%2!=0) flag=0;
		xx=x,yy=y,tt=t;
	}
	printf(flag?"Yes\n":"No\n");
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  int cnt = 0;
  int ret = 0;
  while(1){
    for(int i = 0; i < N; i++){
      if(A.at(i) & 0x1){
//        cout << "A" << A.at(i) << endl;
        cout << cnt << endl;
        ret  = 1;
        break;
      } else {
//        cout << "befor" << A.at(i) << endl;
        A.at(i) >>= 1;
//        cout << "after" << A.at(i) << endl;
      }
    }
    if(ret == 1){
      break;
    }else{
      cnt++;
    }
  }
  if(ret == 0){
    cout << cnt << endl;
  }
//  for(int i = 0; i < N; i++){
//	cout << A.at(i) << endl;
//  }
}

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

int main() {
  int N;
  cin >> N;
  int AC, WA, TLE, RE;
  AC = 0;
  WA = 0;
  TLE = 0;
  RE = 0;
  for(int i=0; i<N; i++){
    string C;
    cin >> C;
    if(C=="AC"){
      AC++;
    }
    else if(C=="WA"){
      WA++;
    }
    else if(C=="TLE"){
      TLE++;
    }
    else{
      RE++;
    }
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
}

Measured memory_bytes: 3608
package main

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

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	
	n := scanInt()
	// a := make([]int, n)
	b := 0.0
	for i := 0; i < n; i++ {
		a := scanInt()
		b += 1.0/float64(a)
	}

	fmt.Println(1.0/b)

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, long long K, long long S){
	ll maxS = 1000000000;
	vector<ll> A(N);
	if (S != maxS) {
		rep(i, K) {
			A[i] = S;
		}
		for (ll i = K; i < N; i++) {
			A[i] = maxS;
		}
	} else {
		A[0] = maxS;
		for (ll i = 1; i < K; i++) {
			A[i] = maxS;
		}
		for (ll i = K; i < N; i++) {
			A[i] = 1;
		}
	}
	rep(i, N) {
		cout << A[i];
		if (i != N-1) cout << " "; else cout << endl;
	}
}

int main(){	
	long long N;
	long long S;
	long long K;
	scanf("%lld",&N);
	scanf("%lld",&K);
	scanf("%lld",&S);
	solve(N, K, S);
	return 0;
}



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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int total = 0;
  for(int i = a; i <= n; i++){
    int sum = 0, temp = i;
    while(temp > 0){
      sum += temp % 10;
      temp /= 10;
    }
    if(sum >= a && sum <= b){
      total += i;
    }
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 3592
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

MOD = 10**9+7

MAXN = N+5
fac = [1,1] + [0]*MAXN
finv = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def ncr(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

combs = []
l = N-K+1
for i in range(l):
    combs.append(ncr(N-l+i,i))

cmax = [0]*(N-l) + combs
cmin = combs[::-1]

from collections import Counter
mins = Counter()
maxs = Counter()

for a,c in zip(A,cmax):
    maxs[a] += c
for a,c in zip(A,cmin):
    mins[a] += c

mx = A[-1]
mn = A[0]
ans = ncr(N,K) * (mx-mn)
for k,v in maxs.items():
    ans -= v * (mx-k)
    ans %= MOD
for k,v in mins.items():
    ans -= v * (k-mn)
    ans %= MOD
print(ans)

Measured memory_bytes: 36460
package main 

import "fmt"

func main() {
  var s, t, u string
  var a, b int
  fmt.Scan(&s, &t, &a, &b, &u)
  
  if s == u{
  	a --
  } else {
  	b --
  }
  
  fmt.Println(a, b)
  
}

Measured memory_bytes: 512
#include <stdio.h>

int main(){
  char c;
  scanf("%c",&c);
  if (c == 'a'||c == 'i'||c == 'u'||c == 'e'||c == 'o'){
    printf("vowel\n");
  }
  else{
    printf("consonant\n");
  }
  return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<algorithm>
using namespace std;
 
 
const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {

	int max = 2000000000;
	int n = getint();
	for(int i = 0; i < n; i++){
		int a = getint();
        int b = getint();
		if(a+b < max) {
			max = a+b;
		}
	}
	printf("%lld", max);
	return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define eps 0.00000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define f(n) for(int i=0;i<n;++i)
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	string s;
	cin >> s;
	cout << s[0] << s.length() - 2 << s[s.length() - 1] << endl;
	return 0;
}

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

const double PI = acos(-1);

int main()
{
    int a,b;
    cin >> a >> b;
    int h,m;
    cin >> h >> m;

    double th = double(h*60+m)/720 * 2 * PI;
    double tm = double(m)/60 * 2 * PI;
    double xh = a*cos(th), yh = a*sin(th);
    double xm = b*cos(tm), ym = b*sin(tm);

    double dx = xh - xm, dy = yh - ym;

    double ans = sqrt(dx*dx + dy*dy);

    printf("%.10f\n", ans);

    
    return 0;
}

Measured memory_bytes: 4128
//file_name:ABC102_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&y);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    ll max = 0;
    ll min = 1000000000;
    rep(i,n){
        if(a[i]<min){
            min = a[i];
        }
        if(a[i]>max){
            max = a[i];
        }
    }

    ll ans = 0;

    cout << max - min << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
int main(){
  int h,w,d,a,q,start,goal,cnt;
  scanf("%d%d%d",&h,&w,&d);
  int hw=h*w;
  int height[hw+1],width[hw+1],memo[hw+1];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      scanf("%d",&a);
      height[a]=i;
      width[a]=j;
    }
  }
  for(int i=1;i<=d;i++)memo[i]=0;
  for(int i=d+1;i<=hw;i++)memo[i]=memo[i-d]+abs(height[i]-height[i-d])+abs(width[i]-width[i-d]);
  scanf("%d",&q);
  for(int i=0;i<q;i++){
    scanf("%d%d",&start,&goal);
    printf("%d\n",memo[goal]-memo[start]);
  }
  return 0;
}

Measured memory_bytes: 2176
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let s = sc.chars();
    let mut result = 0;
    for i in 0..n - 2 {
        if s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C' {
            result += 1;
        }
    }
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
#include<iostream>
using namespace std;
#define E 1000000000
int main()
{
	long long x,y;
	cin>>x>>y;
	
	 if(x==y||x%y==0)cout<<-1;
	 else
	{
	 for(int i=1;i<=y;i++)
	 {
	 	if(x*i%y!=0)
	 	{
	 	cout<<x*i;
		 return 0;	
	 	}
	 }
	 cout<<-1;
	}
	return 0;
} 

Measured memory_bytes: 256