akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static long solve[][] = new long[100001][4];
    public static int a[] = new int[100001];
    public static int b[] = new int[100001];
    public static int c[] = new int[100001];
    public static long n;
    public static void main(String args[])throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        n=Long.parseLong(br.readLine());
        for(int i=0;i<n;i++)
        {
            for(int j=1;j<4;j++)
                solve[i][j]=-1;
        }
        for(int j=1;j<4;j++)
            solve[(int)n][j]=0;
        for(int i=0;i<n;i++)
        {
            String S[]=br.readLine().split(" ");
            a[i]=Integer.parseInt(S[0]);
            b[i]=Integer.parseInt(S[1]);
            c[i]=Integer.parseInt(S[2]);
        }
        //System.out.println(DP(0,-1));
        System.out.println(Math.max(Math.max((DP(1,1)+a[0]),(DP(1,2)+b[0])),(DP(1,3)+c[0])));
        //System.out.println("\n\n\n");
        /*for(int i=0;i<n;i++)
            System.out.println(solve[i]);*/
    }
    public static long DP(int x,int lastChosen)
    {
        if(solve[x][lastChosen]==-1)
        {
            if(lastChosen==1)
                solve[x][lastChosen]=Math.max((DP(x+1,2)+b[x]),(DP(x+1,3)+c[x]));
            else if(lastChosen==2)
                solve[x][lastChosen]=Math.max((DP(x+1,1)+a[x]),(DP(x+1,3)+c[x]));
            else /*if(lastChosen==3)*/
                solve[x][lastChosen]=Math.max((DP(x+1,1)+a[x]),(DP(x+1,2)+b[x]));
        }
        return solve[x][lastChosen];
    }
}

Measured memory_bytes: 66764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
void mmin(int &a, int b) {
	a = min(a, b);
}
void mmax(int &a, int b) {
	a = max(a, b);
}
int nibl(vel &v, int tan) {
	int up = v.size() - 1;
	int lo = 0;
	if (v[up] <= tan) return up;
	while (up - lo > 1) {
		int mi = (up + lo) / 2;
		if (v[mi] <= tan) lo = mi;
		if (tan < v[mi]) up = mi;
	}
	return lo;
}
signed main() {
	int n;
	int q;
	cin >> n >> q;
	vel a(n+1);
	int ma = 100;
	ma *= 100 * 100;
	ma++;
	vel s(n + 1);
	vel bes(n + 1);
	s[0] = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		s[i] = s[i - 1] + a[n - i];
	}
	int ko = (n + 1) / 2;
	bes[0] = 0;
	for (int i = n - 1; i >= 0; i -= 2) {
		bes[0] += a[i];
	}
	for (int i = 1; i <= ko; i++) {
		bes[i] = bes[i - 1] - a[n+1-2*i];
	}
	vel qa = a;
	for (int i = 0; i < n; i++) {
		a[i] = ma - qa[n-1-i];
	}
	a[n] = 2*ma;
	for (int i = 0; i < q; i++) {
		int x; cin >> x;
		x = ma - x;
		int lo = 1;
		int up = (n + 3) / 2;
		while (up-lo>1) {
			int mi = (up + lo) / 2;
			if (2 * mi -1< n) {
				if (abs(x - a[mi]) >= abs(x - a[2 * mi])) {
					lo = mi;
				}
				else if (abs(x - a[mi - 1]) < abs(x - a[2 * mi-2])) {
					up = mi;
				}
				else {
					lo = mi;
					up = mi + 1;
				}
			}
			else if (2 * mi - 1 == n) {
				if (abs(x - a[mi - 1]) >= abs(x - a[2 * mi - 2])) {
					lo = mi;
					up = mi + 1;
				}
				else {
					up = mi;
				}
			}
			else {
				up = mi;
			}
		}
		cout << s[lo] + bes[lo] << endl;
	}
	return 0;
}

Measured memory_bytes: 4864
main()
{
 int x , y;
 int z;

 do{
  scanf("%d%d", &x, &y);
  if(x > y){
   z = x;
   x = y;
   y = z;
  }
  if(x != 0 || y != 0)printf("%d %d\n", x, y);

 }while(x != 0 || y != 0);

 return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

map<char,ll> table;

ll calc(string s){
	ll res = 0;
	ll c = 1;
	rep(i,s.size()){
		if(s[i] >= '2' && s[i] <= '9')c = s[i] - '0';
		else{
			res += c*table[s[i]];
			c = 1;
		}
	}
	return res;
}

string solve(ll num){
	string res = "";
	ll cnt = 0;
	while(num >= 1000){
		num -= 1000;
		cnt++;
	}
	if(cnt >= 2)res += (char)('0'+cnt);
	if(cnt >= 1)res += "m";

	cnt = 0;
	while(num >= 100){
		num -= 100;
		cnt++;
	}
	if(cnt >= 2)res += (char)('0'+cnt);
	if(cnt >= 1)res += "c";

	cnt = 0;
	while(num >= 10){
		num -= 10;
		cnt++;
	}
	if(cnt >= 2)res += (char)('0'+cnt);
	if(cnt >= 1)res += "x";

	cnt = 0;
	while(num >= 1){
		num -= 1;
		cnt++;
	}
	if(cnt >= 2)res += (char)('0'+cnt);
	if(cnt >= 1)res += "i";
	return res;
}

int main(){
	cin >> n;
	table['m'] = 1000;
	table['c'] = 100;
	table['x'] = 10;
	table['i'] = 1;
	while(n--){
		string s,t;
		cin >> s >> t;
		ll num = calc(s)+calc(t);
		// cout << "!" << num << endl;
		cout << solve(num) << endl;
	}
}


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

int main(){

  int n;
  cin >> n;
  int k = n%10;
  if(k==3){
    cout << "bon" << endl;
  }
  else if(k==0 || k==1 || k==6 || k==8){
    cout << "pon" << endl;
  }
  else {
    cout << "hon" << endl;
  }

}


Measured memory_bytes: 3592
// ------------------------------------
// Date:2018/ 2/28
// Problem:ABC 063 Varied b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

int main()
{
  bool check[28];
  bool ok = true;
  memset(check, false, sizeof(check));
  string inputStr;
  cin >> inputStr;
  REP(n, inputStr.size()) {
    if (check[(int)inputStr[n] - 97]) {
      ok = false;
    }
    check[(int)inputStr[n] - 97] = true;
  }
  cout << (ok ? "yes" : "no") << endl;
  return 0;
}



Measured memory_bytes: 256
N = int(input())
t,a = (int(i) for i in input().split())
A = list(map(int,input().split()))
x = 10**9
ans = 0
for i in range(N):
    if abs(a-(t - (A[i]*0.006))) < x:
        x = abs(a-(t - (A[i]*0.006)))
        ans = i
print(ans + 1)


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

int main(){
  int N,k=0;
  long long sum=0;
  cin >> N;
  vector<int> length(N);
  
  for(int i=0; i<N; i++)
    cin >> length.at(i);
  
  for(int j=0; j<N-1; j++){
    if(length.at(j)>length.at(j+1)){
      k=length.at(j+1);
      length.at(j+1)=length.at(j);
      sum += length.at(j)-k;
    }
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 4052
#include<iostream>
using namespace std;
int main() {
  int N, M, K, A, f[31], ans = 0;
  cin >> N >> M;
  for (int i = 0;i <= M;++ i) f[i] = 0;
  for (int i = 0;i < N;++ i) {
    cin >> K;
    while(K--) {
      cin >> A;
      if (++f[A] >= N) ++ ans;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#20:58
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = []
for i in range(m):
  now = list(map(int,input().split()))
  now.reverse()
  b.append(now)
b.sort()
b.reverse()
c = []
for i in range(m):
  c += [b[i][0]] * b[i][1]
  if len(c) > n:
    c = c[:n]
    break
if len(c) < n:
  c += [0] * (n-len(c))
ans = 0
for i in range(n):
  ans += max(a[i],c[i])
#print(a)
#print(c)
print(ans)

Measured memory_bytes: 33872
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    string S;cin>>S;
    ll ans=0,count=0;
    rep(i,S.size()){
        if(S[i]=='B')count++;
        else ans+=count;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define HpOut(S) cout << setprecision(20) << S << endl;
#define print(x) cout << (x) << endl;
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


// res は答え
vector<ll> ans;
vector<vector<ll>> G;

void dfs(ll v, ll p=-1) {
    for (auto e : G[v]) {
        if (e == p) continue;
        ans[e] += ans[v];
        dfs(e, v);
    }
}

int main(void){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N,Q;
    cin >> N >> Q;
    G.assign(N, vector<ll>());
    for (int i = 0; i < N-1; ++i) {
        int a, b; cin >> a >> b; 
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ans.assign(N, 0);
    for (int q = 0; q < Q; ++q) {
        int p, x; cin >> p >> x; --p;
        ans[p] += x;
    }
    dfs(0);
    rep(i,N) cout << ans[i] << " ";
}


Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second
 
const int MOD = 1e9 + 7;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0}; 
const char dir[] = {'R', 'L', 'D', 'U'};
 
int add(int a, int b){
    a += b;
    if(a >= MOD){
        a -= MOD;
    }
    return a;
}
 
int sub(int a, int b){
    a -= b;
    if(a < 0) a += MOD;
    return a;
}
 
int mult(int a, int b){
    return ((ll) a * b) % MOD;
}
 
void setIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    freopen((s+".in").c_str(),"r",stdin);
//    freopen((s+".text").c_str(),"w",stdout);
}
 
//ctrl q is comment
//ctrl b is run
//ctrl s is compile
//alt r is search & replace
//alt d is delete a line
 
bool comp(pii a, pii b){
    return a.y < b.y;
}
 
int main(){
    setIO();
    string s; cin >> s;
    int sum = 0;
    for(int i = 0; i < s.length(); ++i){
        sum += s[i] - '0';
    }
    cout << (sum % 9 == 0 ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!


void solve(){

    int n,m;
    cin>>n>>m;
    vector<int> adj[55];
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for(int i=1;i<=n;i++){
        cout<<adj[i].size()<<endl;
    }
}




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

Measured memory_bytes: 3628
#include <stdio.h>

int main(void)
{
	int height[10];
	int i, j;
	int t;
	
	for (i = 0; i < 10; i++){
		scanf("%d", &height[i]);
	}
	
	for (i = 0; i < 9; i++){
		for (j = 0; j < 9; j++){
			if (height[j] < height[j + 1]){
				t = height[j + 1];
				height[j + 1] = height[j];
				height[j] = t;
			}
		}
	}
	
	for (i = 0; i < 3; i++){
		printf("%d\n", height[i]);
	}
	
	return (0);
}

Measured memory_bytes: 600
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias t = Tuple!(string, "name", long, "y");

void main()
{
    auto n = lread!(real);
    auto lim = n.sqrt.ceil();
    real f_min = INF;
    foreach (a; iota(1, lim + 1))
    {
        if (n % a)
            continue;

        auto b = n / a;
        auto disit_a = a.getdisit();
        auto disit_b = b.getdisit();
        auto f = max(disit_a, disit_b);
        f_min = min(f, f_min);
    }
    f_min.writeln();
}

auto getdisit(T)(T n)
{
    T i = 0;
    while (abs(n) >= 1)
    {
        n /= 10;
        i++;
    }
    return i;
}

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,k,c;
    cin>>n>>k>>c;
    string s;
    cin>>s;
    int a[n];
    for(int i=n-1;i>=0;i--){
        int g=0;
        if(s[i]=='x'){
            if(i < n-1) g=a[i+1];
        }
        else{
            g=1;
            if(i+c+1 < n) g+=a[i+c+1];
        }
        a[i]=g;
    }
    int took=0;
    int last=-10000000;
    for(int i=0;i<n;i++){
        int r=max(last+c+1,i+1);
        int g=took+(r < n ? a[r] : 0);
        if(g < k) cout<<i+1<<'\n';
        if(s[i]=='x') continue;
        if(i>=last+c+1){
            took++;
            last=i;
        }
    }
}


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

#define PI 3.14159265359

int main()
{
    int a = 0, b = 0, h = 0, m = 0;
    double deg_h = 0, deg_m = 0;
    double ans = 0;
    scanf("%d%d%d%d", &a, &b, &h, &m);

    deg_m = 6*m;
    deg_h = 30*h+0.5*m;

    // printf("deg h = %lf\n", deg_h);
    // printf("deg m = %lf\n", deg_m);
    // printf("abs = %lf\n", abs(deg_h-deg_m));
    // printf("cos = %lf\n", abs(deg_h-deg_m));


    ans = sqrt(a*a + b*b - 2*a*b*cos(abs(deg_h-deg_m)*PI/180.0));
    printf("%.20lf\n", ans);

    return 0;
}



Measured memory_bytes: 4224
import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
from collections import defaultdict
PY = defaultdict(list)
for i in range(M):
  p,y = map(int,readline().split())
  PY[p].append([y,i])

res = []
for key,value in PY.items():
  value = sorted(value, key = lambda x:x[0])
  for i in range(len(value)):
    res.append([key,i + 1,value[i][1]])

res = sorted(res, key = lambda x:x[2])
for r in res:
  print(str(r[0]).zfill(6) + str(r[1]).zfill(6))

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

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

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    cin >> n >> k;
    ll idx_1;
    NREP() {
        cin >> tmp;
        if (tmp == 1) idx_1 = i;
    }
    ll before = 0;
    ll after = 0;
    ll next = idx_1;
    while (next > 0) {
        next = next - k + 1;
        before++;
    }
    ll rem = -next;

    next = idx_1 + rem;
    while (next < n-1) {
        next = next + k - 1;
        after++;
    }

    MSG(before + after)
}


Measured memory_bytes: 256
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   string s;
   cin>>s;
   ll cnt1=0,cnt2=0;
   for(ll i=0;i<s.size();i++)
   {
       if(s[i]=='A')
       cnt1++;
       else
       cnt2++;
   }
   if(cnt1>=1&&cnt2>=1)
   cout<<"Yes";
   else
   cout<<"No";
}




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

using namespace std;
int main(){
    string n; cin>> n;
    char c=n[0];
    int cont=1;
    for(int i=1;i<n.size();++i){
        if(n[i]==c){
            cont++;
        }else{
           c=n[i];
           cont=1;
        }
        if(cont==3){
            cout<<"Yes"<<endl; return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
def ranking(x):
    if(x>=400):
        if(x<600):
            return 8
        elif(x<800):
            return 7
        elif (x < 1000):
            return 6
        elif (x < 1200):
            return 5
        elif (x < 1400):
            return 4
        elif (x < 1600):
            return 3
        elif (x < 1800):
            return 2
        elif (x < 2000):
            return 1
x=int(input())
print(ranking(x))

Measured memory_bytes: 9132
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<char> dchar;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
ll infi=1e18+100;

//x=10111;
//x<<2 = 1011100 (右シフト),x>>2 = 101 (左シフト)
//(x>>2)&1 = 101 & 001 = 1
//iビット目は、(x>>i) & 1 でわかる(x>>i)%2 でもよい

int X;


int main(){
	cin>>X;
	Rep(i,100000){
		if((i*(i-1))/2<X && X<=(i*(i+1))/2){
			cout<<i<<endl;
			break;
		}
	}
	  return 0;
  }

Measured memory_bytes: 256
import math

t = [int(input()) for _ in range(5)]

min1 = map(lambda x: x % 10, t)
min1 = min([10 if i == 0 else i for i in min1])

print(sum(map(lambda x: math.ceil(x) * 10, [i/10 for i in t])) - (10 - min1))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;


int n;


set<vector<int>> done;
set<string> ans;
void search(int index, string s, int maxI) {

   // cout << index << " " << s << endl;

    if(index == n) {
        cout << s << endl;
        return;
    }

    for(int i = 0; i <= maxI; ++i) {

        s[index] = 'a' + i;

        search(index + 1, s, max(i + 1, maxI));
    
    }

}

int main() {

    cin >> n;
    string s(n, 'a');
    search(1, s, 1);


    return 0;

}

Measured memory_bytes: 1536
#include <iostream>
#include <numeric>
#include <cmath>

int main()
{
        using namespace std;

        float a, b;
        int ans = -1;
        cin >> a >> b;

        int amax, amin, bmax, bmin;

        bmax = ((b+1) * 100 / 10) - 1;
        bmin = b * 100 / 10;
        amax = (int)ceil(((a+1.0) * 100.0 / 8.0) - 1.0);
        amin = (int)ceil(a * 100.0 / 8.0);

        if(!(bmin > amax || amin > bmax))
        {
            ans = max(amin, bmin);
        }

        cout << ans << endl;

        return 0;
}


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

vector<int> par;
vector<ll> siz;

int root(int x){
  if(par.at(x)==-1) return x;
  return par.at(x) = root(par.at(x));
}

bool same(int x, int y){
  return root(x)==root(y);
}

void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x==y) return;
  if(siz.at(x) < siz.at(y)) swap(x, y);
  par.at(y) = x;
  siz.at(x) += siz.at(y);
  
}
ll size(int x){
  return siz.at(root(x));
}

int main() {
  ll N, M;
  cin >> N >> M;
  par = vector<int> (N, -1);
  siz = vector<ll> (N, 1);
  vector<ll> ans (M, 0);
  
  int A, B;
  vector<P> node(M);
  rep(i, M){
    cin >> A >> B;
    node.at(i) = make_pair(--A, --B);
  }
  
  ans.at(M-1) = (N*(N-1)) / 2;

  for(int i=M-1; i>=1; --i){
    int x, y;
    tie(x, y) = node.at(i);
    
    if(same(x, y)) ans.at(i-1) = ans.at(i);
    else{
     ans.at(i-1) = ans.at(i) - (size(x)*size(y));
   	 unite(x, y);
    }
  }
  
  for(auto e:ans) cout << e << endl;

  return 0;
}

Measured memory_bytes: 5836
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#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()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  vector<ll> l(n+1);
  l[0]=2; l[1]=1;
  for(int i=2;i<n+1;i++){
    l[i]=l[i-1]+l[i-2];
  }
  cout<<l[n]<<endl;

  return 0;
}


Measured memory_bytes: 256
<?php
function kitai($a) {
    $l = 0;
    for ($i = 1; $i <= $a; $i++) {
        $l += $i * (1 / $a);
    }
    return $l;
}

fscanf(STDIN, "%d %d", $n, $k);
$arr = array_map('intval', explode(' ', trim(fgets(STDIN))));

$kitaiMap = [];
for($i = 1; $i <= 1000; $i++) {
    $kitaiMap[$i] = kitai($i);
}

$max = 0;
$current = 0;
for($i = 0; $i < $n; $i++) {
    $current += $kitaiMap[$arr[$i]];
    $max = max($current, $max);
    
    if ($i - $k + 1 >= 0) {
        $current -= $kitaiMap[$arr[$i - $k + 1]];
    }
}
echo $max;

Measured memory_bytes: 27120
#include <stdio.h>
 
int main(void) {
    
    int N, cost_train, cost_taxi;

    scanf("%d %d %d", &N, &cost_train, &cost_taxi);

    int cost_train_all = N * cost_train;

    if(cost_train_all >= cost_taxi)
        printf("%d\n", cost_taxi);
    
    else
        printf("%d\n", cost_train_all);
 
    return 0;
}

Measured memory_bytes: 128
s = list(input())
ans = [0] * len(s)

p = 0
cnt = 0
for i in range(len(s)):
    if s[i] == 'R':
        p = i
        cnt = 0
    if s[i] == 'L':
        cnt += 1
        if cnt % 2 == 0:
            ans[p] += 1
        else:
            ans[p+1] += 1

s.reverse()
#print(s)
for i in range(len(s)):
    if s[i] == 'L':
        p = i
        cnt = 0
    if s[i] == 'R':
        cnt += 1
        if cnt % 2 == 0:
            ans[-(p+1)] += 1
        else:
            ans[-(p+2)] += 1

print(' '.join(map(str,ans)))

Measured memory_bytes: 11176
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
vector<vector<int> > d; 
ll power(ll a,int n){
  if(n==0)
    return 1;
  if((n%2)==0)
    return (power((a*a)%mod,n/2))%mod;
  else
    return (a*(power((a*a)%mod,n/2))%mod)%mod;    
}
double sqrt1(double a){
    double l=0;
    double h=a;
    double m;
    double ans;
    while((h-l)>=1e-8){
       m=(h+l)/2;
       if((m*m)<a){
             ans=m;
             l=m;
       }
       else if(m*m==a){
             ans=m;
             break;
       }
       else{
          h=m;
       }
    }
    return ans;
}
int main(){
FASTIO
string s;
cin>>s;
int a=0;
int b=0;
for(int i=0;i<s.size();i++){
  if(s[i]=='A')
    a++;
  else
    b++;
}
if((a>0)&&(b>0)){
    cout<<"Yes";
}
else
   cout<<"No";
return 0;
}

Measured memory_bytes: 256
import numpy as np
def solve():
    N = int(input())
    A = np.array(list(map(int, input().split())),dtype=np.int64)
    count = 0
    while True:
        if np.sum(A%2) ==0:
            A = A//2
            count += 1
        else:
            return print(count)

if __name__ == '__main__':
    solve()

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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    long long N, M;
    cin >> N >> M;    
    vector<long long> A(N);
    for (int i=0; i<N; ++i) cin >> A[i];
    sort(A.begin(), A.end());

    vector<long long> ac(N+1, 0);
    for (int i=0; i<N; ++i) {
        ac[i+1] = ac[i] + A[i];
    }

    // 和がx以上となるペアの個数
    auto f = [&](long long x) {
        long long ret = 0;
        for (int i=0; i<N; ++i) {
            ret += A.end() - lower_bound(A.begin(), A.end(), x-A[i]);
        }
        return ret;
    };

    // 和がx以上となるペアの総和
    auto f2 = [&](long long x) {
        long long ret = 0;
        for (int i=0; i<N; ++i) {
            auto it = lower_bound(A.begin(), A.end(), x-A[i]);
            if (it == A.end()) continue;
            int j = it - A.begin();
            ret += A[i] * (N-j) + ac[N] - ac[j];
        }
        return ret;
    };

    long long l, r;
    l = 0;
    r = A[N-1]*2+1;
    while (r - l > 1) {
        long long mi = (l+r) / 2;
        if (f(mi) >= M) l = mi;
        else r = mi;
    }

    long long res = f2(l) - (f(l) - M) * l;
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
  int N;
  cin >> N;
  int o;
  
  for(int i=1;i<=N;i++){
    if(i % 2 != 0) o++;
  }
  
  double a = N;
  double b = o;
  
  cout << setprecision(10) << b / a << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    int N;
    cin >> N;
    
    vector<int> Vs;
    REP(i, N) {
        int v;
        cin >> v;
        Vs.push_back(v);
    }
    ll r = 0;
    REP(i, N) {
        int c;
        cin >> c;
        if (Vs[i] - c > 0) r+= Vs[i]-c;
    }
    cout << r << endl;
}


Measured memory_bytes: 256
# after reading editorial
n = gets.to_i
a = gets.split.map(&:to_i)
data1 = Hash.new(0)
data2 = Hash.new(0)
n.times{|i|
  next if a[i] >= n-1
  data1[i + a[i]] += 1
  data2[i - a[i]] += 1
}
p data1.map{|k, v| data2[k] * v }.sum


Measured memory_bytes: 42268
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

const int N_MAX = 1e5;

int N, M;
int L[N_MAX + 1], R[N_MAX + 1];

int main() {
  scanf("%d %d", &N, &M);

  rep(i, M) scanf("%d %d", &L[i], &R[i]);

  int max_l = L[0];
  int min_r = R[0];
  rep(i, M) {
    max_l = max(max_l, L[i]);
    min_r = min(min_r, R[i]);
  }
  printf("%d\n", max(min_r - max_l + 1, 0));
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define let const auto
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout<< (x) << '\n'

int main()
{
   cin.tie(0), ios::sync_with_stdio(false);
   int a, b, c;
   cin >> a >>b >> c;

   outl( (a+b >= c)? "Yes" : "No");

}



Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:1024000000,1024000000")
/* vim: set fdm=marker */
//{{{
#define __ return
int ATTENTION() {
	/* pls IGNORE this function and go down and HACK me
	 * read this AFTER contest
	 * this function is empty and it will not be called !
	 */

	http://codeforces.com/group/Pmz2A2x7ES
	/* I created a group there.
	 * I hope with the group, people can finish
	 * past contests, which is important for 
	 * increasing rating.
	 * I am still getting familiar with this function.
	 */
	 __ 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < 0) return gcd(-a, b);
	if(b < 0) return gcd( a,-b);
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}

ll qpow(ll a, ll n, ll mod) {
	a %= mod;
	ll ans = 1LL;
	while(n) {
		if(n & 1) ans = (ans*a % mod);
		a = (a*a % mod);
		n >>= 1;
	}
	return ans;
}

inline ll rev(ll a, ll p) {
	return qpow(a, p - 2, p);
}

#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define rep(x, st, en) for(int x = st; x < en; x++)
#define rer(x, st, en) for(int x = st; x >= en; x--)
#define pb push_back
#define mp make_pair
#define dbgm(msg, var) cerr<<#msg<<" "<<#var<<" = "<<var<<endl; 
#define dbg(var) cerr<<#var<<" = "<<var<<endl;
#define X first
#define Y second
// build prefix sum
template<typename T>
inline void BPS(T* DST, T* SRC, int N, int s = 0) {
	DST[s] = SRC[s];
	rep(i, 1, N) DST[s + i] = DST[s + i - 1] + SRC[s + i];
}
inline int in() { int x; cin>>x; return x; }
#ifdef ALNDBG
namespace alndbg {
	clock_t s, e;
}
#endif

inline void tic() {
#ifdef ALNDBG
	alndbg::s = clock();
#endif
}

inline void toc() {
#ifdef ALNDBG
	alndbg::e = clock();
	cerr<<1000.0 * (alndbg::e - alndbg::s) / CLOCKS_PER_SEC<<" ms"<<endl;
#endif
}



//}}}

// -------------------- Spliters ------------------------
// BFS求最短路小心vis可能访问过
const int maxn = 1;

int main() {
	ios::sync_with_stdio(0);
  ll x,y; cin>>x>>y;
  ll q = y / x;
  int ans = 0;
  for(int i = 63;i>=0;i--) {
    if( (q & (1ll<<i)) != 0) {
      ans = i;
      break;
    }
  }
  cout<<1+ans<<endl;
	return 0;
}
// --USE C++11
// *-USE O2


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}
//ll calc_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        ++res;
//        N /= 10;
//    }
//    return res;
//}
//ll sum_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        res += N % 10;
//        N /= 10;
//    }
//    return res;
//}

int main() {
    string s; int n ; cin >> s >> n;
    deque<char> ans(s.size());
    for(int i = 0;i < s.length();i++) ans[i] = s[i];
    int rev = 0;
    for(int i = 0;i < n;i++){
        int x; cin >> x;
        if(x == 1){
            rev = 1 - rev;
        }else{
            int f; char z;
            cin >> f >> z;f--;
            if (rev) f = 1 - f;
                
                if(f == 0){
                    ans.push_front(z);
                }else{
                    ans.push_back(z);
                }
            
        }
    }
    if(rev) reverse(ans.begin(),ans.end());
    for(auto x:ans){
        cout << x;
    }
}




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

int main(){

  int h1,h2;
  int k1,k2;
  int a,b,c,d;
  cin>>h1>>h2>>k1>>k2>>a>>b>>c>>d;
  if(k1/10*c+k2/20*d+k1*a+k2*b < h1/10*c+h2/20*d+h1*a+h2*b){
    cout<<"hiroshi"<<endl;
  }else if(k1/10*c+k2/20*d+k1*a+k2*b > h1/10*c+h2/20*d+h1*a+h2*b){
    cout<<"kenjiro"<<endl;
  }else{
    cout<<"even"<<endl;
  }
  return 0;
}

 
  


 

    
  



Measured memory_bytes: 3112
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

typedef long long ll;

void solver_main()
{
	int n;
	double sum = 0;
	cin >> n;
	vector<double> a(n);
	for (int i = 0; i < a.size(); i++) {
		cin >> a[i];
		sum += 1 / a[i];
	}
	cout << 1 / sum << endl;
	
}

int main(void)
{
	solver_main();
	return 0;
}

Measured memory_bytes: 256
n, money = map(int, input().split())

result = "-1 -1 -1"
flag = False
for x in range(money//10000+1):
    if flag:
        break
    if x > n:
        break
    for y in range((money-10000*x)//5000+1):
        if x + y > n:
            break
        z = (money - 10000 * x - 5000 * y) // 1000
        if x + y + z == n:
            result = "{} {} {}".format(x,y,z)
            flag = True
            break
print(result)


Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const int MOD=1e9+7;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

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

  int n;
  string s;

  cin >> n;
  int cnt = 0;
  FOR(i, 1, n+1){
    if(i%2 == 1) cnt++;
  }
  cout << setprecision(10) << fixed;
  cout << (double)cnt/n << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
using namespace std;

string get_red_string(int red_set, string S){
  string ans = "";
  for(int i = 0; i < S.size(); i++){
    if(((red_set >> i) & 1) == 1){
      ans.push_back(S[i]);
    }
  }
  return ans;
}

string get_blue_string(int red_set, string S){
  string ans = "";
  for(int i = 0; i < S.size(); i++){
    if(((red_set >> i) & 1) == 0){
      ans.push_back(S[i]);
    }
  }
  return ans;
}

long long dp[18][19];

int main(){
   int N;
   cin >> N;
   string S;
   cin >> S;

   long long ans = 0;
   for(int red_set = 0; red_set < (1 << N); red_set++){
     string red_string = get_red_string(red_set, S.substr(0, N));
     string blue_string = get_blue_string(red_set, S.substr(0, N));

     reverse(blue_string.begin(), blue_string.end());
     reverse(red_string.begin(), red_string.end());
     string target_red_string = blue_string;
     string target_blue_string = red_string;

     for(int i = 0; i < N; i++){
       for(int j = 0; j < i + 2; j++){
         dp[i][j] = 0;
       }
     }

     if(S[N] == target_red_string[0]){
       dp[0][1] = 1;
     }
     if(S[N] == target_blue_string[0]){
       dp[0][0] = 1;
     }
     if(dp[0][1] == 0 && dp[0][0] == 0){
       continue;
     }
     for(int i = 1; i < N; i++){
       for(int j = 0; j < i + 2; j ++){
         if(0 < j && j <= target_red_string.size() && target_red_string[j - 1] == S[N + i]){
           dp[i][j] += dp[i - 1][j - 1];
         }

         if(j <  i + 1 && target_blue_string[i - j] == S[N + i]){
           dp[i][j] += dp[i - 1][j];
         }
       }
     }
     ans += dp[N - 1][target_red_string.size()];
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   int N;
   cin>>N;

   vector<int> W(N);
   for(int i=0;i<N;i++){
      cin>>W.at(i);
   }

   int sa=-1;
   for(int T=1;T<N;T++){
      int sum_left=0;
      int sum_right=0;
      for(int i=0;i<T;i++){
         sum_left+=W.at(i);
      }
      for(int j=T;j<N;j++){
         sum_right+=W.at(j);
      }
      if(sa==-1)
         sa=max(sum_right,sum_left)-min(sum_right,sum_left);
      else
         sa=min(sa,max(sum_right,sum_left)-min(sum_right,sum_left));
   }
   cout<<sa<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define CLR(array) memset( array, 0, sizeof array )
typedef long long int ll;

#define MAXN 100010

ll n,m;
ll A[MAXN];

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

int main(){
	std::cin >> n >> m;
	for( int i = 1; i <= n; i++ )
		std::cin >> A[i];
	std::sort( A+1, A+1+n );

	m *= 2;
	

	ll res = -1;
	int flag = 1;
	for( int i = 1; i <= n; i++ ){
		ll t = A[i], c = 0;

		
		while( (t & 1) == 0){

			++c;
			t >>= 1;
		}
		if( res == -1 )
			res = c;
		else if( res != c ){
			flag = 0;
			break;
		}
		// printf("res = %lld\n", res);
	}
	if( !flag ){
		printf("0\n");
		return 0;
	}

	ll LCM = 1;
	flag = 1;
	for( int i = n; i >= 1; i-- ){
		//printf("%lld\n", A[i]);
		LCM /= gcd( LCM, A[i] );
		LCM *= A[i];
		if( LCM > m ){
			flag = 0;
			break;
		}
	}
	if( !flag ){
		printf("0\n");
		return 0;
	}

	printf("%lld\n", ((m / LCM) + 1 ) / 2);
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
cumsum = [a[0]]
for i in range(len(a)-1):
  cumsum.append(cumsum[i] + a[i+1])

min = float('inf')
for i in range(len(cumsum)-1):
  f1 = cumsum[i]
  f2 = cumsum[-1] - cumsum[i]
  d = abs(f1 - f2)
  if min >  d:
    min = d

print(min)

Measured memory_bytes: 24832
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define bit(n) 1 << n
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <pair <int, int> > vii;
typedef map <int, int> mii;
 
const int Inf = 1000000007;
//const int mod = 998244353;//1000000007;
const double Pi = acos(-1);
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m, q, ans = 0;
int a[55], b[55], c[55], d[55], A[15];
void Back(int pos)
{
	if(pos == 11)
	{
		int temp = 0;
		for(int i = 1; i <= q; i++)
		{
			if(A[b[i]] - A[a[i]] == c[i])
			{
				temp += d[i]; 
			}
		}
		ans = max(ans, temp);
		return;
	}
	for(int i = A[pos - 1]; i <= m; i++)
	{
		A[pos] = i;
		Back(pos + 1);
	}
}

void Solve()
{
	A[1] = 1;
	cin >> n >> m >> q;
	for(int i = 1; i <= q; i++)
	{
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	Back(2);
	cout << ans;
}
 
int main()
{
	Fastio();
	Solve();
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

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

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

	vector<int> A(N);
	for (auto &x : A) {
		cin >> x;
	}
	int ans = accumulate(A.begin(), A.end(), A[0], gcd);
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int grundy(int A, int K)
{
    if (A<K) return 0;
    A = A/K*K + A%K%(A/K+1);
    if (A%K==0) return A/K;
    return grundy(A-A/K-1, K);
}
int main()
{
    int N; cin >> N;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int A, K; cin >> A >> K;
        ans ^= grundy(A, K);
    }
    cout << (ans != 0 ? "Takahashi" : "Aoki") << '\n';
    return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() { // 日本語文字列のテスト
    int w = readint;
    int n = readint;

    auto xs = new int[w + 1];
    for (int i = 0; i < xs.length; i++)
        xs[i] = i;

    for (int i = 0; i < n; i++) {
        auto ab = readln.chomp.split(",").to!(int[]);
        int a = ab[0], b = ab[1];
        swap(xs[a], xs[b]);
    }

    foreach (x; xs[1 .. $])
        writeln(x);
}

Measured memory_bytes: 2452
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int w, h, n;
	cin >> w >> h >> n;
	int x[n], y[n], a[n];
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> a[i];
	}
	int WL = 0, WR = w, HA = h, HB = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == 1) {
			WL = max(WL, x[i]);
		}
		else if (a[i] == 2) {
			WR = min(WR, x[i]);
		}
		else if (a[i] == 3) {
			HB = max(HB, y[i]);
		}
		else {
			HA = min(HA, y[i]);
		}
	}
	// cout << WL << " " << WR << " " << HA << " " << HB << endl;
	if (WL > WR || HA < HB) {
		cout << 0 << endl;
	} else {
		cout << (WR - WL) * (HA - HB) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t syou1,oo1,syou2,oo2;
  cin >> syou1 >> oo1 >> syou2 >> oo2;
  int64_t kari1 = max(syou1*syou2,syou1*oo2);
  int64_t kari2 = max(oo1*syou2,oo1*oo2);
  int64_t ans = max(kari1,kari2);
  cout << ans << endl;
}

Measured memory_bytes: 3580
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
		
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final double L = sc.nextLong();
			final double one = (L / 3.0);
			
			
			System.out.printf("%.10f\n", one * one * one);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 23252