akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int N;
    cin >> N;

    if(__builtin_popcount(N) == 1) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    int n = N;
    if(n % 2 == 0) n--;

    FOR(i, 2, n + 1) cout << 1 << " " << i << endl;
    FOR(i, 2, n + 1) cout << i << " " << (i ^ 1) + N << endl;
    cout << 2 + N << " " << 1 + N << endl;
    if(N != n) {
        cout << N << " " << N - 1 << endl;
        cout << 2 * N << " " << (N ^ 1 ^ N - 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 2304
#include <cstdio>
using namespace std;
int main() {
	
  	int n,counter;
	int a[20];
  	counter=0;
  	scanf("%d",&n);
  		
  	for(int i=0; i<n; i++){      
    	scanf("%d",&a[i]);
    }
// 	printf("%d\n",a[4]);
	
  	for(int i=1; i<n-1; i++){
    		
      if((a[i-1]<a[i]&&a[i]<a[i+1])||(a[i-1]>a[i]&&a[i]>a[i+1])){
      	
        counter++;
      
      }
    
    }
  
  printf("%d\n",counter);

}

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

using namespace std;

typedef long long ll;
string s;
int n;

ll r;
ll gr;
ll br;
ll gbr;
ll bgr;

ll g;
ll rg;
ll bg;
ll rbg;
ll brg;

ll b;
ll rb;
ll gb;
ll rgb;
ll grb;

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

    cin >> n >> s;
    n = (int) s.size();
    for (int i = 1; i <= n; i++)
    {
        if (s[i - 1] == 'R')
        {
            r++;
            gr += g;
            br += b;
            gbr += gb;
            bgr += bg;
        }
        if (s[i - 1] == 'G')
        {
            g++;
            rg += r;
            bg += b;
            rbg += rb;
            brg += br;
        }
        if (s[i - 1] == 'B')
        {
            b++;
            rb += r;
            gb += g;
            rgb += rg;
            grb += gr;
        }
    }
    ll ans = gbr + bgr + rbg + brg + rgb + grb;
    for (int i = 1; i <= n; i++)
    {
        for (int d = 1; i - d >= 1 && i + d <= n; d++)
        {
            int x = s[i - d - 1];
            int y = s[i - 1];
            int z = s[i + d - 1];
            if (x != y && x != z && y != z)
            {
                ans--;
            }
        }
    }
    cout << ans << "\n";
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  if ((a+b)>(c+d)){cout << "Left" << endl;}
  if ((a+b)==(c+d)){cout << "Balanced" << endl;}
  if ((a+b)<(c+d)){cout << "Right" << endl;}
}

Measured memory_bytes: 3608
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 

int main(){
    fastio
    int n ; 
    cin >> n ; 
    vector<int> v(n) ; 
    for(int &x : v){
    	cin >> x ; 
    }
    vector<int> t(v.begin(),v.end()) ; 
    sort(t.begin(),t.end()) ; 
    int median = t[n/2] ;
    int cur = t[n/2-1] ;
    for(int &x : v){
    	if ( x < median ){
    		cout << median << endl;
    	}
    	else cout << cur << endl;
    }
    return 0 ;
}


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

using namespace std;

#define N_TIMES(i, n)     for (uint64_t i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for ( int64_t i = n - 1; i >= 0; --i)

const uint64_t MOD = 998244353;

uint64_t mod_bin_power(uint64_t x, uint64_t y)
{
  if (y == 0) return 1;
  if (y == 1) return x % MOD;
  
  uint64_t z = mod_bin_power(x, y >> 1);
  z = (z * z) % MOD;
  if ((y & 1) == 1) { z = (z * x) % MOD; }
  return z;
}

uint64_t search1(uint64_t N, uint64_t S, const vector<uint64_t> &a)
{
  vector<vector<uint64_t>> dp(N + 1);
  N_TIMES(n, N + 1) { dp[n] = vector<uint64_t>(S + 1, 0); }
  dp[0][0] = 1;
    
  N_TIMES(n, N) {
    N_TIMES(r, S + 1) {
      dp[n + 1][r] += (dp[n][r] << 1) % MOD;
      dp[n + 1][r] %= MOD;
      
      if (r + a[n] <= S) {
        dp[n + 1][r + a[n]] += dp[n][r] % MOD;
        dp[n + 1][r + a[n]] %= MOD;
      }
    }
  }
  
  uint64_t sum = 0;
  for (uint64_t s = ((S + 1) >> 1); s <= S; ++s) {
    sum = (sum + dp[N][s]) % MOD;
  }
  return sum;
}

uint64_t search2(uint64_t N, uint64_t S, const vector<uint64_t> &a)
{
  vector<vector<uint64_t>> dp(N + 1);
  N_TIMES(n, N + 1) { dp[n] = vector<uint64_t>(S + 1, 0); }
  dp[0][0] = 1;
  
  N_TIMES(n, N) {
    N_TIMES(r, S + 1) {
      dp[n + 1][r] += dp[n][r] % MOD;
      dp[n + 1][r] %= MOD;
       
      if (r + a[n] <= S) {
        dp[n + 1][r + a[n]] += dp[n][r] % MOD;
        dp[n + 1][r + a[n]] %= MOD;
      }
    }
  }
  
  return dp[N][S >> 1];
}

int main(int argc, char **argv)
{
  uint64_t N;
  cin >> N;
  
  vector<uint64_t> a(N);
  N_TIMES(n, N) { cin >> a[n]; }
  
  uint64_t S = accumulate(a.begin(), a.end(), 0);
  
  uint64_t total = mod_bin_power(3, N);
  
  uint64_t sum1 = search1(N, S, a);
  sum1 = (sum1 * 3) % MOD;
  
  uint64_t sum2 = search2(N, S, a);
  sum2 = (sum2 * 3) % MOD;
  
  uint64_t ans = ((total + MOD) - sum1) % MOD;
  if (S % 2 == 0) { ans = (ans + sum2) % MOD; }
  cout << ans << endl;
  
  return 0;
}

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

//Let's JUMPSTYLE
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[][][] m = new int[n][n][2];
			for(int i=0;i<n;i++)for(int j=0;j<n;j++)for(int k=0;k<2;k++)m[i][j][k]=sc.nextInt();
			boolean[][] u = new boolean[n][n];
			int c = 0;
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					if(u[i][j])continue;
					u[i][j] = true;
					Set<Integer> set = new HashSet<Integer>();
					set.add(i*n+j);
					int nj = m[i][j][0];
					int ni = m[i][j][1];
					while(true){
						if(u[ni][nj]){
							if(set.contains(ni*n+nj))c++;
							break;
						}
						u[ni][nj] = true;
						set.add(ni*n+nj);
						int ti = ni;
						int tj = nj;
						nj = m[ti][tj][0];
						ni = m[ti][tj][1];
					}
				}
			}
			System.out.println(c);
		}
	}

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

Measured memory_bytes: 13000
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a, b, c, d;
string s;

bool check(int p, int q) {
    for (int i = p; i < q; i++) {
        if (s[i] == '#' && s[i+1] == '#') return false;
    }
    return true;
}

bool check2() {
    for (int i = b; i <= d; i++) {
        if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') return true;
    }
    return false;
}

bool solve() {
    if (!check(a, c) || !check(b, d)) return false;
    if (d < c && !check2()) return false;
    return true;
}

void input() {
    cin >> n >> a >> b >> c >> d >> s;
    a--; b--; c--; d--;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << (solve()?"Yes":"No") << endl;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
//#define MOD (998244353)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

int n,k;
int fac[200001];

int poww(int a,int b){
    if(b==0)return 1;
    int ans=poww(a,b/2);
    ans=(ans*ans)%MOD;
    if(b&1)ans=(ans*a)%MOD;
    return ans;
}

int f(int n,int r){
    return fac[n]*poww(fac[n-r],MOD-2)%MOD*poww(fac[r],MOD-2)%MOD;
}

signed main(){
    FASTER;
    cin>>n>>k;
    
    fac[0]=1;
    for(int i=1;i<=200000;i++)fac[i]=(fac[i-1]*i)%MOD;
    
    int ans=0;
    
    for(int i=0;i<=min(k,n-1);i++){
        ans=(ans+f(n,i)*f(n-1,i)%MOD)%MOD;
    }
    cout<<ans;
}




Measured memory_bytes: 1920
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A, B, C, D = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    HP_takahashi = A
    HP_aoki = C
    while HP_takahashi-D > 0 or HP_aoki-B > 0:
        HP_aoki -= B
        HP_takahashi -= D
    else:
        if HP_takahashi <= 0 and HP_aoki <= 0:
            TF = 'Yes'
        elif HP_takahashi <= 0:
            TF = 'No'
        else:
            TF = 'Yes'
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

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

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int ExtendedGCD(int a,int b,int& x,int& y)
{
	if(b==0){
		x=1; y=0;
		return a;
	}
	else{
		int g=ExtendedGCD(b,a%b,y,x);
		y-=a/b*x;
		return g;
	}
}

int ModInverse(int a,int m)
{
	int x,y;
	int g=ExtendedGCD(a,m,x,y);
	if(g==1)
		return (x+m)%m;
	else
		return 0; // invalid
}

vi facts(300000),ifacts(300000);
int ncr(int n,int r)
{
	return (ll)facts[n]*ifacts[r]%MOD*ifacts[n-r]%MOD;
}

int main()
{
	facts[0]=1;
	repi(i,1,facts.size()) facts[i]=(ll)facts[i-1]*i%MOD;
	rep(i,ifacts.size()) ifacts[i]=ModInverse(facts[i],MOD);
	
	for(int n,m,k;cin>>n>>m>>k && n|m|k;){
		vi dp1(k+1),dp2(k+1); dp1[0]=dp2[0]=1;
		vi dp(max(n,m)+1+k,1);
		rep(i,k){
			dp[0]=dp[1];
			repi(j,1,dp.size()-1)
				dp[j]=(dp[j-1]+dp[j+1])%MOD;
			dp1[i+1]=dp[m];
			dp2[i+1]=dp[n];
		}
		
		int res=0;
		rep(i,k+1){
			int tmp=(ll)ncr(m+n+2*k,m+2*i)*dp1[i]%MOD*dp2[k-i]%MOD;
			(res+=tmp)%=MOD;
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 3904
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;

typedef tuple<int, int, int> tri;

vector<int> get_unique(vector<int> v) {
    // sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v;
}

tri counter(const vector<int> &org, const vector<int> &uv) {
    int max_ct1 = 0;
    int max_ct2 = 0;
    int max_v = -1;
    int last_lb = 0;
    int ct = 0;
    REP(i, uv.size()) {
        int lb = upper_bound(org.begin(), org.end(), uv[i]) - org.begin();
        ct = lb - last_lb;
        last_lb = lb;
        if (ct > max_ct1) {
            max_ct2 = max_ct1;
            max_ct1 = ct;
            max_v = uv[i];
        } else if(ct > max_ct2) {
            max_ct2 = ct;
        }
    }

    return make_tuple(max_v, max_ct1, max_ct2);
}

int main() { 
    int n; cin >> n;
    vector<int> v1(n/2);
    vector<int> v2(n/2);
    REP(i, n) {
        if(i%2==0) cin >> v1[i/2];
        else cin >> v2[i/2];
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    auto uv1 = get_unique(v1);
    auto uv2 = get_unique(v2);
    int res = 0;
    auto tri1= counter(v1, uv1);
    int maxv1 = get<0>(tri1);
    int ct11 = get<1>(tri1);
    int ct12 = get<2>(tri1);

    auto tri2= counter(v2, uv2);
    int maxv2 = get<0>(tri2);
    int ct21 = get<1>(tri2);
    int ct22 = get<2>(tri2);

    if (maxv1 == maxv2) {
        if(ct12>ct22) {
            res += (n/2) - ct12;
            res += (n/2) - ct21;
        } else {
            res += (n/2) - ct11;
            res += (n/2) - ct22;
        }
    } else {
        res += (n/2) - ct11;
        res += (n/2) - ct21;
    }

    print(res);
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
//#include <iomanip>
using namespace std;

int main(){

	int H, W;

	while(1){
		cin >> H >> W;
		if(H == 0 && W == 0){
			break;
		}
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if((i + j) % 2 == 0){
					cout << "#";
				}else{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

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

using namespace std;

typedef vector<int> VI;

int main ( void )
{
	int n, q;
	while ( cin >> n >> q, n | q ) {
		VI date_cnts( 101, 0 );
		for ( int i = 0; i < n; ++i ) {
			int m;
			cin >> m;
			for ( int j = 0; j < m; ++j ) {
				int date;
				cin >> date;
				++date_cnts[date];
			}
		}
		int ans = 0;
		for ( int i = 1; i < 101; ++i ) {
			if ( date_cnts[ans] < date_cnts[i] && q <= date_cnts[i] ) {
				ans = i;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll mod = 1000000007;
const int N = 100005;
int dp[N][13];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	string s; cin>>s;
	int n = s.size();
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){
		if(s[i - 1] != '?'){
			int val = s[i - 1] - '0';
			for(int j = 0; j < 13; j++){
				int nj = (10*j + val)%13;
				dp[i][nj] += dp[i - 1][j];
				if(dp[i][nj] >= mod)dp[i][nj] -= mod;
			}
		}else{
			for(int j = 0; j < 13; j++){
				for(int k = 0; k < 10; k++){
					int nj = (10*j + k)%13;
					dp[i][nj] += dp[i - 1][j];
					if(dp[i][nj] >= mod)dp[i][nj] -= mod;
				}
			}
		}
	}
	cout<<dp[n][5]<<'\n';

	return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{   
    gearup;
    ll n,k,c; cin >> n >> k >> c;
    string s; cin >> s;
    vl left(n,-1),right(n,-1);
    ll pre_day = -L_INF;
    ll cnt = 0;
    rep(i,n){
        if(s[i] == 'o'){
            if(i - pre_day > c){
                left[i] = cnt;
                pre_day = i;
                //out(i);
                cnt++;
                if(cnt >= k)break;
            }
        }
    }
    pre_day = L_INF;
    cnt = 0;
    for(int i=n-1;i>=0;i--){
        if(s[i] == 'o'){
            if(pre_day - i > c){
                right[i] = cnt;
                pre_day = i;
                //out(i);
                cnt++;
                if(cnt >= k)break;
            }
        }
    }

    rep(i,n)if(right[i] >= 0)right[i] = k-right[i]-1; //leftに合わせる
    rep(i,n){
        if(left[i] >= 0 && right[i] >= 0 && left[i] == right[i]){
            out(i+1);
        }
    }
}


Measured memory_bytes: 6780
S = list(map(int, list(input())))
N = len(S)
P = 673

cnt = [[0,0,0]  for i in range(P)]
cnt[0][0] = 1
rem1 = 0
rem2 = 0
ans = 0


for i in range(N):
    rem1 = (int(S[-i - 1]) * pow(10, i, P) + rem1) % P
    rem2 = (int(S[-i - 1]) * pow(10, i, 3) + rem2) % 3
    ans += cnt[rem1][rem2]
    cnt[rem1][rem2] += 1

print(ans)



Measured memory_bytes: 11972
/*
      @author: Charan Sai
*/
#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define ppi pair<int, int>
#define endl "\n"
#define nl cout << "\n"
#define deb(x) cout << #x << " " << x << endl;

const int MAX_N=3005;
int arr[MAX_N];
int n;
int dp[MAX_N][MAX_N][2]; 
// dp[i][j] = Max (X - Y) for subsequence arr[i...j] when 0th player starts the game
int bactrack(int start = 1, int end = n, int turn = 0) {
    // Base Case
    if(start == end) {
        if(turn == 0) return arr[start];
        return -arr[start];
    }
    if(dp[start][end][turn]!=-1) return dp[start][end][turn];
    // Choice
    int l = bactrack(start+1, end, !turn);
    int r = bactrack(start, end-1, !turn);
    if(turn == 0) {
        return 
        (dp[start][end][turn]=max(arr[start]+l,
                    arr[end]+r));
    }
    return 
    (dp[start][end][turn] = min(l-arr[start], r-arr[end]));
}


int32_t main() {
    IOS;
    cin >> n;
    memset(dp, -1, sizeof(dp));
    for(int i = 1; i <= n; ++i) cin >> arr[i];
    cout << bactrack();
}

Measured memory_bytes: 141568
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, p;
  cin >> a >> p;

  int piece = p + 3 * a;
  cout << piece / 2 << endl;
}


Measured memory_bytes: 3544
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n; cin>>n; 
    if (n%1000==0) cout << 0 << endl;
    else cout << (1000-(n%1000)) << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

int main(){
    long long k=0;
    string tmp;
    string ans="";

    string pre,now;
    cin>>tmp;
    cin>>k;
        long long N=0,A=0;
    int i=0;

    for(i=0;i<tmp.size();i++){
        if(tmp[i]=='1'&&k==i+1)break;
        else if(tmp[i]!='1')break;


    }

    cout<<tmp[i]<<endl;

}

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

int main() {
    int n;
    cin >> n;
    vector<int> b(n-1);
    rep(i, n-1) {
        cin >> b[i];
    }
    vector<int> a(n);
    a[0] = b[0];
    for (int i = 1; i < n-1; i++)
    {
        a[i] = min(b[i-1], b[i]);
    }
    a[n-1] = b[n-2];
    int sum = 0;
    rep(i, n) {
        sum += a[i];
    }
    cout << sum;
}

Measured memory_bytes: 256
from functools import reduce

MOD = 10**9+7


def gcd(a, b):
    """
    return gcd of a,b
    ユークリッド
    """
    while b:
        a, b = b, a % b
    return a


def list_gcd(l):
    """
    l: list
    l のgcd を返す
    """
    return reduce(gcd, l)


def lcm(a, b):
    """
    a,bの最小公倍数
    """
    return a*b//gcd(a, b)


def list_lcm(l):
    """
    l:list
    lのlcmを返す
    """
    return reduce(lcm, l)


N = int(input())
L = list(map(int, input().split()))

LCM = list_lcm(L)
print(sum([LCM//v for v in L]) % MOD)


Measured memory_bytes: 263140
import java.lang.System;
import java.util.Scanner;

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

        while (sc.hasNextInt()) {
            int d = sc.nextInt();
            int sum = 0;
            for (int i = d; i <= (600 - d); i += d) {
                sum += i*i*d;
            }
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 17204
#include <iostream>
using namespace std;
int a[100001],n,m=0,tot=0,i;
void search(int j)
{
	if(a[j]==j)
	{
		m++;
		search(j+1);
	}
	else
	{
		i=j;
	}
}
int main()
{
	cin>>n;
	for(i=1;i<=n;i++) cin>>a[i];
	for(i=1;i<=n;i++)
	{
		int ans;
		search(i);
		if(m%2==1) tot+=(m+1)/2;
		else tot+=m/2;
		m=0;
	}
	cout<<tot;
	return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	int a;
	cin >> a;
	string s;
	cin >> s;
	assert((int)s.length() == 4);
	int b = (s[3] - '0');
	b += (10 * (s[2] - '0'));
	b += (100 * (s[0] - '0'));
	int ans = a * b;
	ans /= 100;
	cout << ans << endl;
}

int32_t main(){
	IO;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif // ONLINE_JUDGE
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 3660
#include<iostream>
using namespace std;
int main(){

	int H,W,j,i;
	for(;;){
		int x=0;
		cin>>H>>W;
		if(H==0 && W==0){
			break;
		}
		for(j=1;j<=H;j++){
			for(i=1;i<=W;i++){
				cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;

}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		int K = scanner.nextInt();
		int from = scanner.nextInt();
		int to = scanner.nextInt();
		String result = "NG";
		
		scanner.close();
		
		for (int i = from; i <= to; i++) {
			
			if (i % K == 0) {
				result = "OK";
				break;
			} else {
			}

		}
		
		System.out.println(result);
	}

}


Measured memory_bytes: 27040
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
 
int main()
{
    ll n,k;
    cin >> n >> k;
    vector<P> ab;
    for(int i = 0; i < n; i++){
        int a,b; cin >> a >> b;
        ab.emplace_back(a,b);
    }
    sort(ab.begin(),ab.end());
    for(int i = 0; i < n; i++){
        k -= ab[i].second;
        if(k <= 0){
            cout << ab[i].first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1400
import java.util.Scanner;

/**
 * https://abc047.contest.atcoder.jp/tasks/abc047_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();
		
		String ans = (a+b)==c || (b+c)==a || (c+a)==b ? "Yes" : "No";
		System.out.println(ans);

	}

}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
typedef vector<int> vi;
#define pb push_back
#define all(v) (v).begin(),(v).end()
//int xx[]={0,1,0,-1,-1,-1,1,1,-1};int yy[]={1,0,-1,0,1,1,-1,-1}; //E S W N NE SE SW NW

int main() {
_
ll q,h,s,d,n;
cin>>q>>h>>s>>d>>n;
ll qv=q*8LL,hv=h*4LL,sv=s*2LL;
ll ans=0;

    ans=ans+(ll)(n/2)*min(min(qv,hv),min(sv,d));
    if(n%2==1){
        ans=ans+min(4LL*q,min(2LL*h,s));
    }
cout<<ans<<"\n";
return 0;
}


Measured memory_bytes: 256
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 1e5 + 5;

int N;
int cnt[2];

void input()
{
    read(N);
    for (int i = 1; i <= N; ++i) {
        int x;
        read(x);
        ++cnt[x & 1];
    }
}

void solve()
{
    puts(cnt[1] & 1 ? "NO" : "YES");
}

int main()
{
#ifdef __DEBUG
    freopen("A.in", "r", stdin);
    freopen("A.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 辱骂与恐吓不是战斗。
//   --鲁迅


Measured memory_bytes: 256
n = gets.to_i
people = gets.chomp.chars

must_face_W = people[1..people.length - 1].select {|direction| direction == "E"}.length
must_face_E = 0
min = must_face_W

people[1..people.length - 1].each_with_index do |person, index|
  if person == "E"
    must_face_W -= 1
  end
  if people[index] == "W"
    must_face_E += 1
  end
  sum = must_face_W + must_face_E
  if sum < min
    min = sum
  end
end
puts min

Measured memory_bytes: 29828
#include <iostream>
using namespace std;
int main()
{
	int n,x,g, h = 0, p = 1;
	int a[10000];
	cin >> n >> x;
	for (int i = 0; i < n; ++i) {
		cin >> g;
		h += g;
		if (h > x) break;
		++p;
	}
	cout << p;
}	

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

using namespace std;


int n,x,t;

int main()
{
	
    #ifdef patil
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    cin>>n>>x>>t;
     int ans ;
    if(n%x==0)ans = n/x;
    else ans=(n/x)+1;

    cout<<ans*t;

    return 0;


}

Measured memory_bytes: 3596
// Problem : B - An Odd Problem
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		int arr[n+1];
		int ct = 0;
		for(int i=1;i<=n;++i)
		{
			cin>>arr[i];
			if(i&1 and arr[i]&1)
			++ct;
		}		
		cout<<ct;
    }
    return 0;
}


Measured memory_bytes: 3648
#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>;

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double S = x / a;
    if(S == a * b / 2) {
        cout << 45 << endl;
    } else if(S < a * b / 2) {
        cout << fixed << setprecision(6)
             << (360 / (2 * M_PI)) * atan((b * b) / (2 * S)) << endl;
    } else if(S > a * b / 2) {
        cout << fixed << setprecision(6)
             << (360 / (2 * M_PI)) * atan(2 * (a * b - S) / (a * a)) << endl;
    }
    return 0;
}

Measured memory_bytes: 4024
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    string a, b; cin >> a >> b;
    int t = atoi((a + b).c_str());
    int x = sqrt(t);

    cout << (x * x == t ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer

import scala.reflect.ClassTag

object Main {
  def main(args: Array[String]): Unit = {
    try {
      val (in, out) =
        if (isOnlineJudge) {
          (
            new FastScanner(new InputStreamReader(System.in)),
            new PrintWriter(System.out)
          )
        } else {
          (
            new FastScanner(new FileReader(new File("src/resource/problem.in"))),
            new PrintWriter(new File("src/resource/problem.out"))
          )
        }
      new Flipping(in, out).solve()
      out.flush()
      out.close()
    } catch {
      case e: IOException => e.printStackTrace()
    }
  }

  private[this] val isOnlineJudge = true

  class FastScanner(val streamReader: InputStreamReader) {
    private[this] val reader = new BufferedReader(streamReader, 32768)
    private[this] var tokenizer: StringTokenizer = _

    @inline private[this] final def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = Integer.parseInt(next())

    def nextLong(): Long = java.lang.Long.parseLong(next())

    def nextChar(): Char = next().charAt(0)

    def ni(): Int = nextInt()

    def nl(): Long = nextLong()

    def nc(): Char = nextChar()

    def ns(): String = next()

    def ns(n: Int): Array[Char] = ns().toCharArray

    def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)

    def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
      val A1, A2 = Array.ofDim[Int](n)
      REP(n) { i =>
        A1(i) = ni() + offset
        A2(i) = ni() + offset
      }
      (A1, A2)
    }

    def nm(n: Int, m: Int): Array[Array[Int]] = {
      val A = Array.ofDim[Int](n, m)
      REP(n) { i =>
        REP(m) { j =>
          A(i)(j) = ni()
        }
      }
      A
    }

    def nal(n: Int): Array[Long] = map(n)(_ => nl())

    def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n)(_ => ns(m))
  }

  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while (i < N) {
      f(i);
      i += 1
    }
  }

  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while (i >= offset) {
      f(i);
      i -= 1
    }
  }

  def TO(from: Int, to: Int)(f: Int => Unit): Unit = {
    REP(to - from + 1, from)(f)
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]): Array[Long] = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

class Flipping(fScanner: Main.FastScanner, out: java.io.PrintWriter) {

  import Main._
  import fScanner._

  def solve(): Unit = {
    val X = ni()
    val A = ni()

    out.print(if(X < A) 0 else 10)
  }
}


Measured memory_bytes: 25412
#include <algorithm>
#include <string>
#include <queue>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;
#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;

const int INF = 1001001001;

int formula(const string& str, int& cur)
{
//	puts(str.substr(cur).c_str());
	if(isdigit(str[cur])){
		++cur;
		return str[cur-1] - '0';
	}
	if(str[cur] == '-'){
		++cur;
		return 2 - formula(str, cur);
	}

	++cur;
	int a = formula(str, cur);
	char op = str[cur];
	++cur;
	int b = formula(str, cur);
	++cur;
	if(op == '+')
		return max(a, b);
	else
		return min(a, b);
}

int main()
{
	char str[128];
	while(scanf("%s", str), str[0]!='.'){
		int n = strlen(str);
		int cnt = 0;
		rep(p, 3) rep(q, 3) rep(r, 3){
			string tmp = str;
			rep(i, n){
				if(tmp[i] == 'P') tmp[i] = p + '0';
				if(tmp[i] == 'Q') tmp[i] = q + '0';
				if(tmp[i] == 'R') tmp[i] = r + '0';
			}
			int cur = 0;
			cnt += formula(tmp, cur) == 2;
		}

		printf("%d\n", cnt);
	}
	return 0;
}

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

int main() {
	long long S; scanf("%lld",&S);
	long long k = (S - 1) / (int)1e9 + 1;
	printf("0 0 %lld %lld 1000000000 1", k*(int)1e9 - S, k);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
double PI=acos(-1);
int n,k,arr[105];
ll dp[105][100005];
int const mod=1e9 +7;

int main(){
    IO
    cin>>n>>k;
    for(int i=0;i<105;i++) dp[i][0]=1;
    for(int i=1;i<n+1;i++) cin>>arr[i];
    sort(arr,arr+n+1);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=100000;j++){
            if(arr[i]>=j) dp[i][j]=dp[i][j-1]+dp[i-1][j];
            else dp[i][j]=dp[i][j-1]+dp[i-1][j]-dp[i-1][j-arr[i]-1];
            dp[i][j]=(dp[i][j]+mod)%mod;
        }
    }
    cout<<dp[n][k]<<'\n';


    return 0;
}


Measured memory_bytes: 81780
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<priority_queue<ll>> S(N);
    for (int i = 0; i < N; i++) {
        int t;
        ll d;
        cin >> t >> d;
        t--;
        S[t].push(d);
    }
    vector<ll> tops;
    vector<ll> others;
    int T = 0;
    for (int i = 0; i < N; i++) {
        if (S[i].empty()) {
            continue;
        }
        T++;
        tops.push_back(S[i].top());
        S[i].pop();
        while (!S[i].empty()) {
            others.push_back(S[i].top());
            S[i].pop();
        }
    }

    sort(tops.begin(), tops.end(), greater<ll>());
    sort(others.begin(), others.end(), greater<ll>());
    for (int i = 1; i < (int)tops.size(); i++) {
        tops[i] += tops[i - 1];
    }
    for (int i = 1; i < (int)others.size(); i++) {
        others[i] += others[i - 1];
    }

    ll ans = 0;
    for (ll k = 1; k <= min(T, K); k++) {
        if (K - k - 1 >= (int)others.size()) {
            continue;
        }
        ll sum = k * k + tops[k - 1];
        if (k == K) {
            sum += 0;
        } else {
            sum += others[K - k - 1];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 7672
// C++ program to count common subsequence in two strings
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int mod=1e9+7;

int a1,a2,dp[2003][2003],s[2004],t[2004];

// return the number of common subsequence in
// two strings
int CommomSubsequencesCount(){
    for (int i = 1; i <= a1; i++) {
        for (int j = 1; j <= a2; j++) {
            if (s[i-1] == t[j-1]){
                dp[i][j] = 1 + dp[i][j - 1] + dp[i - 1][j];
                dp[i][j]=dp[i][j]%mod;
            }
            else{
                dp[i][j] = dp[i][j - 1] + dp[i - 1][j] -
                                        dp[i - 1][j - 1];
                while(dp[i][j]<0) dp[i][j]+=mod;
                dp[i][j]=dp[i][j]%mod;
            }
        }
    }
    return dp[a1][a2];
}

int32_t main(){
    cin >> a1 >> a2;
    for(int i=0;i<a1;i++) cin >> s[i];
    for(int i=0;i<a2;i++) cin >> t[i];
    cout << CommomSubsequencesCount() + 1 << endl;
}


Measured memory_bytes: 31616
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


const int mod=1000000007;
//const int mod=998244353;




int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r,z;
    string s;
    cin >> s;
    n=(int)s.length();
    for(int i=1; i<n; i++){
        if(s[i]==s[i-1]){
            cout << i << ' ' << i+1 << el;
            return 0;
        }
    }
    for(int i=2; i<n; i++){
        if(s[i]==s[i-2]){
            cout << i-1 << ' ' << i+1 << el;
            return 0;
        }
    }
    cout << -1 << ' ' << -1 << el;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
  int month;
  int day;
  int count_takahashi=0;
  int i,j;

  scanf("%d %d",&month,&day);

  if(month>day){
    day=month-1;
  }

  for(i=1;i<=month;i++){
    for(j=1;j<=day;j++){
      if(i==j){
        count_takahashi++;
      }
    }
  }

  if(count_takahashi>12)
    count_takahashi=12;

  printf("%d\n",count_takahashi);

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
long long int h[200005], l;
long long int abs(long long int n)
{
	if (n < 0)
		n *= -1;
	return n;
}
int comp_h(long long int a, long long int b)
{
	if (abs(h[a]) < abs(h[b]))return 1;
	return -1;
}
void swap_h(long long int a, long long int b)
{
	long long int f = h[a];
	h[a] = h[b];
	h[b] = f;
	return;
}
void f1(long long int ne)
{
	h[l] = ne;
	long long int p = l;
	l++;
	while (p > 0)
	{
		if (comp_h((p - 1) / 2, p) > 0)
			swap_h((p - 1) / 2, p);
		p = (p - 1) / 2;
	}
	return;
}
long long int f2()
{
	l--;
	swap_h(0, l);
	long long int p = 0;
	for (;;)
	{
		if (2 * p + 2 < l)
		{
			if (comp_h(2 * p + 1, 2 * p + 2) > 0)
			{
				if (comp_h(p, 2 * p + 2) > 0)
					swap_h(p, 2 * p + 2);
				p = 2 * p + 2;
			}
			else
			{
				if (comp_h(p, 2 * p + 1) > 0)
					swap_h(p, 2 * p + 1);
				p = 2 * p + 1;
			}
		}
		else if (2 * p + 1 < l)
		{
			if (comp_h(p, 2 * p + 1) > 0)
				swap_h(p, 2 * p + 1);
			p = 2 * p + 1;
		}
		else
			break;
	}
	return h[l];
}
int main()
{
	long long int n, k;
	scanf("%lld %lld", &n, &k);
	long long int i, j;
	long long int a[200005];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	l = 0;
	for (i = 0; i < n; i++)
		f1(a[i]);
	for (i = 0; i < n; i++)
		a[i] = f2();
	long long int P = 1000000007;
	long long int v = 1;
	for (i = 0; i < k; i++)
		v = v * a[i] % P;
	if (v >= 0)
	{
		printf("%lld\n", v);
		return 0;
	}
	long long int cnt[3];
	cnt[0] = cnt[1] = cnt[2] = 0;
	for (i = 0; i < n; i++)
	{
		if (a[i] < 0)
			cnt[0]++;
		else if (a[i] == 0)
			cnt[1]++;
		else
			cnt[2]++;
	}
	if (cnt[0] / 2 * 2 + cnt[2] < k || (k % 2 > 0 && cnt[2] == 0))
	{
		if (cnt[1] > 0)
		{
			printf("0\n");
			return 0;
		}
		v = 1;
		for (i = 0; i < k; i++)
			v = v * a[n - i - 1] % P;
		printf("%lld\n", (v + P) % P);
		return 0;
	}
	int s, t, p, q;
	s = k - 1;
	t = k - 1;
	while (a[s] * a[t] > 0 && t < n)
		t++;
	p = k - 1;
	while (a[p] * a[s] > 0 && p >= 0)
		p--;
	q = n + 1;
	if (p >= 0)
	{
		q = k;
		while (a[p] * a[q] > 0 && q < n)
			q++;
	}
	if (t < n && q < n)
	{
		if (abs(a[s] * a[q]) > abs(a[t] * a[p]))
		{
			v = 1;
			for (i = 0; i < p; i++)
				v = v * a[i] % P;
			for (i = p + 1; i < k; i++)
				v = v * a[i] % P;
			v = v * a[q] % P;
			v = (v + P) % P;
		}
		else
		{
			v = 1;
			for (i = 0; i < s; i++)
				v = v * a[i] % P;
			for (i = s + 1; i < k; i++)
				v = v * a[i] % P;
			v = v * a[t] % P;
			v = (v + P) % P;
		}
		printf("%lld\n", v);
		return 0;
	}
	if (t < n)
	{
		v = 1;
		for (i = 0; i < s; i++)
			v = v * a[i] % P;
		for (i = s + 1; i < k; i++)
			v = v * a[i] % P;
		v = v * a[t] % P;
		v = (v + P) % P;
		printf("%lld\n", v);
		return 0;
	}
	v = 1;
	for (i = 0; i < p; i++)
		v = v * a[i] % P;
	for (i = p + 1; i < k; i++)
		v = v * a[i] % P;
	v = v * a[q] % P;
	v = (v + P) % P;
	printf("%lld\n", v);
	return 0;
}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
int main() { // input
int N; cin >> N;
vector<int> H(N);
for (int i = 0; i < N; ++i) {
cin >> H[i]; }
// compute
int ans = 0;
for (int i = 0; i < N; ++i) {
bool is_candidate = true;
for (int j = 0; j < i; ++j) {
if (H[j] > H[i]) { is_candidate = false; break;
} }
if (is_candidate) { ++ans;
} }
// output
cout << ans << endl; }

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

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  bool is_zero=false;
  int minus=0;
  ll ans=0;
  vecll a(n);
  rep(i,n){
    ll tmp;
    cin >> tmp;
    if(tmp<0) minus++;
    if(tmp==0) is_zero=true;
    a[i]=abs(tmp);
    ans+=a[i];
  }

  if(is_zero || minus%2==0){
    prt(ans);
  } else {
    sortall(a);
    ans-=2*a[0];
    prt(ans);
  }

}


Measured memory_bytes: 1024
import java.util.*;
import java.util.function.Predicate;

public class Main {

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

    void run() {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        Work W[] = new Work[N];
        for (int i = 0; i < N; i++){
            A[i] = cin.nextInt();
            B[i] = cin.nextInt();
            W[i] = new Work(A[i], B[i]);
        }
        if(solve(N, W)) System.out.println("Yes");
        else System.out.println("No");
    }

    class Work implements Comparable<Work>{
        public int A, B;
        public Work(int A, int B){
            this.A = A; this.B = B;
        }
        @Override
        public int compareTo( Work w ){
            return this.B - w.B;
        }
    }

    boolean solve(int N, Work[] W){
        //締切の早い順にソートする
        Arrays.sort(W);
        int time = 0;
        //順番に仕事を消化していく
        for (Work w: W){
            time += w.A;
            // 納期を過ぎていたら失敗
            if(time > w.B) return false;
        }
        //最後まで仕事を終えることが出来たら
        return true;
    }
}



Measured memory_bytes: 109508