akhauriyash/Code-Regression huggingface dataset:
/* ex 5_4
   seira3 */

#include <stdio.h>
#define SIZE 11 //10文字以下なので最大の要素数は\0を含めて11

int main(void){
    int ans = 0, count = 0;
    char str[SIZE], *ptr; //str: 文字列を格納する配列, ptr: strの各要素へのポインタ
    scanf("%s",&str[0]); //strに入力
    ptr = &str[0]; //ptrにstrのアドレスを代入
    while(*ptr){ //'\0'にだどり着くまでwhile文内の動作を行う
        if(*ptr=='A' || *ptr=='C' || *ptr=='G' || *ptr=='T'){ //もし*ptrが'A''C''G''T'のうちどれかならば
            count++; //countに1を足す
        }
        else{ //そうでなければcountを0でリセット
            count = 0;
        }
        if(ans < count){ //もしcountがansを上回ったら
            ans = count; //ansにcountを代入
        }
        ptr++; //隣にいくために一つずらす
    }
    printf("%d\n",ans); //答えであるansを出力
    return 0;
}

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

using namespace std;

typedef long long ll;

int N, MOD;
map<pair<int, int>, ll> dp;
vector<vector<int>> adj;
vector<vector<ll>> seg;

ll range(int, int, int, int, int, int);
ll paint(int, int);

void put(int v, int i, int L, int R, int pos, ll x) {
    if (L == R)
        seg[v][i] = x;
    else {
        int M = (L + R) / 2;
        if (pos <= M)
            put(v, 2 * i + 1, L, M, pos, x);
        else
            put(v, 2 * i + 2, M + 1, R, pos, x);
        if (seg[v][2 * i + 1] != -1 && seg[v][2 * i + 2] != -1)
            seg[v][i] = seg[v][2 * i + 1] * seg[v][2 * i + 2] % MOD;
    }
}

ll range(int v, int i, int L, int R, int l, int r) {
    if (l > r)
        return 1;
    else if (l <= L && R <= r && seg[v][i] != -1)
        return seg[v][i];
    else if (L == R) {
        int n = adj[v].size();
        ll x = (1 + paint(adj[v][L], v)) % MOD;
        put(v, 0, 0, n - 1, L, x);
        return seg[v][i];
    } else {
        int M = (L + R) / 2;
        ll result = 1;
        if (l <= M)
            result = result * range(v, 2 * i + 1, L, M, l, r) % MOD;
        if (r > M)
            result = result * range(v, 2 * i + 2, M + 1, R, l, r) % MOD;
        return result;
    }
}

ll paint(int v, int u) {
    pair<int, int> key = {v, u};
    int n = adj[v].size();
    if (!dp.count(key)) {
        if (v == u)
            dp[key] = range(v, 0, 0, n - 1, 0, n - 1);
        else {
            ll result = 1;
            int i = lower_bound(adj[v].begin(), adj[v].end(), u) - adj[v].begin();
            if (i > 0)
                result = result * range(v, 0, 0, n - 1, 0, i - 1) % MOD;
            if (i < n - 1)
                result = result * range(v, 0, 0, n - 1, i + 1, n - 1) % MOD;
            dp[key] = result;
        }
    }
    return dp[key];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> MOD;
    adj.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (int v = 0; v < N; v++)
        sort(adj[v].begin(), adj[v].end());
    seg.resize(N);
    for (int v = 0; v < N; v++)
        seg[v].assign(4 * adj[v].size(), -1);
    for (int v = 0; v < N; v++)
        cout << paint(v, v) << endl;
}


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

int main() {
    int ans = 0;
    int N;
    cin >> N;
    vector<vector<int>> Robot(N, vector<int>(2));
    for(int i = 0; i < N; i++) {
        int X, L;
        cin >> X >> L;
        Robot.at(i).at(0) = X - L;
        Robot.at(i).at(1) = X + L;
    }
    sort(Robot.begin(), Robot.end(),
         [](const vector<int> &alpha, const vector<int> &beta) {
             return alpha[1] < beta[1];
         });
    int p = Robot.at(0).at(0);
    for(int i = 0; i < N; i++) {
        if(p <= Robot.at(i).at(0)) {
            ans++;
            p = Robot.at(i).at(1);
        }
    }

    cout << ans << endl;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    string s; cin >> s;
    int x,y; cin >> x >> y;

    vector<int> move;
    int cnt = 0;
    REP(i,s.size()){
        if(s[i] == 'F'){
            cnt++;
        }else{
            move.push_back(cnt);
            cnt = 0;
        }
    }
    if(cnt!=0) move.push_back(cnt);

    vector<int> X,Y;

    int x_pos = 0;
    int y_pos = 0;

    REP(i,move.size()){
        if(i==0) x_pos = move[i];
        else if(i%2==0) X.push_back(move[i]);
        else Y.push_back(move[i]);
    }

    sort(ALL(X), greater<int>());
    sort(ALL(Y), greater<int>());

    
    REP(i,X.size()){
        if(x_pos < x) x_pos += X[i];
        else x_pos -= X[i];
    }
    REP(i,Y.size()){
        if(y_pos < y) y_pos += Y[i];
        else y_pos -= Y[i];
    }

    if(x==x_pos && y==y_pos) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3652
# 各unionのsizeを持つパターン
class UnionFindWithSize
  def initialize(size)
    @rank = Array.new(size) { 0 }
    @parent = Array.new(size) { |id| id }
    @union_size = Array.new(size) { 1 }
    @max_union_size = 0
  end

  def unite(id_x, id_y)
    x_parent = get_parent(id_x)
    y_parent = get_parent(id_y)
    return if x_parent == y_parent

    ary = [@union_size[x_parent], @union_size[y_parent]]
    if @rank[x_parent] > @rank[y_parent]
      @parent[y_parent] = x_parent
      @union_size[x_parent] += ary[1]
      @max_union_size = @union_size[x_parent] if @union_size[x_parent] > @max_union_size
    else
      @parent[x_parent] = y_parent
      @union_size[y_parent] += ary[0]
      @max_union_size = @union_size[y_parent] if @union_size[y_parent] > @max_union_size
      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
    ary
  end

  def get_parent(id_x)
    @parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
  end

  def max_us
    @max_union_size
  end
end

N,M = gets.chomp.split.map(&:to_i)

ufs = UnionFindWithSize.new(N)
M.times do |i|
  a, b = gets.chomp.split.map(&:to_i)
  ufs.unite(a - 1, b - 1)
end

if M == 0
  puts 1
else
  puts ufs.max_us
end




Measured memory_bytes: 19040
#include <bits/stdc++.h>
  using namespace std;
  #define int long long int
  #define vi vector<int>
  #define pii pair<long long ,long long>
  #define pll pair<int,int>
  #define mod 1000000007
  #define hell 998244353
  #define all(x) x.begin(),x.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define eb push_back
  #define ff first
  #define ss second
  #define rep(n) for(int i=0;i<n;i++)
  #define lb lower_bound
  #define up upper_bound
  const int N=(1<<21);
  int dp[N];
  void solve()
  { 
     
     int n;
     cin>>n;
     vector<vector<int> > v(n,vector<int> (n,0));

      for(int i=0;i<n;i++)
      {
         for(int j=0;j<n;j++)
         {
             cin>>v[i][j];
         }
      }

      dp[0]=1;
    
         for(int mask=0;mask<(1<<n)-1;mask++)
         {
            int a=__builtin_popcount(mask);
              for(int j=0;j<n;j++)
              {
                   if(v[a][j] && !(mask & (1<<j)))
                   {
                        int new_mask=mask ^ (1<<j);
                        dp[new_mask]=(dp[new_mask]%mod+dp[mask]%mod)%mod;
                   }
              }
         }
      

      cout<<dp[(1<<n)-1];
     
   

   

  






  }



  signed main()
  {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


   
    
    
    int T;
    T=1;
    
    while(T--)
    {
      solve();
    }
    return 0;
  }

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int main(){

  ll sum = 0, n, x;
  cin >> n;
  for(int i = 1; i <= n; i++){
    if(i % 3 and i % 5)sum += i;
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3600
n,a,b = map(int, input().split())
s = list(input())

sa = 0
sb = 0
for i in range(n):
    if s[i]=="a":
        if sa+sb<a+b:
            print("Yes")
            sa += 1
        else:
            print("No")
    elif s[i]=="b":
        if sa+sb<a+b and sb<b:
            print("Yes")
            sb += 1
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4712
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N,P=map(int,input().split())
c = collections.Counter(prime_factorize(P))
#print(c)
value=[i**(c[i]//N) for i in c if c[i]>=N]
count=1
for i in value:
    count*=i
print(count)


Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(ll i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ll j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


const int dishNum = 5;

int resolve(vector<int> & dishes) {
    int ans = 0;
    REPinit(i, 0, dishNum - 1) {
        ans += dishes[i];
        if (ans % 10 != 0) {
            ans = ans + 10 - (ans % 10);
        }
    }
    return (ans + dishes[dishNum - 1]);
}

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

    vector<int> dishes(dishNum);
    REPinit(i, 0, dishNum) cin >> dishes[i];

    int ans = 10000;
    do
    {
        ans = min(ans, resolve(dishes));
    } while (std::next_permutation(CONTAINER_ALL(dishes)));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3612
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int c = s.nextInt();
		int k = s.nextInt();
		int a[] = new int[n];
		int b[] = new int[n];
		int d[] = new int[n];
		int x = 0, y = 0;
		for (int i = 0; i < n; i++) {
			a[i] = s.nextInt();

		}
		Arrays.sort(a);
		for (int j = 0; j < n; j++) {
			d[j] = a[j] + k;

		}
//		int i = 0;
//		while (i < n) {
//			x = 0;
//			int j = i;
//			int flag = 0;
//			while (j < n) {
//				if (d[i] >= a[j]  && a[j] >= a[i] && (x<c)) {
//					x++;
//					flag = 1;//////time limit exceed
//				}
//				
//				
//				j++;
//			}
//			if (flag == 1) {
//				y++;
//			}
//			
//			i = i + x;
//		}
//		System.out.println(y);

		y = 1;
		int j= a[0];
		 x= 1;
		for(int i = 1; i < n; i++) {
			if(x >= c ||  j+k<a[i]) {
				y++;
				
				x = 0;
				j = a[i];
			}
			x++;
		}
 
		System.out.println(y);
	}
}



Measured memory_bytes: 58972
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 9999999999999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;
const int SIZE = 1 << 17;

template<typename T>
struct lazysegtree {
	T node[2 * SIZE], lazy[2 * SIZE], mon;
	bool used[2 * SIZE];
	T(*upd_f)(T, T, int, int), (*qry_f)(T, T);
	lazysegtree(T(*op1)(T, T, int, int), T(*op2)(T, T), T X) {
		upd_f = op1;
		qry_f = op2;
		mon = X;
		fill(lazy, lazy + 2 * SIZE, mon);
		fill(node, node + 2 * SIZE, mon);
		fill(used, used + 2 * SIZE, false);
	}

	void lazy_eval(int a, int b, int c) {
		if (!used[a]) { return; }
		node[a] = upd_f(node[a], lazy[a], b, c);
		if (c - b > 1) {
			lazy[2 * a + 1] = upd_f(lazy[2 * a + 1], lazy[a], 0, 1);
			lazy[2 * a + 2] = upd_f(lazy[2 * a + 2], lazy[a], 0, 1);
			used[2 * a + 1] = used[2 * a + 2] = true;
		}
		lazy[a] = mon;
		used[a] = false;
	}

	void update(int a, int b, T val, int c = 0, int d = SIZE, int e = 0) {
		lazy_eval(e, c, d);
		if (b <= c || d <= a) { return; }
		if (a <= c && d <= b) {
			lazy[e] = upd_f(lazy[e], val, 0, 1);
			used[e] = true;
			lazy_eval(e, c, d);
		}
		else {
			int monn = (c + d) / 2;
			update(a, b, val, c, monn, 2 * e + 1);
			update(a, b, val, monn, d, 2 * e + 2);
			node[e] = qry_f(node[2 * e + 1], node[2 * e + 2]);
		}
	}

	T query(int a, int b, int c = 0, int d = SIZE, int e = 0) {
		lazy_eval(e, c, d);
		if (b <= c || d <= a) { return mon; }
		if (a <= c && d <= b) { return node[e]; }
		int monn = (c + d) / 2;
		T lmon = query(a, b, c, monn, 2 * e + 1);
		T rmon = query(a, b, monn, d, 2 * e + 2);
		return qry_f(lmon, rmon);
	}
};

int upd(int a, int b, int c, int d) { return b; }
int fin(int a, int b) { return min(a, b); }
lazysegtree<int>seg(upd, fin, INT_MAX);

//ex(DSL_2)
int main() {
	int a, b;
	cin >> a >> b;
	while (b--) {
		int n;
		cin >> n;
		if (n) {
			int c, d;
			cin >> c >> d;
			cout << seg.query(c, d + 1) << endl;
		}
		else {
			int c, d, e;
			cin >> c >> d >> e;
			seg.update(c, d + 1, e);
		}
	}
}


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

int main(){
    ll X;
    cin >> X;
    REP(i,-200,200){
        REP(j,-200,200){ 
            ll proi = i*i*i*i*i;
            ll proj = j*j*j*j*j;
           if(proi - proj == X){
               cout << i << " " << j << endl;
               return 0;
           }
    }
 }
}

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

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

int main()
{
    int N;
    string S;
    cin >> N >> S;
    int sum = 0, left = 0, right = 0;
    for (int i = 1; i < N;i++)
    {
        if(S[i] == 'E')
        {
            right++;
        }
    }
    sum = left + right;

    for (int i = 1; i < N;i++)
    {
        if(S[i - 1] == 'W')
        {
            left++;
        }
        if(S[i] == 'E')
        {
            right--;
        }
        if(sum > (left + right))
        {
            sum = left + right;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 900
#include<iostream>
#include<vector>
using namespace std;

int reduce_ene(int day, int except_num, vector<int> &c, vector<int> &last){
    int i;
    int sum_reduce;
    sum_reduce = 0;

    for(i=0;i<c.size();i++){
        if(i != except_num-1){
            sum_reduce += c[i] * (day+1 - last[i]);
        }
    }
    return sum_reduce;
}

int plus_ene(int day, vector<int> &t, vector<vector <int> > &s){
    return s[day][t[day] - 1];
}


int ene_cal(int D, vector<int> &t, vector<vector <int> > &s, vector<int> &last, vector<int> &c){
    int day;
    int ene, ene_new;
    ene = 0;
    ene_new = 0;
    for(day=0;day<D;day++){
        ene += plus_ene(day, t, s);  
        ene -= reduce_ene(day, t[day], c, last);
        cout << ene << endl;
        last[t[day] - 1] = day + 1;
    }
    return ene;

}




int main(){
    /* init */

    int i,j;
    int D;
    vector<int> c;
    vector<int> t;

    cin >> D;
    int sum_c; 
    sum_c = 0;
    for(i=0;i<26;i++){
        int ci;
        cin >> ci;
        c.push_back(ci);
        sum_c += ci;
    }


    vector<int> last(c.size(), 0);
    vector<vector <int> > s(D, vector<int>(c.size(), 0));

    for(j=0;j<D;j++){
        for(i=0;i<c.size();i++){
            int sij;
            cin >> sij;
            s.at(j).at(i) = sij;
    }}

    for(i=0;i<D;i++){
        int ti;
        cin >> ti;
        t.push_back(ti);
    }

    //end init
    long int ene;


    ene = ene_cal(D, t, s, last, c);







    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int a,b,c,k; cin>>a>>b>>c>>k;
    int cnt=0;
    while(a>=b){
        b*=2;
        cnt++;
    }
    while(b>=c){
        c*=2;
        cnt++;
    }
    if(cnt<=k){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3636
using System;
using System.Linq;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray();
            int n = input[0];
            int k = input[1];

            double[] hArray = Console.ReadLine().Split(' ').Select(e => double.Parse(e)).ToArray();

            double[] dpArray = (new double[n]).Select(e => double.MaxValue).ToArray();


            dpArray[0] = 0;

            for (int idx = 0; idx < n; idx++)
            {
                for (int j = Math.Max(0, idx - k); j < idx; j++)
                {
                    double dist = Math.Abs(hArray[idx] - hArray[j]) + dpArray[j];
                    dpArray[idx] = Math.Min(dpArray[idx], dist);
                }
            }
            Console.WriteLine(dpArray.Last());
        }
    }
}


Measured memory_bytes: 24288
// Ballazt
//0a..brute force
//0b..greedy
//1..memorizatton of some sort	remember something cleverly
//2..sort
//3..binary search	keep check a particular solution
//4..dp				repeating strucutre,limited choices
//5..dfs/bfs		matrix with obstacles
//6..correlate to graph in some way		each state is a point
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"


int main()

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

	
	int s,w;
	cin>>s>>w;

	if(w>=s) cout<<"unsafe";
	else cout<<"safe";

	
	return 0;

	
}

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

int main() {
    int n;
    cin >> n;
    uint64_t a = 2, b = 1;

    if (n == 0) {
        cout << a << endl;
    } else if (n == 1) {
        cout << b << endl;
    } else {
        uint64_t l;
        for (int i = 2; i < n + 1; i++) {
            l = b + a;
            a = b;
            b = l;
        }
        cout << l << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#ifndef M_PI
const double M_PI=acos(-1);
#endif
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

int cost[100][100];
int ti[100][100];

main(){
  int n,m;
  while(cin>>n>>m,n|m){
    rep(i,m){
      rep(j,m)cost[i][j]=ti[i][j]=1<<28;
      cost[i][i]=ti[i][i]=0;
    }
    rep(i,n){
      int a,b,c,t;
      cin>>a>>b>>c>>t;
      --a,--b;
      cost[b][a]=cost[a][b]=min(cost[a][b],c);
      ti[a][b]=ti[b][a]=min(ti[a][b],t);
    }
    rep(k,m)rep(i,m)rep(j,m){
      cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
      ti[i][j]=min(ti[i][j],ti[i][k]+ti[k][j]);
    }
    int k;
    cin>>k;
    rep(i,k){
      int p,q,r;
      cin>>p>>q>>r;
      --p,--q;
      cout<<(r?ti[p][q]:cost[p][q])<<endl;
    }
  }
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

template<class T>
class StarrySkyTree {
    private:
        int N;
        const T MIN;
        const T ZERO;
        std::vector<T> dat, lazy;
    public:
        StarrySkyTree(int n) : MIN(std::numeric_limits<T>::min()), ZERO(static_cast<T>(0)) {
            N = 1;
            while (N < n) N *= 2;
            dat.assign(2*N, MIN);
            lazy.assign(2*N, ZERO);
        }
        // a is 0-indexed
        void set(int a, const T v) { dat[a+N] = v; }
        void build() { for (int i=N-1; i>0; --i) dat[i] = std::max(dat[2*i], dat[2*i+1]); }
        void eval(int k, int l, int r) {
            if (lazy[k] == ZERO) return;

            dat[k] += lazy[k];
            if (r - l > 1) {
                lazy[2*k] += lazy[k];
                lazy[2*k+1] += lazy[k];
            }
            lazy[k] = ZERO;
        }
        // add v to [a, b)
        // a and b are 0-indexed
        void add(int a, int b, const T v) { return add (a, b, v, 1, 0, N); }
        void add(int a, int b, const T v, int k, int l, int r) {
            eval(k, l, r);

            if (b <= l || r <= a) return;
            if (a <= l && r <= b) {
                lazy[k] += v;
                eval(k, l, r);
            } else {
                add(a, b, v, 2*k, l, (l+r)/2);
                add(a, b, v, 2*k+1, (l+r)/2, r);
                dat[k] = std::max(dat[2*k], dat[2*k+1]);
            }
        }
        // get max of [a, b)
        // a and b are 0-indexed
        T get(int a, int b) { return get(a, b, 1, 0, N); }
        T get(int a, int b, int k, int l, int r) {
            eval(k, l, r);

            if (b <= l || r <= a) return MIN;
            if (a <= l && r <= b) return dat[k];
            T vleft = get(a, b, 2*k, l, (l+r)/2);
            T vright = get(a, b, 2*k+1, (l+r)/2, r);
            return std::max(vleft, vright);
        }
};

void solve() {
    int N, M;
    cin >> N >> M;
    vector<vector<pair<int, int>>> ls(N+1);
    for (int i=0; i<M; ++i) {
        int l, r, a;
        cin >> l >> r >> a;
        ls[r].emplace_back(l, a);
    }

    StarrySkyTree<ll> dp(N+1);
    for (int i=0; i<N+1; ++i) dp.set(i, 0);
    dp.build();
    for (int i=1; i<N+1; ++i) {
        dp.add(i, i+1, dp.get(0, i));
        for (auto p : ls[i]) dp.add(p.first, i+1, p.second);
    }
    cout << dp.get(0, N+1) << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 22412
'''
n = int(input())
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [int(input()) for i in range n]
p = [list(map(int, input().split()))]

a = input()
a, b = input().split()
a = [input() for i in range n]
'''

Numbers = list(map(int, input().split()))

ans = "No"

import collections
counter = collections.Counter(Numbers)

for i in counter.values():
    if i == 2:
        ans = "Yes"

print(ans)


Measured memory_bytes: 3444
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

        h[0]--;
        for (int i = 1; i < n; i++)
        {
            if (h[i - 1] > h[i])
            {
                Console.WriteLine("No");
                return;
            }

            if (h[i - 1] <= h[i] - 1)
            {
                h[i]--;
            }
        }

        Console.WriteLine("Yes");
    }
}


Measured memory_bytes: 24668
#include <cstdio>

using namespace std;

void nap(int max,int i){
	int memo[1001]={0};
	int n,v,w;//n:個数 v:価値 w:重さ
	int ansV=0;
	int ansW=0;
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d,%d",&v,&w);
		for(int j=max;j>=w;j--){
			if(j==w || memo[j-w]>0){
				if(memo[j]<memo[j-w]+v){
					memo[j]=memo[j-w]+v;
				}
			}
		}
	}
	
	for(int i=0;i<=max;i++){
		if(memo[i]>ansV){
			ansV=memo[i];
			ansW=i;
		}
	}
	printf("Case %d:\n",i);
	printf("%d\n%d\n",ansV,ansW);
}

int main(){
	int w,i=1;
	scanf("%d",&w);
	while(w!=0){
		nap(w,i);
		i++;
		scanf("%d",&w);
	}
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int m = scn.nextInt();
      	int d = scn.nextInt();
		int count = 0;
		for(int i=2; i<=m; ++i){
          for(int j=21; j<=d; ++j){
            int jj = j%10;
            int jjj = j/10;
            if(jj>=2 && jj*jjj==i){
              count = count + 1;
            }
          }
		}
      System.out.println(count);
	}
}


Measured memory_bytes: 35672
#include <iostream>
#include <algorithm>
using namespace std;
int e;

void solve() {
  int minm = 1000000;
  for (int z = 0; z*z*z <= e; z += 1) {
    for (int y = 0; y*y <= e-z*z*z; y += 1) {
      int x = e - z*z*z - y*y;
      if (x < 0) continue;
      int m = x + y + z;
      minm = min(minm, m);
    }
  }
  cout<<minm<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>e, e) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 864
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>

int main()
{
    int a = 0;
    std::cin >> a;
    int b = 0;
    std::cin >> b;

    int hour = 0;
    std::cin >> hour;

    int minute = 0;
    std::cin >> minute;

    // 長針はh * 360 / 12 度 + minute * 360 / 12 / 60度
    // 短針はminute * 360 / 60

    const double hDeg = double(hour) * 360 / 12 + double(minute) * 360 / 12 / 60;


    const double hRad = hDeg * M_PI / 180.0;
    const auto hx = a * sin(hRad);
    const auto hy = a * cos(hRad);

    const double mDeg = double(minute) * 360 / 60;
    const double mRad = mDeg * M_PI / 180.0;
    const auto mx = b * sin(mRad);
    const auto my = b * cos(mRad);

    const auto dx = std::abs(hx - mx);
    const auto dy = std::abs(hy - my);
    const auto dist = std::sqrt((dx * dx) + (dy * dy));
    std::cout << std::fixed << std::setprecision(20) << dist;
}

Measured memory_bytes: 4160
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	for(int i=0;i<n;i++)
	{
		string s_temp=s.substr(i);
		string t_temp=t.substr(0,(int)s_temp.size());
		if(s_temp==t_temp)
		{
			cout<<(2*i)+(s_temp.size());
			return 0;
		}
	}
	cout<<2*n;
	return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(){
  int max, min, x, y, n, m;
  scanf("%d %d %d %d", &n, &m, &max, &min);
  int i;
  for(i=0;i<n;i++){
    scanf("%d", &x);
    if(max<x) max=x;
  }
  for(i=0;i<m;i++){
    scanf("%d", &y);
    if(y<min) min=y;
  }
  if(max<min) puts("No War");
  else puts("War");
  return 0;
}

Measured memory_bytes: 128
def main():
    s = input()
    k = int(input())

    count_l = []
    i = 0
    counter = 1
    while True:
        if len(s) == 1:
            count_l.append(counter)
            break
        elif s[i] == s[i+1]:
            counter += 1
        else:
            count_l.append(counter)
            counter = 1
        i += 1
        if i == len(s)-1:
            if counter == 1:
                break
            else:
                count_l.append(counter)
                break

    answer = 0
    if len(count_l) >= 3 and s[0] == s[-1] and k >= 2:
        sub_l = [count_l[0] + count_l[-1]] + count_l[1:-1]
        for i in range(len(sub_l)):
            answer += (sub_l[i] // 2) * (k - 1)
        for j in range(len(count_l[:-1])):
            answer += count_l[j] // 2
        answer += count_l[-1] // 2
    elif len(count_l) == 1:
        answer += (count_l[0] * k) // 2
    else:
        for i in range(len(count_l)):
            answer += (count_l[i] // 2) * k

    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62016
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 1000000007;

int main(){
	string S;
	int ans=0;
	cin>>S;

	for(int i=0;i<4;i++){
		if(S[i]=='+') ans++;
		else ans--;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int N;
char s[200000 + 100];
LL A[200000 + 100][30];
int main()
{
	scanf("%s", s + 1);
	N = strlen(s + 1);
	for (int i = 1; i <= N; ++i)
	{
		for (int j = 0; j < 26; ++j)
			A[i][j] = A[i-1][j];
		++ A[i][s[i] - 'a'];
	}
	LL Ans = 1;
	for (int i = 1; i <= N; ++i)
		Ans += N - i - A[N][s[i] - 'a'] + A[i][s[i] - 'a'];
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 47360
#include<bits/stdc++.h>
#define n 500000
#define mem(arr) memset(arr, 0, sizeof(arr))
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
void solve();
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int times = 1;
//	cin >> times;
	for(int i=0; i<times; i++)
	{
		solve();
		cout << '\n';
	}
	return 0;
}

int a, b, c, d, e, f, g, h;
//int arr[n + 50], arr1[n + 50], arr2[n + 50];

//type here

void solve()
{
	cin >> a;
	pair<lli, lli> arr[a + 50];
	for(int i=0; i<a; i++)
		cin >> arr[i].first >> arr[i].second;
	for(int i=1; i<a; i++)
	{
		if(arr[i].first >= arr[i - 1].first && arr[i].second >= arr[i - 1].second) continue;
		lli one = arr[i - 1].first / arr[i].first, two = arr[i - 1].second / arr[i].second;
		if(arr[i - 1].first % arr[i].first != 0) one ++;
		if(arr[i - 1].second % arr[i].second != 0) two ++;
		lli res = max(one, two);
		arr[i].first *= res; arr[i].second *= res;
	}
	lli ans = arr[a - 1].first + arr[a - 1].second;
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;
typedef vector<int> vec;

int main(){
  int r;
  cin >> r;
  if(r<1200){
    cout << "ABC" << endl;
    return 0;
  }
  if(r<2800){
    cout << "ARC" << endl;
    return 0;
  }
  cout << "AGC" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
//	freopen("A.in","r",stdin);
//	freopen("A.out","w",stdout);
	cin>>a>>b;
	if(a%2!=b%2){
		printf("IMPOSSIBLE");
		return 0;
	}
	int dis = abs(a+b)/2;
	cout<<dis<<endl;
	return 0;
}

Measured memory_bytes: 256
// 3_abc122_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

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 SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;

    vector<int> sum(n + 1);
    sum[0] = 0;
    rep1(i, n){
        if(s.substr(i - 1, 2) == "AC"){
            sum[i] = sum[i - 1] + 1;
        }else{
            sum[i] = sum[i - 1];
        }
    }

    rep(i, q){
        int l, r;
        cin >> l >> r;
        l--; r--;

        cout << sum[r] - sum[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 1488
import itertools

h, w, k = map(int, input().split())
c = [input() for i in range(h)]
ans = 0
for i in itertools.product(range(2), repeat=h):
  for j in itertools.product(range(2), repeat=w):
    s = 0
    for x in range(h):
      for y in range(w):
        if c[x][y] == '#' and i[x] and j[y]:
          s += 1
    if s == k:
      ans += 1
print(ans)


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,M;
char S[202020];
vector<ll> ans;
ll i, j;
int main(){
    scanf("%lld%lld%s", &N,&M,S);
    i = N;
    while(i>0){
        j = i < M ? i : M;
        if(S[i-j]=='1'){
            for (j = M - 1; j > 0;j--){
                if(S[i-j]!='1')
                    break;
            }
            if(j==0){
                printf("-1");
                return 0;
            }
        }
        ans.push_back(j);
        i -= j;
    }
    for (i = ans.size() - 1; i >= 0;i--)
    {
        printf("%lld ", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template<class T>inline void read(T &res)
{
    char c;
    T flag=1;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
    res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';
    res*=flag;
}
void gcd(ll a,ll b,ll &d,ll &x,ll &y)
{
    if(!b)
    {
        d=a;
        x=1;
        y=0;
    }
    else
    {
        gcd(b,a%b,d,y,x);
        y-=x*(a/b);
    }
}
ll in(ll a,ll mod)
{
    ll d,x,y;
    gcd(a,mod,d,x,y);
    return d==1?(x+mod)%mod:-1;
}

ll qp(ll a,ll x,ll mod)
{
    ll ans=1;
    while(x)
    {
        if(x%2==1)
            ans=(ans*a)%mod;
        a=(a*a)%mod;
        x/=2;
    }
    return ans;
}
int cmp(ll a,ll b)
{
    return a<b;
}

int ok(ll a,ll b,ll c)
{
    if(a==b||a==c||b==c)
        return 0;
    if(a+b>c)
        return 1;
    return 0;
}
ll a[105];
int main()
{
    int n,ans=0;
    read(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n,cmp);
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
                if(ok(a[i],a[j],a[k]))
                    ans++;
        }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
int ss(int x)
{
    int n,t=0;
    if(x%3==0)
    t=1;
    do
    {
        if(x%10==3)
        {
            t=1;
            break;
        }
        x/=10;    
    }
    while(x);
    return t;
}
int main()
{
    int x,n;
    scanf("%d",&n);
    int t;
    for(x=3;x<=n;x++)
    {
        t=ss(x);
        if(t==1)
        printf(" %d",x);
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>
using namespace std;
bool judge(int,int,int);

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        int a, b, c;
        cin >> a >> b >> c;
        if (judge(a, b, c)){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}

bool judge(int a, int b, int c){
    if (a > b && a > c && a * a == b * b + c * c){
        return true;
    }else if(b > a && b > c && b * b == c * c + a * a){
        return true;
    }else if(c > a && c > b && c * c == a * a + b * b){
        return true;
    }else{
        return false;
    }
}

Measured memory_bytes: 1152
n,k=map(int,input().split())
a=list(map(int,input().split()))

for i in range(1,10**5+1):
  if i>=n:
    p=str(i)
    ch=0
    for y in range(len(p)):
      if int(p[y]) in a:
        ch+=1
    if ch==0:
      print(i)
      break

Measured memory_bytes: 9200
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a<b&&b<c){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return(0);
}



Measured memory_bytes: 3084
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);
#define PI (3.14159265358979323846)

using ll = int64_t;
using ull = uint64_t;

using namespace std;

[[maybe_unused]] static auto __x = [](){ios_base::sync_with_stdio(0); cin.tie(0);};

int main() {
    string a, b;
    cin >> a >> b;

    int res = 0;
    for (int i = 0; i < 3; ++i) {
        if (a[i] == b[i]) ++res;
    }
    cout << res;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b)(fabs((a)-(b))<EPS)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

struct Point {
	double x, y;
	Point(double x = 0, double y = 0) :x(x), y(y) {}
	Point operator*(double a) { return Point(a*x, a*y); }
	Point operator-(Point p) { return Point(x - p.x, y - p.y); }
};
struct Segment {
	Point p1, p2;
};
double cross(Point a, Point b) {
	return a.x*b.y - a.y*b.x;
}
bool isPrallel(Segment s1, Segment s2) {
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
int main() {
	int n; cin >> n;
	rep(i, n) {
		double x1, y1, x2, y2, x3, y3, x4, y4;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		Segment s1{ {x1,y1},{x2,y2} };
		Segment s2{ {x3,y3},{x4,y4} };
		puts(isPrallel(s1, s2) ? "YES" : "NO");
	}
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;


    
int main(){
    long long n,k,sum=0;
    cin>>n>>k;
    vector<long long> h(n);
    rep(i,n){
        cin>>h[i];
    }
    sort(ALL(h));
    rep(i,n-k) sum += h[i];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1792
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
N = lines.shift() * 1
p = lines.shift().split(' ')
a = 0
for (i=0; i<N; i++) {
    if (i+1 != p[i]) {
        a++
    }
    if (a > 2) {
        break;
    }
}
console.log(a == 0 || a == 2 ? 'YES' : 'NO')


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

#define pb push_back
#define fi first
#define se second


using namespace std;


vector< double > v;

int main()
{
	int n, d;

	cin>>n>>d;

	for (int i = 0; i < n; ++i)
	{
		long long a, b;

		cin>>a>>b;

		v.pb( sqrt(a*a + b*b) );
	}


	int count = 0;
	for (int i = 0; i < n; ++i)
	{
		if(v[i] <= d)
			count++;
	}

	cout<<count<<endl;

	return 0;
}


Measured memory_bytes: 5336
#include<bits/stdc++.h>
using namespace std;
#define int long long
int m(int a,int k){
  if(!a) return 0;
  string s;
  while(a){
    int tmp=a%k;
    if(tmp>9) return -1;
    s+='0'+tmp;
    a/=k;
  }
  reverse(s.begin(),s.end());
  return stoll(s);
}
signed main(){
  int a,b,c;
  while(cin>>a>>b>>c,~a){
    bool f=1;
    for(int i=2;i<=16;i++) f&=m(a,i)!=b;
    int res=b;
    for(int j=a;j<=c;j++){
      int tmp=-1;
      for(int i=2;i<=16;i++)
	if(m(j,i)>=res)
	  if(tmp<0||m(j,i)<tmp) tmp=m(j,i);
      if(tmp<0){
	f=1;
	break;
      }
      res=tmp;
    }
    cout<<(f?-1:res)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3132
import sys
input = lambda: sys.stdin.readline().rstrip()

n = int(input())
a = []
b = []
for _ in range(n):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)
a.sort()
b.sort()
if n % 2 == 1:
    a_m = a[n // 2]
    b_m = b[n // 2]
    print(b_m - a_m + 1)
else:
    a_m = (a[n // 2 - 1] + a[n // 2]) #/ 2
    b_m = (b[n // 2 - 1] + b[n // 2]) #/ 2
    print(int(b_m - a_m) + 1) 




Measured memory_bytes: 92104
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;

long long sx,sy,tx,ty;
const int MAX=3000005;
long long fact[MAX],fact_inv[MAX];

long long modpow (long long a,long long n)
{
	if(n==0) return 1;
	if(n%2)
		return (a%mod*modpow(a,n-1)%mod)%mod;
	else
		return modpow((a*a)%mod,n/2)%mod;
}

void make_fact()
{
	long long val=1;
	fact[0]=1;
	for(int i=1;i<MAX;i++)
	{
		val=(val*i)%mod;
		fact[i]=val;
	}
	fact_inv[MAX-1]=modpow(fact[MAX-1],mod-2);
	for(int i=MAX-2;i>=0;i--)
		fact_inv[i]=(fact_inv[i+1]%mod*(i+1)%mod)%mod;
}

long long comb(long long n,long long k)
{
	long long ret=1;
	ret=((ret*fact[n]*fact_inv[k])%mod*fact_inv[n-k])%mod;
	return ret;
}

int main()
{
	make_fact();
	cin>>sx>>sy>>tx>>ty;
	long long ans=0;
	for(int i=sx;i<=tx;i++)
	{
		ans+=comb(i+ty+1,ty);
		ans=ans%mod;
		ans+=mod-comb(i+(sy-1)+1,sy-1);
		ans=ans%mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    int N;
    cin >> N;
    if(N%10==9 or N/10==9) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	S := nextBytes()
	N := len(S) + 1
	c := int64(0)

	C := make([]byte, 1)
	L := make([]int, 1)
	n := 0

	C[0] = S[0]
	L[0] = 1

	for i := 1; i < N-1; i++ {
		if C[n] != S[i] {
			C = append(C, S[i])
			L = append(L, 0)
			n++
		}
		L[n]++
	}
	if C[n] == '<' {
		C = append(C, '>')
		L = append(L, 0)
	}

	n = 0
	if C[0] == '>' {
		c = c + sum(L[0])
		n++
	}
	for ; n < len(C); n += 2 {
		if L[n] < L[n+1] {
			c = c + sum(L[n]-1) + sum(L[n+1])
		} else {
			c = c + sum(L[n]) + sum(L[n+1]-1)
		}
	}

	fmt.Println(c)
}

func sum(n int) int64 {
	return int64((n * (n + 1)) / 2)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long i,j,n,k=0,x,y,q;
  cin>>n;
  long long a[n];
  
  for(i=0;i<n;i++){
    cin>>a[i];
    k^=a[i];
  }
  
  
  for(i=0;i<n;i++)
  {
    a[i]^=k;
    cout<<a[i]<<" ";
  }
  
  return 0;
}

Measured memory_bytes: 5176
# import math
# import statistics
# import itertools
a=int(input())
# b=input()
# c=[]
# for i in a:
#     c.append(int(i))
# N,K= map(int,input().split())
f = list(map(int,input().split()))
# g = [int(input()) for _ in range(N)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen
ans=[f[0],f[-1]]
for i in range(a-2):
    ans.append(min(f[i],f[i+1]))

print(sum(ans))

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


using namespace std;

int main()
{
    int m;
    string s,new_string="";
    char a=',';
    cin>>s;
    m=s.length();
    for(int i=0;i<m;i++)
    {
        if(s[i]==a)
            new_string=new_string+" ";
        else
            new_string=new_string+s[i];

    }
    cout<<new_string;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
using namespace std;
int a = 0, b = 0, c = 0, d = 0, e[60][60], f[120], g[101000], h[10100], counto = 1, ans = 0, x[100] = {}, y, z;
int64_t ab[10000] = {}, abc = 0, abcd = 0;
pair<int, int>manji[101] = {};
char rikka, toka[150][150] = {};
vector<int> train,code;
vector<char>aka,ao;
string saya, homu, kyok, mami[108], mado[100];
bool gg;
bool exist[1000];
int main() {
	cin >> a >> b;
	for (int i = 0; i < a; i++) {
		if (counto >= b) {
			counto = counto + b;
		}
		else { counto = counto * 2; }
	}
	cout << counto << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
list($N, $M, $X) = array_map(function ($n) {
    return (int)$n;
}, explode(' ', fgets(STDIN)));

$C = [];
$A = [];

for ($i = 0; $i < $N; $i++) {
    $input = array_map(function ($n) {
        return (int)$n;
    }, explode(' ', fgets(STDIN)));
    $C[] = array_shift($input);
    $A[$i] = $input;
}

$ans = -1;
for ($i = 0; $i < pow(2, $N); $i++) {
    $money = 0;
    $skills = [];
    for ($j = 0; $j < $M; $j++) {
        $skills[$j] = 0;
    }
    $buy_or_nots = str_split(sprintf("%0{$N}d", decbin($i)));
    foreach ($buy_or_nots as $index => $buy_or_not) {
        if ((int)$buy_or_not) {
            $money += $C[$index];
            for ($j = 0; $j < $M; $j++) {
                $skills[$j] += $A[$index][$j];
            }
        }
    }

    $clear_skill = true;
    foreach ($skills as $skill) {
        if ($skill < $X) {
            $clear_skill = false;
            break;
        }
    }
    if ($clear_skill) {
        if ($ans === -1) {
            $ans = $money;
        } elseif($money < $ans) {
            $ans = $money;
        }
    }
}

echo $ans;

Measured memory_bytes: 16232
import java.util.Scanner;

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

        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int c = stdIn.nextInt();

        if (a <= b && b <= c)
            System.out.printf("%d %d %d\n", a, b, c);
        else if (a <= c && c <= b)
            System.out.printf("%d %d %d\n", a, c, b);
        else if (b <= a && a <= c)
            System.out.printf("%d %d %d\n", b, a, c);
        else if (b <= c && c <= a)
            System.out.printf("%d %d %d\n", b, c, a);
        else if (c <= a && a <= b)
            System.out.printf("%d %d %d\n", c, a, b);
        else if (c <= b && b <= a)
            System.out.printf("%d %d %d\n", c, b, a);

    }
}


Measured memory_bytes: 26320
#include<stdio.h>

int main()
{
    char string[15];
    scanf("%s",string);
    if(string[0]!='A')
    {
        printf("WA\n");
        return 0;
    }
    int c=0,i=0;
    for(i=1;string[i]!='\0';i++)
    {
        if(i>1 && string[i]=='C') c++;
        else {
            if(string[i]>='A'&& string[i]<='Z')
            {
                printf("WA\n");
                return 0;
            }
        }
    }
    if(i>3)
    {
        if(c!=1)
        {
            printf("WA\n");
            return 0;
        }
        else
        {
            if(string[i-1]=='C')
            {
                printf("WA\n");
                return 0;
            }
        }
    }
    else
    {
        if(c==1)
        {
            printf("WA\n");
            return 0;
        }
    }
    printf("AC\n");
    return 0;
}


Measured memory_bytes: 128