akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main(){
  int N, A;
  cin >> N >> A;
  vector<int> X(N);
  for( int i = 0; i < N; i++ ){
    cin >> X.at(i);
    X.at(i) -= A;
  }

  //Xの合計が0になるような組み合わせを求める
  int mid = 3000;
  vector<vector<int>> dp(N+10, vector<int>(7000));
  dp[0][mid] = 1;

  for( int i = 0; i < N; i++ ){ //i番目までの数字を使って
    for( int j = -2500; j <= 2500; j++ ){
      //i番目の数字を使わない場合
      dp[i+1][mid+j] += dp[i][mid+j];
      //i番目の数字を使う場合
      dp[i+1][j+mid+X.at(i)] += dp[i][mid+j];
    }
  }
  
  cout << dp[N][mid] -1 << endl;
 }


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-10;

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

int main(){
	int n, T;
	cin>>n>>T;
	int a, b;
	string t1, t2, n1, n2;
	vector<pair<string, int> > ans;
	cin>>t1>>n1;
	//cout<<n-1<<endl;
	//cout<<T<<endl;
	rep(i, n-1){
		cin>>t1>>n1>>t2>>n2;
		//if(n2!=n1) continue;
		a = b = 0;
		a = (t1[0]*10+t1[1])*60+t1[3]*10+t1[4];
		b = (t2[0]*10+t2[1])*60+t2[3]*10+t2[4];
		//cout<<(b-a >= T)<<n1<<endl;
		if(b-a >= T){
			ans.pb(mp(n1, b-a));
		}
	}
	cin>>t1>>n1;
	cout<<ans.size()<<endl;
	rep(i, ans.size()){
		cout<<ans[i].fi<<" "<<ans[i].se<<endl;
	}
}

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

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

    int n, k;
    cin >> n >> k;
    int h, res = 0;
    rep (i, n) {
        cin >> h;
        if (h >= k) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3624
function Main(input) {
  
  if (input >= 400 && input <= 599)  console.log('8');
  else if (input >= 600 && input <= 799)  console.log('7');
  else if (input >= 800 && input <= 999)  console.log('6');
  else if (input >= 1000 && input <= 1199)  console.log('5');
  else if (input >= 1200 && input <= 1399)  console.log('4');
  else if (input >= 1400 && input <= 1599)  console.log('3');
  else if (input >= 1600 && input <= 1799)  console.log('2');
  else if (input >= 1800 && input <= 1999)  console.log('1');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

#ifdef __WIN32
#define LLFORMAT "I64"
#define Rand() ((rand() << 15) + rand())
#else
#define LLFORMAT "ll"
#define Rand() (rand())
#endif

using namespace std;

const int maxn = 6060;

int n, sb[maxn];
string s, dp[maxn];
set<pair<int, int> > ab, ba;

int cntb(int l, int r) { return sb[r] - (l ? sb[l - 1] : 0); }

void upd(string &s, const string &t) {
	for (int i = 0; i < s.size() && i < t.size(); ++i) if(s[i] != t[i]) { if(s[i] < t[i]) s = t; return; }
	if(s.size() < t.size()) s = t;
	return;
}

string DP(int beg) {
	if(beg >= n) return "";
	auto &dp = ::dp[beg]; if(dp.size() != 0) return dp;
	auto it = ba.lower_bound(make_pair(beg, -1));
	if(it == ba.end()) {
		int lst = beg - 1;
		it = ab.lower_bound(make_pair(beg, -1));
		while(it != ab.end()) {
			if(it->first > lst) dp += "ab", lst = it->second;
			++it;
		}
		upd(dp, DP(beg + 1));
		return dp;
	}
	if(it->first > beg) return dp = DP(beg + 1);
	vector<int> tmp;
	int lst = it->second; tmp.push_back(it->first); tmp.push_back(it->second);
	++it;
	while(it != ba.end()) {
		if(it->first > lst) break;
		lst = it->second; tmp.push_back(it->first); tmp.push_back(it->second);
		++it;
	}
	sort(tmp.begin(), tmp.end());
	for (int i: tmp) dp += s[i];
	dp += DP(tmp.back() + 1);
	upd(dp, DP(beg + 1));
	return dp;
}

int main() {
	cin >> n >> s; n *= 2;
	for (int pb = -1, pa = 0; pa < n; ++pa) if(s[pa] == 'a') {
		++pb; while(s[pb] != 'b') ++pb;
		if(pa < pb) ab.insert(make_pair(pa, pb));
		else ba.insert(make_pair(pb, pa));
	}
	cout << DP(0) << endl;
	return 0;
}



Measured memory_bytes: 61184
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 * 2 + 100, INF = 1e9, MOD = 1e9 + 7;

bool gt[SIZE], used[SIZE];
ll dsu[SIZE][2], sz[SIZE][2];
vector<vector<ll>> graph;
vector<pair<ll, ll>> cur;


ll find(int v, int ind) {
    if (dsu[v][ind] == v) return v;
    else return dsu[v][ind] = find(dsu[v][ind], ind);
}
void dfs(int v) {
    used[v] = 1;

    cur.push_back({ find(v, 0), v });
    for (auto to : graph[v]) {
        if (!used[to]) {

            dfs(to);
        }
    }
}
void uni(int v, int u, int ind) {
    u = find(u, ind);
    v = find(v, ind);

    if (u != v) {
        dsu[u][ind] = v;
        sz[v][ind] += sz[u][ind];
    }
}
int main()
{
    fastInp;

    string s;

    ll n, k, l;
    cin >> n >> k >> l;

    for (int i = 0; i < n; i++) {
        sz[i][0] = 1;
        sz[i][1] = 1;
        dsu[i][0] = i;
        dsu[i][1] = i;
    }

    for (int i = 0; i < k; i++) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        uni(u, v, 0);
    }

    graph.resize(n);
    for (int i = 0; i < l; i++) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    for (int i = 0; i < n; i++) {
        if (!used[i]) {
            cur.clear();
            dfs(i);
            sort(cur.begin(), cur.end());
            for (int j = 1; j < cur.size(); j++) {
                if (cur[j].first == cur[j - 1].first) uni(cur[j].second, cur[j - 1].second, 1);
            }
        }
    }

    for (int i = 0; i < n; i++) {
        ll u = find(i, 1);
        cout << sz[u][1] << " ";
    }
    return 0;
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int sum = (b-1)/(a-1);
    if((a-1)*(sum-1) + a < b) {
      sum+=1;
    }
    System.out.println(sum);
  }
}

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

int N, A[303030];

bool check(int K) {
    stack<pair<int, int>> st;
    rep(i, N-1) {
        if (A[i] >= A[i+1]) {
            while (st.size() and st.top().first > A[i+1]) st.pop();
            if (st.size() and st.top().first == A[i+1]) {
                st.top().second++;
            }
            else {
                st.push({A[i+1], 1});
            }
            while (st.top().second == K) {
                int d = st.top().first;
                if (d == 1) return false;
                st.pop();
                if (st.size() and st.top().first == d-1) {
                    st.top().second++;
                }
                else {
                    st.push({d-1, 1});
                }
            }
        }
    }
    return true;
}

int main() {
    cin >> N;
    rep(i, N) cin >> A[i];

    bool incr = true;
    for (int i=0; i<N-1; ++i) if (A[i] >= A[i+1]) incr = false;
    if (incr) {
        cout << 1 << endl;
        return 0;
    }

    int ng = 1, ok = N;
    while (ok-ng>1) {
        int m = (ng+ok)/2;
        if (check(m)) ok = m;
        else ng = m;
    }

    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

const int kMaxN = 2000001;

long long n, ans;
int a[kMaxN];

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 2; i <= n; i++) {
    ans += max(a[i - 1] - a[i], 0);
    a[i] = max(a[i], a[i - 1]);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 4384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);

    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }

    sort(a.begin(), a.end());
    int i,j, sum=0;
    for(i=0; i<n; i++){
        int cnt = 0;
        for(j=i; j<n; j++){
            if(a.at(i) == a.at(j)){
                cnt++;
            }
            else break;
        }
        if(a.at(i) < cnt)
            sum += cnt - a.at(i);
        else if(a.at(i) > cnt)
            sum += cnt;
        i += cnt - 1;
    }
    cout << sum << '\n';
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
 int a,b;
 scanf("%d",&a);
 scanf("%d",&b);
 if(a < b){
  printf("a < b\n");
 }else if(a > b){
  printf("a > b\n");
 }else{
  printf("a == b\n");
 }
 return 0;
}


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

using namespace std;
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int a, b, c, d; cin >> a >> b >> c >> d;
    cout << max(a*b, c*d);

    return 0;
}


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

namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int x =  a * b;
            int y = 2 * (a + b);

            Console.WriteLine(x + " " + y);
           
         

        }
    }
}

Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a ;
  int b , c, d ,e;
  b = a/100;
  c = a - b*100;
  d = c/10;
  e = c- d *10 ;
  cout << b + d + e << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll x;
    cin>>x;
    ll sum=0;
    for(int i=1;;i++){
        sum+=i;
        if(sum>=x)
        {
            printf("%d\n",i);return 0;
        }
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
const int MAXV = 3;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int L, R, d;
    scanf("%d%d%d", &L, &R, &d);
    printf("%d\n", R / d - (L - 1) / d);
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef set<int> si;
typedef set<ll, ll> sll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<int, int> mii;
typedef map<int, ll> mil;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort((c).begin(),(c).end())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define PB push_back

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

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

ll in[10000];
int main(){
	while(true){
	ll n;
	cin>>n;
	if(n==0)return 0;
	for(ll i=0;i<n;i++){
		cin>>in[i];
		
	}
	ll c1=0,c2=0;
	for(ll i=0;i<n;i++){
		if(in[i]!=0)c1++;
		if(in[i]==1)c2++;
		
	}
	if(c2==c1)cout<<"NA"<<endl;
	else cout<<c1+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1232
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

void solve() {
    cini(h);
    cini(w);
    cini(k);

    vector<vector<char>> c(h, vector<char>(w));
    for(int i=0; i<h; i++) 
        for(int j=0; j<w; j++) {
            cin>>c[i][j];
        }

    int ans=0;
    for(int i=0; i<(1<<h); i++)
        for(int j=0; j<(1<<w); j++) {
            int lans=0;
            for(int ii=0; ii<h; ii++)  {
                for(int jj=0; jj<w; jj++) {
                    if((i&(1<<ii)) && (j&(1<<jj)) && c[ii][jj]=='#')
                        lans++;
                }
            }
            if(lans==k)
                ans++;
        }

    cout<<ans<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


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

struct P
{
    int x,y;
    bool operator<(const P &a)const{
              return x>a.x;
    }
};

vector<int> v[11];
//bitset<4001000> b;
int a,c,i,b,k,n,d,e,m;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int o[120];
long long l[333310];
int j[22];
int dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};


long long x,y,mod=998244353;
long long z;

P u[550];
stack<int> s;

//set<int> s;
queue<int> q;


//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p[11];
//list<int> l;

string r;
//char r[33];
//deque<int> de;
bool as(int a,int b)
{

    return i>2;
}

long long f(int a,int b)
{
    if(!b) return 1;
    long long x=f(a,b/2);
    x*=x,x%=mod;
    if(b&1) x*=a,x%=mod;
    return x;
}

int main()
{

    scanf("%d %d %d %lld",&a,&b,&c,&x);
    l[1]=a,l[0]=1;
    for(int t=2;t<=a;t++)
    {
        l[t]=l[t-1]*(a-t+1)%mod*f(t,mod-2)%mod;
        //printf("%lld ",l[t]);
    }
    for(long long t=0;t*b<=x&&t<=a;t++)
    {

        if((x-t*b)%c==0&&(x-t*b)/c<=a)
        {
            //printf("%lld %lld %lld\n",t,(x-t*b)/c,y);
            y+=l[t]*l[(x-t*b)/c]%mod,y%=mod;
        }
    }
    printf("%lld",y);
}








Measured memory_bytes: 2560
#include "bits/stdc++.h"

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
char capitalize(char c) { return static_cast<char>(std::toupper(static_cast<unsigned char>(c))); }
// template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
// template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "YES"
#define NO "NO"
#define MOD 1000000000 + 7
#define forit(v) for (auto it = v.begin(); it != v.end(); ++it)

using namespace std;

signed main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int num = 0;
  // num = numeric_limits<int>::max();
  // num = numeric_limits<int>::min();
  bool flag = false;
  // flag = true;

  int n;
  cin >> n;

  int m = (int)sqrt(n);

  cout << m * m << endl;

  // cout << num << endl;
  // cout << (flag ? YES : NO) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int a[];
		a = new int [n + 1];

		for (int i = 1; i <= n; i++){
			a[i] = sc.nextInt();
		}

		int idx = 1;
		int cnt = 0;
		Set<Integer> set = new HashSet<Integer>();
		set.add(idx);
		while (true){

			idx = a[idx];
			cnt++;

			if (idx == 2){
				break;
			}
			if (set.contains(idx)){
				cnt = -1;
				break;
			}
			set.add(idx);
		}


		System.out.println(cnt);
	}

}


Measured memory_bytes: 54904
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    ll a, b, c; cin >> a >> b >> c;
    cout << (4 * a * b < (c- a - b) * (c - a - b) && c - a- b > 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	
	int result = 0;
	if( a > b){
		result += a;
		a--;
	}
	else{
		result += b;
		b--;
	}

	if( a > b){
		result += a;
		a--;
	}
	else{
		result += b;
		b--;
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const LL mod=998244353;
const int Maxn=405;
int n,a[Maxn],b[Maxn];
LL p[Maxn],pw[Maxn][Maxn];
LL fact[Maxn],ivf[Maxn];
LL qp(LL x,LL p){
	LL ret=1;
	while (p){
		if (p&1) ret=ret*x%mod;
		x=x*x%mod;
		p>>=1;
	}
	return ret;
}
LL inv(LL x){
	return qp(x,mod-2);
}
LL dp[Maxn][Maxn][Maxn],S[Maxn];
LL _coef[Maxn][Maxn],tmp[Maxn][Maxn],C[Maxn][Maxn];
//_coef[i][j]: [x^j][(n+i)_i]
/*dp(i,j,k):
considering the product of the first i factors
the coefficient of x^je^(kx)
*/
void Add(LL &x,LL y){
	x+=y;
	if (x>=mod) x-=mod;
}
void _init(){
	fact[0]=1;
	for (int i=1;i<Maxn;i++){
		fact[i]=fact[i-1]*i%mod;
	}
	for (int i=0;i<Maxn;i++) ivf[i]=inv(fact[i]);
	for (int i=0;i<Maxn;i++){
		for (int j=0;j<=i;j++){
			C[i][j]=fact[i]*ivf[j]%mod*ivf[i-j]%mod;
		}
	}
	//memset(tmp,0,sizeof(tmp));
	_coef[0][0]=1;
	for (int j=1;j<Maxn;j++){
		for (int k=0;k<Maxn;k++){
			_coef[j][k]=_coef[j-1][k]*j%mod;
			if (k) Add(_coef[j][k],_coef[j-1][k-1]%mod);
		}
	}
}
int main(){
	_init();
	
//	cout<<"OK"<<endl;
	scanf("%d",&n);
	int sa=0;
	for (int i=1;i<=n;i++) scanf("%d %d",&a[i],&b[i]),sa+=a[i];
	for (int i=1;i<=n;i++) p[i]=1ll*a[i]*inv(sa)%mod;
	for (int i=1;i<=n;i++){
		pw[i][0]=1;
		for (int j=1;j<Maxn;j++){
			pw[i][j]=pw[i][j-1]*p[i]%mod;
		}
	}
	dp[0][0][0]=1;
	for (int i=1;i<=n;i++){
		for (int j=0;j<=400;j++){
			for (int k=0;k<=sa;k++){
				
				if (k>=a[i]){
					Add(dp[i][j][k],dp[i-1][j][k-a[i]]);
				}
				for (int l=0;l<b[i];l++){
					if(j>=l) Add(dp[i][j][k],(mod-pw[i][l]*ivf[l]%mod)*dp[i-1][j-l][k]%mod);
				}
			}
		}
	}
	LL ans=0;
	for (int k=0;k<sa;k++){
		LL v=1ll*k*inv(sa)%mod;
		S[0]=inv((1-v+mod)%mod);
		LL t=S[0];
		for (int i=1;i<Maxn;i++){
			S[i]=0;
			for (int l=0;l<i;l++){
				LL coef=(i-l)&1?(1):(mod-1);
				coef=coef*C[i][l]%mod;
				if (l)S[i]+=coef*S[l];
				else S[i]+=coef*(S[l]-1);
				S[i]%=mod;
			}
			if (S[i]<0) S[i]+=mod;
			S[i]=S[i]*t%mod;
		}
	//	cout<<'S'<<' '<<v<<' '<<S[1]<<' '<<S[2]<<' '<<S[3]<<' '<<_coef[2][2]<<' '<<_coef[2][1]<<endl;
		for (int j=0;j<=400;j++){
			if (dp[n][j][k]){
		//		cout<<j<<' '<<k<<' '<<dp[n][j][k]<<' '; 
				LL c=mod-dp[n][j][k];
			//	c=c*fact[j]%mod;
				if (k==0){
				//	cout<<c<<endl;
					ans+=c*fact[j];ans%=mod;
					continue;
				}
				LL res=0;
				for (int k=0;k<Maxn;k++){
					if (_coef[j][k]!=0){
						res+=_coef[j][k]*S[k];
						res%=mod;
					}
				}
			//	cout<<c*res%mod<<endl; 
				ans+=c*res;
				ans%=mod;
			}
		}
	}
	printf("%lld\n",ans);
	//cout<<25ll*inv(4)%mod<<endl;
	return 0;
}
/*
2
1 1
1 3
*/

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

int main(){
  int N; cin >> N;
  int Q; cin >> Q;
  string S,T; cin >> S;
  vector<int> a(N,0);
  for (int i=0;i<N-1;i++){
    if(S[i]=='A' && S[i+1]=='C'){
      a[i+1]=1;
    }
  }
  vector<int> v(N+1,0);
  v[0]=0;
  for (int i=0;i<N;i++){
    v[i+1]=v[i]+a[i];
  } 
  for (int i=0;i<Q;i++){
    int x,y;
    cin >> x >> y;
    cout << v[y]-v[x] << endl;
  }
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    /**
     * 数値を受け取り、その数値以下の素数がいくつあるかを求める。
     *
     * @param args
     */
    public static void main(String[] args) throws IOException {

        // 入力値をリストで受け取る
        List<Integer> inputList = readNumberList();

        // 必要な組み合わせ数のマップを作成する
        int maxInput = getMaxNumber(inputList);
        boolean[] primeMap = createPrimeMap(maxInput);

        // 結果を出力する
        printResult(inputList, primeMap);

    }

    /**
     * 標準入力から数値を読んでリストとして返却する。
     *
     * @return 入力された数値のリスト
     */
    protected static List<Integer> readNumberList() throws IOException {

        List<Integer> inputList = new ArrayList<Integer>();

        String line = null;
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                System.in));
        while ((line = reader.readLine()) != null) {
            inputList.add(Integer.parseInt(line));
        }

        if (reader != null) {
            reader.close();
        }

        return inputList;
    }

    /**
     * 数値リストのうち最大の数値を取得する。
     *
     * @param inputList 数値リスト
     * @return 数値リスト内の最大の数値
     */
    protected static int getMaxNumber(List<Integer> inputList) {
        int maxInput = 0;
        for (Integer input : inputList) {
            if (maxInput < input) {
                maxInput = input;
            }
        }
        return maxInput;
    }

    /**
     * 指定された数値までの素数マップを作成する。
     *
     * @param max 基準となる数値
     * @return 基準値までの素数マップ
     */
    protected static boolean[] createPrimeMap(int max) {

        boolean[] primeMap = new boolean[max + 1];

        // マップを初期化（全て素数とする）
        for (int i = 0; i <= max; i++) {
            primeMap[i] = true;
        }

        // 0 と 1 は直接指定する
        primeMap[0] = false;
        primeMap[1] = false;

        // 最大値の平方根まで計算すればふるい落としは完了する
        int loopEnd = (int) Math.floor(Math.sqrt(max));
        for (int i = 2; i <= loopEnd; i++) {
            // 素数だったらその倍数をふるい落とす
            if (primeMap[i]) {
                for (int j = i * 2; j <= max; j += i) {
                    primeMap[j] = false;
                }
            }
        }

        return primeMap;
    }

    /**
     * 数値リストの数値ひとつひとつに対して、その数値以下の素数の数を求め、出力する。
     *
     * @param inputList 数値のリスト
     * @param primeMap 素数マップ
     */
    protected static void printResult(List<Integer> inputList, boolean[] primeMap) {
        for (int input : inputList) {
            System.out.println(getNumberOfPrime(input, primeMap));
        }
    }

    /**
     * 基準値までに素数がいくつあるかをカウントし、返却する。
     *
     * @param input 基準値
     * @param primeMap 素数マップ
     * @return 基準値までに素数がいくつあるか
     */
    protected static int getNumberOfPrime(int input, boolean[] primeMap) {
        int count = 0;
        for (int i = 0; i <= input; i++) {
            if (primeMap[i]) {
                count++;
            }
        }
        return count;
    }

}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <queue>
#include <list>
#include <limits>
#include <string>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 998244353;


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

int main()
{
  string year;
  int num;
  bool a=false,b=false;
  cin >> year;
  num = year[0]*10 + year[1] - '0'*10 - '0';
  if(num != 0 && num <= 12) b = true; 
  num = year[2]*10 + year[3] - '0'*10 - '0';
  if(num != 0 && num <= 12) a = true; 
  if(a&&b) cout << "AMBIGUOUS";
  else if(a) cout << "YYMM";
  else if(b) cout << "MMYY";
  else cout << "NA";
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#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;
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<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const ll MOD=1000000007;
const ll LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};

ll op(ll a, ll b){
    return max(a, b);
}

ll e(){
    return -LINF;
}

int main(){
    int n,q;cin >> n >> q;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    auto seg = segtree<ll, op, e> (a);
    while(q--){
        ll t,a,b;cin >> t >> a >> b;
        if(t == 1){
            a--;
            seg.set(a, b);
        }
        else if(t == 2){
            a--;
            cout << seg.prod(a, b) << endl;
        }
        else{
            a--;
            auto f = [&](ll x){
                return x < b;
            };
            cout << seg.max_right(a, f) + 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 9100
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n, m;
    cin>>n>>m;
    int i;
    int a[n+5];
    int sum = 0;
    FOR0(i, n)
    {
        cin>>a[i];
        sum += a[i];
    }
    sort(a, a+n, greater<int>());
    if( a[m-1]*4*m < sum) cout<<"No";
    else cout<<"Yes";
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forloop for(int i = 0; i < n; i++)
int main(){
	string a; cin>>a;
	for(int i = 0; i < a.size(); i++){
		if((i%2 && a[i] == 'R')  || (!(i%2) && a[i] == 'L')){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

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


signed main(){
    int n;ll p,q;cin>>n>>p>>q;
    vector<ll> c(n),d(n),ds(n+1);
    ll s=0;
    cin>>c;
    ds[0]=0;
    rep(i,n){
        s+=c[i];
        d[i]=c[i]+p*i;
    }
    sort(ALL(d));
    rep(i,n)ds[i+1]=ds[i]+d[i];

    ll res=-LINF;
    rep(i,n+1)chmax(res,s+p*q*i+p*i*(i-1)-ds[i]);
    cout<<res<<endl;
    return 0;
}



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

using namespace std;
#define int long long

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

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE
void solve(void)
{
  int H,W;
  cin>>H>>W;
  if(H == 1 || W == 1) cout<<abs(H*W -2)<<endl;
  else
  cout<<H*W -2*(H+W) +4<<endl;
  return;
}

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

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

  return 0;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long lpow(int x, int y){
	long long ret = 1;
	for(int i = 0; i < y; i++){
		ret = ret*x;
	}
	return ret;
}

void dfs(vector<int> &v, int len, long long &count, long long n){
	if(v.size()==len){
		long long s = 0;
		int ret = 1, c7 = 0, c5 = 0, c3 = 0;
		for(int i = 0; i < v.size(); i++){
			int u = v[i];
			s  += (int) u*lpow(10, i);
			if(u != 7 && u != 5 && u != 3){
				ret = 0;
				break;
			}
			if(u == 7){ c7++; }
			if(u == 5){ c5++; }
			if(u == 3){ c3++; }
		}
		if(s > n) return;
		if(ret == 1 && c7 > 0 && c5 > 0 && c3 > 0){
			count++;
		}
		return;
	}

	for(int i=3; i<9; i+=2){ //i=3, 5, 7
		v.push_back(i);
		dfs(v, len, count, n);
		v.pop_back();
	}
}

int main(int argc, char* argv[]){
	long long N;

	cin >> N ;

	long long ans = 0;
	for(int len = 3; len<=9; len++){
		vector<int> v;
		dfs(v, len, ans, N);
		v.clear();
	}
	cout << ans << endl ;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mov(i,a,b) for(int i = a; i < b; i++)
#define MOD 1000000007
#define INF 1e9+5
typedef long long ll;
using namespace std;
bool isPowerOfTwo(ll n){
	return (ceil(log2(n)) == floor(log2(n)));
}
long long binpow(long long a, long long b){
	long long res = 1;
	while(b>0){
		if(b&1) res *= a;
		a = a*a;
		b >>= 1;
	}
	return res;
}
int main(){
	
	ll n,m,c;
	cin>>n>>m>>c;
	ll arr[m];
	mov(i,0,m) cin>>arr[i];
	ll co = 0;
	ll x;
	while(n--){
		ll sum = 0;
		mov(i,0,m){
			cin>>x;
			sum += x*arr[i];
		}
		if(sum+c > 0) co++;
	}
	cout<<co<<"\n";
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<fstream>
#include<map>
#include<bitset>
#include<unordered_map>
#include<cstring>
#include<cctype>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define mod 1000000007
#define INF LLONG_MAX
#define PI acos(-1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
#define md  998244353
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
ll fix_mod(ll x, ll y)
{
	return (y + x % y) % y;
}
void fast() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);

#ifdef ONLINE_JUDGE
	//freopen("crosses.in", "r", stdin);

	//freopen("crosses.out", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
}
string s, t;
int mem[3001][3001];
int solve(int i, int j)
{
	if (i == s.size() || j == t.size())return 0;
	int& ret = mem[i][j];
	if (~ret)return ret;
	ret = solve(i + 1, j);
	ret=max(ret,solve(i, j + 1));
	if (s[i] == t[j])ret = max(ret, solve(i + 1, j + 1) + 1);
	return ret;
}
void build(int i, int j)
{
	if (i == s.size() || j == t.size())return;
	int ret = mem[i][j];
	if (ret == solve(i + 1, j))
	{
		build(i + 1, j);
		return;
	}
	if (ret == solve(i, j + 1))
	{
		build(i, j + 1);
		return;
	}
	if (s[i] == t[j])
	{
		cout << s[i];
		build(i + 1, j + 1);
		return;
	}
}
int main()
{
	Mohammed_Atef_Hassan
		clr(mem, -1);
		cin >> s >> t;
		solve(0, 0);
		build(0, 0);
}

Measured memory_bytes: 35840
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <regex>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

int main() {
	int ans = 0;
	string s;

	cin >> s;

	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '+')ans++;
		else ans--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
S = input()
s = list(S)

e = '0'
if (s[0] == '0'):
    e = '1'

s.pop(0)
count = 0
for c in s:
    if c != e:
        count += 1
    if e == '0':
        e = '1'
    else:
        e = '0'

print(count)


Measured memory_bytes: 3956
import java.util.*;
import java.util.regex.*;
import static java.lang.System.out;

// String
public class Main {
	public static void main(String[] args) {
		new Main().AOJ0084();
	}
	Scanner sc = new Scanner(System.in);
	
	void AOJ0084(){	// Search Engine
		StringBuilder sb = new StringBuilder();
		while(sc.hasNext()){
			String s=sc.next().replaceAll(",", "").replaceAll("\\.", "").replaceAll(" ", "");
			// out.println(s);
			if(s.length()<=2 || s.length()>=7)	continue;
			sb.append(s+" ");
		}
		out.println(sb.deleteCharAt(sb.length()-1));
	}
	
	void AOJ0077(){	// Run Length
		while(sc.hasNext()){
			char[] c=sc.nextLine().toCharArray();
			StringBuilder sb = new StringBuilder();
			for(int i=0; i<c.length; i++){
				if(c[i]=='@'){
					for(int j=0; j<Character.digit(c[i+1], 10); j++)	sb.append(c[i+2]);
					i+=2;
				}else	sb.append(c[i]);
			}
			out.println(sb.toString());
		}
	}
	
	void AOJ0064(){	// Secret Number
		int ans=0;
		while(sc.hasNext()){
			Matcher m = Pattern.compile("\\d+").matcher(sc.nextLine());
			while(m.find())	ans+=Integer.parseInt(m.group());
		}
		out.println(ans);
	}
	
	void AOJ0050(){	// Apple and Peach
		while(sc.hasNext()) out.println(sc.nextLine().replaceAll("apple", "PEACH").replaceAll("peach", "apple").replaceAll("PEACH", "peach"));
	}
	
	void AOJ0039(){	// Roman Figure ローマ数字 -> 10進数
		HashMap<Character,Integer> dic = new HashMap<Character,Integer>();
		dic.put('I', 1);	dic.put('V', 5);	dic.put('X', 10);	dic.put('L', 50);
		dic.put('C', 100);	dic.put('D', 500);	dic.put('M', 1000);
		while(sc.hasNext()){
			char[] c = sc.next().toCharArray();
			int ans=0,last=dic.get(c[0]);
			for(int i=0; i<c.length; i++){
				if(last>=dic.get(c[i])){
					ans+=dic.get(c[i]);
					last=dic.get(c[i]);
				}else{
					ans+=dic.get(c[i])-last-last;
					last=dic.get(c[i]);
				}
			}
			out.println(ans);
		}
	}
	
	void AOJ0020(){	// Capitalize 大文字変換
		while(sc.hasNext())	out.println(sc.nextLine().toUpperCase());
	}
}

Measured memory_bytes: 12000
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SZ(x) ((int)(x).size())
typedef long long ll;

using namespace std;
int main(){
  int S, FH, LH;
  cin >> S;
  FH = S/100;
  LH = S%100;
  if(FH>0 && FH<13 && LH>0 &&LH<13) cout << "AMBIGUOUS" << endl;
  else if(FH>0 && FH<13) cout << "MMYY" << endl;
  else if(LH>0 && LH<13) cout << "YYMM" << endl;
  else cout << "NA" << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  string s;
  cin >> s;

  if(s.length() == 26) {
    map<char, int> mp;
    int c = 0;
    dep(i, 25, 0) {
      for(auto it = mp.begin(); it != mp.end(); it++) {
        if((int)it->first > (int)s[i]) {
          rep(i, 0, s.length() - c - 1) {
            cout << s[i];
          }
          cout << it->first << endl;
          return 0;
        }
      }
      c++;
      mp[s[i]] = 1;
    }
    cout << -1 << endl;
  }else {
    map<char, int> mp;
    rep(i, 0, s.length()) {
      mp[s[i]] = 1;
    }
    rep(i, 0, 26) {
      if(!mp[(char)('a' + i)]) {
        cout << s << (char)('a' + i) << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sca = new Scanner(System.in);
		int k = sca.nextInt();
		long loop = 1;
		long loop_hantei = 0;
		int[] keta = new int[12];
		boolean flag_runrun = true;
		while(k != 0) {
			flag_runrun = true;
			loop_hantei = loop;
			int i = 0;
			do {
				keta[i] = (int)(loop_hantei % 10);
				loop_hantei /= 10;
				i++;
			} while(loop_hantei != 0);
			for(int j = i-1; j >= 1; j--) {
				if(keta[j] - keta[j-1] > 1 || keta[j-1] - keta[j] > 1) {
					flag_runrun = false;
					loop += (int)(Math.pow(10, (j-1)));
					break;
				}
			}
			if(flag_runrun == true) {
				loop++;
				k--;
			}
			else {
			}
		}
		System.out.println(loop - 1);

		// 後始末
		sca.close();
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1000000001;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  rep(i,n) cin >> a[i], a[i]--;
  rep(i,n) cin >> b[i];
  rep(i,n-1) cin >> c[i];
  
  int ans = 0;
  int pre = -2;
  rep(i, n){
    if(pre + 1 == a[i]){
      ans += c[pre];
    }
    ans += b[a[i]];
    pre = a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define txt                        \
    freopen("ip.txt", "r", stdin); \
    freopen("op.txt", "w", stdout)
#define a3 INT_MAX
#define i3 INT_MIN
#define a6 INT64_MAX
#define i6 INT64_MIN
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define quickie                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define div2(a) (!(a & 1))
#define deb(x) cout << (#x) << " " << (x) << "\n";
#define newl cout << "\n"
#define pi 3.14159265358979323846
#define mod 1000000007
#define all(s) s.begin(), s.end()
#define fp(x) fixed << setprecision(x) <<
#define split(x)                                                 \
    while ((cout << s[i], i += 1) && (i < n - 1) && (cout << x)) \
        ;
int digit(ll a)
{
    vector<long long> dig = {
        0,
        9,
        99,
        999,
        9999,
        99999,
        999999,
        9999999,
        99999999,
        999999999,
        9999999999,
        99999999999,
        999999999999,
        9999999999999,
        99999999999999,
        999999999999999,
        9999999999999999,
        99999999999999999,
        999999999999999999,
        INT64_MAX};
    auto it = lower_bound(dig.begin(), dig.end(), a);
    int idx = (it - dig.begin());
    return idx;
}
int digit(int a)
{
    int r;
    r = (a >= 1000000000) ? 9 : (a >= 100000000) ? 8 : (a >= 10000000) ? 7 : (a >= 1000000) ? 6 : (a >= 100000) ? 5 : (a >= 10000) ? 4 : (a >= 1000) ? 3 : (a >= 100) ? 2 : (a >= 10) ? 1 : 0;
    return r + 1;
}
int main()
{
    quickie;
    //txt;
    char c;
    string s = "";
    while (cin >> c)
    {
        if (c == ',')
        {
            cout << s << " ";
            s = "";
        }
        else
        {
            s+=c;
        }
    }
    cout<<s;
    return 0;
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, auto init = 0) {
    return std::accumulate(all(vec), T(init));
}
// -------------------------------------------------------------------

using P = pair<int, int>;

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    vector<P> v(n);

    rep (i, n) {
        cin >> a[i] >> b[i];
        v[i] = P{a[i] + b[i], i};
    }

    sort(all(v), greater<P>());

    bool taka = true;
    int ans = 0;
    repall (e, v) {
        if (taka) {
            ans += a[e.second];
            taka = false;
        } else {
            ans -= b[e.second];
            taka = true;
        }
    }

    print(ans);

    return 0;
}


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

int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  vector<vector<char>> b(h + 2, vector<char>(w + 2, '#'));
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      cin >> a.at(i).at(j);
    }
  }

  for (int i = 0; i < h + 2; i++){
    for (int j = 0; j < w + 2; j++){
      if (i == 0 || i == h + 1 || j == 0 || j == w + 1) {
        continue;
      } else {
        b.at(i).at(j) = a.at(i - 1).at(j - 1);
      }
    }
  }

  for (int i = 0; i < h + 2; i++){
    for (int j = 0; j < w + 2; j++){
      cout << b.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
n,m = map(int,input().split())
PS = [list(input().split()) for _ in range(m)]
ac = 0
wa = 0
tac = [0]*n
twa = [0]*n
for ps in PS:
  if tac[int(ps[0])-1]==0:
    if ps[1]=='AC':
      ac += 1
      wa += twa[int(ps[0])-1]
      tac[int(ps[0])-1] = 1
    else:
      twa[int(ps[0])-1] += 1
print(ac,wa)

Measured memory_bytes: 27484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int a[2010];

int main() {
    int s,ans = 0;
    cin >> s;
    a[0] = 1;
    a[1] = 0;
    a[2] = 0;
    for (int i = 3; i <= s; ++i) {
        for (int j = i-3; j >= 0; --j) {
            a[i] += a[j];
            a[i] %= mod;
        }
    }
    cout << a[s] << endl;
    return 0;
}

Measured memory_bytes: 3628