akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

struct BIT{
  int size;
  vector< ll > t;
  void re(){
    for(int i=0;i<(int)t.size();i++)
      t[i]=0;
  }
  void init(int n){
    size=n;
    t.resize(n,0);
  }

  void add(int i,ll x){
    i++;
    while( i < size ){
      t[i]+=x;
      i+=(i&-i);
    }
  }

  ll sum(int i){
    i++;
    ll res=0;
    while(i){
      res+=t[i];
      i-=(i&-i);
    }
    return res;
  }
};


ll N;
ll a[100005];

ll b[100005];

BIT T;

ll Count(ll x){
  T.re();
  for(int i=0;i<N;i++)b[i]=(a[i]<=x? 1:-1);

  ll res=0;
  ll sum=150000;
  T.add(sum,1);
  
  for(int i=0;i<N;i++){
    sum+=b[i];
    res+=T.sum(sum-1);
    T.add(sum,1);
  }
  return res;
}

int main(){

  T.init(300005);
  
  cin>>N;
  for(int i=0;i<N;i++)cin>>a[i];

  ll total = (N+1)*N/2;
  ll target = total/2+1;
  
  ll left=1, right=1e9, mid;
  while( left < right ){
    mid=(left+right)/2;
    if( Count(mid) < target )left=mid+1;
    else right=mid;
  }

  cout<<left<<endl;
  return 0;
}


Measured memory_bytes: 4096
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String[] A = sc.next().split("");
        String[] B = sc.next().split("");
        
        int ans = 0;
        
        if(A.length == B.length){
            for(int i=0; i<A.length; i++){
                if(Integer.parseInt(A[i]) == Integer.parseInt(B[i])){
                    ans++;
                }else if(Integer.parseInt(A[i]) > Integer.parseInt(B[i])){
                    System.out.println("GREATER");
                    return;
                }else{
                    System.out.println("LESS");
                    return;
                }
            }
        }else if(A.length > B.length){
            System.out.println("GREATER");
            return;
        }else{
            System.out.println("LESS");
            return;
        }
        
        if(ans == A.length){
            System.out.println("EQUAL");
        }
    }
}

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

namespace AtCoder
{
    public class MainClass
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var red = s.Count(c => c == '0');
            var blue = s.Count(c => c == '1');
            var rem = Math.Abs(red - blue);

            Console.WriteLine(s.Length - rem);
        }
    }

    public static class EnumerablePlus
    {
        ///<summary>出力文字列に変換。</summary>
        public static string MkString<T>(this IEnumerable<T> list)
        {
            return list.Aggregate(
                new System.Text.StringBuilder(),
                (a, b) => ((a.Length > 0) ? a.Append(' ') : a).Append(b)
                ).ToString();
        }

        ///<summary>添字付きfor。</summary>
        public static void ForEach<T>(this IEnumerable<T> list, Action<T, int> a)
        {
            int i = 0;
            foreach (var item in list)
            {
                a(item, i);
            }
        }

        ///<summary>指定回数デリゲートを呼び出す。</summary>
        public static IEnumerable<T> Repeat<T>(int n, Func<T> f)
        {
            for (int i = 0; i < n; i++)
            {
                yield return f();
            }
        }
    }

    public static class MathPlus
    {
        ///<summary>素因数分解。昇順。</summary>
        public static List<int> Prime(int a)
        {
            var res = new List<int>();

            for (int b = 2, c = (int)Math.Ceiling(Math.Sqrt(a)); b <= c; ++b)
            {
                while (a % b == 0)
                {
                    res.Add(b);
                    a = a / b;
                }
            }

            return res;
        }

        ///<summary>最小公倍数。</summary>
        public static long Lcm(IEnumerable<long> list)
        {
            return list.Aggregate(0L, (a, b) => a == 0L ? b : Lcm(a, b));
        }

        ///<summary>最小公倍数。</summary>
        public static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        ///<summary>最大公約数。</summary>
        public static long Gcd(IEnumerable<long> list)
        {
            return list.Aggregate(0L, (a, b) => a == 0L ? b : Gcd(a, b));
        }

        ///<summary>最大公約数。</summary>
        public static long Gcd(long a, long b)
        {
            if (a < b)
                Gcd(b, a);

            while (b != 0)
            {
                long rem = a % b;
                a = b;
                b = rem;
            }

            return a;
        }
    }

}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int N;

ll dfs(ll n)
{
    if (n > N) return 0;
    ll ret = 0;
    int count[10] = {0};
    ll num = n;
    while(num > 0)
    {
        int r = num % 10;
        num /= 10;
        count[r]++;
    }
    if (count[3] >= 1 && count[5] >= 1 && count[7] >= 1) ret = 1;
    ll addNum[3] = {3, 5, 7};
    REP(i, 3)
    {
        ret += dfs(10 * n + addNum[i]);
    }

    return ret;
}

int main()
{
    cin >> N;
    cout << dfs(0) << endl;
}


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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */
signed main() 
{
  string o,e;
  cin>>o>>e;
  string ans;
  rep(i,o.length())
  {
    ans+=o[i];
    if(i>=e.length()) break;
    ans+=e[i];
  }
  print(ans);
  return 0;
}

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

typedef long long ll;

int n;
ll dist[502][502];
bool used[502][502];

ll cnt[502][502]={};
void upd(int x,int y,int z){
	if(!used[x][y])z++;
	if(dist[x][y]<=z)return;
	//cnt[x][y]++;
	//if(x==40&&y==40)cerr<<dist[x][y]<<" "<<z<<endl;
	dist[x][y]=z;
	if(x>0)upd(x-1,y,z);
	if(x<n-1)upd(x+1,y,z);
	if(y>0)upd(x,y-1,z);
	if(y<n-1)upd(x,y+1,z);
}

int main(){
	static int p[250010];
	scanf("%d",&n);
	for(int i=0;i<n*n;i++)scanf("%d",&p[i]);
	//n=500;
	//for(int i=0;i<n*n;i++)p[i]=i+1;
	//random_shuffle(p,p+(n*n));
	for(int i=0;i<n;i++)for(int j=0;j<n;j++){
		dist[i][j]=100000;
		used[i][j]=false;
	}
	for(int i=0;i<n;i++)for(int j=0;j<n;j++){
		dist[i][j]=1+min(min(i,n-1-i),min(j,n-1-j));
	}
	
	ll ret=0;
	for(int i=0;i<n*n;i++){
		int x=(p[i]-1)/n;
		int y=(p[i]-1)%n;
		ret+=dist[x][y]-1;
		used[x][y]=true;
		upd(x,y,dist[x][y]-1);
		//cerr<<i<<" "<<ret<<endl;
	}
	/*for(int x=0;x<n;x++)for(int y=0;y<n;y++){
		cerr<<cnt[x][y]<<endl;
	}*/
	cout<<ret<<endl;
}



Measured memory_bytes: 25632
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 


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

    LL ans = N * N * N;

    cout << ans << endl;

    return 0;
}


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

struct Node {
    int p, y, i;
    bool operator< (const Node& b) const {
        return y < b.y;
    }
}in[100005];

int ans[100005], cnt[100005];

int main() {
    int n, m;
    while (scanf("%d%d", &n, &m) == 2) {
        for (int i = 1; i <= m; i++) {
            scanf("%d%d", &in[i].p, &in[i].y);
            in[i].i = i;
        }
        sort(in + 1, in + 1 + m);
        memset(cnt, 0, sizeof cnt);
        for (int i = 1; i <= m; i++) {
            ans[in[i].i] = ++cnt[in[i].p];
        }
        sort(in + 1, in + 1 + m, [](const Node& a, const Node& b) {
            return a.i < b.i;
        });
        for (int i = 1; i <= m; i++) {
            printf("%06d%06d\n", in[i].p, ans[i]);
        }
    }
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
 
using namespace std;
 
#define MD 1000000007
typedef long long int ll;
 
int main(){
    int x=0,n,ans=0;
    string s;
    cin>>n>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='I'){
            x++;
        }else{
            x--;
        }
        ans=max(x,ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 1e5 + 5;

int n;
string s;
int L[N], R[N];
int ans[N];

int main()
{
  cin >> s;
  n = sz(s);
  for(int i = 0 ; i < n ; i++){
    if(s[i] == 'R')
      L[i] = 0;
    else
      L[i] = L[i - 1] + 1;
  }
  for(int i = n - 1 ; i >= 0 ; i--){
    if(s[i] == 'L')
      R[i] = 0;
    else
      R[i] = R[i + 1] + 1;
  }
  for(int i = 0 ; i < n ; i++){
    if(s[i] == 'L'){
      int d = L[i];
      if(d & 1)
        d--;
      ans[i - d]++;
    }else{
      int d = R[i];
      if(d & 1)
        d--;
      ans[i + d]++;
    }
  }
  for(int i = 0 ; i < n ; i++)
    cout << ans[i] << " ";
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

const double EPS = 1e-10;

typedef vector<int> vi;

int main()
{
	double xa, ya, xb, yb, xc, yc, xd, yd;

	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd) != EOF)
		puts(fabs((xa-xb)*(xc-xd)+(ya-yb)*(yc-yd)) < EPS ? "YES" : "NO");

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b){
	if(b==0){
		return a;
	}
	return gcd(b, a % b);
}
int main()
{
	ll a, b;
	cin >> a >> b;
	cout << a * b / gcd(a, b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define int long long
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	int N;
	double x,sum=0;
	string S;
	cin >> N;
	rep(i, N) {
		cin >> x >> S;
		if (S == "JPY")
			sum += x;
		else
			sum += x * 380000;
	}
	cout << sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int N = 20000;
const int oo = 0x3f3f3f3f;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int n, cnt;
pii t[N + 5];
int x[N + 5], y[N + 5];

vector<int> G[(N << 1) + 5];
void addedge(int u, int v) { G[u].pb(v); }

int stk[(N << 1) + 5], top;
int bel[(N << 1) + 5], scc_cnt;
int dfn[(N << 1) + 5], low[(N << 1) + 5], dfs_clock;

void dfs(int u) {

    stk[top ++] = u;
    low[u] = dfn[u] = ++ dfs_clock;

    for(int i = 0; i < int(G[u].size()); ++i) {
        int v = G[u][i];
        if(!dfn[v]) {
            dfs(v);
            chkmin(low[u], low[v]);
        }else if(!bel[v]) {
            chkmin(low[u], dfn[v]);
        }
    }

    if(low[u] == dfn[u]) {
        ++ scc_cnt;
        do {
            bel[stk[top - 1]] = scc_cnt;
        } while(stk[-- top] != u);
    }
}

bool scc_chk() {
    memset(bel, 0, sizeof bel);
    memset(dfn, 0, sizeof dfn);
    top = scc_cnt = dfs_clock = 0;

    for(int i = 0; i <= (N << 1); ++i) if(!dfn[i]) { dfs(i); }
    for(int i = 1; i <= n; ++i) if(bel[N - i] == bel[N + i]) return false;
    return true;
}

bool chk(int len) {
    for(int i = 0; i <= (N << 1); ++i) G[i].clear();
    for(int i = 0; i < cnt; ++i) {
        int K = 0;
        for(int j = i-1; j >= 0 && t[i].fst - t[j].fst < len; --j) {
            addedge(N + t[i].snd, N - t[j].snd);
            addedge(N + t[j].snd, N - t[i].snd);
            if(++ K >= 100) break;
        }
        K = 0;
        for(int j = i+1; j < cnt && t[j].fst -t[i].fst < len; ++j) {
            addedge(N + t[i].snd, N - t[j].snd);
            addedge(N + t[j].snd, N - t[i].snd);
            if(++ K >= 100) break;
        }
    }
    return scc_chk();
}

int main() {


    scanf("%d", &n);
    int lim = oo / (n - 1);
    for(int i = 1; i <= n; ++i) {
        scanf("%d%d", x + i, y + i);

        t[cnt ++] = mp(x[i], i);
        t[cnt ++] = mp(y[i], -i);
    }
    for(int i = 1; i <= n; ++i) 
        for(int j = i + 1; j <= n; ++j) {
            int a = abs(max(x[i], y[i]) - min(x[j], y[j]));
            int b = abs(max(x[j], y[j]) - min(x[i], y[i]));
            chkmin(lim, max(a, b));
        }

    sort(t, t + cnt);

    int l = 0, r = lim, ans = -1;
    while(l <= r) {
        int mid = (l + r) >> 1;
        if(chk(mid)) ans = mid, l = mid + 1; else r = mid - 1;
    }

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


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

using namespace std; 	
typedef long long ll;
const int N = 1e5+50;
const int oo = 1e9;

ll cost[10][10];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			cin>>cost[i][j];
		}
	}
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			for(int l=0;l<=9;l++){
				if(cost[j][i]+cost[i][l]<cost[j][l]){
					cost[j][l] = cost[j][i]+cost[i][l];
				}
			}
		}
	}
	ll sum =0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			int a;
			cin>>a;
			if(a==-1)continue;
			sum+=cost[a][1];
		}
	}
	cout << sum << endl;
}

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

int main() {
   int A, B;
   cin >> A >> B;
   if (A + B >= 10) 
   {
       /* code */
       cout << "error" << endl;
   }else
   {
       
       cout << A + B << endl;
   }
   
   
    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;//这里char[]也行
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        cout<<s[i];
        if(i==3)cout<<" ";//到第四位了就多输出一个空格
    }
    cout<<endl;//别忘了换行
    return 0;
}

Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    sum = 0

    for j in range(m):
        sum += a[i][j] * b [j]

    if sum + c > 0:
        ans += 1


print(ans)

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

typedef long long ll ;
using namespace std;

void solve(){
    int n;
    cin >> n;

    string s;
    cin >> s;

    if ((int)s.size() > n) {
        for (int i = 0; i < n; i++) cout << s[i];
        cout << "..." << endl;
    }
    else cout << s << endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    int a[100][2];
    for (int i=0; i<n; i++){
        cin >> a[i][0] >> a[i][1];
    }
    //ループの終了条件に注意
    for (int i=0; i<n-2; i++){
        if(a[i][0]==a[i][1] && a[i+1][0]==a[i+1][1] && a[i+2][0]==a[i+2][1]){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const double EPS = 0.000000000000001;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int X,Y;
int ans;
int p=1;

signed main(){
    cin>>X>>Y;
    while(1){
        if(X*p>Y)break;
        ans++;
        p*=2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
----
local MOD = 1000000007
local N = read.nl()
local s1 = read.l():totable()
local s2 = read.l():totable()

local H = 'H'
local V = 'V'

local function iter()
    local x = 1
    local y = 1
    local function start()
        while true do
            if x > N then
                return
            end
            if y == 1 then
                local a, b = s1[x], s1[x+1]
                if a == b then
                    coroutine.yield(H)
                    y = 2
                else
                    coroutine.yield(V)
                    x = x + 1
                end
            else
                coroutine.yield(H)
                y = 1
                x = x + 2
            end
        end
    end
    return coroutine.wrap(start)
end

local ans = 1
local state = 0
--[[
    state 0: Initial state
    state 1: First domino is H
    state 2: A V is on the left, now y = 1
    state 3: Two Hs are on the left, now y = 1
    state 4: A V is on the left, now y = 2
    state 5: Two Hs are on the left, now y = 2 (calculated at state 3.)
]]
for b in iter() do
    if state == 0 then
        if b == H then
            state = 1
        else
            state = 2
        end
        ans = ans * 3
    elseif state == 1 then
        assert(b == H)
        ans = ans * 2
        state = 3
    elseif state == 2 then
        if b == H then
            state = 4
        else
            state = 2
        end
        ans = ans * 2
    elseif state == 3 then
        if b == H then
            ans = ans * 3
            state = 5
        else
            ans = ans * 1
            state = 2
        end
    elseif state == 4 then
        ans = ans * 1
        state = 3
    elseif state == 5 then
        state = 3
    end
    ans = ans % MOD
end

print(ans)


Measured memory_bytes: 760
N, A, B, C, D = map(int, input().split())
S = input()
A -= 1
B -= 1
C -= 1
D -= 1
if A < B and B < D and A < C and S[A] == "." and S[B] == "." and S[C] == "." and S[D] == ".":
    ans = True
else:
    ans = False

if C < B:
    count_x = 0
    for i in range(A, C):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
    if ans:
        count_x = 0
        for i in range(B, D):
            if S[i] == "#":
                count_x += 1
            else:
                count_x = 0
            if count_x > 1:
                ans = False
                break
elif C < D:
    count_x = 0
    for i in range(A, D):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
else:
    count_x = 0
    for i in range(A, C):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
    if ans:
        count_o = 0
        ans = False
        for i in range(B-1, D+2):
            if S[i] == "#":
                count_o = 0
            else:
                count_o += 1
            if count_o > 2:
                ans = True
                break
if ans:
    print("Yes")
else:
    print("No")


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

int main(){
int N,K;
  cin >> N >> K;
  int c = 0;
  for(int i = 0; i < N; i++){
  	int buff;
    cin >> buff;
    if(buff >= K) c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

ll dp[3000][3000][2];
const ll INF = 1e18;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll L,N; cin >> L >> N;
    vector<ll> X(N);
    rep(i,N) cin >> X[i];

    if (N <= 2000) {
        auto pos=[&](ll x) {
            if (x < 0) return x+N;
            if (x >= N) return x-N;
            return x;
        };
        auto calc=[&](int l, int r) {
            ll ret = X[r] - X[l];
            if (ret < 0) ret += L;
            return ret;
        };
        rep(i,N+1) rep(j,N+1) rep(k,2) dp[i][j][k] = -INF;
        dp[0][0][0] = X[0];
        dp[N-1][N-1][1] = L - X[N-1];
        rep(k,N) {
            rep(l,N) {
                int r = pos(l+k);
                if (dp[l][r][0] != -INF) {
                    chmax(dp[l][pos(r+1)][0],dp[l][r][0]+calc(r,pos(r+1)));
                    chmax(dp[pos(l-1)][r][1],dp[l][r][0]+calc(pos(l-1),r));
                }
                if (dp[l][r][1] != -INF) {
                    chmax(dp[l][pos(r+1)][0],dp[l][r][1]+calc(l,pos(r+1)));
                    chmax(dp[pos(l-1)][r][1],dp[l][r][1]+calc(pos(l-1),l));
                }
            }
        }
        ll ans = 0;
        rep(i,N) rep(j,2) chmax(ans,dp[i][pos(i+N-1)][j]);
        cout << ans << ln;
        return 0;
    }

    auto func=[&](int x) {
        ll val = X[x];
        int l = x, r = N-1;
        int d = r - l;
        rep(i,d) {
            val += L - (X[r] - X[l]);
            if (~i&1) l++;
            else r--;
        }
        return val;
    };

    ll ans = 0;
    int ok = 0;
    int ng = N;
    while (ng - ok > 1) {
        int mid = (ok+ng)/2;
        if (func(mid) - func(mid-1) >= 0) ok = mid;
        else ng = mid;
    }
    chmax(ans,func(ok));
    rep(i,N) X[i] = L - X[i];
    reverse(all(X));
    ok = 0;
    ng = N;
    while (ng - ok > 1) {
        int mid = (ok+ng)/2;
        if (func(mid) - func(mid-1) >= 0) ok = mid;
        else ng = mid;
    }
    chmax(ans,func(ok));

    cout << ans << ln;
}


Measured memory_bytes: 74116
import com.sun.java.swing.plaf.windows.WindowsTextAreaUI;

import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        String text = scanner.next();
        String pattern = scanner.next();
        Zalgolithm z = new Zalgolithm();
        List<Integer> ans = z.search(text, pattern);
        PrintWriter pw = new PrintWriter(System.out);
        for (int i: ans) {
            pw.println(i);
        }
        pw.flush();
    }

}

class Zalgolithm {
    static Character DELIMITER = '#';
    public int[] zArr;

    public List<Integer> search(String text, String pattern) {
        String s = pattern + DELIMITER + text;
        calcZarray(s);

        List<Integer> ans = new ArrayList<>();
        int pre = pattern.length() + 1;
        for (int i = 0; i < text.length(); i++) {
            if (zArr[pre + i] == pattern.length()) {
                ans.add(i);
            }
        }
        return ans;
    }

    private void calcZarray(String s) {
        int n = s.length();
        zArr = new int[n];

        // range of z-box
        int l = 0, r = 0;
        for (int i = 1; i < n; ++i) {
            if (i > r) {
                l = r = i;
                while (r < n && s.charAt(r - l) == s.charAt(r)) {
                    r++;
                }
                zArr[i] = r - l;
                r--;
            } else {
                int k = i - l;
                if (zArr[k] < r - i + 1)
                    zArr[i] = zArr[k];
                else {
                    l = i;
                    while (r < n && s.charAt(r - l) == s.charAt(r)) {
                        r++;
                    }
                    zArr[i] = r - l;
                    r--;
                }
            }
        }
    }

}




Measured memory_bytes: 100204
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int N,P,i,A,even=1;
	long long ans;
	scanf("%d%d",&N,&P);
	for(i=0;i<N;i++){
		scanf("%d",&A);
		if(A%2==1)even=0;
	}
	if(even){
		if(P)ans=0;
		else ans=(long long)1<<N;
	}else{
		ans = (long long)1<<N-1;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <cstring>
#include <cassert>
#include <list>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <limits>
using namespace std;
typedef long long          ll;
typedef unsigned long long ull;
typedef long double        ld;
typedef pair<int,int>      pii;
typedef pair<ll,ll>        pll;
typedef vector<int>        vi;
typedef vector<long long>  vll;
#define left(x)		   (x << 1)
#define right(x) 	   (x << 1) + 1
#define mid(l, r) 	   ((l + r) >> 1)
#define mp                 make_pair
#define pb                 push_back
#define all(a)             a.begin(),a.end()
#define debug(x)	   {cerr <<#x<<" = " <<x<<"\n"; }
#define debug2(x, y)       {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<"\n";}
#define debug3(x, y, z)    {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<"\n";}
#define debug4(x, y, z, w) {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<", "<<#w << " = " <<w <<"\n";}
#define ss                 second
#define ff                 first
#define m0(x) 		   memset(x,0,sizeof(x))

template<typename T >T min_ ( T a , T b ) { return a > b ? b : a ; }
template < typename T ,  typename... Ts > T min_( T first , Ts... last ){ return  min_(first, min_(last...)); }
template<typename T >T max_ ( T a , T b ) { return a > b ? a : b ; }
template < typename T ,  typename... Ts > T max_( T first , Ts... last ){ return  max_(first, min_(last...)); }

template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<typename T> ostream& operator<< (ostream& out, const vector<T>& v) {
    out << "["; size_t last = v.size() - 1; for(size_t i = 0; i < v.size(); ++i) {
    out << v[i]; if (i != last) out << ", "; } out << "]"; return out;
}
const int mod = 1e9+7;

ll pwr(ll base, ll p){
ll ans = 1; while(p) { if(p&1) ans=(ans*base)%mod; base=(base*base)%mod; p/=2; } return ans;
}
ll gcd(ll a, ll b) {  return b == 0 ? a : gcd(b,a%b); }
ll lcm(ll a, ll b) {  return a*(b/gcd(a,b)); }

const long double PI = (long double)(3.1415926535897932384626433832795);
const ll  mx_ll   = numeric_limits<ll> :: max();
const int mx_int  = numeric_limits<int> :: max();

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

    float a, b; cin >> a >> b; // ta (health strength)
    float c, d; cin >> c >> d; // ao
    // t a t a t a

   int nt = ceil(c/b);
   int na = ceil(a/d);
   if(nt <= na) {
       cout << "Yes";
   } 
   else {
       cout << "No";
   }
      return 0;
}


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

int main () {
  int N,A,B,C,D;
  string S;
  cin >> N >> A >> B >> C >> D >> S;
  
  for (int i = A; i < max(C,D); i++) {
    if (S.at(i) == '#' && S.at(i-1) == '#'){
      cout << "No" << endl;
      return 0;
    }
  }
  
  if (C < D){
    cout << "Yes" << endl;
    return 0;
  }
  else {
    for (int i = B-1; i < D; i++) {
      if (S.at(i) == '.' && S.at(i-1) == '.' && S.at(i+1) == '.'){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}
    
  

Measured memory_bytes: 3728
N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort(key=lambda x: (x[1], x[0]))
s = 0
for t in AB:
    s += t[0]
    if (s > t[1]):
        print('No')
        quit()
print('Yes')

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

int N, M;
ll x[1010],y[1010],z[1010];
ll dp[1010][1010];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M;
    cin >> N >> M;
    for (int i = 0; i < N; i++)
        cin >> x[i] >> y[i] >> z[i];

    ll ans = -1*(1LL << 60);
    for (int a = -1; a <= 1; a+=2)
        for (int b = -1; b <= 1; b+=2)
            for (int c = -1; c <= 1; c+=2) {
                for (int i = 0; i <= N; i++)
                    for (int j = 0; j <= M; j++)
                        dp[i][j] =  -1*(1LL << 60);

                dp[0][0] = 0;
                for (int i = 0; i < N; i++)
                    for (int j = 0; j <= M; j++) {
                        ll d = a*x[i] + b*y[i] + c*z[i];
                        if (dp[i+1][j] < dp[i][j])
                            dp[i+1][j] = dp[i][j];
                        if (dp[i+1][j+1] < dp[i][j] + d)
                            dp[i+1][j+1] = dp[i][j] + d;

                    }
                ans = max(ans, dp[N][M]);

            }
            cout << ans << endl;


    return 0;
}


Measured memory_bytes: 8192
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
import java.io.InputStream;
import java.io.IOException;


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

    int n = sc.nextInt();
    int[] heights = new int[n + 1];
    int[] dp = new int[n + 1];
    for(int i = 1; i <= n; i++){
      heights[i] = sc.nextInt();
      dp[i] = Integer.MAX_VALUE;
    }
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = Math.abs(heights[2] - heights[1]);
    for (int i = 3; i <= n; i++) {
        dp[i] = Math.min(dp[i -1] + Math.abs(heights[i] - heights[i -1]), 
        dp[i - 2] + Math.abs(heights[i] - heights[i - 2]));
    }
    System.out.println(dp[n]);
  }
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;

      public InputReader(InputStream stream) {
          this.stream = stream;
      }

      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }

      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }

      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }

      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }

      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }

      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(int size) {
        prime.resize(size + 1, 1);
        prime[0] = 0;
        prime[1] = 0;
        FOR(i, 2, size) {
            if (prime[i]) {
                for (int j = 2 * i; j <= size; j += i) {
                    prime[j] = 0;
                }
            }
        }
    }

};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};

ll A, B;

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


int main() {
    cin >> A >> B;
    ll x = GCD(A, B);
    int cnt = 1;
    for (ll i = 2; i * i < x; i++) {
        if (x % i == 0) {
            cnt++;
            while (x % i == 0)x /= i;
        }
    }
    if (x != 1)cnt++;
    cout << cnt << endl;
    return 0;
}



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

int main()
{
	int N;
	scanf("%d",&N);
	
	int ans = 0;
	for(int i = 1;i*i <= N;++i)
		for(int j = i;i*j < N;++j)
		{
				if(i != j) ans+=2;
				else ans++;
		}
	printf("%d",ans);
	return 0;
 } 

Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define dbg(a)                   cout<< #a <<" --> "<<(a)<<endl;
#define read                     freopen("tst.txt","r",stdin)
#define write                    freopen("out.txt","w",stdout)
typedef long long ll;
using namespace std;




main(){
//read;

ll n;
scanf("%lld",&n);
ll ans = 1e18;
for(ll i = 1; i*i<=n; i++){
    ll x = n/i,p;
    if(n%i==0){
        p = x-1+i-1;
        ans = min(ans,p);
    }
}
cout<<ans;

return 0;
}


Measured memory_bytes: 256
s = input()
t = input()
cnt = 0
last = 0
b = [{} for i in range(len(s))]
b[-1][s[-1]] = len(s) - 1
for i in range(len(s)-1)[::-1]:
    b[i] = b[i + 1].copy()
    b[i][s[i]] = i
if t[0] in b[0]:
    last = b[0][t[0]]
else:
    print(-1)
    exit()
for i in t[1:]:
    if last < len(s) - 1 and i in b[last + 1]:
        last = b[last + 1][i]
    else:
        if i not in s:
            print(-1)
            exit()
        last = b[0][i]
        cnt +=1
print(cnt*len(s) + last + 1)



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

using namespace std;

int a[100005];
int b[100005];
vector<int> g[100005];

int main(){
	memset(a, -1, sizeof(a));
	memset(b, -1, sizeof(b));

	int n;
	scanf("%d", &n);
	for(int i=0;i<n-1;i++){
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}

	a[1] = 0;
	b[n] = 0;

	queue<int> q;
	q.push(1);
	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(int i=0;i<g[u].size();i++){
			int v = g[u][i];
			if(a[v] == -1){
				a[v] = a[u]+1;
				q.push(v);
			}
		}
	}

	q.push(n);
	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(int i=0;i<g[u].size();i++){
			int v = g[u][i];
			if(b[v] == -1){
				b[v] = b[u]+1;
				q.push(v);
			}
		}
	}

	int ans1 = 0;
	int ans2 = 0;
	for(int i=1;i<=n;i++){
		if(a[i] <= b[i]) ans1++;
		else ans2++;
	}

	if(ans1 > ans2) printf("Fennec\n");
	else printf("Snuke\n");
}

Measured memory_bytes: 6656
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>

using namespace std;
string map[1000];
int w, h;
vector<pair<int, int>> stack;
void f(int x, int y) {
	if (x < 0 || x >= w || y < 0 || y >= h||map[y][x]!='.')return;
	map[y][x] = 'o';
	stack.push_back(make_pair(x - 1, y));
	stack.push_back(make_pair(x, y - 1));
	stack.push_back(make_pair(x + 1, y));
	stack.push_back(make_pair(x, y + 1));
	return;
}
void g(int x, int y) {
	stack.push_back(make_pair(x, y));
	while (stack.size()) {
		auto a = stack.back();
		stack.pop_back();
		f(a.first, a.second);
	}
}
bool ch(int x, int y) {
	if (x < 0 || x >= w || y < 0 || y >= h)return false;
	return map[y][x] == 'o';
}
bool check(int x, int y) {
	return ch(x - 1, y) || ch(x, y - 1) || ch(x + 1, y) || ch(x, y + 1);
}
int main(){
	int n,tx,ty;
	cin >> w >> h;
	for (int i = 0; i < h; i++) {
		cin >> map[i];
	}
	cin >> n;
	for (int i = 0; i < h; i++) {
		size_t pos = map[i].find('t');
		if (pos == string::npos)continue;
		tx = pos, ty = i;
		break;
	}
	if (map[0][0] == 't') {
		cout << 0 << endl;
		return 0;
	}
	g(0, 0);
	if (check(tx, ty)) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		map[y][x] = '.';
		if (check(x, y)) {
			g(x, y);
		}
		if (check(tx, ty)) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 20472
#include <functional>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<complex>
#include <numeric>
#include <string>
#include<iostream>
#include <fstream>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
using namespace std;
const double PI = acos(-1.0);
const double  EPS = 1e-11;
typedef long long ll;
//freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
void fast()
{
	std::ios_base::sync_with_stdio(0);
}
	int arr[50];
int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < 3; i++)
	{
		arr[s[i] - 'a']++;
	}
	if (arr[0] && arr[1] && arr[2])
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>


using namespace std;


int main()
{
  char s[201];
  int ans;

  cin >> s;
  for (int i=strlen(s)-2; i>1; i-=2){
    if (strncmp(s, s+i/2, i/2) == 0){
      ans = i;
      break;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	FOR(i,1,n+1){
		ll a=i%k;
		ll b=(k-a)%k,c=(k-a)%k;
		if((b+c)%k==0){
			ll cnt=n/k;
			if(b!=0){
				if(n%k>=b) cnt++;
			}
			ans+=cnt*cnt;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
"""
E-Knapsack2
Wが10**9まであるのでdpの置き方を工夫する。
dp[i]:=価値がiのときのナップザックの重さ
"""
N,W = map(int,input().split())
dp = [0]+[W+1]*(N*10**3)
for i in range(N):
    w,v = map(int,input().split())
    for j in range(N*10**3+1-v)[::-1]:
        dp[j+v] = min(dp[j+v],dp[j]+w)
for i in range(N*10**3+1)[::-1]:
    if dp[i]<=W:
        print(i)
        exit()

Measured memory_bytes: 41692
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <complex>
#include <vector>
#include <iomanip>
#define EPS 1e-10
#define EQ(a,b) (abs(a - b) < EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()))
using namespace std;

typedef complex<double> P;

double cross (P a, P b) {
    return (a.real() * b.imag() - a.imag() * b.real());
}

bool cmp_x (const P& p, const P& q) {
    if (p.real() != q.real()) return p.real() < q.real();
    else return p.imag() < q.imag();
}
vector<P> convex_hull (vector<P> ps) {
    int n = ps.size(), k = 0;
    vector<P> qs (n * 2);
    sort(ps.begin(), ps.end(), cmp_x);
    for (int i = 0; i < n; i++) {
        while (k > 1 && cross (qs[k-1] - qs[k-2], ps[i] - qs[k-1]) <= 0) k--;
        qs[k++] = ps[i];
    }
    for (int i = n - 2, t = k; i >= 0; i--) {
        while (k > t && cross (qs[k-1] - qs[k-2], ps[i] - qs[k-1]) <= 0) k--;
        qs[k++] = ps[i];
    }
    qs.resize(k-1);
    return qs;
}

double triangle (P a, P b, P c) {
    double x = abs(a-b), y = abs(b-c), z = abs(c-a);
    double Z = (x + y + z) / 2.0;
    return sqrt(Z * (Z - x) * (Z - y) * (Z - z));
}

double area_size (vector<P> v) {
    if (v.size() < 3) return 0;
    double res = 0.0;
    for (int i = 1; i < v.size() - 1; i++) {
        res += triangle(v[0], v[i], v[i+1]);
    }
    return res;
}

int main ()
{
    vector<P> p;
    double a,b;
    while (scanf("%lf,%lf", &a, &b) != EOF) {
        p.push_back(P(a,b));
    }

    auto v = convex_hull(p);
    printf("%.6f\n" , area_size(v));

    return 0;
}

Measured memory_bytes: 1244
import java.util.Scanner;

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

        while (str.charAt(0) != '0') {
            strArray = str.split("");
            sum = 0;
            for(String s : strArray) 
                sum += Integer.parseInt(s);
            System.out.println(sum);
            str = sc.next();
        }
    }
}


Measured memory_bytes: 27120
n_a_b = list(map(int,input().split()))

ans = 0

for i in range(0,n_a_b[0]+1,1):
    plus = i - (int(i/10) * 9 + int(i/100) * 9 + int(i/1000) * 9+ int(i/10000) * 9)

    if  n_a_b[1] <= plus and plus <= n_a_b[2]:
        ans = ans + i

print(ans)

Measured memory_bytes: 3060