akhauriyash/Code-Regression huggingface dataset:
import scala.io.StdIn.readInt

object Main {
  def sieve(n:Int) = {
    val primes = Array.tabulate(n+1) { _ % 2 }
    primes(1) = 0
    primes(2) = 1

    for( i <- 3 to Math.sqrt(n).toInt by 2 )
      if(primes(i) == 1)
        (i*i to n by i*2).foreach { primes(_) = 0 }
    primes
  }

  def main(args:Array[String]) = {
    val p = sieve(1000001)
    var n = 0
    while( { n = readInt; n} != 0 ) {
      var cnt = 0
      for(i<- 3 to n/2 by 2)
        if((p(i) & p(n-i)) ==1)
          cnt += 1
      println(cnt)
    }
  }
}

Measured memory_bytes: 63896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n, m;

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

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        m = sc.nextInt();
        solve();
    }

    void solve() {
        System.out.println((n - 1) * (m - 1));
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    int sum = 0;
    rep(i, n) cin >> d[i];
    rep(i, n - 1)
    {
        for (int j = i + 1; j < n; j++)
            if (i != j)
                sum += d[i] * d[j];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  int n;

  int debt;
  
  int i;

  scanf("%d",&n);

  debt=100000;

  for(i=0;i<n;i++) {

    debt*=1.05;
    if(debt%1000!=0) debt+=1000-(debt%1000);
    //printf("%d\n",debt);
  }

  printf("%d\n",debt/1000*1000);

  return 0;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> a(5);
    ll flag = INF;
    for(ll i=0;i<5;++i){
        cin>>a[i];
        flag = min(flag, a[i]);
    }

    ll ans = 5;
    ans += (n-1) / flag;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int a,b,h;
	int ans=0;
	
	cin>>a>>b>>h;
	ans=(a+b)*h/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
from copy import copy

MOD = 10**9 + 7
s = input()
count = [0 for _ in range(13)]
count[0] = 1
for i in range(len(s)):
    new = [0 for _ in range(13)]
    for m in range(13):
        new[(m * 10) % 13] = count[m]
    count = new
    if s[i] != "?":
        div = int(s[i])
        count = count[-div:] +  count[:-div]
    else:
        new = [0 for _ in range(13)]
        pre = sum(count[:3])
        SUM = sum(count) % MOD
        for j in range(13):
            pre += count[(j+3) % 13]
            pre -= count[j % 13]
            new[j] = (SUM - pre) % MOD
        count = new
print(count[5])

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

bool solve(vector<int> H) {

  int N = H.size();
  int last = -1;
  for (int i = 0; i < N; i++) {
    if (last <= H[i] - 1) {
      H[i]--;
    }
    if (last > H[i]) return false;
    last = H[i];
  }
  return true;
}

int main2() {
  int N = nextInt();
  vector<int> H(N);
  REP(i, N) H[i] = nextInt();
  cout << (solve(H) ? "Yes" : "No") << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

using namespace std;

const int maxn=1e5+10; 

#define pt pair<double,double> 
#define x first 
#define y second 

double cross2( pt o , pt a , pt b ){
	return ( a.x - o.x )*( b.y - o.y ) - ( a.y - o.y )*( b.x - o.x );
} 
pt p[ maxn ];
int n; 
vector<pt> hull; 
void convexhull(){ 
	hull.push_back( p[ 0 ] ); 
	for( int i = 1 ; i < n ; i++ ){ 
		while( hull.size() > 1 && cross2( hull[ hull.size()-2 ] , hull.back() , p[ i ] ) > 0){
			hull.pop_back(); 
		}
		hull.push_back( p[ i ] );
	}
	int hs = hull.size(); 
	for( int i = n-2 ; i >= 0 ; i-- ){ 
		while( hull.size() > hs && cross2( hull[ hull.size()-2 ] , hull.back() , p[ i ] ) > 0){
			hull.pop_back();
		}
		hull.push_back( p[ i ] );
	}
} 
int main(){ 
	cin >> n; 
	for( int i = 0 ; i < n ; i++ ){
		cin >> p[ i ].x >> p[ i ].y;
	}
	sort( p , p+n ); 
	convexhull(); 
	//the first point is repeated at last! 
	hull.pop_back(); 
	cout << hull.size() << endl; 
	int my = 1e6 , mx = 1e6 , ind; 
	for( int i = 0 ; i < hull.size() ; i++ ){
		if( hull[i].y < my ){
			my = hull[i].y , mx = hull[ i ].x , ind = i;
		}
		else if( hull[ i ].y == my && mx > hull[ i ].x ){
			mx = hull[ i ].x , ind = i;
		}
	}
	for( int i = ind , cnt = hull.size() ; cnt ; cnt-- , i = ( i-1 + hull.size() ) % hull.size() ){
		cout << hull[ i ].x << " " << hull[ i ].y << endl;
	}
}


Measured memory_bytes: 6228
#include<bits/stdc++.h>
#define int         int64_t
#define pb          push_back
#define endl        '\n'
#define pll         pair<int,int>
#define vll          vector<int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define hell2        1000000009
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mi        map<int,int>
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
int n,i,j,k,l,sum=0,flag=0,t,a[200005],ans=0;
string s;
vector<int> v[5003],vv[5003];
bool check(int len){
    map<pair<int, int> , int> m;
    for(int j=0;j<v[len].size();j++){
        if(j-len >= 0) m[{v[len][j-len],vv[len][j-len]}]++;
        if(m.count({v[len][j],vv[len][j]})){
            return true;
        }
    }
    return false;
}
void solve(){
    cin>>n>>s;
    for(int i=0;i<n;i++){
        int h1 = 0, h2 = 0;
        for(int j=i; j < n ; j++){
            h1 = (h1*37LL + s[j]-'a'+1)%hell;
            v[j-i+1].pb(h1);
            h2 = (h2*31LL + s[j]-'a'+1)%hell2;
            vv[j-i+1].pb(h2);
        }
    }
    int high = n/2,low=0,mid=(high+low)/2;
    while(high-low>1){
        if(check(mid)) low=mid;
        else high=mid;
        mid=(low+high)/2;
    }
    if(check(high)) cout<<high<<endl;
    else cout<<low<<endl;
}
signed main()
{
    ios
    int test=1;
    //cin>>test;
    while(test--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 259328
using System;
using System.Linq;
 
class program
{
    static void Main()
    {
        var xkd = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        long x = xkd[0], k = xkd[1], d = xkd[2];
        long move = x / d;
        if (Math.Abs(x - (move + 1) * d) < Math.Abs(x - move * d)) move++;
        if (Math.Abs(x - (move - 1) * d) < Math.Abs(x - move * d)) move--;
        long ans = 0;
        if (Math.Abs(move) > k)
        { 
          if(Math.Abs(x - k * d) < Math.Abs(x + k * d)) ans = Math.Abs(x - k * d);
          else ans = Math.Abs(x + k * d);
        }
        else
        {
            if ((k - move) % 2 == 1)
            {
                if (Math.Abs(x - (move + 1) * d) < Math.Abs(x - (move - 1) * d))
                    ans = Math.Abs(x - (move + 1) * d);
                else
                    ans = Math.Abs(x - (move - 1) * d);
            }
            else ans = Math.Abs(x - move * d);
        }
        Console.Write(ans);
 
    }
}


Measured memory_bytes: 28188
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
num = a[0]
if n == 2 :
    num += 0
elif n%2 == 0 :
    for i in range(2,n,2) :
        num += 2 * a[int(i/2)]
else :
    for i in range(2,n,2):
        num += 2 * a[int(i/2)]
    num -= a[int((n-1)/2)]
print(num)



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

using namespace std;

#define EPS 1e-10
#define INF 1e8
#define equal(a,b) (fabs(a-b) < EPS)
#define not_equal(a,b) (!equal(a,b))
#define lt(a,b) (a-b < -EPS)

struct Point{
  double x,y;

  Point(){}
  Point(double x,double y) : x(x),y(y) {}

  Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
  Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
  Point operator * (const double &k)const{ return Point(x*k,y*k); }
  Point operator / (const double &k)const{ return Point(x/k,y/k); }
  bool operator < (const Point &p)const{ return x != p.x ? x < p.x : y < p.y; }
};

istream &operator >> (istream &is,Point &p){ 
  return is >> p.x >> p.y;
}

double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; }
double norm(const Point &p){ return dot(p,p); }
double dist(const Point &a,const Point &b){
  return sqrt(pow(a.x-b.x,2) + pow(a.y-b.y,2));
}

#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
typedef Point Vector;

int ccw(Point p0,Point p1,Point p2){
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if(cross(a,b) > EPS){ return COUNTER_CLOCKWISE; }
  if(cross(a,b) < -EPS){ return CLOCKWISE; }
  if(dot(a,b) < -EPS){ return ONLINE_BACK; }
  if(norm(a) < norm(b)){ return ONLINE_FRONT; }
  return ON_SEGMENT;
}

struct Segment{
  Point s,t;
  Segment(){}
  Segment(Point s,Point t) : s(s),t(t) {}
};

bool isIntersectSP(const Segment &s,const Point &p){
  return equal(ccw(s.s,s.t,p),0);
}

bool isIntersectSS(const Segment &a,const Segment &b){
  Point s[2] = {a.s,a.t}, t[2] = {b.s,b.t};
  return (ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
          ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0);
}

struct State{
  double d;
  int v;
  State(double d,int v) : d(d),v(v) {}
  
  bool operator < (const State &s)const{
    if(not_equal(d,s.d)){
      return lt(s.d,d);
    }
  }
};

double solve(int x,vector<Point> A[2]){
  priority_queue<State> Q;
  Q.push(State(0,0));
  double d[1010];
  fill(d,d+1010,INF);
  d[0] = 0;
  
  while(!Q.empty()){
    State s = Q.top(); Q.pop();
    int v = s.v;
    if(lt(d[v],s.d)){ continue; }
    if(v == 1){ return d[v]; }
    for(int i = 1 ; i < (int)A[x].size() ; i++){
      if(v == i){ continue; }
      Segment s1(A[x][v],A[x][i]),s2(A[1-x][0],A[1-x][1]);
      if(isIntersectSS(s1,s2)){ continue; }
      double nd = d[v]+dist(A[x][v],A[x][i]);
      if(lt(nd,d[i])){
        d[i] = nd;
        Q.push(State(d[i],i));
      }
    }
  }
  return INF;
}

int main(){
  int N,M;
  vector<Point> A[2];
  cin >> N >> M;
  A[0].resize(N); A[1].resize(M);
  for(int i = 0 ; i < N ; i++){
    cin >> A[0][i];
  }
  for(int i = 0 ; i < M ; i++){
    cin >> A[1][i];
  }
  double res = INF;
  Segment s[2] = {Segment(A[0][0],A[0][1]),
                  Segment(A[1][0],A[1][1])};
  for(int i = 0 ; i < 2 ; i++){
    res = min(res,solve(1-i,A)+dist(s[i].s,s[i].t));
  }
  if(res == INF){
    cout << -1 << endl;
  }else{
    printf("%.10f\n",res);
  }
  return 0;
}

Measured memory_bytes: 1388
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int main()
{
    string S;
    cin >> S;
    ull K;
    cin >> K;
    ull ans = 0;
    for(int i=0; i<(int)S.size(); i++){
        if(S.at(i) != '1'){
            cout << S.at(i) << endl;
            return 0;
        }
        else{
            ans += 1;
        }
        if(ans >=K){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 1 << endl;
}



Measured memory_bytes: 3616
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, ans, a[1001];
ll MOD = 1000000007;

int main(){
	cin >> n;
	
	memset(a, 0, sizeof(a));
	for(ll j = 2; j <= n; j++){
		ll resource = j;
		for(ll i = 2; i <= j; i++){
			while(resource%i == 0){
				resource /= i;
				a[i]++;
			}
			//a[i] %= MOD;
		}
	}
	
	ans = 1;
	for(ll j = 2; j <= n; j++){
		ans *= a[j]+1;
		ans %= MOD;
	}
	
	//cout << a[2] << a[3] <<endl;
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
dp_1 = [0]*(n)
dp_1[0] = min(a[0], b[0])
dp_2 = [0]*(n)
dp_2[0] = min(a[1], b[0]-min(a[0], b[0]))
for i in range(n-1):
    dp_1[i+1] = min(b[i+1], a[i+1] - dp_2[i])
    dp_2[i+1] = min(a[i+2], b[i+1] - dp_1[i+1])
print(sum(dp_1+dp_2))

Measured memory_bytes: 21324
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/
template<typename T>
vector<pair<T,long long>> RunLengthEncoder(vector<T> &v){
    vector<pair<T,long long>> RLE;
    long long cnt = 1;
    for(int i = 0; i < (int)v.size(); ++i){
        if(i == (int)v.size()-1){
            RLE.push_back(make_pair(v[i], cnt));
            continue;
        }
        if(v[i] == v[i+1])cnt++;
        else{
            RLE.push_back(make_pair(v[i],cnt));
            cnt = 1;
        }
    }
    return RLE;
}

vector<pair<char,long long>> RunLengthEncoder_ForString(string v){
    vector<pair<char,long long>> RLE;
    long long cnt = 1;
    for(int i = 0; i < (int)v.size(); ++i){
        if(i == (int)v.size()-1){
            RLE.push_back(make_pair(v[i], cnt));
            continue;
        }
        if(v[i] == v[i+1])cnt++;
        else{
            RLE.push_back(make_pair(v[i],cnt));
            cnt = 1;
        }
    }
    return RLE;
}
/*------------------------------------*/
//
//dp[i][k][j]
//i回目までで、i回目にkを出して、
ll dp[123456][10][10];

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

    ll N,K,R,S,P;
    string T;

    cin>>N>>K>>R>>S>>P>>T;

    //勝つ手
    map<char, ll> map;
    map['r'] = P;
    map['s'] = R;
    map['p'] = S;

    ll ans = 0;
    vector<string> vt(K,"");
    rep(i,K){
        int idx = i;
        while(idx < N){
            vt[i].push_back(T[idx]);
            idx += K;
        }
    }
    rep(i,K){
        //cerr<<vt[i]<<endl;
        auto v = RunLengthEncoder_ForString(vt[i]);
        for(int j = 0; j < (int)v.size(); j++){
            if(v[j].second % 2 == 0){
                ans += map[v[j].first] * v[j].second/2;
            }
            else{
                ans += map[v[j].first] * (v[j].second/2 + 1);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5200
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

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

	Int N, W;
	cin >> N >> W;

	vector<Int> w(N);
	vector<Int> v(N);

	for (Int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
	}

	vector<vector<Int>> dp(N + 10, vector<Int>(W + 10));
	for (Int i = 1; i < W+10; i++) {
		dp[0][i] = -INF;
	}

	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j <= W; j++) {
			if (j - w[i] >= 0) {
				dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i + 1][j]);
			}
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		}
	}

	Int ans = 0;
	for (Int i = 0; i <= W; i++) {
		ans = max(ans, dp[N][i]);
	}
	cout << ans << "\n";

}

Measured memory_bytes: 87296
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) cin >> H.at(i);

    int cnt = 0;
    rep(i, N) {
        if(i == 0) {
            cnt++;
        } else {
            bool flg = true;
            rep(j, i) {
                if(H.at(j) > H.at(i)) {
                    flg = false;
                    break;
                }
            }
            if(flg) cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];

int main() {
    long long a;
    cin>>a;
    vector<long long> vec(a);
    rep(i,a){
        cin>>vec.at(i);
    }

    vector<long long> svec(a);
    rep(i,a){
        svec.at(i)=vec.at(i);
    }
    sort(svec.begin(),svec.end());
    rep(i,a){
        if(vec.at(i)<svec.at(a/2)){
            cout<<svec.at(a/2)<<endl;
        }
        else{
            cout<<svec.at(a/2-1)<<endl;
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    string S;
    vector<string> SS;
    map<string,bool> check;
    int K;
    cin>>S>>K;
    int N=S.length();
    rep(i,N){
        REP(j,1,K+1){
            string A=S.substr(i,j);
            if(check[A])continue;
            check[A]=true;
            SS.pb(A);
        }
    }
    sort(SS.begin(),SS.end());
    cout<<SS[K-1]<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <stack>
#include <cassert>
using namespace std;
typedef long long LL;
const int M = 1e6 + 5;
const int N = 3e5 + 5;
const LL mod = 19260817;
const int MAX = 5e5 + 5;
const int MAXV = 100000 + 5;
const LL INF = (1LL << 62);
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.);
const int limit = 4;
int a[N];
int main() {
#ifdef local
    freopen("input", "r", stdin);
//    freopen("w", "w", stdout);
//    freopen("input", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i = 1; i <= n; i++)cin>>a[i];
    if(n&1){
        cout<<a[n];
        for(int i = n - 2; i >= 1; i -= 2){
            cout<<" "<<a[i];
        }
        for(int i = 2; i <= n; i += 2){
            cout<<" "<<a[i];
        }
        cout<<endl;
    }
    else {
        for(int i = n; i >= 1; i -= 2){
            cout<<a[i]<<" ";
        }
        for(int i = 1; i <= n; i += 2){
            cout<<a[i]<<" ";
        }
        cout<<endl;
    }
}



Measured memory_bytes: 2944
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int[] c = new int[N];
		int[] t = new int[N];
		for(int i = 0; i < N; i++) {
			c[i] = sc.nextInt();
			t[i] = sc.nextInt();
		}
		int ans = 2000000000;
		for(int i = 0; i < N; i++) {
			if(t[i] <= T) {
				if(c[i] < ans) {
					ans = c[i];
				}
			}
		}
		if(ans == 2000000000) {
			System.out.println("TLE");
		}else{
			System.out.println(ans);
		}
	}

}


Measured memory_bytes: 23764
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main() {
    int n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = 0, ex = 0, sum = 0;
    int right = 0;
    for (int left = 0; left < n; left++) {
        while (right < n && (ex ^ a[right]) == (sum + a[right])) {
            ex ^= a[right];
            sum += a[right];
            right++;
        }
        ans += right - left;
        if (left == right)
            right++;
        else {
            ex ^= a[left];
            sum -= a[left];
        }
    }
    OUT(ans);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	string s;
	cin>>s;
	int i=0;
	while(i<n&&s[i]=='R')
	i++;
	if(i==n)
	cout<<0<<endl;
	else
	{
		int j=n-1,cnt=0;
		while(i<j)
		{
			if(s[j]=='R')
			{
				swap(s[j],s[i]);
				while(i<j&&s[i]=='R')
				i++;
				j--;
				cnt++;
			}
			else
			j--;
		}
		cout<<cnt<<endl;
	}
	return 0;
}


Measured memory_bytes: 3752
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

D = I()
c = [0] + LI()
s = [0] + [[0] + LI() for i in range(D)]
t = [0] + [I() for i in range(D)]

last = [0]*27
manzokudo = 0

for i in range(1,D+1):
    last[t[i]] = i
    manzokudo += s[i][t[i]]
    r = 0
    for j in range(1,27):
        r += c[j]*(i-last[j])
    manzokudo -= r
    print(manzokudo)

Measured memory_bytes: 68560
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    unsigned long long x = 0;
    int n;
    cin >> n;
    vector<unsigned long long> mask(n);
    rep(i, n) {
        int k;
        cin >> k;
        rep(j, k) {
            int b;
            cin >> b;
            mask[i] |= (1ULL << b);
        }
    }
    int q;
    cin >> q;
    while(q--) {
        int t, i;
        cin >> t >> i;
        switch(t) {
            case 0: cout << (x>>i&1ULL) << '\n'; break;
            case 1: x |= mask[i]; break;
            case 2: x &= ~mask[i]; break;
            case 3: x ^= mask[i]; break;
            case 4: cout << ((x&mask[i]) == mask[i]) << '\n'; break;
            case 5: cout << (!!(x&mask[i])) << '\n'; break;
            case 6: cout << (!(x&mask[i])) << '\n'; break;
            case 7: cout << __builtin_popcountll(x&mask[i]) << '\n'; break;
            default: cout << (x&mask[i]) << '\n'; break;
        }
    }
}


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

int main()
{
    int N, A, B;
    cin >> N >> A >> B;

    int ans = 0;
    int sum;
    for (int i = 1; i <= N; i++)
    {
        sum = 0;
        sum += i % 10;
        sum += (i / 10) % 10;
        sum += (i / 100) % 10;
        sum += (i / 1000) % 10;
        sum += (i / 10000) % 10;
        if (A <= sum && sum <= B)
        {
            ans += i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
		#include <bitset>
		using namespace std;
		#define ll long long int 
		#define MOD 1000000007
		#define mod9 1000000009
		#define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
		#define mp make_pair
		#define pb push_back
		#define ct ll t;cin>>t;while(t--)
		#define bi begin()
		#define ei end()
		#define fi first 
		#define se second
	
bool isPrime(ll n) 
{ 
    // Corner case 
    if (n <= 1) 
        return false; 
  
    // Check from 2 to n-1 
    for (ll i = 2; i*i <= n; i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
}
  ll fact[1000007]={0};
  ll expo(ll x, ll y) {ll res=1;x=x%MOD;while(y>0){if(y&1)res=(1ll*res*x)%MOD;
    y=y>>1;x=(1ll*x*x)%MOD;} return res;}
void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%MOD;}
  ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res; }
  
		 int main()
		 {
		 	fast
		 	
		 	// ct
			 {
				ll n;
				cin>>n;
				string s;
				set<string>s1;
				for(ll i=0;i<n;i++)
				{
					cin>>s;
					s1.insert(s);
				}
				cout<<s1.size()<<"\n";
			 }			 
}	


Measured memory_bytes: 19232
/**
 *  author: andychen
 *  created: 09.13.2020 20:01:40
**/

#include <bits/stdc++.h>

using namespace std;

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

    cout << max({a * c, a * d, b * c, b * d}) << '\n';

    return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int R;
  cin >> R;
  double p = M_PI;

  cout << 2.0 * p * R << endl;

  return 0;
}


Measured memory_bytes: 3220
//提出時は下二行と一番下のコメントアウトを外す。
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

/// 空白で区切られた複数の値の読み込む。
/// # Example
/// ```ignore
/// use cp_template::*;
///
/// let (a,b):(usize,usize);
/// input!(a,b);
/// ```
#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

/// 文字列を一行読み込む
/// # Example
/// ```ignore
/// use cp_template::*;
///
/// let s = input_line_str();
/// ```
#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

/// 一つの変数を出力する。
/// ```
/// use cp_template::*;
///
/// let a=100;
/// p(a);
/// //上と下は等価です。
/// println!("{}",a);
/// ```
#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

/// 指定した行数を読み込み、二次元配列に変換する。
/// # Examples
/// ```ignore
/// use cp_template::*;
///
/// //10行読み込む。
/// let v = input_vector2d::<usize>(10);
/// ```
#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

/// 一行読み込み、配列(Vec)に変換する。
/// # Examples
/// ```ignore
/// use cp_template::*;
///
/// let v=input_vector::<usize>();
/// ```
#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

/// String(str)を配列(Vec<char>)に変換する。
/// # Examples
/// ```ignore
/// use cp_template::*;
///
/// let s = String::from("abc");
/// let v = str2vec(&s);
/// let v = str2vec(&input_line_str());
/// ```
#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

//提出用
#[allow(unused_imports)]
use input::*;

fn main() {
    let (a, b): (usize, usize);
    input!(a, b);
    let s = str2vec(&input_line_str());
    let mut flag = true;
    if s.len() != a + b + 1 {
        flag = false;
    }
    for z in 0..s.len() {
        if z == a {
            if s[z] != '-' {
                flag = false;
            }
        } else {
            if s[z] == '-' {
                flag = false;
            }
        }
    }
    if flag {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
// 修改自提交记录：227576
// 原记录作者：E.Space (UID: 1579)
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
}
const int M=1000000007;
int f[2222][2222];
int main()
{
	//freopen("slime.in","r",stdin);
	//freopen("slime.ans","w",stdout);
	int n=io::F(),m=io::F(),k=io::F();
	for(register int i=1;i<k;++i)
		if(k-i<=n&&i<=m)f[k-i][i]=1;
	for(int i=k;i<n+m;i+=k-1)
		for(int j=1;j<=n;++j)
			if(i-j>0&&i-j<=m&&f[j][i-j])
			{
				register int F=f[j][i-j];
				for(register int l=0;l<k;++l)
					if(j+l<=n&&i-j+k-1-l>0&&i-j+k-1-l<=m)(f[j+l][i-j+k-1-l]+=F)%=M;
			}
	int ans=0;
	for(register int i=n;i>=0;i-=k-1)
		for(register int j=m;j>=0;j-=k-1)
			(ans+=f[i][j])%=M;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 18560
#include <iostream>
using namespace std;
int main()
{
    int n,a,b,x,y,z,j,k,s=0;
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++){
        x=i%10;
        y=(i%100-x)/10;
        z=(i%1000-10*y-x)/100;
        j=(i%10000-100*z-10*y-x)/1000;
        k=i/10000;
        if(x+y+z+j+k>=a&&x+y+z+k+j<=b){
            s=s+i;
        }
    }
    cout<<s<<endl;
    return 0;
}


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

int main(){
  string S;
  cin>>S;
  for(int i=0; i<3; i++){
    if(S[i]==S[i+1]){
      cout<<"Bad"<<endl;
      return 0;
    }
  }
  cout<<"Good"<<endl;
}

Measured memory_bytes: 3624
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"

  val input: Array[Array[Int]] = Array.ofDim(6, 6000000)
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val n, m = sc.nextInt
//  val b = sc.nextInt
//  val a = List.fill(n)(sc.nextInt)
//  val b = List.fill(m)(sc.nextInt)
//  val c = List.fill(n - 1)(sc.nextInt)
//  val list = List.fill(n, 2)(sc.next)

  val a = (1 to n).foldLeft(Seq.empty[Seq[Int]]){ case (acc, _) =>
    val k = sc.nextInt
    acc :+ List.fill(k)(sc.nextInt)
  }.flatten

  val ans = a.groupBy(identity).foldLeft(0){ case (acc, in) => if (in._2.size == n) acc + 1 else acc }


  println(ans)

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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

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

int cntdigits(long long x){
  int digits = 0;

  while(x > 0) {
    x = x/10;
    digits = digits + 1 ;
  }

  return digits;
}


int main(void) {
  long long N;
  cin >> N;
  
  int ans = cntdigits(N); 
  
  for(long long i = 1; i*i <= N ; i++) {
    if( N%i == 0 ) {
      long long j = N/i;
      int cur = max(cntdigits(i),cntdigits(j));
   
      if( ans > cur ) {
        ans = cur;
      }
    }
  }

  cout << ans << endl;
  return 0;
      
}

Measured memory_bytes: 256
def main():
    import sys
    sys.setrecursionlimit(1000000)
    # 行先、上限、逆辺

    def add_edge(From, to, cap):
        g[From][to] = cap
        g[to][-From-1] = 0

    def max_flow(s, t):
        def dfs(v, t, f):
            q.append(v)
            if v == t:
                return f
            used[v] += 1
            for i in range(len(gkey[v])):
                to = gkey[v][i]
                cap = g[v][to]
                if to < 0:
                    to2 = -to-1
                else:
                    to2 = to
                if used[to2] or cap == 0:
                    continue
                d = dfs(to2, t, min(f, cap))
                if d > 0:
                    g[v][to] -= d
                    g[to2][-v-1] += d
                    return d
            q.pop()
            return 0

        flow = 0
        while True:
            used = [0]*n
            q = []
            f = dfs(s, t, 10**100)
            if not q:
                return flow
            flow += f

    h, w = map(int, input().split())
    n = h+w+2
    g = [dict() for _ in range(n)]
    for i in range(h):
        A = input()
        for j in range(w):
            if A[j] == "o":
                add_edge(i, j+h, 1)
                add_edge(j+h, i, 1)
            elif A[j] == "S":
                add_edge(h+w, i, 10**6)
                add_edge(h+w, j+h, 10**6)
            elif A[j] == "T":
                add_edge(i, h+w+1, 10**6)
                add_edge(j+h, h+w+1, 10**6)
    gkey = [list(i.keys()) for i in g]

    ans = max_flow(h+w, h+w+1)
    if ans >= 10**6:
        print(-1)
    else:
        print(ans)


main()


Measured memory_bytes: 6644
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	string S;
	cin >> S;
	if (S == "AAA" || S == "BBB") {
		cout << "No" << endl;
	}
	else {
		cout << "Yes " << endl;
	}
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


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

#define all(x) (x).begin(), (x).end()

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; ++i) {
        if (i % k == 0) {
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
}


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

int main(){
  long long X,risi,year = 0;
  long long moto = 100;
  cin >> X;
  
  while(moto < X){
    risi = moto / 100;
    moto += risi;
    year++;
  }
  
  cout << year << endl;
}
    

Measured memory_bytes: 3636
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  map<lli,lli>mp;
  rep(i,0,N){
    cin >> P[i];
    mp[P[i]]++;
    sum+=P[i];
  }
  cin >> R;
  queue<lli>que;
  while(R--){
    cin >> B >> C;
    if(mp.find(B)==mp.end()||mp[B]==0){
      que.push(sum);
    }
    else{
      sum+=mp[B]*(C-B);
      mp[C]+=mp[B];
      mp[B]=0;
      que.push(sum);
    }
  }
  while(!que.empty()){
    Out(que.front());
    que.pop();
  }
}



Measured memory_bytes: 9748
#include <bits/stdc++.h>
#define fastIO ios::sync_with_stdio(NULL); cin.tie(NULL);

using namespace std;
const int N = 1E6+7;

long long a[N], b[N], c[N], f[N][4];
int n;

int main()
{
    fastIO
    cin>>n;
    
    for (int i = 1;i <= n;++i) cin>>a[i]>>b[i]>>c[i];
    
    int tmp = 0;
    int save = 0;
    
    if (tmp < a[1]) { tmp = a[1]; save = 1; }
    if (tmp < b[1]) { tmp = b[1]; save = 2; }
    if (tmp < c[1]) { tmp = c[1]; save = 3; }
    
    f[1][save] = tmp;
    
    for (int i = 2;i <= n;++i) 
    {
        for (int j = 1;j <= 3;++j)
        {
            if (j == 1) f[i][j] = max(f[i-1][j+1],f[i-1][j+2])+a[i];
            if (j == 2) f[i][j] = max(f[i-1][j-1],f[i-1][j+1])+b[i];
            if (j == 3) f[i][j] = max(f[i-1][j-1],f[i-1][j-2])+c[i];
        }
    }
    
    long long res = 0;
    for (int i = 1;i <= 3;++i) res = max(res,f[n][i]);
    
    cout<<res;
}

Measured memory_bytes: 9016
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 200000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
int a[N];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);

    if(n%2){
        for(int i=n;i>=1;i-=2)
            printf("%d ",a[i]);
        for(int i=2;i<=n;i+=2)
            printf("%d ",a[i]);
        printf("\n");
    }
    else{
        for(int i=n;i>=1;i-=2)
            printf("%d ",a[i]);
        for(int i=1;i<=n;i+=2)
            printf("%d ",a[i]);
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2944
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

N, x = map(int, raw_input().split())

a = map(int, raw_input().split())

a.sort()

ans = 0

for num in a:
    x -= num
    if x < 0:
        break
    ans += 1

if ans == N and x > 0:
    ans -= 1

print ans

Measured memory_bytes: 28012
#include <iostream>
#include <string>

using namespace std;

int main(){
  int max_int, min, max;
  int answer = 0;

  cin >> max_int >> min >> max;

  for(int i = 1; max_int >= i; i++){
    string str_num = to_string(i);
    const char* cstr = str_num.data();
    int sum = 0;

    for(size_t j = 0; str_num.length() > j; j++){
      // cout << i << ":" << ((int)cstr[j]) - 48 << endl;
      sum += ((int)cstr[j]) - 48;
    }

    if(min <= sum && sum <= max){
      answer += i;
    }
  }

  cout << answer << endl;

  return 0;
}


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

int n,m;
long long ans;
int a[maxl];
long long f[maxl];
struct lne
{
	int l,r,c;
};
multiset <long long> s; 
vector <lne> in[maxl],out[maxl];

inline void prework()
{
	scanf("%d%d",&n,&m);
	int l,r,c;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&l,&r,&c);
		in[l].push_back(lne{l,r,c});
		out[r].push_back(lne{l,r,c});
	}
}

inline void mainwork()
{
	f[1]=0;
	for(auto d: in[1])
		s.insert(d.c);
	for(int i=2;i<=n;i++)
	{
		if(s.begin()==s.end())
		{
			ans=-1;
			return;
		}
		f[i]=(*s.begin());
		for(auto d: in[i])
			s.insert(f[i]+d.c);
		for(auto d: out[i])
			s.erase(s.lower_bound(f[d.l]+d.c));
	}
	ans=f[n];
}

inline void print()
{
	printf("%lld",ans);
}

int main()
{
	int t=1;
	//scanf("%d",&t);
	for(int i=1;i<=t;i++)
	{
		prework();
		mainwork();
		print();
	}
	return 0;
}

Measured memory_bytes: 24320
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

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

    vvll cnt(10);
    for (size_t i = 0; i <= 9; i++)
    {
        cnt[i] = vll(10, 0);
    }

    for (int i = 1; i <= n; i++)
    {
        string str = to_string(i);
        int st = str[0] - '0';
        int ed = str[str.length() - 1] - '0';
        cnt[st][ed]++;
    }

    ll ans = 0;
    for (size_t st = 1; st <= 9; st++)
    {
        for (size_t ed = 1; ed <= 9; ed++)
        {
            ans += (cnt[st][ed] * cnt[ed][st]);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256