akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

ll factorialMethod(int k){
    ll sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
        sum %= C;
    }
    return sum;
}

int main(){
    int N, M;
    cin >> N >> M;

    if(abs(N-M) > 1) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = factorialMethod(N) * factorialMethod(M);
    ans %= C;
    if(N == M) ans *= 2;
    ans %= C;

    cout <<  ans << endl;


}

Measured memory_bytes: 3600
s=input()
ls =len(s)
for i in range(ls//2):
    if s[i]!=s[ls-1-i]:
        print("No")
        exit(0)
s1=s[0:(ls-1)//2]
ls1=len(s1)
for i in range(ls1//2):
    if s1[i]!=s1[ls1-1-i]:
        print("No")
        exit(0)
s2=s[(ls+1)//2:]
ls2=len(s2)
for i in range(ls2//2):
    if s2[i]!=s2[ls2-1-i]:
        print("No")
        exit(0)
print("Yes")

Measured memory_bytes: 3064
N = int(input())
AB = []
for _ in range(N):
  AB.append([int(x) for x in input().split()])

def solve():
  current_time = 0
  for work in sorted(AB, key=lambda x: x[1]):
    current_time += work[0]
    if current_time <= work[1]:
      pass
    else:
      return False
  return True

if solve():
  print('Yes')
else:
  print('No')

Measured memory_bytes: 42720
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9
const int MAXN = 100001;

/*struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];*/


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

//-----Template---------
string s;
int main(){
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    cin>>s;
    LL len=s.length(); LL sNum=0;
    for (int i = 0; i < s.length(); ++i) {
        if(s[i]=='S'){
            sNum++;
        }else{//T
            if(sNum>0){
                len-=2;sNum--;
            }
        }
    }
    cout<< len<<endl;

}

Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int N, M, Q, ans;
vector<int> a, b, c, d;
vector<vector<int>> allA;
void solve(int n, int i, vector<int> &A);

int main()
{
    cin >> N >> M >> Q;
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    rep(0, i, Q)
    {
        cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
        a.at(i)--;
        b.at(i)--;
    }
    ans = 0;
    vector<int> A(15, -1);
    solve(0, 1, A);

    for (int i = 0; i < allA.size(); i++)
    {
        int sum = 0;
        for (int j = 0; j < Q; j++)
        {
            if (allA.at(i).at(b.at(j)) - allA.at(i).at(a.at(j)) == c.at(j))
            {
                sum += d.at(j);
            }
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

void solve(int n, int i, vector<int> &A)
{
    if (n == N)
    {
        allA.push_back(A);
        return;
    }
    for (int j = i; j <= M; j++)
    {
        A.at(n) = j;
        solve(n + 1, j, A);
    }
    return;
}

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

int A,B,C,n;
vector<int> l,kekka;
void dfs(int k,int selecta,int selectb,int selectc,int selectnuma,int selectnumb,int selectnumc){
  if(k == n){
    if(selectnuma != 0 && selectnumb != 0 && selectnumc != 0){
      int t = 0;
      t += 10*(selectnuma + selectnumb + selectnumc - 3);
      t += abs(selecta - A) + abs(selectb - B) + abs(selectc - C);
      kekka.push_back(t);
    }
    return;
  }
  else{
    dfs(k+1,selecta+l.at(k),selectb,selectc,selectnuma+1,selectnumb,selectnumc);
    dfs(k+1,selecta,selectb+l.at(k),selectc,selectnuma,selectnumb+1,selectnumc);
    dfs(k+1,selecta,selectb,selectc+l.at(k),selectnuma,selectnumb,selectnumc+1);
    dfs(k+1,selecta,selectb,selectc,selectnuma,selectnumb,selectnumc);
  }
}

int main(){
  cin >> n >> A >> B >> C;
  for(int i = 0;i < n;i++){
    int c;
    cin >> c;
    l.push_back(c);
  }
  dfs(0,0,0,0,0,0,0);
  sort(kekka.begin(),kekka.end());
  cout << kekka.at(0) << endl;
}     

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



int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("maxflow.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int ar[n];
    vector<int> v;
    int cnt=0;
    for(int i=0;i<n;i++){
        v.push_back(i+1);
        cin>>ar[i];
        if(ar[i]!=v.back()){
            cnt++;
        }
    }
    if(cnt<=2){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#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)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int H, W, K; cin >> H >> W >> K;
  string S[H]; int ans[H][W] = {};
  rep(i, H){
    cin >> S[i];
  }
  int cnt = 0;
  rep(i, H){
    rep(j, W){
      if(S[i][j]=='#'){
        cnt ++;
        ans[i][j] = cnt;
        for(int k=i-1; k>=0; k--){
          if(ans[k][j] == 0) ans[k][j] = cnt;
          else break;
        }
      }
    }
  }
  rep(i, H-1){
    rep(j, W){
      if(ans[i+1][j] == 0) ans[i+1][j] = ans[i][j];
    }
  }
  rep(i, W-1){
    if(ans[0][i+1]==0){
      rep(j, H){
        ans[j][i+1] = ans[j][i];
      }
    }
  }
  for(int i=W-1; i>=0; i--){
    if(ans[0][i]==0){
      rep(j, H){
      ans[j][i]=ans[j][i+1];
      }
    }
  }
  rep(i, H){
    rep(j, W){
     if(j!=0) cout << " ";
     cout << ans[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 1280
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
 
long long Ftr(int x){
    if(x == 0) return 1;
    else return ((x % 1000000007) * (Ftr(x - 1) % 1000000007)) % 1000000007;
}
 
int main(){
    int n, m;
    cin >> n >> m;
 
    long long ans = 1;
    if(abs(n - m) <= 1){
        ans *= Ftr(n) % 1000000007;
        ans *= Ftr(m) % 1000000007;
        if(n == m) ans = (ans * 2) % 1000000007;
    }else ans = 0;
    cout << ans % 1000000007 << endl; // modified by hamko
 
    return 0;
}

Measured memory_bytes: 1792
/********************************************************************************
	
	Code by a weak man named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

const int MAXN = 200010;
const ll inf = 1e18;

struct Segment_Tree {
#define ls (x << 1)
#define rs (x << 1 | 1)

	struct Node { ll v1, v2, v3, t; } T[MAXN << 2];

	inline void pushup(int x) {
		T[x].v1 = min(T[ls].v1, T[rs].v1);
		T[x].v2 = min(T[ls].v2, T[rs].v2);
		T[x].v3 = min(T[ls].v3, T[rs].v3);
	}

	inline void Pls(int x, ll v) { T[x].v1 += v, T[x].v2 += v, T[x].v3 += v, T[x].t += v; }
	inline void pushdown(int x) { if(T[x].t) Pls(ls, T[x].t), Pls(rs, T[x].t), T[x].t = 0; }

	inline void build(int x, int l, int r, int p) {
		if(l == r) return p == l ? 0 : T[x].v1 = T[x].v2 = T[x].v3 = inf, T[x].v1 -= l, T[x].v3 += l, void();
		int mid = (l + r) >> 1; build(ls, l, mid, p), build(rs, mid + 1, r, p), pushup(x);
	}

	inline void Add(int x, int l, int r, int L, int R, int v) {
		if(L <= l && r <= R) return Pls(x, v);
		int mid = (l + r) >> 1; pushdown(x);
		if(L <= mid) Add(ls, l, mid, L, R, v);
		if(mid < R) Add(rs, mid + 1, r, L, R, v);
		pushup(x);
	}

	inline void Give(int x, int l, int r, int p, ll v) {
		if(l == r) return T[x].v1 = T[x].v2 = T[x].v3 = v, T[x].v1 -= l, T[x].v3 += l, void();
		int mid = (l + r) >> 1; pushdown(x);
		p <= mid ? Give(ls, l, mid, p, v) : Give(rs, mid + 1, r, p, v);
		pushup(x);
	}

	inline ll Q(int x, int l, int r, int L, int R, int k) {
		if(L <= l && r <= R) return k == 1 ? T[x].v1 : (k == 2 ? T[x].v2 : T[x].v3);
		int mid = (l + r) >> 1; pushdown(x);
		if(R <= mid) return Q(ls, l, mid, L, R, k);
		if(mid < L) return Q(rs, mid + 1, r, L, R, k);
		return min(Q(ls, l, mid, L, R, k), Q(rs, mid + 1, r, L, R, k));
	}

#undef ls
#undef rs
}seg;

int main() {
#ifdef LOCAL
	FILE("");
#endif

	int n = ri, q = ri, A = ri, B = ri, las;

	seg.build(1, 1, n, A), las = B;
	for(int i = 1; i <= q; i++) {
		int x = ri;
		ll f = min(seg.Q(1, 1, n, 1, x, 1) + x, seg.Q(1, 1, n, x, n, 3) - x);
		seg.Give(1, 1, n, las, f);
		if(las > 1) seg.Add(1, 1, n, 1, las - 1, abs(x - las));
		if(las < n) seg.Add(1, 1, n, las + 1, n, abs(x - las));
		las = x;
	} cout << seg.Q(1, 1, n, 1, n, 2);
	return 0;
}

Measured memory_bytes: 18944
#include <stdio.h>
#include <string.h>

int main()
{
    int t, h;
    int n;
    char s1[128], s2[128];
    int c;

    scanf("%d", &n);
    t = h = 0;
    while (n--)
    {
        scanf("%s %s", s1, s2);
        c = strcmp(s1, s2);
        if (c > 0)
            t += 3;
        else if (c < 0)
            h += 3;
        else
            ++t, ++h;
    }
    printf("%d %d\n", t, h);

    return 0;
}


Measured memory_bytes: 2104
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

signed main(){ 
    IOS
    //io_set();
    ll n, k;
    cin >> n >> k;
    vector < ll > v(n+1);
    v[0] = 0;
    fo(i, 1, n){
        cin >> v[i];
        v[i] += v[i-1];
    }
    ll x = upb(all(v), k) - v.begin();
    cout << x << endl;
    return 0;
}



Measured memory_bytes: 256
c;main(n){while(~scanf("%d",&n)){int m[15][15]={0},x=n/2,y=x+1;for(;c<n*n;m[x++%n][y++%n]=++c)for(;m[x%n][y%n];y++)x--;for(y=-1;++y<n;putchar(10))for(c=x=0;x<n;)printf("%4d",m[x++][y]);}exit(0);}

Measured memory_bytes: 0
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

struct Node {
	int a, b, c;
	long long int cost;
	Node(const int aa, const int bb, const int cc, const long long int co) {
		a = aa, b = bb, c = cc, cost = co;
	}
	bool operator<(const Node&n)const {
		return cost > n.cost;
	}
};

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

	cin >> N;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	sort(v.begin(), v.end());
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			for (int k = j + 1; k < N; k++) {
				if (v[i] + v[j] > v[k]&&v[i]!=v[j]&&v[j]!=v[k]) {
					M++;
				}
			}
		}
	}
	cout << M << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

LL dp[1002][1001];
vector<LL> fact;
vector<LL> inver(1001);

LL combination(int n,int r){
    if(n<0||r<0||n<r) return 0;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}

LL fpow(LL a, LL n){
    int x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}

int main(){
    int N;
    cin >> N;
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    LL s=1;
    fact.push_back(1);
    for(int i=1;i<=1000;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[1000]=fpow(fact[1000],mod-2);
    for(int i=999;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
    dp[A][0]=1;
    for(int i=A;i<=B;i++){
        for(int j=0;j<=N;j++){
            LL sum=1;
            (dp[i+1][j]+=dp[i][j])%=mod;
            for(int k=1;k<C;k++){
                (sum*=combination(N-(j+(k-1)*i),i))%=mod;
            }
            for(int k=C;j+k*i<=N&&k<=D;k++){
                (sum*=combination(N-(j+(k-1)*i),i))%=mod;
                (dp[i+1][j+k*i]+=dp[i][j]*sum%mod*(inver[k]%mod))%=mod;
            }
        }
    }
    cout << dp[B+1][N]%mod << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int MAX_N = 5005;
const int MAX_K = 5005;

int N, K;
vector<int> a;
bool dp[MAX_N][MAX_K]; // dp[x][y] := x 枚目をみたとき、総和を y にできるか？

bool solve(int x){

	memset(dp, false, sizeof(dp));
	dp[0][0] = true;
	rep (j, N){
		rep (k, K){
			if (dp[j][k]){
				dp[j+1][k] |= true;
				if (x != j && k + a[j] < K) dp[j + 1][k + a[j]] |= true;
			} // end if
		} // end rep
	} // end rep

	rep (k, K){
		if (dp[N][k] && k + a[x] >= K){	
			return true;
		} // end if
	} // end for

	return false;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> K;
	a.clear(); a.resize(N, 0);
	rep (i, N){
		cin >> a[i];
	} // end rep

	sort(ALL(a));

	// 最小値を求める
	int ok = N;
	int ng = -1;	
	while(abs(ok - ng) > 1){
		int mid = (ok + ng) / 2;
		if (solve(mid)){
			ok = mid;
		}else{
			ng = mid;
		} // end if
	} // end while
	
	cout << ok << endl;

	return 0;
}

Measured memory_bytes: 24704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long N, long long X, std::vector<long long> L){
    int tmp = 0;
    int ans = 1;
    for (int i = 0; i < N; i++)
    {
        tmp+=L[i];
        if(tmp <= X){
            ans++;
        }
    }
    
    cout << ans << endl;
}  

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&L[i]);
    }
    solve(N, X, std::move(L));
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	// 整数の入力
	long n = sc.nextLong();

	String ans = "second";

	for(int i = 1; i <= n; i++){
	    long a = sc.nextLong();
	    if (a % 2 == 1){
		ans = "first";
	    }
	}

	System.out.println(ans);
    }
}





Measured memory_bytes: 48292
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        char[] cs = cin.next().ToCharArray();
        Array.Sort(cs);
        for (int i = 0; i < cs.Length - 1; i++)
        {
            if(cs[i] == cs[i + 1])
            {
                Console.WriteLine("no");
                return;
            }
        }
        Console.WriteLine("yes");
    }
}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();

        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 11604
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define vc vector<char>
#define eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fo(i,x,n) for(int i=x;i<n;i++)
#define csb(x) __builtin_popcount(x)
#define tz(x) __builtin_ctz(x)
#define lsbp(x) __builtin_ffs(x)
#define msbp(x) __lg(x)
#define btoi(str,i) stoi(str,0,i)
#define ff first
#define ss second
#define pie 3.141592653589793238
const int inf=0x3f3f3f3f3f3f3f3f;

void zz(){
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

int32_t main(){
zz();
int n;cin>>n;
double x=2*pie*n*(1.0);
cout<<x<<endl;

}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    string s;
    cin>>n>>s;
    ll mx=LLONG_MIN;
    for(int i=1;i<n;i++)
    {
        string a=s.substr(0,i);
        string b=s.substr(i,n-i);
        set<char>st;
        for(int i=0;i<a.size();i++)
        {
            char x=a[i];
            for(int j=0;j<b.size();j++)
            {
                if(x==b[j])
                {
                    st.insert(x);
                }
            }
        }
        mx=max(mx,(ll)st.size());
        st.clear();
    }
    cout<<mx<<endl;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MOD = 1000 * 1000 * 1000 + 7;
const int MAX = 3030;

int DP[MAX][MAX][2];

void ADD(int& a, int val)
{
	a += val;
	if (a >= MOD) a -= MOD;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

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

	n--; // first red, res *= 2

	m--; // don't count last, res *= 2

	FOR (i, 0, n + 1)
	{
		DP[0][i][i==0] = 1;
	}

	FOR (i, 0, m)
	{
		FOR (j, 0, n + 1)
		{
			FOR (s, 0, 2)
			{
				ADD(DP[i+1][j][s], DP[i][j][s]);
				ADD(DP[i+1][j][s], DP[i][j][s]);

				if (j != n)
				{
					ADD(DP[i+1][j+1][s], DP[i][j][s]);
				}

				if (j != 0)
				{
					ADD(DP[i+1][j-1][s || (j-1 == 0)], DP[i][j][s]);
				}
			}
		}
	}

	LL res = 0;
	FOR (i, 0, n + 1)
	{
		res += DP[m][i][1];
		if (res >= MOD) res -= MOD;
	}

	res *= 4;
	res %= MOD;
	cout<<res<<endl;




}


Measured memory_bytes: 71936
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    for (int i = 0; i < H; i++)
    {
        cin >> a[i];
    }
    
    int delH[H] = {};
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (a.at(i)[j] == '#')
            {
                //cout << "黒だ！";
                break;
            }
            //cout << "白だ！";
            delH[i] += 1;
        }   
        // cout << '\n';
    }

    /* for (int i = 0; i < H; i++)
    {
        cout << delH[i] << endl;
    } */
    
    int delW[W] = {};
    for (int j = 0; j < W; j++)
    {
        for (int i = 0; i < H; i++)
        {
            if (a.at(i)[j] == '#')
            {
                //cout << "黒だ！";
                break;
            }
            //cout << "白だ！";
            delW[j] += 1;
        }   
        // cout << '\n';
    }

    /* for (int j = 0; j < W; j++)
    {
        cout << delW[j] << endl;
    } */
    

    for (int i = 0; i < H; i++)
    {
        if(delH[i] == W) continue;

        for (int j = 0; j < W; j++)
        {
            if (delW[j] != H)
            {
                cout << a.at(i)[j];
            }

        }
        cout << '\n';
    }
    
    return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

const ll dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };

ll H, W, K;
ll x1, x2, y1, y2;
std::string fld[1000010];

int main() {
  std::cin >> H >> W >> K;
  std::cin >> x1 >> y1 >> x2 >> y2;
  --x1; --y1; --x2; --y2;

  std::vector<std::vector<ll>> dist( H, std::vector<ll>( W, INF ) );

  rep( i, H ) {
    std::cin >> fld[i];
  }

  dist[x1][y1] = 0;

  std::queue<P> que;
  que.emplace( x1, y1 );

  while( !que.empty() ) {
    P p = que.front(); que.pop();
    ll i = p.first, j = p.second;

    if( i == x2 && j == y2 ) {
      std::cout << dist[i][j] << std::endl;

      return 0;
    }
  
    rep( d, 4 ) repi( len, 1, K+1 ) {
      ll ni = i+dy[d]*len, nj = j+dx[d]*len;

      if( !(ni >= 0 && ni < H && nj >= 0 && nj < W) )
        break;

      if( fld[ni][nj] == '@' )
        break;

      if( dist[ni][nj] != INF && dist[i][j] >= dist[ni][nj] )
        break;

      if( dist[ni][nj] != INF )
        continue;

      dist[ni][nj] = dist[i][j]+1;
      que.emplace( ni, nj );
    }
  }

  std::cout << -1 << std::endl;

  return 0;
}

Measured memory_bytes: 50248
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int t = (h2-h1)*60 + (m2 - m1);
  cout << t-k << endl;
}

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

int main(){
	while(1){
        int l; cin >> l;
        if(l==0) break;

        int n, m; cin >> n >> m;
        vector<int> d(n+1), k(m);
        d[0]=0, d[n]=l;
        for(int i=1; i<n; i++) cin >> d[i];
        for(int i=0; i<m; i++) cin >> k[i];
        sort(d.begin(), d.end());

        int ans=0;
        for(int i : k){
            int itr=distance(d.begin(), lower_bound(d.begin(), d.end(), i));
            ans += min(d[itr]-i, i-d[itr-1]);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3280
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.io.PrintWriter;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        long N = scan.nextLong();
        long A = scan.nextLong();
        long B = scan.nextLong();

        if(A+B-1>N || A*B<N){
            System.out.println(-1);
            return;
        }

        List<Long> ansList = new ArrayList<>();
        long n=0,m=0,l=0;
        if(B>1){
            n=(N-A)/(B-1);
            m=A-n-1;
            l=N-n*B-m;
        }else{
            m=A;
        }
 
        // for(int i=1;i<=N;++i){
        //     if(N-i*B <= (A-i-1)+B){
        //         n=i;
        //         m=A-i-1;
        //         l=N-n*B-m;
        //         break;
        //     }
        // }



        for(long i=0;i<n;++i){
            for(long j=B;j>0;--j)ansList.add(i*B+j);
        }
        for(long i=n*B+l;i>n*B;--i)ansList.add(i);
        for(long i=n*B+l+1;i<=N;++i)ansList.add(i);
        PrintWriter pw = new PrintWriter(System.out);
        for(int i=0;i<N;++i)pw.print(ansList.get(i)+(i==N-1 ? "\n":" "));
        pw.flush();pw.close();
    }
}

Measured memory_bytes: 66060
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
int main()
{
  //flash;
  string sal;
  cin>>sal;
  int asn=0;
  for (int i = 0; i < sal.size()/2; ++i)
  {
    if(sal[sal.size()-i-1]!=sal[i])asn++;
  }
  cout<<asn;
  return 0;
}
//code the AC sol !
// BS/queue/map


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val k = readLine()!!.split(" ").map { it.toInt() }[0]
    var count = 0
    for (a in 1..k){
        for (b in 1..k){
            var gcdAandB = 0
            var x = a
            var y = b
            for (i in 0..300){
                if (x == 0){
                    gcdAandB = y
                    break
                } else if (y == 0){
                    gcdAandB = x
                    break
                } else if (x > y){
                    x = x % y
                } else if(x == y){
                    gcdAandB = x
                    break
                } else {
                    y = y % x
                }
            }
            for (c in 1..k){
                var z = c
                var xy = gcdAandB
                for (i in 0..300){
                    if (z == 0){
                        count += xy
                        break
                    } else if (xy == 0) {
                        count += z
                        break
                    } else if (z > xy){
                        z = z % xy
                    } else if (z == xy){
                        count += z
                        break
                    } else {
                        xy = xy % z
                    }
                }
            }
        }
    }
    println(count)
}

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

int main(){

  int r, deg, theta;
  double x, y, rad;

  x = 0.0;
  y = 0.0;
  theta = 0;
  rad = M_PI / 180;
  do{
    scanf("%d, %d", &r, &deg);
    if(r == 0 && deg == 0) break;
  	x += r * cos(theta * rad);
  	y += r * sin(theta * rad);
    theta = theta + deg;
  }while(1);

  cout << (int)y << endl << (int)x << endl;

  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;

void solve()
{
	int n;
	cin>>n;
	ll sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3!=0 && i%5!=0)
			sum+=i;
	}
	cout<<sum;
}
 
int main()
{
    NFS
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		solve();
 	}
    return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main(){
  int n; cin >> n;
  vector<int> L(n+1);
  rep(i,n) cin >> L[i];
  L[n] = INF;
  sort(L.begin(), L.end());
  int ans = 0;
  for (int i=0; i<n-2; i++){
    for (int j=i+1; j<n-1; j++){
      for (int k=j+1; k<n; k++){
        if (L[k] < L[i] + L[j]) ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;


signed main() {
	ios::sync_with_stdio(false);
	int i, j;
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans =  min(b, d) - max(a, c);
	if (ans >= 0)
		cout << ans << endl;
	else
		cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 764
/*
        karmany evadhikaras te
        ma phalesu kadacana 
        ma karma-phala-hetur bhur
        ma re sango'stv akarmani (B.G.-2.47)
 
Translation:
        Lord Krsna to Arjuna.
You have a right to perform your prescribed duty, 
but you are not entitled to the fruits of action. 
Never consider yourself the cause of the results of your activities, 
and never be attached to not doing your duty.    
*/
#include <bits/stdc++.h>

using namespace std;
#define ll long long
const int N = 1005;
const ll mod = 2000000011;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 10000000;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
//1. Ends here

//2. Extra Functions here
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}

void solve()
{
    
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    int n=s.length();
    int a[n];
    a[0]=1;

    int ten=1;
    int now=0;
    int cnt[2019]={0};

    cnt[0]++;

    for(int i=0;i<n;i++){
        now+=(s[i]-'0')*ten;
        now%=2019;
        cnt[now]++;
        ten*=10;
        ten%=2019;
    }

    ll ans=0;

    for(int i=0;i<2019;i++){
        ans+=(cnt[i]*(cnt[i]-1))/2;
    }

    cout<<ans;

    return;
}
// how r u bro

Measured memory_bytes: 3800
import math

x, y, a, b, c = map(int, input().split(" "))
qL = sorted(list(map(int, input().split(" "))), reverse=True)[:x]
pL = sorted(list(map(int, input().split(" "))), reverse=True)[:y]
rL = sorted(list(map(int, input().split(" "))), reverse=True)

print(sum(sorted(qL + pL + rL, reverse=True)[:x + y]))


Measured memory_bytes: 22456
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<limits.h>
#include<float.h>

int gcm(int a, int b){
	int d;
	if(a<b){
		int tmp = a;
		a = b;
		b = tmp;
	}
	d = a%b;
	while(d){
		a = b;
		b = d;
		d = a % b;
	}
	return b;
}

int main(){
	int n, a, g;
	scanf("%d\n", &n);
	for(int i=0; i<n; i++){
		scanf("%d", &a);
		if(i==0) g = a;
		else g = gcm(g, a);
	}
	printf("%d", g);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long long N,A,B,C,D,E;
int main(){
  cin >> N >> A >> B >> C >> D >> E;
  vector<long long> data(5,0);
  data[0] = A;
  data[1] = B;
  data[2] = C;
  data[3] = D;
  data[4] = E;

  int min_idx = min_element(data.begin(),data.end()) - data.begin();
  long long min_v = data[min_idx];
  long long ret = 0;
  ret = 4 + (N + min_v - 1) / min_v;
  cout << ret << endl;
}


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

int main() {
	int a, b, n;
	int  ans = 0;
	cin >> a >> b;
	n = b - a;
	for (int i = 0; i < n; i++) {
		ans += i;
	}
	cout << ans - a<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


#define huge 1000000007
typedef long long ll;

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll K = 0;
	ll T = 0;
	ll X = 0;
	//ll m[100000] = {};
	//ll p[100] = {};
	//ll x[100] = {};
	ll *x, *c, *d;
	//string S,T,U;
	ll count = 0;
	ll sum = 0;
	ll min = 1;
	ll max = 0;
	int flag = 0;
	//char p;
	cin >> N >> T;
	
	x = (ll *)malloc(N * sizeof(ll));

	rep(i, 0, N) {
		cin >> x[i];
	}

	rep(i, 0, N-1) {

		if (x[i + 1] - x[i] < T) {
			sum += x[i + 1] - x[i];
		}
		else {
			sum += T;
		}
		//cout << sum << endl;
	}

	sum += T;
		cout << sum << endl;


	return 0;

}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define vvdebug(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	int r, g, b; cin >> r >> g >> b;
	bool f = (10 * g + b) % 4 == 0;
	YN(f);	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  string s;
  ll c=0,t;
  cin >> t;
  cin >> s;
  rep(i,s.length()){
    if(s[i]=='R')c++;
    if(s[i]=='B')c--;
  }
  if(c>0)printf("Yes");
  else printf("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n,m,a[50+2],ans;
bool cmp (int c1,int c2)
{
	return c1 > c2;
}
int main()
{
	cin >> n >> m;
	for (int i = 1;i <= n;i++)
	{
		cin >> a[i];
	}
	sort (a+1,a+n+1,cmp);
	for (int i = 1;i <= m;i++)
	{
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
#define pi acos(-1);
ll strtoint(string str);
int main(){
	fast;
	ll a,b,c,k,s=0; cin>>a>>b>>c>>k;
	if(k>=a){
		s+=a;
		k-=a;
		if(k>=b)k-=b;
		else{
			cout<<s<<'\n';
			return 0;
		}
		if(k>=c){
			k-=c;
			s-=c;
		}else{
			s-=k;
			cout<<s<<'\n';
			return 0;
		}
		cout<<s<<'\n';
	}else{
		cout<<k<<'\n';
	}
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
		if(s[i]!=',')
			cout<<s[i];
		else
			cout<<" ";
	return 0;
}



Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define ll long long
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl;
using namespace std;

int n,k;
int a[105];
int memo[100005][2];

int dp(int rem,int move){
    if(rem<0) return 1;
    if(memo[rem][move]!=-1)
        return memo[rem][move];
    int flag=0;
    for(int i=0;i<n;++i){
        int ret;
        ret=dp(rem-a[i],move^1);
        if(ret==0)
            flag=1;
    }
    return memo[rem][move]=flag;
}

int main(){
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;++i) scanf("%d",&a[i]);
    memset(memo,-1,sizeof memo);
    if(dp(k,0))
        printf("First\n");
    else
        printf("Second\n");
    return 0;
}


Measured memory_bytes: 8832
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
 
 
 
int main(){
    
    int n,a[100];
    double sum=0;
    ll ans=0;
    
    cin>>n;
    rep(i,0,n){
        cin>>a[i];
        sum+=a[i];
    }
    sum=round(sum/n);
    rep(i,0,n){
        ans+=(a[i]-sum)*(a[i]-sum);
    }
    cout<<ans<<endl;
    
    return 0;
}

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

char* keta[]={"","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan",
	"Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"};
int kazu[18];
int m,n;

int main(){
	int i,j;
	int tmp,kuriage;

	while(cin>>m>>n,m && n){
		for(i=0;i<18;i++){
			kazu[i]=0;
		}
		kazu[0]=1;
		kuriage=0;
		for(i=0;i<n;i++){
			for(j=0;j<18;j++){
				tmp=kazu[j]*m+kuriage;
				kuriage=tmp/10000;
				kazu[j]=tmp%10000;
			}
		}
		for(i=17;0<=i;i--){
			if(kazu[i]==0) continue;
			cout<<kazu[i]<<keta[i];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3076
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long X = sc.nextLong();
    long Y = sc.nextLong();
    
    int ans = 0;
    long A = X;
    while (A <= Y) {
      A *= 2;
      ans++;
    }
     
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int a[10001],b;
long long magic_number_that_can_be_used=0;
long long magic_number_that_you_need=0;
int main()
{
	int n,i;
	scanf("%d",&n);
	//printf("%d",n/2);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=0;i<n;i++)
	{
		scanf("%d",&b);
		if(a[i]<b)
		{
			if((b-a[i])%2==1)
			{
				b++;
				magic_number_that_you_need++;
			}
			magic_number_that_can_be_used+=(b-a[i])/2;
		}
		else
			magic_number_that_you_need+=a[i]-b;
		//printf("need=%d used=%d\n",magic_number_that_you_need,magic_number_that_can_be_used);
	}
	if(magic_number_that_you_need<=magic_number_that_can_be_used)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double N;
  cin>>N;
  double a=0;
  int i=1;
  for(;i<N+1;i++){
    if(i%2==1){
      a++;
    }
  }
  double b=a/N;
  cout<<b;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)
//辺の情報を個別に持つタイプ

ll a[99];
ll temp[99];
int main(){
	//左からl個、右からr個と取ってそのうちx個捨てる
	ll n,k;
	scanf("%lld%lld",&n,&k);
	rep(i,0,n)scanf("%lld",a+i);
	ll ans=0;
	rep(l,0,k+1)rep(r,0,k+1)if(l+r<=n&&l+r<=k){
		ll cnt=0;
		rep(i,0,l)temp[cnt++]=a[i];
		rep(i,0,r)temp[cnt++]=a[n-1-i];
		sortup(temp,cnt);
		ll tans=0,tesuu=cnt;
		rep(i,0,cnt){
			if(temp[i]<0&&tesuu<k){
				tesuu++;
			}else{
				tans+=temp[i];
			}
		}
		ans=max(ans,tans);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool fa[26],fb[26];
char pa[26],pb[26];
int main() {
  string a,b;
  cin>>a>>b;
  bool ans=1;
  for(int i=0;i<a.size();i++){
    ll x=(a[i]-'a');
    if(fa[x]){
      if(b[i]!=pa[x])ans=0;
    }else{
      pa[x]=b[i];
      fa[x]=1;
    }
    x=(b[i]-'a');
    if(fb[x]){
      if(a[i]!=pb[x])ans=0;
    }else{
      pb[x]=a[i];
      fb[x]=1;
    }
  }
  cout<<(ans?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 776