akhauriyash/Code-Regression huggingface dataset:
mod = 10**9+7
MAX_N = 10 ** 6

fact = [1]
fact_inv = [0] * (MAX_N + 4)
for i in range(MAX_N + 3):
    fact.append(fact[-1] * (i + 1) % mod)

fact_inv[-1] = pow(fact[-1], mod - 2, mod)
for i in range(MAX_N + 2, -1, -1):
    fact_inv[i] = fact_inv[i + 1] * (i + 1) % mod

def mod_comb_k(n, k, mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod

OK = False
X, Y = map(int, input().split())
for i in range(0, max(X, Y)+1):
    if (Y - (X - i*2)*2) == i and X-2*i >= 0:
        x = i
        y = X - i*2
        print(mod_comb_k(x + y, min(x, y), mod))
        OK = True
        break
if not OK:
    print(0)

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

string S, T;
vector<int> table(26, -1);

bool solve(){
    const int N = S.size();
    for(int i=0; i<N; i++) table[S[i]-'a'] = T[i]-'a';
    
    //単射性のチェック
    for(int i=0; i<26; i++){
        for(int j=0; j<i; j++){
            if(table[i]!=-1 && table[j]!=-1 && table[i]==table[j]) return false;
        }
    }

    //写像のチェック
    for(int i=0; i<N; i++)
        if(table[S[i]-'a']!=T[i]-'a') return false;

    return true;
}

int main() {
    cin >> S >> T;
    cout << (solve()? "Yes" : "No") << endl;
    return 0;
}


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

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    int M = max(H, W);
    for(int i = 1; i <= M; ++i) {
        if(i * M >= N) {
            cout << i << '\n';
            return 0;
        }
    }
    return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    int H, W;
    cin >> H >> W;

    vector<string> G(H);
    rep(i, H) cin >> G[i];

    int cnt = 0;
    rep(i, H) rep(j, W) {
        if (G[i][j] == '#') { cnt++; }
    }

    vector<vector<lint>> dist(H, vector<lint>(W, LINF));
    dist[0][0] = 0;
    queue<pair<int, int>> q({{0, 0}});
    while (!q.empty()) {
        int cx, cy;
        tie(cx, cy) = q.front();
        q.pop();
        int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
        for (int i = 0; i < 4; i++) {
            int nx = cx + dx[i], ny = cy + dy[i];
            if (0 <= nx && nx < H && 0 <= ny && ny < W && G[nx][ny] == '.' &&
                dist[nx][ny] == LINF) {
                dist[nx][ny] = dist[cx][cy] + 1;
                q.push({nx, ny});
            }
        }
    }
    // ddump(G);
    // ddump(dist);

    if (dist[H - 1][W - 1] == LINF) {
        cout << -1 << endl;
    } else {

        cout << (H * W - cnt) - (dist[H - 1][W - 1] + 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>//accumulateを使うためにインクルード

using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    char v[h][w];

    for(size_t i = 0; i < h; i++)
    {
        for(size_t j = 0; j < w; j++)
        {
            cin >> v[i][j];
        }
    }

    for(size_t i = 0; i < h; i++)
    {
        for(size_t j = 0; j < w; j++)
        {
            cout << v[i][j];
        }
        cout << endl;
        for(size_t k = 0; k < w; k++)
        {
            cout << v[i][k];
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const ll INF = 10000000000;//INFinity
using namespace std;//namespace

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

//#define int long long // yabai

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout

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

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    int h,w,n;
    cin>>h>>w>>n;
    vector<int>a(n);
    REP(i,n)cin>>a[i];

    vector<vector<int>> ans(h);
    for(auto&t:ans)t.resize(w);

    vector<pair<int,int>> pair_;//   vector pair < kazu , id >
    REP(i,n)pair_.pb(mp(a[i],i+1));
    sort(ALL(pair_));

    int count=0;
    int count_two=0;
    bool ue_sita=true;
    REP(i,h){
        REP(jj,w){
            int j = (ue_sita?jj:w-1-jj);
            if(count>=pair_[count_two].first){count=0;count_two++;}
            ans[i][j]=pair_[count_two].second;
            ++count;
        }
        ue_sita= !ue_sita;
    }
    REP(i,h){REP(j,w)cout<<ans[i][j]<<" ";cout<<endl;}

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
  int n;
  int retval;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    retval=0;
    while(n>0){
      n=n/5;
      retval+=n;
    }
    printf("%d\n",retval);
  }
  return 0;
}



Measured memory_bytes: 2036
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  for(in z=1;z<=n;++z){
    if(z*(z+1)/2>=n){
      for(in i=z;i>=1;--i){
	if(i<=n){
	  cout<<i<<"\n";
	  n-=i;
	}
      }
      break;
    }
  }
  return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair < int , int >;
using i3 = pair < int , ii >;
using vi = vector < int >;
using vii = vector < ii >;
using vi3 = vector < i3 >;

const int N = 2e5 + 5;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

int n , m;
int a[55];
int b[55];

void solve(){
    scanf("%d" , &n);

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

    sort(b , b + n);

    int s = 0;
    for(int i = 0 ; i < n ; i ++)if(a[i] != b[i])s ++;
    if(s <= 2){
        printf("YES\n");
    }
    else printf("NO\n");
}

main(){

    int t = 1;
    //scanf("%d" , &t);

    while( t -- ){
        solve();
    }

    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    int L[N],R[N];
    for(int i=0;i<M;i++) cin >> L[i] >> R[i];
    int count[N];
    for(int i=0;i<N;i++) count[i] = 0;
    for(int i=0;i<M;i++){
        count[L[i]-1]++;
        count[R[i]]--;
    }
    for(int i=1;i<N;i++){
        count[i] = count[i]+count[i-1];
    }
    int ans = 0;
    for(int i=0;i<N;i++){
        if(count[i]==M) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0 ,1, 1, 1, 0, -1, -1, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
ll sumMod(ll a, ll b){return a + b > mod ? a + b - mod : a + b;}
int H, W;
char v[1005][1005];
ll dp[1005][1005];
ll f(int i, int j){
    if(i == H - 1 && j == W - 1)
        return 1;
    ll &ans = dp[i][j];
    if(ans == -1){
        ans = 0;
        for(int k = 0; k < 2; k++){
            int x = i + dx[k];
            int y = j + dy[k];
            if(x >= 0 && x < H && y >= 0 && y < W && v[x][y] == '.')
                ans = (ans % mod + f(x, y)% mod) % mod;
                //ans = sumMod(ans, f(x, y));
        }
    }
    return ans;
}
int main(){
    //FL;
    FIN;
    cin >> H >> W;
    for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++)
            cin >> v[i][j];
    cls(dp, -1);
    cout << f(0, 0) << '\n';
    EjecuteTime;
    return 0;
}       

Measured memory_bytes: 12792
package main

import (
	"fmt"
)

func main() {
	var n [][]int

	var mid, final, re int

	for {
		fmt.Scan(&mid, &final, &re)
		if mid == -1 && final == -1 && re == -1 {
			break
		}
		n = append(n, []int{mid, final, re})
	}

	for _, v := range n {
		if v[0] == -1 || v[1] == -1 {
			fmt.Println("F")
			continue
		}

		total := v[0] + v[1]

		if 80 <= total {
			fmt.Println("A")
			continue
		}

		if 65 <= total && total < 80 {
			fmt.Println("B")
			continue
		}

		if 50 <= total && total < 65 {
			fmt.Println("C")
			continue
		}

		if 30 <= total && total < 50 {
			if 50 <= v[2] {
				fmt.Println("C")
				continue
			}
			fmt.Println("D")
			continue
		}
		fmt.Println("F")
	}
}



Measured memory_bytes: 1132
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  i64 n;
  cin >> n;
  vector<i64> p(n);
  for(int i = 0;i < n;i++) cin >> p[i];
  i64 cnt = 0;
  for(int i = 1;i < n - 1;i++) {
    if(p[i - 1] < p[i] && p[i] < p[i + 1]) {
      cnt++;
    }
    if(p[i - 1] > p[i] && p[i] > p[i + 1]) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int mod = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    ll a,v,b,w;
    ll t;
    cin>>a>>v>>b>>w;
    cin>>t;
    if(a == b){cout << "YES" << endl;return 0;}
    if(v <= w){
        cout << "NO" << endl;
        return 0;
    }
    ll dis = abs(b-a);
    ll speed = v - w;
    if(dis <= speed * t){
        cout << "YES" << endl;
    }else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3640
var s,t,v:ansistring;
    i:longint;
    a,b:int64;
    x:boolean;
begin
  readln(s);
  x:=true;
  for i:=1 to length(s) do begin
    if (s[i]='+') or (s[i]='-') then begin
      if (s[i]='+') then x:=false;
      break;
    end;
  end;
  if (x=false) then begin
    val(copy(s,1,pos('+',s)-2),a);
    val(copy(s,pos('+',s)+2,length(s)),b);
    writeln(a+b);
  end
  else begin
    val(copy(s,1,pos('-',s)-2),a);
    val(copy(s,pos('-',s)+2,length(s)),b);
    writeln(a-b);
  end;
end.

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

int  yakusuu(int A){
  int count=0;
  for(int i=1;i*i<=A;i++){
    if(A%i==0){
      count++;
      if(A/i!=i){
        count++;
      }
    }
  }
  return count ;
}
    
int main(){
  int N,count=0;
  cin >> N;
 for(int i=0;i<N;i+=2){
    int C=yakusuu(i+1);
    if(C==8){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3636
# 1回の操作で引き出す可能性のある金額リスト
cash = [1]
n = int(input())
# nを超えない範囲で6,9の累乗を追加する
for i in range(1, n):
    if 6 ** i > n:
        break
    cash.append(6 ** i)
for i in range(1, n):
    if 9 ** i > n:
        break
    cash.append(9 ** i)
cash.sort()
# ans[i]: i円ちょうど引き出すのに必要な操作の最小回数
ans = [float('inf')] * (n + 1)
ans[0] = 0
for i in range(1, n + 1):
    for j in cash:
        if i - j < 0:
            break
        else:
            ans[i] = min(ans[i], ans[i - j] + 1)
print(ans[n])

Measured memory_bytes: 44368
use std::vec::Vec;

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

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

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    assert_eq!(v.len(), 2);
    (v[0], v[1])
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let t: Vec<char> = read::<String>().chars().collect();

    let mut ans = "Yes";
    for i in 0..s.len() {
        if s[i] != t[i] {
            ans = "No";
        }
    }

    println!("{}", ans);
}


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

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

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

    ll n,a,b,c,d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    a--;
    b--;
    c--;
    d--;

    bool ans = true;

    for (ll i = a; i <= max({c-1,d-1}); i++){
        if (s[i] == '#' && s[i+1] == '#'){
            ans = false;
        }
    }

    if (c < d){
        if (ans){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
        return 0;
    }

    if (!ans){
        cout << "No" << endl;
        return 0;
    }

    bool ans2 = false;

    for (ll i = b-1; i <= d-1; i++){
        if (s[i] == '.' && s[i+1] == '.' && s[i+2] == '.'){
            ans2 = true;
        }
    }
    
    if (ans2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define endl "\n"
 
const LD EPS=1e-10;
const long long INFLL=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	for(int i=0;i<q;i++)
		t*=p;
	return t;
}

template <typename T>
struct has_iter
{
	private:
		template <typename U>
		static constexpr true_type check(typename U::iterator*);
		template <typename U>
		static constexpr false_type check(...);

	public:
		static constexpr bool value = decltype(check<T>(nullptr))::value;
};


template<typename T, typename U = typename T::iterator>
void print(const T& container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}


extern void* enabler;
template<typename Head, typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<> void print<string>(const string& container)
{
	cout<<container<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec)
{
	for(T& x: vec) is >> x;
	return is;
}


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

template<typename T>
vector<T> read(int n)
{
	vector<T> t(n);
	cin>>t;
	return t;
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}

template<typename Head, typename... Tail>
struct vector_demensions
{
	using type=vector<typename vector_demensions<Tail...>::type>;
};

template<typename Head>
struct vector_demensions<Head> { using type=Head; };

template<typename T>
vector<T> make_vectors(int size, T val)
{
	return vector<T>(size, val);
}

template<typename T=int, typename... Args>
auto make_vectors(int size, Args... tail)
	-> typename vector_demensions<Args..., T>::type
{
	auto val=make_vectors<T>(forward<Args>(tail)...);
	return vector<decltype(val)>(size, val);
}


int main()
{
	LL d,n,m;
	cin>>n>>m>>d;
	LL p=0;
	if(d!=0)
	p+=(n-d)*2;
	else
	p+=n-d;
	p*=(m-1);
	LD ans=p;
	ans/=n;
	ans/=n;
	cout<<setprecision(10)<<fixed<<ans<<endl;
}


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

namespace abc107_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            int count = 0;

           
                if (S[0] == T[0])
                {
                    count += 1;
                }

                if (S[1] == T[1])
                {
                    count += 1;
                }

                if (S[2] == T[2])
                {
                    count += 1;
                }
            

            Console.WriteLine(count);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;

int main(){

    int n,m;
    cin >> n >> m;

    ll summod = 0;
    map<ll, int> modm;

    modm[0]++;

    rep(i,n){
        int tmp;
        cin >> tmp;
        tmp = tmp % m;
        summod = (summod + tmp) % m;
        modm[summod]++; 
    }

    ll ans = 0;

    for(auto itr = modm.begin(); itr != modm.end(); itr++){
        ll tmp = (*itr).second;

        if(tmp > 1){
            ans = ans + tmp * (tmp - 1) / 2;
        }
    }

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

Measured memory_bytes: 4224
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int loop;
    double xa, ya, ra, xb, yb, rb;
    
    cin >> loop;
    for(int i = 0; i < loop; i++){
        cin >> xa >> ya >> ra >> xb >> yb >> rb;
        double d = sqrt(pow(xa - xb, 2) + pow(ya - yb, 2));

        if(d < ra - rb){
            cout << 2 << endl;
        } else if(d < rb - ra){
            cout << -2 << endl;
        } else if(d > rb + ra){
            cout << 0 << endl;
        } else {
            cout << 1 << endl;
        }
    }
}



Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = scanner.nextInt();
		int e = scanner.nextInt();
		int k = scanner.nextInt();
		System.out.println(e - a > k ? ":(" : "Yay!");
		scanner.close();
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
    chutiyaap;
    int n,m,x;cin>>n>>m>>x;
    int c[n+1][m+1];
    for(int i=0;i<n;i++)
    {
    	cin>>c[i][0];
    	for(int j=1;j<=m;j++)cin>>c[i][j];
    } 
	int opsize = pow(2, n);
	int final=INT_MAX;
    for (int counter = 1; counter < opsize; counter++) 
    { 
    	vector<int>sm(n,0);
    	int res=0;
        for (int j = 0; j < n; j++) 
        {
            if (counter & (1<<j)) 
            {
            	//c[j][0]
            	res+=c[j][0];
            	for(int k=1;k<=m;k++)sm[k-1]+=c[j][k];
            }
        } 
        int cnt=0;
        for(int i=0;i<m;i++)if(sm[i]>=x)cnt++;
        if(cnt==m)final=min(final,res);
        res=0;
        // cout << endl; 

    }
    if(final<INT_MAX)cout<<final;
    else cout<<-1;
    return 0;
}


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+5;
typedef long long ll;
const ll inf = 1e18;
ll a[maxn];
ll n,cp,cn,c0,k;
ll solve1()
{
    vector<ll>x(a+1,a+cn+1);
    vector<ll>y(a+n-cp+1,a+n+1);
    ll l = x[0]*y.back();
    ll r = x.back()*y[0];
    reverse(x.begin(),x.end());
    reverse(y.begin(),y.end());
    while(l<=r)
    {
        ll mid = l+r>>1;
        ll c = 0;
        for(ll i = 0,j = 0;i < x.size();++i){
            for(;j < y.size()&& x[i]*y[j]<=mid;++j);
            c+=j;
        }
        if(c<k)l = mid+1;
        else r = mid-1;
    }
    return l;
}
ll solve2()
{
    vector<ll>x(a+1,a+cn+1);
    vector<ll>y(a+n-cp+1,a+n+1);
    reverse(x.begin(),x.end());
    ll l,r;
    l = inf,r = -inf;
    if(x.size()>1)
    {
        r = x[x.size()-1]*x[x.size()-2];
        l = x[0]*x[1];
    }
    if(y.size()>1)
    {
        r = max(r,y[y.size()-1]*y[y.size()-2]);
        l = min(l,y[0]*y[1]);
    }
    while(l <= r){
        ll mid = l+r>>1;
        ll c = 0;
        for(ll i = x.size()-1,j = 0;i >= 0;--i){
            for(;j < i&& x[i]*x[j]<=mid ;++j);
            c += min(j,i);
        }
        for(ll i = y.size()-1,j = 0;i >= 0;--i){
            for(; j < i&& y[i]*y[j]<=mid;++j);
            c += min(j,i);
        }
        if(c<k)l = mid+1;
        else r = mid-1;
    }
    return l;
}
int main()
{
    scanf("%d%lld",&n,&k);
    for(int i = 1;i <= n;++i){
        scanf("%lld",&a[i]);
        if(a[i]<0)cn++;
        else if(a[i]==0)c0++;
        else cp++;
    }
    sort(a+1,a+1+n);
    ll ans;
    if(k<=cn*cp)
        ans=solve1();
    else if(k <= cn*cp+c0*(c0-1)/2+c0*(n-c0))ans=0;
    else {
        k-=cn*cp+c0*(c0-1)/2+c0*(n-c0);
        ans=solve2();
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3200
fun main(args: Array<String>) {
    abc143d()
}

fun abc143d() {
    val n = readLine()!!.toInt()
    val lines = readLine()!!.split(" ").map { it.toInt() }
        .sorted().toIntArray()

    var answer = 0
    for (ai in 0 until n) {
        var right = ai + 2
        for (bi in ai + 1 until n) {
            while (right < n && lines[right] < lines[ai] + lines[bi]) right++
            val left = bi + 1
            answer += right - left
        }
    }

    println(answer)
}


Measured memory_bytes: 37808
import java.io.*;
import java.lang.*;

public class Main {
	public static void main(String[] args)  throws IOException
		{
		    BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		    int[] count = new int[51];
		    for(int a=0; a<=9; a++){
		    	for(int b=0; b<=9; b++){
		    		for(int c=0; c<=9; c++){
		    			for(int d=0; d<=9; d++){
		    				count[a+b+c+d]++;
		    			}
		    		}
		    	}
		    }
		    String s;
		  while((s=buf.readLine()) != null){
		    System.out.println(count[Integer.parseInt(s)]);
		  }
		}
}

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

int main(){
  ll x; cin >> x;

  for(int a = 1; a <= x; a++){
    int b = -1 * a;
    while(b < a) {
      if(a*a*a*a*a - b*b*b*b*b == x){
        cout << a << ' ' << b << endl;
        return 0;
      }
      b++;
    }
  }

}



Measured memory_bytes: 3624
import java.util.*;
import java.io.*;
class Main{
	public static void main(String[] args){
      Scanner sc  = new Scanner(System.in);
      int n = Integer.parseInt(sc.next());
      long sum = (long)n*(n+1)/2;
      long min = 0;
      boolean[] is = new boolean[n+1];
      for(int i=n;i>0;i--){
        if(sum-i>=n){
          is[i] = true;
          sum-=i;
        }
      }
      PrintWriter out = new PrintWriter(System.out);
      for(int i=1;i<=n;i++){
        if(!is[i]){
          out.println(i);
        }
      }
      out.flush();
      
    }
}

Measured memory_bytes: 46388
#include <iostream>

using namespace std;

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    cout << x2 + y1 - y2 << " "
         << y2 + x2 - x1 << " "
         << x1 + y1 - y2 << " "
         << y1 + x2 - x1 << endl;

    return 0;
}

Measured memory_bytes: 256
// AOJ ALDS1_6_C Quick Sort
// 2018.5.1 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char buf[20];
void mypr(int n)
{
	int i;
	if (!n) { pc('0'); return; }
	i = 0; while (n) buf[i++] = n%10 + '0', n/=10;
	while (i--) pc(buf[i]); 
}

typedef struct { char c; int a; int id; } DATA;

int partition(DATA *a, int lo, int hi)
{
	int i, j;
	int key;
	DATA t;
	
	key = a[hi].a, i = lo-1;
	for (j = lo; j < hi; j++) {
		if (a[j].a <= key) i++, t = a[i], a[i] = a[j], a[j] = t;
	}
	t = a[++i], a[i] = a[hi], a[hi] = t;
	return i;
}

void quick_sort(DATA *a, int lo, int hi)
{
	int mi;

	if (lo < hi) {
		mi = partition(a, lo, hi);
		quick_sort(a, lo, mi-1);
		quick_sort(a, mi+1, hi);
	}
}

DATA a[100002];

int main()
{
	int N, i, f;

	N = in();
	for (i = 0; i < N; i++) {
		a[i].c = gc(), gc();
		a[i].a = in(), a[i].id = i;
	}
	quick_sort(a, 0, N-1);
	f = 0; for (i = 1; i < N; i++) {
		if (a[i-1].a == a[i].a && a[i-1].id > a[i].id) { f = 1; break; }
	}
	puts(f? "Not stable": "Stable");
	for (i = 0; i < N; i++) {
		pc(a[i].c), pc(' '), mypr(a[i].a), pc('\n');
	}
	return 0;
}



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

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

int main(){
    string s,t; cin >> s >> t;
    int n=s.size();
    int ans=0;
    rep(i,n){
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3916
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  r=I()
  return r*r

# main()
print(main())


Measured memory_bytes: 7848
H, W = map(int, input().split())
 
if H % 2 == 0:
    ans = (H / 2) * W
else:
    if H == 1 or W == 1:
        ans = 1
    else:
        cal_low = W // 2
        cal_large = W - cal_low
        ans_low = ((H // 2)) * cal_low
        ans_large = ((H // 2) + 1) * cal_large
        ans = ans_low + ans_large
 
print(round(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int answer = 0;
int N = 0;
int M = 0; 
int key, value;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    vector<vector<int>> p;
    cin >> N;
    int T[N];
    for (int i = 0; i < N; ++i) {
        cin >> T[i];
    }
    cin >> M;
    p.resize(M);
    for (int i = 0; i < M; ++i) {
        vector<int> aaa;
        aaa.resize(2);
        cin >> key >> value;
        aaa[0] = key;
        aaa[1] = value;
        p[i] = aaa;
    }

    for (int i = 0; i < M; ++i) {
        answer = 0;
        for (int j = 0; j < N; ++j) {
            if (p[i].at(0) - 1 == j) {
                answer += p[i].at(1);
            } else {
                answer += T[j];
            }
        }
        cout << answer << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    ll n, w;
    cin>>n>>w;
    vl weight(n), value(n);
    forr(i, n)
    cin>>weight[i]>>value[i];
    ll ans[n+1][w+1];
    for(ll i=0; i<=n; i++)
    {
        for(ll j=0; j<=w; j++)
        {
            if(i==0||j==0)
            {
                ans[i][j]=0;
            }
            else if(weight[i-1]<=j)
            {
                ans[i][j]=max(ans[i-1][j-weight[i-1]]+value[i-1], ans[i-1][j]);
            }
            else
                ans[i][j]=ans[i-1][j];
        }
    }
    cout<<ans[n][w];
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 79104
/**
 *    author:  tourist
 *    created: 21.12.2019 21:42:49       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<vector<long long>> dp(n, vector<long long>(n));
  for (int i = n - 1; i >= 0; i--) {
    for (int j = i; j < n; j++) {
      if (i == j) {
        dp[i][j] = a[i];
      } else {
        dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]);
      }
    }
  }
  cout << dp[0][n - 1] << '\n';
  return 0;
}


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

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

    int n, d;
    cin >> n >> d;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        if (1LL * x * x + 1LL * y * y <= 1LL * d * d) ans++;
    }
    cout << ans << endl;
}


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

int main(){
	int n;
	while(cin >> n){
		bool first = true;
		for(int i = 0; i <= 9; i++){
			if((n >> i) & 1){
				if(!first){
					cout << " ";
				}
				cout << (1<<i);
				first = false;
			}
		}
		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 2996
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (a, b, c, d) = (v[0], v[1], v[2], v[3]);
    let mut ans = 0;
    for i in 0..101 {
        if i >= a && i < b && i >= c && i < d {
            ans += 1;
        }
    }
    println!("{}", ans);
}

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

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


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 10000000000LL
#define rep(i,n) for(i=0;i<n;i++)

typedef pair<int,int> pii;

int main(void) {
    while(1){
        int n;
        cin>>n;
        if(n==0)break;
        int len;
        int lenmax=0;
        int i,j,k;
        char str[50][2][60]={};//str[50][0]=name,str[50][1]=code
        rep(i,n){
            scanf("%s",str[i][0]);
            len=(int)strlen(str[i][0]);
            lenmax=max(lenmax,len);
            int now=0;
            str[i][1][now]=str[i][0][0];//first letter
            now++;
            rep(j,len)
                if(str[i][0][j]=='a' || str[i][0][j]=='i' || str[i][0][j]=='u' ||
                   str[i][0][j]=='e' || str[i][0][j]=='o'){
                    str[i][1][now]=str[i][0][j+1];
                    now++;
                }
        }
        int ans;
        for(i=1;i<=lenmax;i++){
            ans=0;
            rep(j,n){
                for(k=j+1;k<n;k++)
                    if(strncmp(str[j][1],str[k][1],i)==0){
                        ans++;
                        break;
                    }//same code
                if(ans)break;//find same name
            }
            if(ans==0){
                cout<<i<<endl;
                ans=-1;
                break;
            }
        }
        if(ans>=0)cout<<"-1"<<endl;
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
ll const INF = INT_MAX;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<P> edges[2510];

void bellmanford(int n,vector<ll>& dist) {
    for (int x = 0;x < n-1;++x) {
        for (int i = 0;i < n;++i) for (P& p : edges[i]) {
            dist[p.first] = min(dist[i]+p.second,dist[p.first]); 
        }
    }
}

int main() {
    int n,m,p;
    cin >> n >> m >> p;
    vector<ll> dist1(2510,INF),dist2;
    for (int i = 0;i < m;++i) {
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        edges[a].push_back(P(b,p-c));
    }
    dist1[0] = 0;
    bellmanford(n,dist1);
    dist2 = dist1;
    bellmanford(n,dist2);
    // p_ary(dist1,0,n,i);
    // p_ary(dist2,0,n,i);
    ll ans = 0;
    if (dist1[n-1] > dist2[n-1]) cout << "-1" << endl;
    else cout << max(0LL,-dist1[n-1]) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int K,A,B;
  cin>>K>>A>>B;
    cout<<max(K+1,(K-A+1)/2*(B-A) +(A) + (K-A+1)%2) <<endl;

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 256
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
void in(int &x);
#define fi first
#define se second
#define pb push_back
using ll = long long;
typedef pair <int , int> ii;
// const int N = ;

int main() {
   int n,m; in(n); in(m);
   vector <double> v(n);
   double sum = 0;
   for (int i = 0 ; i < n ; i++) {
      scanf("%lf" , &v[i]);
      sum += v[i];
   }
   double thres = (sum) / (1.0 * 4 * m);
   int sol = 0;
   for (int i = 0 ; i < n ; i++) {
      if (v[i] >= thres) {
         sol++;
      }
   }
   printf(sol >= m ? "Yes\n" : "No\n");
   return 0;
}

void in(int &x){
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c == '-'){
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	int n,a,b,pass=0,passb=0;
	cin>>n>>a>>b;
	string s;cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]=='c') cout<<"No\n";
		if(s[i]=='a'){
			if(pass<(a+b)){
				pass++;cout<<"Yes\n";
			}
			else {
				cout<<"No\n";
			}
		}
		if(s[i]=='b'){
			if(pass<(a+b)&&passb<b){
				cout<<"Yes\n";pass++;passb++;
			}
			else{
				cout<<"No\n";
			}
		}
	}
}


Measured memory_bytes: 896
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int x,a,b;
  cin >> x >> a >> b;
  if(abs(x - a ) < abs ( x- b))
    cout << "A";
    else cout << "B";
  
  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    string s; cin >> s;
    stack<char> st;
    st.push(s[0]);
    for(int i = 1; i < n; i++){
        if(st.empty()){
            st.push(s[i]);
            continue;
        }
        if(st.top() == '('){
            if(s[i] == '(') st.push(s[i]);
            else st.pop();
        }else{
            st.push(s[i]);
        }
    }
    int left = 0;
    int right = 0;
    while(!st.empty()){
        char c = st.top();
        st.pop();
        if(c == '(')right++;
        else left++;
    }
    string ans = "";
    rep(i,left) ans += '(';
    ans += s;
    rep(j,right) ans += ')';
    cout << ans << endl;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(b <= c) cout << 0 << endl;
    else if(d <= a) cout << 0 << endl;
    else if(a <= c){
        if(b <= d) cout << b - c << endl;
        else cout << d - c << endl;
    }
    else if(c <= a){
        if(b <= d) cout << b - a << endl;
        else cout << d - a << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
sx, sy, tx, ty = list(map(int, input().split()))
ans1 = "U"*(ty-sy)+"R"*(tx-sx)+"D"*(ty-sy)+"L"*(tx-sx)
ans2 = "L"+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"+"R"+"D"*(ty-sy+1)+"L"*(tx-sx+1)+"U"
print(ans1+ans2)

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;


signed main(){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> S(H+2, vector<char>(W+2, '#'));
    rep(i,1,H+1) rep(j,1,W+1) cin >> S[i][j];

    int answer = 0;
    rep(sy,1,H+1) {
        rep(sx,1,W+1) {
            if (S[sy][sx] == '#') continue;
            vector<vector<int>> distances(H+2, vector<int>(W+2, INT_MAX));
            queue<pair<int, int>> que;
            distances[sy][sx] = 0;
            que.push({sy, sx});
            static const vector<int> dx = {-1, 1, 0, 0};
            static const vector<int> dy = {0, 0, -1, 1};
            while (!que.empty()) {
                int y = que.front().first;
                int x = que.front().second;
                que.pop();
                rep(i,0,4) {
                    int ny = y + dy[i];
                    int nx = x + dx[i];
                    if (distances[ny][nx] != INT_MAX || S[ny][nx] == '#') continue;
                    distances[ny][nx] = distances[y][x] + 1;
                    answer = max(distances[ny][nx], answer);
                    que.push({ny, nx});
                }
            }
        }
    }
    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    points = []
    for i in range(n):
        a, b = map(int, input().split())
        points.append((a, b, a + b))

    # print(points)
    points = sorted(points, key=lambda x: x[2], reverse=True)
    # print(points)

    t = 0
    a = 0
    for i, p in enumerate(points):
        if i == 0 or i % 2 == 0:
            t += p[0]
        else:
            a += p[1]

    print(t - a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22956
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,m;
  cin>>n>>m;
  int ans=1900*m+100*(n-m);
  rep(i,m)ans*=2;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	if len(s)%2 == 0 {
		s = s[:len(s)-1]
	}
	for {
		s = s[:len(s)-1]
		if s[:len(s)/2] == s[len(s)/2:] {
			fmt.Println(len(s))
			return
		}
	}
}


Measured memory_bytes: 512
int main(int argc, const char * argv[]) {
    
    int w,h,x,y,r;
    
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    
    if (x - r < 0 || x + r > w || y - r < 0 || y + r > h) {
        printf("No\n");
        return 0;
    }
    
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 584
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

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

int main()
{
	char S[101] = {0};
	int len = 0, i = 0;
	int ans = 0;
	scanf("%s", S);
	len = strlen(S);
	for (i = 0; i < len; i = i+2) {
		if (S[i] == 'R') {

		} else if (S[i] == 'U') {

		} else if (S[i] == 'D') {

		} else {
			ans = -1;
		}
	}
	for (i = 1; i < len; i = i+2) {
		if (S[i] == 'L') {

		} else if (S[i] == 'U') {

		} else if (S[i] == 'D') {

		} else {
			ans = -1;
		}
	}
	if (ans == -1) {
		printf("No\n");
	} else {
		printf("Yes\n");
	}
    return 0;
}


Measured memory_bytes: 128