akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

const int MAX = 100;

int selection_sort(int a[], int n) {
    int count = 0;
    for (int i = 0; i < n-1; ++i) {
        int min_j = i;
        for (int j = i+1; j < n; ++j) {
            if (a[j] < a[min_j]) min_j = j;
        }
        if (min_j != i) {
            int t = a[i]; a[i] = a[min_j]; a[min_j] = t;
            ++count;
        }
    }
    return count;
}

int main() {
    int N;
    int a[MAX];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];
    int count = selection_sort(a, N);
    for (int i = 0; i < N; ++i) {
        if (i) cout << " ";
        cout << a[i];
    }
    cout << endl << count << endl;

    return 0;
}

Measured memory_bytes: 3100
# -*- coding utf-8 -*-

MOD = 10 ** 9 + 7

N = int(input())
S = input()

strs = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
        'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']

ans = []
for s in S:
    ans.append(strs[(strs.index(s)+N) % 26])

print(''.join(ans))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    string S, T;
    cin >> S >> T;

    bool flag = false;
    for (int i = (int)S.size() - 1; i >= 0; i--) {
        string tmp = "";
        for (int j = i; j < S.size(); j++) {
            tmp += S[j];
        }
        for (int j = 0; j < i; j++) {
            tmp += S[j];
        }
        if (tmp == T) {
            flag = true;
            break;
        }
    }

    cout << ((flag) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	int N,K;
	cin>>N>>K;
	int V[55];
	rep1(i,N)cin>>V[i];
	
	int ans=0;
	rep(i,N+1)rep(j,N+1)if(i<=j){
		vi z;
		int ti=0;
		int sm=0;
		rep1(k,N)if(k<=i || j<k){
			ti++;
			sm+=V[k];
			z.push_back(V[k]);
		}
		if(ti>K)continue;
		
		sort(z.begin(),z.end());
		rep(l,sz(z)){
			if(ti>=K)break;
			if(z[l]>=0)break;
          
			if(z[l]<0){
				sm-=z[l];
				ti++;
			}
		}
//		if(ans<sm)cout<<i<<" "<<j<<endl;
		ans=max(ans,sm);
	}
	cout<<ans;
	
}

Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim();
  var r = Number(inputs);
 
  console.log(
    Math.PI * Math.pow(r,2)
    , 2 * Math.PI * r
  );
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

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

int N,M;
vector<vector<int>> sk;
vector<int> p;
int total=0;
void dfs(int n, vector<int> s){
    if(n==N){
        bool is_ok = true;
    // cout << "2:" << endl;

        for(int i=0;i<M;i++){
            int cnt =0;
            for(int j=0;j<sk[i].size();j++){
                if(s[sk[i][j]])cnt++;
            }
            if((p[i]==0 && cnt%2!=0) || (p[i]==1 && cnt%2==0)){
                is_ok = false;
                break;
            }
        }
        if(is_ok)total++;
        return;
    }
    dfs(n+1,s);
    s[n]=1;
    dfs(n+1,s);
}

int main(int argc, char const *argv[])
{
    cin>>N>>M;
    sk.resize(M);
    p.resize(M);
    for(int i=0;i<M;i++){
        int k;cin>>k;
        for(int j=0;j<k;j++){
            int s;cin>>s;
            sk[i].push_back(s-1);
    // cout << "00:" << endl;
        }
    }
    // cout << "0:" << endl;
    for(int i=0;i<M;i++)cin>>p[i];
    vector<int> s(N+1,0);
    // cout << "1:" << endl;
    dfs(0, s);
    cout << total << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define INF 2e9
#define IMAX 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long llong;

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

	if (A > W / 2) {
		cout << "No" << endl;
		return 0;
	}
	if (B > H / 2) {
		cout << "No" << endl;
		return 0;
	}

	REP(hIdx, H) {
		REP(wIdx, W) {
			if (hIdx < B && wIdx < A) {
				cout << "1";
			} else if (hIdx >= B && wIdx >= A) {
				cout << "1";
			} else {
				cout << "0";
			}
		}
		cout << endl;
	}

	return 0;
}


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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<int> x(n, 0);
	vector<int> y(n, 0);
	vector<long long> h(n, 0);

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

	bool finflg = true;
	for (int cx = 0; cx < 101; cx++) {
		for (int cy = 0; cy < 101; cy++) {

			finflg = true;
			long long karih = 0;
			int counter = 0;
			for (int i = 0; i < n; i++) {
				if (h[i] != 0 && counter == 0) {
					karih = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
					counter = 1;
				}
				else if (h[i] != 0) {
					if (karih != h[i] + abs(x[i] - cx) + abs(y[i] - cy)) {
						finflg = false;
						break;
					}
				}
			}
			for (int i = 0; i < n; i++) {

				if (h[i] == 0 ) {
					if (karih - abs(x[i] - cx) - abs(y[i] - cy)>0) {
						finflg = false;
						break;
					}
				}

			}
			if (finflg==true) {
				cout << cx << " " << cy << " " << karih << endl;
				return 0;
			}

		}
	}

}

Measured memory_bytes: 256
/****************************************************************************
Is this the real life? Is this just fantasy?
Caught in a landslide, no escape from reality
Open your eyes, look up to the skies and see
I'm just a poor boy, I need no sympathy
Because I'm easy come, easy go, little high, little low
Any way the wind blows doesn't really matter to me, to me!!!
--------------------------------------------------
CP is quite cool.It becomes cooler when you enjoy learning new things
******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define pool(i,a,b) for(int i=a;i>=b;i--)
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(a) a.size()
#define ff first
#define ss second
#define debug(x) cout<<#x<<" = "<<x<<endl;
const int mod=1e9+7;

ll binpowmod(ll a, ll b,ll p=mod) 
{
  a%=p;
  ll res = 1;
  while (b > 0) 
  {
    if (b & 1)
      res = (res * a)%p;
    a = (a * a)%p;
    b >>= 1;
  }
  return res%p;
}
//FERMAT INVERSE
ll inv(ll x)
{
  int p=1e9+7;  
  /*you can change fixed mod value here*/                       
  return binpowmod(x,p-2,p);
}

void solve()
{
  ll s;
  cin>>s;
  ll dp[s+1];
  for(int i=0;i<=s;i++)
  {
    if(i<3)
      dp[i]=0;
    else
    {
      dp[i]=1;
      for(int j=0;j<=i-3;j++)
      {
        dp[i]+=dp[j];
        dp[i]%=mod;
      }
    }
  }

  cout<<dp[s]<<endl;

} 

int main()
{

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

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

  int t=1;
  // cin>>t;
  while(t--)
  {
    solve();
  }

  return 0;
}


Measured memory_bytes: 3656
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n, a, max = 0, min = 1000000000;
		
		n = Integer.parseInt(sc.next());
		
		for (int i = 0; i < n; i++) {
			a = Integer.parseInt(sc.next());
			max = max < a ? a : max;
			min = min > a ? a : min;
		}
		
		System.out.println(max - min);
	}
}

Measured memory_bytes: 21716
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
ll n, a, b;

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

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

	cin >> n >> a >> b;
	cout << n / (a + b)*a +min(a,n%(a+b)) << endl;
}

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

int main() {
  int sides[3];
  int num;

  cin >> num;
  int sumSidesSq=0;
  for(int i=0; i<num; i++) {
    int maxIndex=0, maxValue=0;
    for(int j=0; j<3; j++) {
      cin >> sides[j];
      if(sides[j] > maxValue) {
        maxValue = sides[j];
        maxIndex = j;
      }
    }

    sumSidesSq = 0;
    for(int j=0; j<3; j++) {
      if(j == maxIndex)
        sumSidesSq -= sides[j]*sides[j];
      else
        sumSidesSq += sides[j]*sides[j];
    }
    cout << ( (sumSidesSq == 0) ? "YES" : "NO" ) << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <climits>
#include <functional>
#include <iterator>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#ifdef _MSC_VER
using ll = __int64;
using ull = unsigned __int64;
#else
using ll = long long int;
using ull = unsigned long long int;
#endif

// ここから解法
ll N, A, B, C, D;
string S;

int main(void) {
	std::ios_base::sync_with_stdio(false);

	cin >> N >> A >> B >> C >> D;
	S.resize(N + 1);
	for (ll i = 1; i <= N; ++i) cin >> S[i];

	auto solve = [&]()
	{
		for (ll i = A + 1; i <= C; ++i)
			if (S[i] == '#' && S[i - 1] == '#') return false;
		for (ll i = B + 1; i <= D; ++i)
			if (S[i] == '#' && S[i - 1] == '#') return false;

		if (C > D)
		{
			for (ll i = B; i <= D; ++i)
				if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') return true;
			return false;
		}
		return true;
	};
	cout << (solve() ? "Yes" : "No") << endl;

	return 0;
}


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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N;  cin >> N;
	int A[2][100];
	for(int i = 0 ; i < 2 ; i++)
	 for(int j = 0 ; j < N ; j++)  cin >> A[i][j];

	int dp[2][100];  dp[0][0] = A[0][0];
	for(int i = 1 ; i < N ; i++)  dp[0][i] = dp[0][i - 1] + A[0][i];

	dp[1][0] = dp[0][0] + A[1][0];
	for(int i = 1; i < N ; i++)  dp[1][i] = max(dp[1][i - 1] + A[1][i], dp[0][i] + A[1][i]);

	cout << dp[1][N - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        if (X == 7 || X == 5 || X == 3) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
        sc.close();
    }
}

Measured memory_bytes: 23124
#!/usr/bin/env python3


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    a = input()
    print("A" if a.isupper() else "a")

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 1000 + 7;

int n;

bool read () {
	if (scanf("%d", &n) != 1)
		return false;
	return true;
}

int a[10][10];
string b[10][10];
bool fl;

void brute(int x, int y, int lst, int val){
	if (lst > 2 * n)
		return;
	if (val != -1 && val != 3 && n != 3)
		return;
	if (fl)
		return;
	if (y == n){
		auto cur = set<int>(a[x], a[x] + n);
		if (cur.count(-1)) cur.erase(-1);
		if (val == -1) val = sz(cur);
		if (val != sz(cur)) return;
		++x;
		y = 0;
	}
	if (x == n){
		forn(i, n){
			set<int> cur;
			forn(j, n) cur.insert(a[j][i]);
			if (cur.count(-1)) cur.erase(-1);
			if (val != sz(cur)) return;
		}
		if (lst == 0) return;
		if (lst != 2 * n && n != 3) return;
		forn(i, n) forn(j, n)
			b[n][i] += (a[i][j] == -1 ? '.' : ('a' + a[i][j]));
		fl = true;
		return;
	}
	brute(x, y + 1, lst, val);
	if (y != n - 1 && a[x][y] == -1 && a[x][y + 1] == -1){
		a[x][y] = a[x][y + 1] = lst;
		brute(x, y + 2, lst + 1, val);
		a[x][y] = a[x][y + 1] = -1;
	}
	if (x != n - 1 && a[x][y] == -1 && a[x + 1][y] == -1){
		a[x][y] = a[x + 1][y] = lst;
		brute(x, y + 1, lst + 1, val);
		a[x][y] = a[x + 1][y] = -1;
	}
}

string ans[N];

void get(int n, int x){
	if (n < 8){
		fore(i, x, x + n) ans[i] += b[n][i - x];
		return;
	}
	int n1 = n / 2;
	int n2 = n - n1;
	get(n1, x);
	fore(i, x, x + n1) ans[i] += string(n2, '.');
	fore(i, x + n1, x + n) ans[i] += string(n1, '.');
	get(n2, x + n1);
}

void solve() {
	if (n == 2){
		puts("-1");
		return;
	}
	
	int nn = n;
	fore(k, 3, 8){
		n = k;
		forn(i, n) forn(j, n)
			a[i][j] = -1;
		fl = false;
		brute(0, 0, 0, -1);
	}
	
	n = nn;
	get(n, 0);
	
	forn(i, n) puts(ans[i].c_str());
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if(read()) {
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 3200
//https://atcoder.jp/contests/abc130/submissions/5989742
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
    bool operator<(const mint a){
        return x < a.x;
    }
};

mint dp0[2005][2005];
mint dp1[2005][2005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> s(n+1), t(m+1);
    rep(i,n) cin >> s[i];
    rep(i,m) cin >> t[i];
    dp0[0][0] = 1;
    rep(i,n+1)rep(j,m+1){
        dp0[i+1][j] += dp0[i][j];
        dp1[i][j] += dp0[i][j];
        dp1[i][j+1] += dp1[i][j];
        if(s[i] == t[j]){
            dp0[i+1][j+1] += dp1[i][j];
        }
    }
    mint ans = dp1[n][m];
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 66492
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define int long long
#define Fast_IO ios::sync_with_stdio(false);
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
int ans;
int query(int x)
{
	printf("? %lld\n",x);
	fflush(stdout);
	char s[3];
	scanf("%s",s);
	if(s[0]=='Y') return 1;
	return 0;
}
signed main()
{
#ifdef __LOCAL__
//	freopen("in.txt","r",stdin);
#endif
	int ans=1e9;
	int x=query(ans);
	if(x==1)
	{
		while(1)
		{
			ans--;
			int x=query(ans);
			if(x==0)
			{
				printf("! %lld\n",ans+1);
				return 0;
			}
			if(ans==9)
			{
				printf("! %lld\n",1);
				return 0;
			}
			ans++;
			ans/=10;
		}
	}
	while(1)
	{
		ans/=10;
		int x=query(ans);
		if(x==1) break;
	}
	int l=ans+1,r=ans*10-1,res;
	while(l<=r)
	{
		int mid=(l+r)/2;
		int x=query(mid*10);
		if(x==1)
		{
			r=mid-1,res=mid;
		}
		else l=mid+1;
	}
	printf("! %lld\n",res);
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 596
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	s := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s[i])
	}

	dp := [110][10100]bool{}
	dp[0][0] = true

	ans := 0
	for i := 0; i < n; i++ {
		for j := 0; j <= 10000; j++ {
			if dp[i][j] {
				dp[i+1][j] = true
				dp[i+1][j+s[i]] = true

				nj := j + s[i]
				if ans < nj && nj%10 != 0 {
					ans = nj
				}
			}
		}
	}

	fmt.Println(ans)
}


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

using namespace std;

using mbin_t = uint64_t;

std::string mbinToBinStr(mbin_t n) {
  if (!n) {
    return "0";
  }
  std::string ret;
  ret.reserve(32);
  do {
    ret.push_back('0' + (n & 1));
    n >>= 1;
  } while (n);
  std::reverse(ret.begin(), ret.end());
  return ret;
}

int64_t mbinToInt(mbin_t mbin) {
  int64_t ret = 0;
  int64_t digit = 1;
  while (mbin) {
    if (mbin & 1) {
      ret += digit;
    }
    digit *= -2;
    mbin >>= 1;
  }
  return ret;
}

mbin_t calcMbin(int64_t n) {
  if (!n) {
    return 0b0LL;
  }
  if (n == 1) {
    return 0b1LL;
  }

  mbin_t ret = 0;
  int64_t digit = 1;
  mbin_t mbin = 1;
  int64_t previousMod = 0;
  int64_t min = 0;
  int64_t max = 0;
  while (true) {
    if (digit > 0) {
      max += digit;
    } else {
      min += digit;
    }
    int64_t mod = n % (digit * 2);
    if (mod != previousMod) {
      if (mod > max) {
        mod -= abs(digit * 2);
      } else if (mod < min) {
        mod += abs(digit * 2);
      }
      if (mbinToInt(ret | mbin) == mod) {
        ret |= mbin;
      }
      previousMod = mod;
    }
    if (abs(n * 16) < abs(digit)) {
      break;
    }
    digit *= -2;
    mbin *= 2;
  }
  return ret;
}

int main() {
  int n;
  std::cin >> n;
  std::cout << mbinToBinStr(calcMbin(n)) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

bool isPrime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

int main() {
    ll p, q;
    cin >> p >> q;
    ll tar = q / gcd(p, q);

    if (isPrime(tar)) {
        cout << tar << endl;
        return 0;
    }

    ll ans = 1;
    for (ll i = 2; i * i <= tar; i++) {
        if (tar % i == 0) {
            ans *= i;
            while (tar % i == 0) {
                tar /= i;
            }

            if (isPrime(tar)) {
                ans *= tar;
                break;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
using namespace std;
int main(){
    string s;
    cin >> s;
    int a[4] = {0,0,0,0};
    for(int i = 0;i<s.size();i++){
        if(s[i] == 'N'){
            a[0]++;
        }
        else if(s[i] == 'S'){
            a[1]++;
        }
        else if(s[i] == 'W'){
            a[2]++;
        }
        else{
            a[3]++;
        }
    }
    if(a[0] == a[1] || a[0]*a[1] != 0){
        if(a[2] == a[3] || a[2]*a[3] != 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	char c; 
	double X,Y,x1,x2,y1,y2,xp,yp,a,b;
	while(cin>>x1>>c>>y1>>c>>x2>>c>>y2>>c>>xp>>c>>yp){
		if(y1==y2){
			a=xp;
			if(yp>y1)
				b=y1-(yp-y1);
			else
				b=2*y1-yp;
		}
		else if(x1==x2){
			b=yp;
			if(xp>x1)
				a=x1-(xp-x1);
			else
				a=2*x1-xp;
			
		}
		else{
			X=x2-x1;
			Y=y2-y1;
			b=(Y*Y*yp+2*xp*X*Y-2*x1*X*Y+2*y1*X*X-yp*X*X)/(X*X+Y*Y);
			a=Y*(yp-b)/X+xp;
		}
		printf("%.6lf %.6lf\n",a,b);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        System.out.print("");
        String str = scanner.nextLine();

        if(Character.isUpperCase(str.charAt(0))){
            System.out.println("A");
        }else{
            System.out.println( "a" );
        }
    }

}


Measured memory_bytes: 35672
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
#define INF 1e9
using ll = int64_t;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

//10^9 + 7
#define yojo 1000000007

std::int64_t gcd(std::int64_t a, std::int64_t b) {
  // a >= b && b != 0
  std::int64_t c;
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb) {
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0) {
    return -1;
  }
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
void rle(std::vector<std::pair<char, std::int64_t>> &data, std::string str) {
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++) {
    if (i == str.size()) {
      data.push_back(make_pair(str[i - 1], count));
      break;
    } else if (now != str[i]) {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return;
}

#define MAX_NUM 200001

void Main() {
  //自動整形防止用コメント
  int n;
  int p[30];
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> p[i];
  }
  int counter = 0;
  
  for (int i = 0; i < n - 2; i++)
  {
    int num_min = min({p[i], p[i+ 1], p[i + 2]});
    int num_max = max({p[i], p[i + 1], p[i + 2]});

    if (p[i + 1] != num_min && p[i + 1] != num_max)
    {
      counter++;
    }
    
  }
  
  std::cout << counter << std::endl;
  
  return;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Card { int value; char c; };
bool comp(const Card& l, const Card& r){ return l.value < r.value; }
int N;
Card stable[36];
Card tmp[36];
Card C[36];


void Out() {
	cout << C[0].c << C[0].value;
	for (int i = 1; i < N; i++)
		cout << ' ' << C[i].c << C[i].value;
	cout << endl;
	bool res = true;
	for (int i = 0; i < N; i++) {
		if (C[i].c != stable[i].c) {
			res = false;
		}
	}
	if (res)
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
}

void BubbleSort() {
	bool flag = true;
	while (flag) {
		flag = false;
		for (int i = N - 1; i >= 0; i--) {
			if (comp(C[i], C[i - 1])) {
				Card ca = C[i];
				C[i] = C[i - 1];
				C[i - 1] = ca;
				flag = true;
			}
		}
	}
}

void SelectionSort() {
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i; j < N; j++) {
			if (comp(C[j], C[minj])) {
				minj = j;
			}
		}
		if (i != minj) {
			Card ca = C[i];
			C[i] = C[minj];
			C[minj] = ca;
		}
	}
}

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> C[i].c >> C[i].value;
		stable[i].c = tmp[i].c = C[i].c;
		stable[i].value = tmp[i].value = C[i].value;
	}
	stable_sort(stable, stable + N, comp);
	BubbleSort();
	Out();
	for (int i = 0; i < N; i++) C[i] = tmp[i];
	SelectionSort();
	Out();
	return 0;
}

Measured memory_bytes: 3160
def patisserie_ABC(N: int, M: int, XYZ: list) -> int:
    ans = 0
    for n in range(8):
        d1 = 1 if n % 2 > 0 else -1
        d2 = 1 if (n // 2) % 2 > 0 else -1
        d3 = 1 if (n // 4) % 2 > 0 else -1

        sorted_XYZ = sorted([
            d1*x + d2*y + d3*z for x, y, z in XYZ],
            reverse=True)
        ans = max(ans, abs(sum(sorted_XYZ[:M])))

    return ans


if __name__ == "__main__":
    N, M = map(int, input().split())
    XYZ = [tuple(int(s) for s in input().split()) for _ in range(N)]
    ans = patisserie_ABC(N, M, XYZ)
    print(ans)


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

using namespace std;

#define PI 3.1415926535897932

int main(){
    int n;
    scanf("%d",&n);
    vector<int>ar(n);
    for (auto&e:ar) {
        scanf("%d",&e);
    }
    sort(ar.begin(),ar.end());
    printf("%d\n",ar[n-1]-ar[0]);

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nk[0];
        var k = nk[1];
        var s = Console.ReadLine().Trim().Select(x => x - '0').ToArray();

        var requirement = new int[s.Length];
        var ls = new int[(s.Length + 1) / 2 + 1];
        var rs = new int[(s.Length + 1) / 2 + 1];
        requirement[0] = s[0] ^ 1;
        for (int i = 1; i < s.Length; i++)
        {
            requirement[i] = requirement[i - 1];
            if (s[i] != s[i - 1])
            {
                if (s[i] == 0)
                {
                    requirement[i]++;
                    rs[requirement[i - 1]] = i;
                }
                else
                {
                    ls[requirement[i]] = i;
                }
            }
        }
        for (int i = requirement.Last(); i < rs.Length; i++)
        {
            rs[i] = s.Length;
        }

        if (k >= rs.Length || rs[k] == s.Length)
        {
            Console.WriteLine(s.Length);
            return;
        }

        for (int i = requirement.Last(); i < ls.Length; i++)
        {
            ls[i] = ls[i - 1];
        }

        var longest = 0;
        for (int i = 0; i < rs.Length; i++)
        {
            if (i + k > rs.Length - 1)
            {
                longest = Math.Max(longest, s.Length - ls[i]);
                break;
            }

            longest = Math.Max(longest, rs[i + k] - ls[i]);
        }
        Console.WriteLine(longest);
    }
}


Measured memory_bytes: 14176
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 100005;
int que[MAXN], x[MAXN], n, T, E;
LL f[MAXN];

int main() {
	scanf("%d%d%d", &n, &E, &T);
	int he = 1, ta = 0;
	LL mn = 1e18;
	que[++ta] = 0;
	for (int i = 1, pos = 0; i <= n; i++) {
		scanf("%d", x + i);
		for (; 2 * (x[i] - x[pos + 1]) >= T; ++pos)
			chkmin(mn, f[pos] - x[pos] - 2 * x[pos + 1]);
		f[i] = mn + 3ll * x[i];
		while (he <= ta && que[he] < pos) ++he;
		chkmin(f[i], f[que[he]] - x[que[he]] + x[i] + T);
		while (he <= ta && f[i] - x[i] <= que[ta]) --ta;
		que[++ta] = i;
	}
	printf("%lld\n", f[n] + E - x[n]);
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
P = [0] * n
for i in range(n):
    P[i] = list(map(int, input().split()))
P = sorted(P, key=lambda x: x[2], reverse=True)

max_h = P[0][2]

P2 = set()
for i in range(101):
    for j in range(101):
        P2.add((i, j))
for hh in range(max_h+200, max_h-1, -1):
    P3 = P2.copy()
    for x, y, h in P:
        for xx, yy in P3.copy():
            dx = abs(xx - x)
            dy = abs(yy - y)
            th = max(hh-dx-dy, 0)
            if th != h:
                P3.remove((xx, yy))
    if len(P3) == 1:
        xx, yy = P3.pop()
        print('%d %d %d' % (xx, yy, hh))


Measured memory_bytes: 5232
def fn(n):
    return n // 2 if n % 2 == 0 else 3 * n + 1


s = int(input())
a = [s]

while True:
    a.append(fn(a[len(a) - 1]))
    if len(a) != len(set(a)):
        print(len(a))
        break


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define maxn 200005
#define MOD 1000000007
#define INF 10000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}


void solve(){
    ll r, c, k;
    cin >> r >> c >> k;
    string a[r];
    for(ll i = 0; i  < r; i++)
        cin >> a[i];
    ll ans = INF;

    for(ll mask = 0; mask < 1<<(r-1); mask++){
        ll sum[r+1], div = __builtin_popcount(mask);
        memset(sum, 0, sizeof(sum));

        for(ll j = 0 ; j < c; j++){
            ll s = 0, f = 0;
            for(ll i = 0; i < r; i++){
                s += a[i][j] - '0';
                if((mask>>i)&1){
                    if(s > k){
                        div = INF;
                    }
                    else{
                        if(sum[i] + s > k){
                            f = 1; break;
                        }
                        else{
                            sum[i] += s; s = 0;
                        }
                    }
                }
            }
            if(s > 0){
                if(s > k) div = INF;
                else{
                    if(sum[r] + s > k){
                        f = 1;
                    }
                    else{
                        sum[r] += s; s = 0;
                    }
                }
            }
            if(div == INF) break;
            if(f){
                div++;
                s = 0;
                for(ll i = 0; i < r; i++){
                    s += a[i][j] - '0';
                    if((mask>>i)&1){
                        sum[i] = s; s = 0;
                    }
                }
                sum[r] = s; s = 0;
            }
            //for(ll i = 0; i <= r; i++)cout << sum[i] << " "; cout << "----" << div << endl;
        }

        //cout << div << "\n";
        ans = min(ans, div);
    }
    cout << ans;


}

int main()
{
    fast(); //power(2, 11);
    int t= 1; //cin >> t;
    while(t--){
//        pre();
        solve();
    }
}

/*
5
1 2
2 3
3 4
3 5
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> segtree(vector<int> &A){
  int N = 1;
  while (N < A.size()){
    N = N * 2;
  }
  vector<int> ST(N * 2 - 1);
  for (int i = 0; i < A.size(); i++){
    ST[i + N - 1] = A[i];
  }
  for (int i = A.size() + N - 1; i < N * 2 - 1; i++){
    ST[i] = 0;
  }
  for (int i = N - 2; i >= 0; i--){
    ST[i] = ST[i * 2 + 1] | ST[i * 2 + 2];
  }
  return ST;
}
void segtree_update(vector<int> &ST, int i, char x){
  int N = (ST.size() + 1) / 2;
  i = i + N - 1;
  ST[i] = 1 << (x - 'a');
  while (i > 0){
    i = (i - 1) / 2;
    ST[i] = ST[i * 2 + 1] | ST[i * 2 + 2];
  }
  return;
}
int segtree_query(vector<int> &ST, int x, int y, int i, int L, int R){
  if (y <= L || R <= x){
    return 0;
  } else if (x <= L && R <= y){
    return ST[i];
  } else {
    int M = (L + R) / 2;
    int A = segtree_query(ST, x, y, i * 2 + 1, L, M);
    int B = segtree_query(ST, x, y, i * 2 + 2, M, R);
    return A | B;
  }
}
int main(){
  int N, Q;
  string S;
  cin >> N >> S >> Q;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    A[i] = 1 << (S[i] - 'a');
  }
  vector<int> ST;
  ST = segtree(A);
  int L = (ST.size() + 1) / 2;
  for (int i = 0; i < Q; i++){
    int q;
    cin >> q;
    if (q == 1){
      int i;
      char c;
      cin >> i >> c;
      i--;
      segtree_update(ST, i, c);
    } else {
      int l, r;
      cin >> l >> r;
      l--;
      int ans = segtree_query(ST, l, r, 0, 0, L);
      cout << __builtin_popcount(ans) << endl;
    }
  }
}

Measured memory_bytes: 6916
#include <stdio.h>
#define MAX 100
#define INFTY 200000
#define SHIRO 0
#define GRAY 1
#define KURO 2
int kazu,M[MAX][MAX],i,j;

int x(){
  int u,min,v;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<kazu;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=SHIRO;
  }
  d[0]=0;
  while(1){
    min=INFTY;
    u=-1;
    for(i=0;i<kazu;i++){
      if(min>d[i] && color[i]!=KURO){
        u=i;
        min=d[i];
      }
    }
    if(u==-1)break;
    color[u]=KURO;
    for(v=0;v<kazu;v++){
      if(color[v]!=KURO && M[u][v]!=INFTY){
        if(d[v]>M[u][v]){
          d[v]=M[u][v];
          p[v]=u;
          color[v]=GRAY;
        }
      }
    }
  }
  int sum=0;
  for(i=0;i<kazu;i++){
    if(p[i]!=-1)sum+=M[i][p[i]];
  }
  return sum;
}

int main()
{
  scanf("%d",&kazu);
  for(i=0;i<kazu;i++){
    for(j=0;j<kazu;j++){
      int e;
      scanf("%d",&e);
      M[i][j]=(e==-1)?INFTY:e;
    }
  }
  printf("%d\n",x());
  return 0;
}



Measured memory_bytes: 2052
s=gets.chomp.to_s.reverse!
d=["dream", "dreamer", "erase", "eraser"].map(&:reverse!)
k=0
s.size.times do |i|
  k+=1
  d.size.times do |j|
    if s[0,k]==d[j] then
      s.slice!(0,k)
      k=0
    elsif k>7
      puts 'NO'
      exit
    end
  end
end
puts 'YES'

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

namespace ABC111A
{
    class Program
    {
        static void Main(string[] args)
        {
            String s,a,b,c;
            s = Console.ReadLine();
            char[] cs = s.ToCharArray();

            if (s[0] == '1')
                cs[0] = '9';

            if (s[0] == '9')
                cs[0] = '1';

            if (s[1] == '1')
                cs[1] = '9';

            if (s[1] == '9')
                cs[1] = '1';

            if (s[2] == '1')
                cs[2] = '9';

            if (s[2] == '9')
                cs[2] = '1';

            Console.WriteLine(cs);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String s = br.readLine();

        int cnt = 0;
        int max = 0;
        for(int i=0; i<n; i++){
            if('I' == s.charAt(i)){
                cnt++;
            } else if('D' == s.charAt(i)){
                cnt--;
            }

            if(max < cnt) max = cnt;
        }

        System.out.println(max);
    }
}

Measured memory_bytes: 21332
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"I=lambda:list(map(int,input().split()))\n"
"n,m,q=I()\n"
"l=[[0]*-~n for _ in range(n+1)]\n"
"for _ in range(m):\n"
"  s,g=I()\n"
"  l[s][g]+=1\n"
"for i in range(1,n+1):\n"
"  for j in range(1,n+1):\n"
"    l[i][j]+=l[i][j-1]\n"
"  for j in range(1,n+1):\n"
"    l[i][j]+=l[i-1][j]\n"
"for _ in range(q):\n"
"  s,g=I()\n"
"  print(l[g][g]-l[s-1][g]-l[g][s-1]+l[s-1][s-1])\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 13748
import java.util.*;
import java.math.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner ob=new Scanner(System.in);
    double h=ob.nextInt();
    double a=ob.nextInt();
    double d=Math.ceil(h/a);
    int t=(int)d;
    System.out.println(t);
  }
}

Measured memory_bytes: 23252
n,k,q = map(int, input().split())
each_point = []
for i in range(n):
  each_point.append(k-q)
 
for j in range(q):
  each_point[int(input())-1] += 1
 
for x in range(n):
  if (each_point[x] < 1):
    print("No")
  else:
    print("Yes")

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

template <class T, class Op = multiplies<T>>
T power(T a, long long n, Op op = multiplies<T>(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  using m = modular;
  unsigned v;
  modular(long long x = 0) : v((x %= M) < 0 ? x + M : x) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m b) { if ((v += b.v) >= M) v -= M; return *this; }
  m& operator-=(m b) { if (v < b.v) v += M; v -= b.v; return *this; }
  m& operator*=(m b) { v = (uint64_t)v * b.v % M; return *this; }
  m& operator/=(m b) { return *this *= power(b, M - 2); }
  friend m operator+(m a, m b) { return a += b; }
  friend m operator-(m a, m b) { return a -= b; }
  friend m operator*(m a, m b) { return a *= b; }
  friend m operator/(m a, m b) { return a /= b; }
  friend bool operator==(m a, m b) { return a.v == b.v; }
  friend string to_string(m a) { return to_string(a.v); }
};

constexpr long long mod = 1e9 + 7;
using mint = modular<mod>;

vector<mint> fact, inv_fact, minv;
void prepare(int n) {
  fact.resize(n + 1), inv_fact.resize(n + 1), minv.resize(n + 1);
  for (int i = 0; i <= n; ++i) fact[i] = i ? i * fact[i - 1] : 1;
  inv_fact[n] = power(fact[n], mod - 2);
  for (int i = n; i; --i) inv_fact[i - 1] = i * inv_fact[i];
  for (int i = 1; i <= n; ++i) minv[i] = inv_fact[i] * fact[i - 1];
}
mint binom(int n, int k) {
  if (k < 0 or k > n) return 0;
  return fact[n] * inv_fact[k] * inv_fact[n - k];
}
template<> mint& mint::operator/=(mint r) {
  return *this *= r.v < minv.size() ? minv[r.v] : power(r, mod - 2);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int m = s.size();
  prepare(n + 1);
  mint res, p2 = power(mint(2), (n - m) / 2);
  for (int k = (n + m) & 1; k <= n - m; k += 2) {
    int x = (n - m - k) / 2, y = m + k + 1;
    res += p2 * y / (2 * x + y) * binom(2 * x + y, x);
    p2 /= 2;
  }
  cout << res.v << '\n';
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;

struct teamscore{
  int team, correct, time;
  int wrong[10];
};

bool comp(const teamscore &a, const teamscore &b)
{
  if(a.correct != b.correct)
    return a.correct > b.correct;
  else if(a.time != b.time)
    return a.time < b.time;
  else
    return a.team > b.team;
}

int main()
{
  while(1){
    int M,T,P,R;
    cin >> M >> T >> P >> R;
    if(M == 0 && T == 0 && P == 0 && R == 0) break;
    vector<teamscore> v(T);
    REP(i,T){
      v[i].team = i+1;
      v[i].correct = v[i].time = 0;
      REP(j,10)
        v[i].wrong[j] = 0;
    }
    REP(i,R){
      int m, t, p, j;
      cin >> m >> t >> p >> j;
      if(j != 0){
        v[t-1].wrong[p-1]++;
      }else{
        v[t-1].time += v[t-1].wrong[p-1]*20 + m;
        v[t-1].correct++;
      }
    }
    sort(v.begin(), v.end(), comp);
    cout << v[0].team;
    for(int i = 1; i < T; i++){
      if(v[i].correct == v[i-1].correct && v[i].time == v[i-1].time)
        cout << "=" << v[i].team;
      else
        cout << "," << v[i].team;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1224
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();

        Set<Character> set = new HashSet<Character>();
        for (char ch : S) {
            set.add(ch);
        }

        for (char ch = 'a'; ch <= 'z'; ch++) {
            if (!set.contains(ch)) {
                System.out.println(ch);
                System.exit(0);
            }
        }

        System.out.println("None");

        return;
    }

}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dumplist_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

inline ll inl() {
    ll x;
    cin >> x;
    return x;
}

inline string ins() {
    string x;
    cin >> x;
    return x;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll k, t;
        cin >> k >> t;
        vl a(t);
        rep(i, t) cin >> a[i];
        ll maxa = *max_element(all(a));
        cout << max(maxa - 1 - (k - maxa), 0LL) << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	string S, T;
	cin >> S >> T;
	vector<pair<int, int> > g;
	int N = S.size();
	for (int i = 0; i < N; ++i) {
		g.push_back(make_pair(S[i] - 'a', T[i] - 'a'));
	}
	sort(g.begin(), g.end());
	g.erase(unique(g.begin(), g.end()), g.end());
	vector<int> d1(26), d2(26);
	for (pair<int, int> i : g) {
		++d1[i.first];
		++d2[i.second];
	}
	int m1 = *max_element(d1.begin(), d1.end());
	int m2 = *max_element(d2.begin(), d2.end());
	cout << (m1 <= 1 && m2 <= 1 ? "Yes" : "No") << endl;
	return 0;
}

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

int main(){
    string s;
    cin>>s;
    int n=s.size();
    int a=0,b=0,c=0;
    for(int i=0;i<n;i++){
        if(s[i]=='a') a++;
        if(s[i]=='b') b++;
        if(s[i]=='c') c++;
    }
    
    if(abs(a-b)<=1&&abs(a-c)<=1&&abs(b-c)<=1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 3764
#n, k = [int(i) for i in input().split()]

s = input()
front = int(s[0] + s[1])
back = int(s[2] + s[3])
answer = ["NA", "YYMM", "MMYY", "AMBIGUOUS"]
ans = 0
if 1 <= back <= 12:
    ans += 1

if 1 <= front <= 12:
    ans += 2

print(answer[ans])

Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)
var buf = make([]byte, 1000)

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

func scanInt() int {
	out, e := strconv.Atoi(inputLine())
	if e != nil {
        panic(e)
    }
	return out
}

func scanIntArray(n int) []int {
	out := make([]int, n)
	for i, v := range(strings.Split(inputLine(), " ")) {
		num, e := strconv.Atoi(v)
		if e != nil {
			panic(e)
		}
		out[i] = num
	}
	return out
}
//  template end

type City struct {
	I int
	P int
	Y int 
	X int
}
type Cities []City

func (c Cities) Len() int {
	return len(c)
}

func (c Cities) Swap(i, j int) {
	c[i], c[j] = c[j], c[i]
}

func (c Cities) Less(i, j int) bool {
	return c[i].Y < c[j].Y
}

type ByI struct {
	Cities
}

func (b ByI) Less(i, j int) bool {
	return b.Cities[i].I < b.Cities[j].I
}

func main() {
	sc.Buffer(buf, 10000)
	nm := scanIntArray(2)
	N, M := nm[0], nm[1]
	all_cities := make([]Cities, N)
	for i:=0; i<M; i++ {
		py := scanIntArray(2)
		p, y := py[0], py[1]
		city := City{
			I : i,
			P : p,
			Y : y,
			X : -1,
		}
		all_cities[p-1] = append(all_cities[p-1], city)
	}
	fmt_cities := make(Cities, 0)
	for i:=0; i<N; i++ {
		sort.Sort(all_cities[i])
		for j:=0; j<len(all_cities[i]); j++ {
			all_cities[i][j].X = j+1
		}
		fmt_cities = append(fmt_cities, all_cities[i]...)
	}
	sort.Sort(ByI{fmt_cities})
	for _, c := range(fmt_cities){
		fmt.Printf("%06d%06d\n", c.P, c.X)
	}
}

Measured memory_bytes: 22144
#include<map>
#include<queue>
#include<cstdio>
#include<algorithm>

#define	mp		make_pair
#define	stat	first
#define	step	second

using namespace std;

typedef	pair<int,int>	pii;

void swp(int &stat,int i,int j)
{
	static int pw[]={1,10,100,1000,10000,100000,1000000,10000000};
	int ith=(stat/pw[7-i])%10,jth=(stat/pw[7-j])%10;
	stat=stat-ith*pw[7-i]-jth*pw[7-j]+jth*pw[7-i]+ith*pw[7-j];
}

int main()
{
	static int memo[40321],pos0[40321];
	for(int i=0;i<=40320;i++)	memo[i]=-1;

	map<int,int> index;
	int stat[]={0,1,2,3,4,5,6,7},i=0;
	do{
		int a=0;
		for(int j=0;j<8;j++)	a=10*a+stat[j];
		index[a]=i;
		for(int j=0;j<8;j++)	if(stat[j]==0)	pos0[i]=j;
		i++;
	}while(next_permutation(stat,stat+8));

	queue<pii> qu;
	qu.push(mp(1234567,0));
	while(!qu.empty()){
		pii a=qu.front();	qu.pop();

		int idx=index[a.stat];
		if(memo[idx]!=-1)	continue;
		memo[idx]=a.step;

		int p0=pos0[idx];
		swp(a.stat,p0,(p0+4)%8),qu.push(mp(a.stat,a.step+1)),swp(a.stat,p0,(p0+4)%8);
		if(p0!=0 && p0!=4)
			swp(a.stat,p0,p0-1),qu.push(mp(a.stat,a.step+1)),swp(a.stat,p0,p0-1);
		if(p0!=3 && p0!=7)
			swp(a.stat,p0,p0+1),qu.push(mp(a.stat,a.step+1)),swp(a.stat,p0,p0+1);
	}

	while(1){
		for(int i=0;i<8;i++)	if(!~scanf("%d",stat+i))	return 0;
		int a=0;
		for(int i=0;i<8;i++)	a=10*a+stat[i];
		printf("%d\n",memo[index[a]]);
	}
}

Measured memory_bytes: 0