akhauriyash/Code-Regression huggingface dataset:
// Snippets
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! stdin {
    () => ({
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    })
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => (
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input.to_string()), $output);
            )*
        }
    )
}

// End Snippets

fn main() {
    println!("{}", solve(stdin!()));
}

fn solve(src: String) -> String {
    input!{
        source = src,
        s: usize
    }
    fn f(n: usize) -> usize {
        match n {
            _ if n % 2 == 0 => n / 2,
            _ => 3 * n + 1,
        }
    }
    let mut vec = vec![s];
    let mut i = 1;
    let mut a = s;
    let ans;
    loop {
        i += 1;
        a = f(a);
        if vec.iter().any(|&x| x == a) {
            ans = i;
            break;
        }
        vec.push(a);
    }
    ans.to_string()
}

test! {
    "8" => "5",
    "7" => "18",
    "54" => "114",
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>

int cmpnum(const void * n1, const void * n2)
{
	if(*(int *)n1 >*(int *)n2)
	{
		return -1;
	}
	else if(*(int *)n1 < *(int *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
}
}

int main(void)
{
	int i,n;
	int a[101]={0};
	int score=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	
	qsort(a, sizeof(a)/ sizeof(a[0]),sizeof(int),cmpnum);
	
	for(i=0;i<n-1;i++){
		if(a[i]==a[i+1])
			score++;
	}
	printf("%d",n-score);
	
	return 0;
}


Measured memory_bytes: 128
n = int(input())
apple = list(map(int, input().split()))
orange = []
for i in apple:
    if i%2 == 0:
        orange.append(i)
    else:
        pass
cnt = 0
for i in orange:
    if i%3==0 or i%5==0:
        cnt += 1
    else:
        pass
print("DENIED" if cnt!=len(orange) else "APPROVED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans;
int main(void){
	ll n; cin>>n;
	double a=sqrt(n);
	ll N=a;
	for(int i=1;i<=N;i++){
		ll k=(n-i)%i,l=(n-i)/i;
		if(k==0&&l>i){
			ans=ans+l;
		}
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>  // std::accumulate(m.begin(), m.end(), 0LL);
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int N, K; std::cin >> N >> K;

  int cur = 1;
  for(int i=0; i<N; i++) {
    if ( cur <= K ) cur *= 2;
    else cur += K;
  }
  std::cout << cur << std::endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)

        {
            var k = long.Parse(Console.ReadLine());
            long ans = 0;
            ans += 1000 * (k / 500);
            ans += 5 * (k % 500 / 5);
            

            Console.WriteLine(ans);
                
                





        }

       
        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }
    }
}


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

#define rep(i,n) for(int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

const int MAX_N = 103;
const int MAX_W = 10003;
int dp[MAX_N][MAX_W];

int main() {
  int n, w;
  cin >> n >> w;
  vector<P> v(n);
  rep(i,n) cin >> v[i].first >> v[i].second;

  rep(i,MAX_N) rep(j,MAX_W) dp[i][j] = 0;

  rep(i,n) {
    for (int j=0; j<=w; ++j) {
      if (j < v[i].second) {
	dp[i+1][j] = dp[i][j];
      } else {
	dp[i+1][j] = max(dp[i][j], dp[i][j-v[i].second] + v[i].first);
      }
    }
  }
  cout << dp[n][w] << endl;
  return 0;
}



Measured memory_bytes: 7124
#include <iostream>
using namespace std;
#define LEN 256
int main(void){
    // Your code here!
    int N,T[LEN],M,P,X;
    int sum=0;
    
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>T[i];
        
    }
    
    cin>>M;
    for(int i=0;i<M;i++){
        cin>>P>>X;
        for(int j=0;j<N;j++){
            if(j==(P-1)){
                sum+=X;
            }else{
                sum+=T[j];
                
            }
        }
        
        cout<<sum<<endl;
        sum=0;
    }
    
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<ctime>

using namespace std;
using ll = long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n, m; cin >> n >> m;

  vector<int> a(n, 0);
  vector<int> used(n, 0);
  a[0] = 1;
  vector<pair<int, int> > q(m);
  for(int i = 0; i < m; i++){
    cin >> q[i].first >> q[i].second;
    q[i].first--;
  }
  for(int i = 0 ; i < m ;i++){
    if(used[q[i].first] && q[i].second != a[q[i].first]){
      cout << -1 << endl;
      return 0;
    }
    else{
      a[q[i].first] = q[i].second;
      used[q[i].first] = 1;
    }
  }
  if(a[0] == 0 && n > 1) cout << -1 << endl;
  else if(n == 1 && m == 0) cout << 0 << endl;
  else{
    for(int i = 0; i < n; i++){
      cout << a[i];
    }
    cout << endl;
  }

  // end-----------------------------------------------
  cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

int degi(ll n) {
	int res = 0;
	while (n > 0) {
		n /= 10;
		res++;
	}
	return res;
}
int main() {
	int N; cin >> N;
	vector<ll> a(N);
	bool zero = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (a[i] == 0) {
			zero = true;
		}
	}
	if (zero) cout << 0 << endl;
	else {
		ll ans = 1;
		bool flag = true;
		for (int i = 0; i < N; i++) {
			if (a[i] == 0) {
				ans = 0;
				break;
			}
			//cout << log10(ans) + log10(a[i]) << endl;
			if (log10(ans) + log10(a[i]) <= 18.0) {
				ans *= a[i];
			}
			else {
				flag = false;
				break;
			}
		}
		if (flag && ans <= (ll)1e18) cout << ans << endl;
		else cout << -1 << endl;
	}
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

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

void Main(){
    int N; cin >> N;
    VI p(N*N); REP(i,N*N){cin >> p[i]; p[i]--;}

    int d[N][N]; REP(i,N)REP(j,N) d[i][j] = min({i,j,N-1-i,N-1-j});
    bool vacant[N][N]; REP(i,N)REP(j,N) vacant[i][j] = false;

    vector<P> v{P(1,0),P(-1,0),P(0,1),P(0,-1)};
    int ans = 0;
    REP(i,N*N){
        int x = p[i]/N, y = p[i]%N;
        ans += d[x][y];
        vacant[x][y] = true;

        queue<tpl> q;
        for(auto& p : v){
            int s = x+p.first, t = y+p.second;
            q.emplace(s,t,d[x][y]);
        }
        while(!q.empty()){
            int s,t,cost; tie(s,t,cost) = q.front(); q.pop();
            if(s<0||t<0||s>=N||t>=N) continue;

            if(chmin(d[s][t], cost)){
                if(vacant[s][t]==false) cost++;
                for(auto& p : v){
                    int a = s+p.first, b = t+p.second;
                    q.emplace(a,b,cost);
                }
            }
        }
    }

    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t){
        Main();
    }
    return 0;
}

Measured memory_bytes: 5444
#include<stdio.h>
#define N 9

void Check1(int);
void Check2(int);
void Check3(int, int);

int data[N][N];
char correct[N][N];

int main(){
  int i, j, k, n;

  scanf("%d", &n);

  for(k=0; k<n; k++){
    for(i=0; i<N; i++){
      for(j=0; j<N; j++){
	scanf("%d", &data[i][j]);
	correct[i][j] = ' ';
      }
    }

    for(i=0; i<N; i++){
      Check1(i);
      Check2(i);
    }

    for(i=0; i<N; i+=3){
      for(j=0; j<N; j+=3)
	Check3(i, j);
    }

    if(k != 0) printf("\n");
    for(i=0; i<N; i++){
      for(j=0; j<N; j++)
	printf("%c%d", correct[i][j], data[i][j]);
      printf("\n");
    }
  }

  return 0;
}


void Check1(int n){
  int i, j;
  for(i=0; i<N-1; i++){
    for(j=i+1; j<N; j++){
      if(data[i][n] == data[j][n]){
	correct[i][n] = '*';
	correct[j][n] = '*';
      }
    }
  }
}

void Check2(int n){
  int i, j;
  for(i=0; i<N-1; i++){
    for(j=i+1; j<N; j++){
      if(data[n][i] == data[n][j]){
	correct[n][i] = '*';
	correct[n][j] = '*';
      }
    }
  }
}

void Check3(int n, int m){
  int i, j, k, check[N];
  char _correct[N];
  for(i=n, k=0; i<n+3; i++){
    for(j=m; j<m+3; j++, k++){
      check[k] = data[i][j];
      _correct[k] = ' ';
    }
  }
  for(i=0; i<N-1; i++){
    for(j=i+1; j<N; j++){
      if(check[i] == check[j]){
	_correct[i] = '*';
	_correct[j] = '*';
      }
    }
  }
  for(i=n, k=0; i<n+3; i++){
    for(j=m; j<m+3; j++, k++){
      if(_correct[k] == '*')
	correct[i][j] = '*';
    }
  }
}

Measured memory_bytes: 0
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

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 all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	rep(i,s.size()-1) if(s[i] == s[i+1]) return cout << "Bad\n",0;
	cout << "Good\n";	
	return 0;	
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>
#include <sys/time.h>
#include <fstream>
#include <iomanip>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define REP(i,n)  FOR(i,0,n)
#define each(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define deb(x) cerr << #x << " = " << (x) << " , ";
#define debl cerr << " (L" << __LINE__ << ")"<< endl;
#define sz(s) (int)((s).size())


#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(x,y) make_pair((x),(y))

double pi=3.14159265358979323846;

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& z){
	os << "[ ";
	REP(i,z.size())os << z[i] << ", " ;
	return ( os << "]" << endl);
}

template<typename T> std::ostream& operator<<(std::ostream& os, const set<T>& z){
	os << "set( ";
	EACH(p,z)os << (*p) << ", " ;
	return ( os << ")" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const map<T,U>& z){
	os << "{ ";
	EACH(p,z)os << (p->first) << ": " << (p->second) << ", " ;
	return ( os << "}" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const pair<T,U>& z){
	return ( os << "(" << z.first << ", " << z.second << ",)" );
}

double get_time(){
	struct timeval tv;
	gettimeofday(&tv, NULL);
	return tv.tv_sec + tv.tv_usec*1e-6;
}

typedef unsigned int uint32_t;
struct RND{
	uint32_t x;
	uint32_t y;
	uint32_t z;
	uint32_t w;
	RND(){
		x=123456789;
		y=362436069;
		z=521288629;
		w=88675123;
	}
	void init(int seed){
		x=123456789;
		y=362436069;
		z=521288629;
		w=seed+100;
		REP(i,10)get();
	}
	uint32_t get(){
		uint32_t t;
		t=x^(x<<11);
		x=y;y=z;z=w;
		w=(w^(w>>19))^(t^(t>>8));
		return w;
	}
};
RND rnd;

void _main(istream &inp){
    int n,k;
    inp >> n >> k;
    cout << (k<=(n+1)/2 ? "YES" : "NO" ) << endl;

}

int main(){
	if(0){
		ifstream ifs("test.txt");
		_main(ifs);
	}
	else{
		_main(cin);
	}
	return 0;
}


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

int main() {
	long long int N, ans = 0;
	cin >> N;
	for (int i = 1; i < (N - i) / i; i++)
	{
		if ((N - i) % i == 0)
		{
			ans+= (N - i) / i;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 384
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do(): 
    n,m,k=INTM()
    A=LIST()
    B=LIST()
    As=[0]*(n+1)
    Bs=[0]*(m+1)
    ans=0
    for i in range(n):
        As[i+1]=As[i]+A[i]
    A=As
    for i in range(m):
        Bs[i+1]=Bs[i]+B[i]
    B=Bs
    #print(A,B)

    if A[-1]+B[-1]<=k:
        ans=n+m

    b_s=m

    for i in range(n+1):

        if A[i]>k:
            #print(i)
            temp=i-1
            ans=max(ans,temp)
            break
        for i2 in range(b_s,-1,-1):
            #print(i,i2)
            #print(A[i]+B[i2])
            if A[i]+B[i2]<=k:
                temp=i+i2
                b_s=i2
                #print(ans,temp)
                ans=max(ans,temp)
                break
        

    
    print(ans)

if __name__ == '__main__':
    do()

Measured memory_bytes: 41192
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>s;
    rep(i,Size(s)){
        if(s[i]=='B')cnt++;
        else ans+=cnt;
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 1360
package main

import "fmt"

type key struct {
	To    int
	Color rune
}

func color3(c1, c2 rune) rune {
	if c1 == 'R' && c2 == 'G' {
		return 'B'
	}
	if c1 == 'R' && c2 == 'B' {
		return 'G'
	}
	if c1 == 'G' && c2 == 'B' {
		return 'R'
	}
	if c1 == 'G' && c2 == 'R' {
		return 'B'
	}
	if c1 == 'B' && c2 == 'R' {
		return 'G'
	}
	if c1 == 'B' && c2 == 'G' {
		return 'R'
	}
	return ' '
}

func main() {
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)

	count := make(map[key]int)
	for i, c := range s {
		if c == 'R' {
			count[key{i, 'R'}] = count[key{i - 1, 'R'}] + 1
			count[key{i, 'G'}] = count[key{i - 1, 'G'}]
			count[key{i, 'B'}] = count[key{i - 1, 'B'}]
		} else if c == 'G' {
			count[key{i, 'R'}] = count[key{i - 1, 'R'}]
			count[key{i, 'G'}] = count[key{i - 1, 'G'}] + 1
			count[key{i, 'B'}] = count[key{i - 1, 'B'}]
		} else {
			count[key{i, 'R'}] = count[key{i - 1, 'R'}]
			count[key{i, 'G'}] = count[key{i - 1, 'G'}]
			count[key{i, 'B'}] = count[key{i - 1, 'B'}] + 1
		}
	}

	sum := 0
	for i := 0; i <= n-3; i++ {
		ci := s[i]
		for j := i; j <= n-2; j++ {
			cj := s[j]
			if ci == cj {
				continue
			}
			ck := color3(rune(ci), rune(cj))
			cnt := count[key{len(s) - 1, ck}] - count[key{j, ck}]
			diff := j - i
			if j+diff <= n-1 && rune(s[j+diff]) == ck {
				cnt--
			}
			sum += cnt
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
 
int main()
{
  int n,q;
  cin>>n>>q;
  Graph field(n);
  vector<int64_t> point(n,0);
  for (int i = 0; i < n-1; ++i)
  {
    int a,b;
    cin>>a>>b;
    field[a-1].emplace_back(b-1);
  }
  
  for (int i = 0; i < q; ++i)
  {
    int a,b;
    cin>>a>>b;
    a--;
    point[a]+=b;
  }
  stack<int> stk;
  for (int i = 0; i < n; ++i)
  {
    for(auto&& e: field[i]) {
      point[e]+=point[i];
    }
  }
 
  for(auto&& e: point) {
    cout<<e<<" ";
  }
}

Measured memory_bytes: 14848
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,A,B;
  cin >> N >> A >> B;
  if ((B - A) % 2 == 1) {
    cout << "Borys" << endl;
  } else {
    cout << "Alice" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<vector<int>> d(N, vector<int>(N));
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++) cin >> d[i][j];

	bool flag = true;
	lint ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {

			bool edge = true;
			for (int k = 0; k < N; k++) {
				if (i == k || j == k) continue;
				if (d[i][j] > d[i][k] + d[k][j]) flag = false;
				if (d[i][j] == d[i][k] + d[k][j]) edge = false;
			}

			if (edge) ans += d[i][j];
		}
	}

	if (flag) cout << ans << "\n";
	else cout << -1 << "\n";

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    double w = get<double>(), h = get<double>(),
        x = get<double>(), y = get<double>();

    bool multi = 2*x == w && 2*y == h;
    cout << h*w/2 << " " << multi << endl;
    return 0;
}

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

int main(){
  double b,v2,n;
  int i;
  while(cin>>b){
    i=0;
    n=0;
    v2=0;
    while(v2<b*b){
    i++;
    n+=5;
    v2=19.6*n;
    }
    cout<<i+1<<endl;
  }
    
    return 0;
}

Measured memory_bytes: 3152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC047A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);
            if (a + b == c || a + c == b || b + c == a)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include<iostream>
using namespace std;
typedef long long ll;
ll a[1000005];
string s,t;
int main()
{
    ll a,b,c,ma=1231231231,ans=0;
    cin>>s>>t;
    for(ll i=0;i<s.size()-t.size()+1;i++)
    {
        ans=0;
        for(ll j=i;j<i+t.size();j++)
        {
            if(s[j]!=t[j-i])
            {
                ans++;
            }
        }
       // printf("*%lld\n",ans);
        ma=min(ma,ans);
    }
    printf("%lld\n",ma);

}


Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>


using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define Rep(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える


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

    vll a(n); rep(i, n) cin >> a[i];

    vll s(n+1, 0); s[0] = 0; rep(i, n) s[i+1] = s[i] + a[i];

    map<ll, ll> mp;

    mp[s[0]]++;
    rep(i, n) mp[s[i+1]]++;

    ll cnt = 0;
    for(auto m: mp) cnt += m.second * (m.second-1)/2;

    cout << cnt << endl;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<int, int>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m; cin >> n >> m;
  vector<vector<int>> G(n);
  REP(i,m){
    int u,v; cin >> u >> v;
    u--, v--;
    G[u].push_back(v);
  }
  int s,t; cin >> s >> t;
  s--, t--;
  
  vector<vector<ll>> dist(n, vector<ll>(3, -1));
  dist[s][0] = 0;
  queue<P> que;
  que.emplace(s, 0);
  while(!que.empty()){
    P cur = que.front();
    que.pop();
    int v = cur.first;
    int step = cur.second;
    for(auto nv: G[v]){
      int np = (step + 1) % 3;
      if(dist[nv][np]==-1){
        dist[nv][np] = dist[v][step] + 1;
        que.emplace(nv, np);
      }
    }
  }
  
  cout << (dist[t][0]==-1 ? -1 : dist[t][0]/3) << endl;
  
  return 0;
}


Measured memory_bytes: 11264
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let v:Vec<usize> = (0..n).map(|_| read()).collect();
    let mut cnt = 0;
    let mut index = 1;
    for _ in 0..n {
        index = v[index -1];
        cnt += 1;
        if index == 2 {
            break;
        }
    }
    if index == 2 {
        println!("{}", cnt);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 2852
a, b, c, x, y = gets.split.map(&:to_i)

abmax = [2 * x, 2 * y].max
mx = 100000000000

0.upto(abmax) do |z|
  resta = [x - z / 2, 0].max
  restb = [y - z / 2, 0].max

  mx = [mx, resta * a + restb * b + z * c].min
end

p mx


Measured memory_bytes: 14400
#include <algorithm>
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#define p 1000000007LL
#define ll long long int
#define rep(i, a, b) for(int i = (a); i <= (b); ++ i)
#define dwn(i, a, b) for(int i = (a); i >= (b); -- i)
using namespace std;
const int maxn = 3e5 + 200;

int n;
ll Ans;
ll a[maxn];
ll wei[maxn][63], num[2][63];
int main()
{
    scanf("%d", &n);
    rep(i, 1, n) scanf("%lld", &a[i]);
    rep(i, 1, n)
    {
        rep(k, 0, 61)
            wei[i][k] = a[i] % 2,
            a[i] >>= 1,
            num[wei[i][k]][k] ++;
    }
    ll no = 1;
    Ans = 0;
    rep(k, 0, 61)
    {
        Ans = (Ans + no * num[0][k] % p * num[1][k] % p) % p;
        no = no * 2LL % p;
    }
    cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 150400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC084D
{
    class Program
    {
        static int max = 100001;
        static void Main(string[] args)
        {
            var Q = int.Parse(Console.ReadLine());
            bool[] Pcontain = new bool[max];
            int[] like = new int[max];

            for(int i = 2; i < max; i++)
            {
                if(Pcontain[i] == false)
                {
                    for (int j = 2 * i; j < max; j += i) Pcontain[j] = true;
                }
            }

            for(int i = 3; i < max - 1; i++)
            {
                if (i % 2 == 1 && Pcontain[i] == false && Pcontain[(i + 1) / 2] == false)
                {
                    like[i] = like[i - 1] + 1;
                }
                else
                {
                    like[i] = like[i - 1];
                }
            }

            int[] l = new int[max];
            int[] r = new int[max];
            for (int i = 0; i < Q; i++)
            {
                var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
                l[i] = line[0];
                r[i] = line[1];
            }
            for(int i = 0; i < Q; i++)
            {
                int ans = like[r[i]] - like[l[i] - 1];
                Console.WriteLine(ans);
            }
            Console.ReadKey();
        }

    }
}


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

const long long MAX = 10000001;

long long factor[MAX] = { 0 };

void generatePrimeFactors()
{
	factor[1] = 1;

	for (long long i = 2; i < MAX; i++)
		factor[i] = i;
	for (long long i = 4; i < MAX; i += 2)
		factor[i] = 2;
	for (long long i = 3; i * i < MAX; i++) {
		if (factor[i] == i) {
			for (long long j = i * i; j < MAX; j += i) {
				if (factor[j] == j)
					factor[j] = i;
			}
		}
	}
}

long long calculateNoOFactors(long long n)
{
	if (n == 1)
		return 1;

	long long ans = 1;

	long long dup = factor[n];
	long long c = 1;
	long long j = n / factor[n];

	while (j != 1) {
		if (factor[j] == dup)
			c += 1;
		else {
			dup = factor[j];
			ans = ans * (c + 1);
			c = 1;
		}
		j = j / factor[j];
	}
	ans = ans * (c + 1);

	return ans;
}

int main()
{
	generatePrimeFactors();
    long long n, ans=0;
    cin >> n;
    for(long long i=1; i<=n; i++) {
        long long x=calculateNoOFactors(i);
        //cout << x << " ";
		ans+=i*x;

    }
    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 81316
use std::cmp::max;
use std::collections::VecDeque;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let m: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut ev: Vec<Vec<usize>> = vec![vec![]; n];
    let mut dv = vec![0i32; n];
    for _ in 0..m {
        let x: usize = read(&mut stdin_lock, &mut buf, b' ');
        let y: usize = read(&mut stdin_lock, &mut buf, b'\n');
        ev[x - 1].push(y - 1);
        dv[y - 1] += 1;
    }

    let mut q = VecDeque::new();
    for i in 0..n {
        if dv[i] == 0 {
            q.push_back(i);
        }
    }

    let mut nv = vec![0i32; n];
    while !q.is_empty() {
        let i = q.pop_front().unwrap();
        for &e in ev[i].iter() {
            dv[e] -= 1;
            if dv[e] == 0 {
                q.push_back(e);
                nv[e] = max(nv[e], nv[i] + 1);
            }
        }
    }
    println!("{}", nv.iter().max().unwrap());
}


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

int main() {
  int K;
  string S;
  cin >> K >> S;
  int len = S.size();
  if (len <= K)
    cout << S << endl;
  else {
    for (int i=0; i<K; i++)
      cout << S[i];
    cout << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;
int main(void)

{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string ans = "01";
    vector<vector<pair<ll, ll>>> v(n);
    rep(i, 0, n - 1)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        v[a].push_back({b, c});
        v[b].push_back({a, c});
    }
    priority_queue<ll> q;
    vector<ll> dist(n, -1);
    q.push(0);
    dist[0] = 0;
    while (!q.empty())
    {
        auto tmp = q.top();
        q.pop();
        for (auto i : v[tmp])
        {
            if (dist[i.first] == -1) //未探索の場合
                dist[i.first] = dist[tmp] + i.second, q.push(i.first);
        }
    }
    rep(i, 0, n) cout << ans[dist[i] % 2] << endl;
}


Measured memory_bytes: 11352
n = int(input())
list = input().split(" ")
min = int(list[0])
max = int(list[0])
total = int(list[0])
for i in range(1, n):
	num = int(list[i])
	if num > max:
		max = num
	if num < min:
		min = num
	total += num
	
print("%s %s %s"%(min, max, total))

Measured memory_bytes: 6336
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  string s;
  cin >> s;
  rep(i,s.size())cout << 'x';
  cout << endl;
return 0;}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int h=sc.nextInt();
        int w=sc.nextInt();
        int output=0;
        int tmpa;
        int tmpb;
        for(int i=0;i<n;i++){
            tmpa=sc.nextInt();
            tmpb=sc.nextInt();
            if(tmpa>=h&&tmpb>=w){
                output++;
            }
        }
        System.out.println(output);
    }
 
    
}

Measured memory_bytes: 25316
fn main() {
    let ab = read_vec::<usize>();
    let a = ab[0];
    let b = ab[1];

    println!("{}", lcm(a, b));
}

fn lcm(a: usize, b: usize) -> usize {
    (a * b) / gcd(a, b)
}

fn gcd(a: usize, b: usize) -> usize {
    if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


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

#define GROW_DIFF_DEG 5.5
#define MIN_PER_HOUR 60
#define TERN_DEG 180
#define RAD 360
#define PI 3.141592653589793238

int main(void) {
  float a, b;
  int h, m;
  scanf("%f %f %d %d", &a, &b, &h, &m);

  int min = h * MIN_PER_HOUR + m;
  long double dig = (long double) GROW_DIFF_DEG * (long double) min;

  int count = 0;
  long double theta = 0;
  while (dig > TERN_DEG) {
    dig -= TERN_DEG;
    count++;
  }
  if (!(count % 2)) theta = dig * (long double) PI * (long double) 2 / (long double) RAD;
  else  {
    theta = ((long double) TERN_DEG - dig) * (long double) PI * (long double) 2 / (long double) RAD;
  }
  long double result_cos;
  if (dig != (double) 90 && dig != (double) 270) {
    result_cos = cosl(theta);
  } else {
    result_cos = 0;
  }
  long double double_s = pow((long double) a, (long double) 2) + pow((long double) b, (long double) 2) - (long double) 2 * (long double) a * (long double) b * result_cos;
  printf("%20.20Lf\n", sqrtl(double_s));

  return 0;
}


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

int main() {
	int x,a,b;scanf("%d%d%d",&x,&a,&b);
	puts(abs(a-x)<abs(b-x)?"A":"B");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl0

ll modpow(ll x, ll y, ll m){
    if(y==0) return 1;
    ll res = modpow(x,y/2,m);
    return res * res % m * (y&1 ? x : 1) % m;
}

int h,w,n,k;

int ask(int a, int b, int c, int d){
    printf("? %d %d %d %d\n", a, b, c-1, d-1);
    fflush(stdout);
    int p;
    cin >> p;
    return p;
}

int ans[50][50];

void solve(int i1, int j1, int i2, int j2, int n){
    int h = i2 - i1;
    int w = j2 - j1;
    if(n == 0 || n == h*w){
        for(int i = i1; i < i2; ++i){
            for(int j = j1; j < j2; ++j){
                ans[i][j] = n == 0 ? 0 : 1;
            }
        }
    } else {
        if(rand()%2){
            int x = ask(i1, j1, i1 + h/2, j2);
            solve(i1, j1, i1 + h/2, j2, x);
            solve(i1 + h/2, j1, i2, j2, n - x);
        } else {
            int x = ask(i1, j1, i2, j1 + w/2);
            solve(i1, j1, i2, j1 + w/2, x);
            solve(i1, j1 + w/2, i2, j2, n - x);
        }
    }
}

int main(){
    srand(time(0));
    cin >> h >> w >> n >> k;
    memset(ans, -1, sizeof ans);
    solve(0, 0, h, w, n);

    // rep(i,h){
    //     rep(j,w){
    //         cerr << ans[i][j];
    //     }
    //     cerr << endl;
    // }

    ll sigma = 0;
    rep(i,h)rep(j,w){
        sigma += ans[i][j] * modpow(2, i*w + j, k);
        sigma %= k;
    }
    cout << "! " << sigma << endl;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


void solve(string& s, int K) {
    int L = s.size();
    rep(i,L) {
        int ch = (int)(s[i] - 'a'); // 0-25
        int mov = (26 - ch) % 26;
        if (mov <= K) {
            K -= mov;
            ch = 0;
        } else {
            ;
        }
        if (i == L-1) {
            ch = (ch + K) % 26;
        }
        assert(IN(ch, 0, 25));
        putchar('a'+ch);
    }
    putchar('\n');
}

int main() {
    string s; cin >> s;
    int K; cin >> K;
    solve(s,K);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <utility>
#include <tuple>
#include <string>
#include <cstdint>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>
using namespace std;
using i64 = int64_t;
const i64 mod = 1e9 + 7;
i64 fact_memo[300000];
i64 fact(i64 x) {
    if (fact_memo[x] > 0) return fact_memo[x];
    return fact_memo[x] = x > 0 ? x * fact(x - 1) % mod : 1;
}
i64 powi(i64 x, i64 k) {
    i64 y = 1, z = x;
    while (k > 0) {
        if (k & 1) y = y * z % mod;
        k >>= 1;
        z = z * z % mod;
    }
    return y;
}
i64 inv(i64 x) {
    return powi(x, mod - 2);
}
i64 perm(i64 a, i64 b) {
    return fact(a) * inv(fact(a - b)) % mod; 
}
i64 conb(i64 a, i64 b) {
    return perm(a, b) * inv(fact(b)) % mod;
}
i64 h, w, a, b;
int main() {
    cin >> h >> w >> a >> b;
    fact_memo[0] = 1;
    for (i64 i = 1; i <= h + w; ++i) {
        fact_memo[i] = i * fact_memo[i - 1] % mod;
    }
    i64 ans = 0;
    for (i64 k = 1; k <= h - a; ++k) {
        ans += conb(k + b - 2, k - 1) * conb(w - b + h - k - 1, h - k) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>

int field[2][100]={};
int cum_u[100]={};
int cum_l[100]={};
int N;
int max=0;
void input(void){
    std::cin>>N;
    for(int i=0;i<N;i++){
        std::scanf("%d",&field[0][i]);
    }
    for(int i=0;i<N;i++){
        std::scanf("%d",&field[1][i]);
    }

    cum_u[0]=field[0][0];
    cum_l[0]=field[1][0];
    for(int i=1;i<N;i++){
        cum_u[i]=cum_u[i-1]+field[0][i];
        cum_l[i]=cum_l[i-1]+field[1][i];
        //std::cout<<cum_u[i]<<"  "<<cum_l[i]<<std::endl;
    }
}
int solve(void){
    max=cum_u[0]+cum_l[N-1];
    //std::cout<<"N is "<<N<<std::endl;
    for(int divide=1;divide<N;divide++){
        
        int ans=cum_u[divide]+cum_l[N-1]-cum_l[divide-1];
        //std::cout<<ans<<std::endl;
        if(ans>max)max=ans;
    }
    return max;
}

int main(void){
    input();
	std::cout<<solve()<<std::endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()

if N >= M:
    print(0)
    exit()

diff = []
for i in range(M-1):
    diff.append(X[i+1] - X[i])

#print(diff)

diff.sort()
for i in range(N-1):
    diff.pop()

print(sum(diff))

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

using ll = long long;
const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, R;
    cin >> N >> R;
    if (N >= 10) {
        cout << R << endl;
    } else {
        cout << R + 100 * (10 - N) << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[3];

        for(int i = 0; i < 3; i++) {
            arr[i] = sc.nextInt();
        }
        int X = sc.nextInt();
        int res = 0;

        for(int i = 0; i <= arr[0]; i++) {
            for(int j = 0; j <= arr[1]; j++) {
                for(int k = 0; k <= arr[2]; k++) {
                    int total = 500*i + 100*j + 50*k;
                    if(total == X) {
                        res++;
                    }
                }
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 23892
#include <iostream>
#include <stdlib.h>
using namespace std;

int main(int argc, const char * argv[]) {
    
    long long A,B;
    cin >> A >> B;
    
    while(A!=B && A % abs(A-B) != 0 )
    {
        
        if(A<B)
        {
            B %= A;
        }
        else
        {
            A %= B;
        }
    }
    
    
    long long k = abs(A-B); //GCD
    
    if(A==B)
    {
        k=A;
    }
    
    int count = 1; //count
    
    for(long long i = 2; i * i<=k; i++)
    {
        if(k%i == 0)
        {
            count ++;
            while(k%i == 0)
            {
                k /= i;
            }
        }
    }
    if(k!=1)
    {
        count ++;
    }
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A = [i-1 for i in A]
    l = []
    v = set()
    t = 0
    while True:
        l.append(t)
        if t in v:
            break
        v.add(t)
        t = A[t]
    ll = len(l) - 1 - l.index(t)
    loop = l[l.index(t):-1]
    s = l.index(t)
    if K < len(l):
        return l[K] + 1
    K -= s
    K %= ll
    return loop[K] + 1
print(main())


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

#define REP(i,n) for (int i=0;i<(n);i++)
#define PII pair<int,int>
#define LL long long

int main(){
  int a,b;
  cin >> a >> b;
  if(a+b>=10){
    cout<<"error"<<endl;
  }else{
    cout << a+b<<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 ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int gcd(int a, int b){
    if(a < b){
        int temp = a;
        a = b;
        b = temp;
    }
    int r = a % b;
    while(r > 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
int main(){
    int N;
    cin >> N;
    int A[100100];
    REP(i,N) cin >> A[i];
    int ans = A[0];
    REP(i,N-1) ans = gcd(ans,A[i+1]);
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

template<typename T>
T Min(T a, T b){
    if(a > b)   return b;
    else        return a;
}

const ll INF = 1001001001001001;

int main(){
    int n;  cin >> n;
    vector<ll>a(n);
    rep(i, n)   cin >> a[i];
    vector<vector<ll> >dp(n+1, vector<ll>(n+1, INF));
    rep(i, n)   dp[i][i+1] = 0;
    vector<ll>cs(n+1);
    rep(i, n)   cs[i+1] = cs[i] + a[i];
    for(int len = 2; len <= n; len++){
        rep(i, n-len+1){
            for(int j = i+1; j < i+len; j++){
                dp[i][i+len] = Min(dp[i][i+len], dp[i][j]+dp[j][i+len]);
            }
            dp[i][i+len] += cs[i+len] - cs[i];
        } 
    }
    cout << dp[0][n] << endl;
}


Measured memory_bytes: 1536
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
ll x[100000], L;
int p[100001];
int d[100001][20];
int Q;

signed main(){
    cin >> N;
    rep(i, N) cin >> x[i];
    cin >> L;

    int r = 0;
    rep(i, N-1){
        while(r < N && x[r]-x[i] <= L) r++;
        p[i] = r-1;
    }
    p[N-1] = N;

    rep(j, 20) d[N][j] = N;
    for(int i=N-1; i>=0; i--){
        d[i][0] = p[i];
        rep(j, 19){
            d[i][j+1] = d[d[i][j]][j];
        }
    }

    cin >> Q;
    rep(i, Q){
        int a, b;
        cin >> a >> b;
        if(a > b) swap(a, b);
        a--; b--;
        int ans = 1;
        while(d[a][0] < b){
            rep(j, 19){
                if(d[a][j] >= b){
                    ans += (1<<j-1);
                    a = d[a][j-1];
                    break;
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 12568