akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
//import java.io.*;
/*
行列 A、ベクトル b はそれぞれ 2 次元配列と１次元配列に記録します。
for ループの入れ子を使って、問題文の公式の通りに ci の値を加算していきます。
*/
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
       Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();//　n行ある
       int m = sc.nextInt();//　m行ある

//      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        int [][] matrix = new int[n][m];//matrix入れる箱
        int [] vector = new int [m];//vector入れる箱

        int x;
        int y;
        int a =0;
        int b =0;

        int i;
        int j;
        int k;
        int num = 0;

        for( i = 0; i < n; i++){
          for( j = 0; j < m; j++){
              x = sc.nextInt();
              matrix[i][j]=x;
 //             System.out.print(x);
          }
        }
          
        for( k = 0; k < m; k++){
            y = sc.nextInt();
            vector[k] = y;
 //           System.out.print(y);
        }
 //       System.out.println();

        int [] answer =new int[n];

         for( i =0; i < n; i++){
             
              for( j = 0; j < m; j++){        
                  
                     a = matrix[i][j];
 //                   System.out.println("a" + a);

                           b = vector[j];
  //                         System.out.println("b" + b);  
                           
                            num = (a*b);
 //                           System.out.println("num" + num);
                            answer[i] = answer[i] + num;
                      }
                      System.out.println(answer[i]);

         }
                      
         
    }
}




Measured memory_bytes: 40300
#include<stdio.h>
int main()
{
    unsigned long long int a,b,sum;
    while(scanf("%llu %llu",&a,&b)!=EOF)

    {

    int cnt=0;
      sum=a+b;
      while(sum!=0){
        sum=sum/10;
        cnt++;
      }
      printf("%d\n",cnt);
    }
return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc084_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;

  bool ok = true;
  rep(i, A) { ok &= S[i] != '-'; }
  ok &= S[A] == '-';
  repi(i, A + 1, S.size()) {
    ok &= S[i] != '-';
  }

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

Measured memory_bytes: 256
import math
from functools import reduce

K = int(input())

def gcd(*numbers):
    return reduce(math.gcd, numbers)

sum = 0

for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            sum += gcd(a, b, c)

print(sum)

Measured memory_bytes: 69660
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
long long int dp[100020] = {};
int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			int a = 0;
			int b = 0;
			int f[10] = {};
			for (int k = 0; k < s.size(); k++) {
				if ((s[k] - '0' == i)&&(a == 0)) {
					a = 1;
					continue;
				}
				if ((a == 1)&&(b == 0) && (s[k] - '0' == j)) {
					b = 1;
					continue;
				}
				if ((a == 1) && (b == 1)) {
					int g = s[k] - '0';
					if (f[g] == 0) {
						ans++;
						f[g]++;
					}
				}
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll, ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

const int N = 3005;
VL nums;

static bool is_set[N][N];
static ll mem[N][N];
//return X-Y for [left, right)
ll solve(int left, int right) {
  if (left == right) return 0; //no choice
  if (!is_set[left][right]) {
    mem[left][right] = max(
        nums[right-1] - solve(left, right-1)   ,
        nums[left] -    solve(left+1, right));
    is_set[left][right] = true;
  }
  return mem[left][right]; 
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  int n;
  cin >> n;
  nums.resize(n);
  memset(is_set, 0, sizeof(is_set));
  forx(i,n) cin >> nums[i];
  cout << solve(0, n) << nl;
  
  cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl;
  return 0;
}



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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define VEC vector

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				Vint;
typedef vector<Vint>			VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100010


const ll LINF = (ll)9e18+7;		//
const int INF = 100100100;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

// int DP[MAX];



int main(){
	ll A;
	double B;
	cin >> A>>B;
	ll C = B*100+0.5;

	ll ans = (ll)A*C/100;

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



Measured memory_bytes: 3784
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,c;
    cin >> n >> c;
    vector<vector<pair<int, int> > > stc(c);
    REP(i,n){
        int s,t,c;
        cin >> s >> t >> c;
        stc[c-1].pb(make_pair(s,t));
    }
    vector<pair<int, int> > st;
    REP(i,c){
        sort(ALL(stc[i]));
        int s = (int)stc[i].size();
        if(s==0)continue;
        auto now = stc[i][0];
        for(int j = 1;j<s;++j){
            auto next = stc[i][j];
            if(now.se==next.fi){
                now = make_pair(now.fi, next.se);
            }else{
                st.pb(now);
                now = next;
            }
        }
        st.pb(now);
    }
    sort(ALL(st));
    multiset<int> ms;
    for(auto i : st){
        int s = i.fi;
        int t = i.se;
        auto itr = ms.lower_bound(s);
        if(itr==ms.begin()){
            ms.insert(t);
        }else{
            itr--;
            ms.erase(itr);
            ms.insert(t);
        }
    }
    cout << (int)ms.size() << endl;
    return 0;
}

Measured memory_bytes: 2552
#include <stdio.h>
#include <string.h>

int max(int a, int b, int c){
  return (a > b) ? (a > c ? a : c) : (b > c ? b : c);
}


 int main() {
   int a,b;
   scanf("%d %d",&a,&b);
   printf("%d\n",max(a*b,a+b,a-b));
 }


Measured memory_bytes: 128
import java.util.Scanner;

public class Main{

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

        // input
        int num = scan.nextInt();
        
        long sum = 0;
        for(int i = 1; i < num; i++){
            sum += i;
        }

        System.out.println(sum);

    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}


int main(){
	int n;
	cin >> n;
	vector<int> v(n);
	int min=300000;
	int ans=0;
	REP(i,n){
		cin >> v[i];
		if(min>=v[i]){
			ans++;
			min=v[i];
		}
	}
	cout << ans << endl;
}

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

int main(int argc, char **argv)
{
    int n, x;
    std::vector<int> l(n + 2);

    std::cin >> n >> x;
    l[0] = 0;
    l[n + 1] = 999999999;
    for (int i = 1; i <= n; i++) {
        std::cin >> l[i];
        l[i] += l[i - 1];
    }
    for (int i = 0; i <= n + 1; i++)
        if (l[i] > x) {
            std::cout << i << std::endl;
            break;
        }

    return 0;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayLong();
            var N = input[0];
            var M = input[1];
            var cnt = new long[N + 1];
            var bro = new bool[N + 1];
            for (int i = 0; i < M; i++) bro[ReadInt()] = true;
            var mod = (long)Math.Pow(10, 9) + 7;
            if (N == 1)
            {
                Console.WriteLine(1);
                return;
            }
            if (!bro[1]) cnt[1]++;
            if (!bro[2]) cnt[2]++;
            for (int i = 1; i < N - 1; i++)
            {
                if (!bro[i])
                {
                    if (!bro[i + 1])
                    {
                        cnt[i + 1] += cnt[i];
                        cnt[i + 1] %= mod;
                    }
                    if (!bro[i + 2])
                    {
                        cnt[i + 2] += cnt[i];
                        cnt[i + 2] %= mod;
                    }
                }
            }
            if (!bro[N - 1])
            {
                cnt[N] += cnt[N - 1];
                cnt[N] %= mod;
            }

            Console.WriteLine(cnt[N]);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13920
N,K = map(int, input().split())
h = [int(input()) for i in range(N)]
h = sorted(h)

ans = h[K - 1] - h[0]
for i in range(1, N - K + 1):
  if h[i + K - 1] - h[i] < ans:
    ans = h[i + K - 1] - h[i]
print(ans)

Measured memory_bytes: 8280
N = int(input())
B = [int(i) for i in input().split()]

A = []
A.append(B[0])
for i in range(N-1):
  if i == 0:
    A.append(B[i])
  else:
    if A[i] > B[i]:
      del A[-1]
      A.append(B[i])
      A.append(B[i])
    else:
      A.append(B[i])

print(sum(A))

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-13

#define INF 1e16
const int MaxSize = 1e5 + 10;
const LL MOD = 1e9 + 7;
const int AS = 26;

string s, t;

/*
 https://atcoder.jp/contests/abc152/tasks/abc152_e
 E - Flatten
 */
int nl[MaxSize][AS];

void precalc() {
	int curL[26];
	memset(curL, 0, sizeof(curL));

	LP(i, 0, s.size())
	{
		int c = s[i] - 'a';
		LPE(l, curL[c], i)
		{
			nl[l][c] = i + 1;
		}
		curL[c] = i + 1;
	}
}

int main() {

	ios_base::sync_with_stdio(false);
	//freopen("/Users/georgeli/pycp/A_1.in", "r", stdin);
	cin >> s >> t;
	precalc();
	LL ans = 0;
	LL sl = 0;

	LP(i, 0, t.size())
	{
		LL nsl = nl[sl][t[i] - 'a'];
//		cout << t[i] << " " << sl << " " << nsl << endl;

		if (nsl == 0) {
			ans += s.size() - sl;
			sl = 0;

			nsl = nl[sl][t[i] - 'a'];
		}

		if (nsl == 0) {
			cout << -1;
			return 0;
		} else {
			ans += nsl - sl;
			sl = nsl;
		}
	}

	cout << ans;

	return 0;
}



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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

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

const ll mod = 1e9 + 7;


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

    int n;
    cin >> n;
    vi h(n);
    rep(i, n){
        cin >> h[i];
    }

    rep(i, n-1){
        if (h[i] <= h[i+1]-1){
            h[i+1]--;
        }
    }

    rep(i, n-1){
        if(h[i] > h[i+1]){
            if(i < n-1){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}



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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(auto&& i : v) cin >> i;

    sort(all(v));
    if(v[n-1]- v[0] > 1) {
        cout << "No" << endl;
        return 0;
    }

    if(v[n-1] == v[0]) {
        cout << (v[0] == n-1 || n / v[0] >= 2 ? "Yes" : "No") << endl;
        return 0;
    }

    int s = 0, l = 0;
    REP(i, n){
        if(v[i] == v[0]){
            s++;
        }else{
            l++;
        }
    }

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

    if(s + 1 <= v[n-1] && s + l / 2 >= v[n-1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


// #define INT_MAX 2147483647
// #define LL_MAX 9223372036854775807

using namespace std;
#define i64  long long

void solve(void)
{
  int a,b;
  cin>>a>>b;
  cout<<a*b<<" "<<2*(a+b)<<endl;
}
int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include<string>
#include<string.h>
#include <iostream>
#include <algorithm>
#include <cstdlib>
//#include <vector.h>
//#include <malloc.h>

#include <math.h>
using namespace std;
#include<stdlib.h>
#include<stdio.h>

  
int main(){
    int n;
    cin>>n;
    int a[200009];
    long long cnt[200009];
    for(int i=0;i<200002;i++){
        cnt[i]=0;
    }
    for(int i=0;i<n;i++){
        cin>>a[i];
        cnt[a[i]]++;
    }
    long long total=0;
    long long ss=0;
    for(int i=0;i<200002;i++){
        ss=0;
        if(cnt[i]>0)
        ss= (cnt[i]*(cnt[i]-1))/2;
        total+=ss;
    }
    for(int i=0;i<n;i++){
        if(cnt[a[i]]>1){
            cout<<total-cnt[a[i]]+1<<"\n";
        }
        else{
            cout<<total<<"\n";
        }
    }
    return 0;
}


Measured memory_bytes: 4864
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int startB = 0;
		int endA = 0;
		int matchCount = 0;
		int abCount = 0;
		for (int i = 0; i < n; i++) {
			char[] arr = sc.next().toCharArray();
			if (arr[0] == 'B' && arr[arr.length - 1] == 'A') {
				startB++;
				endA++;
				matchCount++;
			} else if (arr[0] == 'B') {
				startB++;
				matchCount++;
			} else if (arr[arr.length - 1] == 'A') {
				endA++;
				matchCount++;
			}
			for (int j = 0; j < arr.length - 1; j++) {
				if (arr[j] == 'A' && arr[j + 1] == 'B') {
					abCount++;
				}
			}
		}
		abCount += Math.min(Math.min(startB, endA), Math.max(matchCount - 1, 0));
		System.out.println(abCount);
	}
}


Measured memory_bytes: 31496
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD =1000000007;

     signed main(){
int n,m;
cin>>n>>m;
string s;
cin>>s;
int x[n+1];
for(int i=0;i<=n;i++)x[i]=i;
int l,r;
for(int i=0;i<m;i++){
    cin>>l>>r;
    x[l]=max(x[l],r);
}
for(int i=0;i<n;i++)x[i+1]=max(x[i],x[i+1]);
map<pair<int,int>,int> mp1,mp2;
mp1[{0,0}]=1;

for(int i=0;i<n;i++){
    int t0=0,t1=0;
    for(int j=x[i];j<x[i+1];j++){
        if(s[j]=='0')t0++;
        else t1++;
    }
    for(auto&& j:mp1){
        pair<int,int>p={j.first.first+t0,j.first.second+t1};
        if(p.first!=0)mp2[{p.first-1,p.second}]=(mp2[{p.first-1,p.second}]+j.second)%MOD;
        if(p.second!=0)mp2[{p.first,p.second-1}]=(mp2[{p.first,p.second-1}]+j.second)%MOD;
    }
    swap(mp1,mp2);
    mp2.clear();
   
}
  
cout<<mp1[{0,0}]<<endl;

     }


 


 






    





      

        


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

using namespace std;

const int inf = (int)1e9+7;
const int N = 500005;
const int M = 20 * 5 * 100000;

int cnt[M], l[M], r[M];
int g[27][N];


struct Task {
	int n, q;
	string s;
	vector<vector<pair<int,int>>> que;
	vector<int> result;
	vector<int> good;
	int cur = 0;

	Task() {
		cur = 0;
		memset(cnt, 0, sizeof cnt);
		memset(l, 0, sizeof l);
		memset(r, 0, sizeof r);
		cin >> s;
		n = (int)s.size();
		good.resize(n + 1);
		good[n] = cur++;
		que.resize(n);
		for (int i = 0; i < 27; ++i) {
			g[i][n] = -1;
		}
		cin >> q;
		for (int i = 0; i < q; ++i) {
			int l, r;
			cin >> l >> r;
			--l; --r;
			que[l].emplace_back(r, i);
		}
		result.assign(q, 0);
	}

	void run() {
		for (int i = n - 1; i >= 0; --i) {
			int c = s[i] - 'a';
			for (int j = 0; j < 27; ++j) {
				g[j][i] = -1;
			}
			g[c][i] = i;
			for (int j = c + 1; j < 27; ++j) {
				int pos = g[j - 1][i];
				if (pos == -1) {
					break;
				}
				if (g[j - 1][pos + 1] == -1) {
					break;
				} 
				g[j][i] = g[j - 1][pos + 1];
			}
			int pos = g[26][i];
			if (pos != -1) {
				for (int j = 0; j < c; ++j) {
					g[j][i] = g[j][pos+1];
				}
				good[i] = inc(good[pos+1], 0, n, pos, 1);
			}
			for (auto& query : que[i]) {
				int r = query.first;
				int id = query.second;
				result[id] = go(good[i], 0, n, r);
			}
		}
		for (auto& r : result) {
			cout << (r ? "Yes" : "No") << '\n';
		}
	}

	int inc(int v, int tl, int tr, int pos, int val) {
	      int nv = cur++;

	      if (tl == tr) {
	              l[nv] = r[nv] = 0;
	              cnt[nv] = cnt[v]+1;
	              return nv;
	      }
	      int tm = (tl + tr) / 2;

	      if (pos <= tm) {
	              l[nv] = inc(l[v], tl, tm, pos, val);
	              r[nv] = r[v];
	      } else {
	              l[nv] = l[v];
	              r[nv] = inc(r[v], tm+1, tr, pos, val);
	      }

	      cnt[nv] = cnt[l[nv]] + cnt[r[nv]];
	      return nv;
	}

	int go(int t, int tl, int tr, int element) {
	      if (tl == tr) {
	             return cnt[t];
	      }
	      int tm = (tl + tr) / 2;
	      if (element <= tm) {
	              return go(l[t], tl, tm, element);
	      } else {
	              return go(r[t], tm+1, tr, element);
	      }
	}

};

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

	Task a;
	a.run();

	return 0;
}

Measured memory_bytes: 187932
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 998244353
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1LL<<59

ll col(char c){
    if(c=='B') return 0;
    else if(c=='R') return 1;
    else return 2;
}

int main(){
    ll i,j;
    ll n;
    cin>>n;
    string s;
    cin>>s;
    VI cnt(3,0);

    ll ma=0,mi=0;
    ll ans=1;
    for(i=0;i<s.size();i++){
        cnt[col(s[i])]++;
        ll x=cnt[col(s[i])];
        vector<ll> v;
        for(j=0;j<3;j++){
            if(j!=col(s[i])) v.pb(cnt[j]);
        }
        if(v[0]==0||v[1]==0) {
            if(x<=max(v[0],v[1])){
                ans*=(max(v[0],v[1])+1-x);
            }
        }
        else {
            ans*=min(v[0],v[1]);
            for(j=0;j<3;j++){
                 cnt[j]--;
            }
        }
        ans%=Mod;
    }

    for(i=1;i<=n;i++) ans=(ans*i)%Mod;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define fgx cerr<<" --------------------------------------- "<<endl
#define LL long long
#define DB double
#define LDB long double	 
using namespace std;
namespace IO{
	const int BS=(1<<23)+5; int Top=0;
	char Buffer[BS],OT[BS],*OS=OT,*HD,*TL,SS[20]; const char *fin=OT+BS-1;
	char Getchar(){if(HD==TL){TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);} return (HD==TL)?EOF:*HD++;}
	void flush(){fwrite(OT,1,OS-OT,stdout),OS=OT;}
	void Putchar(char c){*OS++ =c;if(OS==fin)flush();}
	void write(int x){
		if(!x){Putchar('0');return;} if(x<0) x=-x,Putchar('-');
		while(x) SS[++Top]=x%10,x/=10;
		while(Top) Putchar(SS[Top]+'0'),--Top;
	}
	inline LL read(){
		LL nm=0; bool fh=true; char cw=getchar();
		for(;!isdigit(cw);cw=getchar()) fh^=(cw=='-');
		for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
		return fh?nm:-nm;
	}
}using namespace IO;

int main(){
	LL S=read();
	LL sq=ceil(sqrtl(S));
	LL xa,xb,ya,yb;
	LL rem=sq*sq-S;
	xa=yb=sq,ya=rem,xb=1;
	printf("0 0 %lld %lld %lld %lld\n",xa,ya,xb,yb);
	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 PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
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=1e15;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,t;
	cin>>n>>t;
	vector<Pi> g(n);
	rep(i,n) cin>>g[i].fi>>g[i].se;
	sort(begin(g),end(g));
	vector<int> a(n),b(n);
	rep(i,n){
		a[i]=g[i].fi;
		b[i]=g[i].se;
	}
	vector<vector<int>> dp(n+1,vector<int>(t+1,0));
	rep(i,n)rep(j,t+1){
		chmax(dp[i+1][j],dp[i][j]);
		if(j-a[i]>=0){
			chmax(dp[i+1][j],dp[i][j-a[i]]+b[i]);
		}
	}
	int ans=0;
	//cout<<dp<<endl;
	FOR(i,1,n){
		chmax(ans,dp[i][t-1]+b[i]);
	}
	cout<<ans<<endl;
}

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

int main() {
  int N;
  string C;
  cin >> N;
  bool Y = false;
  for (int i = 0; i < N; i++) {
    cin >> C;
    if (C == "Y") Y = true;
  }
  if (Y) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <stack>
#define FOR(arg, ini, end) for(int arg = ini; arg < end; arg++)


using namespace std;

int main(int argc, const char * argv[]) {
    
    string s; cin >> s;

    long sum=0;
    FOR(i, 0, 1<<(s.size()-1) ){
        long st=0;
        string t = s.substr(0,1);
        FOR(j,0,s.size()-1){
            if (i&(1<<j)) {
                // cout << t << "+";
                st += stol(t);
                t= s.substr(j+1, 1);
            }
            else {
                t += s[j+1];
            }
        }
        st += stol(t);
        // cout << t << "=" <<st<<endl;
        sum+=st;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define y1 klfjvkldfngldf

#pragma comment(linker, "/STACK:400000000")

#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <complex>
#include <functional>
#include <numeric>
#include <random>
#include <memory.h>
#include <time.h>

using namespace std;

typedef long long LL;

const int N = 100000;

vector<int> G[N];
int color[N];

int go(int x, int c)
{
	int res = 0;
	color[x] = c;
	for (int i = 0; i < G[x].size(); ++i)
	{
		int to = G[x][i];
		if (color[to] == -1)
			res |= go(to, c ^ 1);
		if (color[to] == color[x])
			res = 1;
	}
	return res;
}

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		int u, v;
		cin >> u >> v;
		u--, v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}

	fill(color, color + n, -1);

	int even = 0;
	int odd = 0;
	int alone = 0;
	for (int i = 0; i < n; ++i)
	{
		if (color[i] != -1)
			continue;
		if (go(i, 0))
			odd++;
		else
		{
			if (G[i].size() == 0)
				alone++;
			else
				even++;
		}
	}
	LL res = (LL)alone * alone + (LL)2 * alone * (n - alone);
	res += (LL)2 * even * even;
	res += (LL)odd * odd;
	res += (LL)2 * even * odd;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 11776
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll K; cin >> K;
    ll rem=7%K;
    for (int i=1; i<1e6; ++i)
    {
        if (rem==0) {
            cout << i << "\n";
            return 0;
        }
        rem=(rem*10+7)%K;
    }
    cout << -1 << "\n";
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    intl a[n];
    cin(i,a);
    intl cnt = n;
    rep(i,n) m -= a[i];
    sort(a,a + n);
    cnt += (m / a[0]);
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

const lim = 2e5 + 10

func rb() []byte {
	sc.Scan()
	return sc.Bytes()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, lim), lim)
	s := rb()

	ctW := 0
	for _, ss := range s {
		if ss == 'W' {
			ctW++
		}
	}

	bIdx := 0
	for i := 0; i < ctW; i++ {
		if s[i] == 'B' {
			bIdx += i
		}
	}
	wIdx := 0
	for i := ctW; i < len(s); i++ {
		if s[i] == 'W' {
			wIdx += i
		}
	}

	fmt.Println(wIdx - bIdx)
}


Measured memory_bytes: 768
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 N,X,Y;
    cin >> N >> X;

    int64 ans=X + N-X; //平行四辺形から始める
    Y=N-X;
    while(X!=0){
        if(X>Y) swap(X,Y);
        // debug(mp(X,Y))
        ans += (Y/X)*2*X;
        auto tmp = X;
        X = Y - X * (Y/X);
        Y = tmp;
        // debug(ans)
    }
    ans -= Y;
    cout << ans << endl;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i * 500 + j * 100 + k * 50 == X:
                ans += 1
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair <long long,long long> ii;
// typedef complex<long double> point;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n;
	cin >> n;
	string s;
	cin >> s;
	char prev = s[0];
	ll ans = 1;
	for (int z=1;z<n;z++){
		if (s[z] == prev) continue;
		prev = s[z];
		ans++;
	}
	cout << ans << endl;
}



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

using namespace std;

#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define dump(x) cerr << "~ " << #x << " = " << x << endl


int main() {

	fast_cin;
	
	long long n,m,ans;

	cin >> n >> m;

	if(n == 1 or m == 1) {
		cout << 1 << endl;
		return 0;
	}

	ans = ((n*m)+1) / 2;

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

Measured memory_bytes: 256
#include<iostream>
const int MAXN = 10005;
const int NIL = -1;
using namespace std;
struct Node{int l, r, p;};  
struct Node T[MAXN]; 

void preoder(int u)
{
	if(u == NIL) return;
	cout << " " << u;
	preoder(T[u].l);
	preoder(T[u].r); 
}

void inorder(int u)
{
	if(u == NIL) return;
	inorder(T[u].l);
	cout << " " << u;
	inorder(T[u].r); 
}

void postorder(int u)
{
	if(u == NIL) return;
	postorder(T[u].l);
	postorder(T[u].r);
	cout << " " << u; 
}

int main ()
{
	int n, l, r, root, u, i;
	cin >> n;
	for(i = 0; i < n; i++)
	{
		T[i].l = T[i].r = T[i].p = NIL;
	}
	for(i = 0; i < n; i++)
	{
		cin >> u >> l >> r;
		T[u].l = l;
		T[u].r = r;
		if(l != NIL) T[l].p = u;
		if(r != NIL) T[r].p = u; 
	}
	for(i = 0; i < n; i++)
	{
		if(T[i].p == NIL) 
			root = i;
	}

	cout << "Preorder"<< endl;
	preoder(root);
	cout << endl;
	cout << "Inorder" << endl;
	inorder(root);
	cout << endl;
	cout << "Postorder" << endl;
	postorder(root);
	cout << endl;	
	return 0;
} 


Measured memory_bytes: 3100
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

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){
		if(fabs((yA-yB)*(yC-yD) + (xA-xB)*(xC-xD)) < 1e-10)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}
	

Measured memory_bytes: 612
#include<stdio.h>
int main(){
    double pai=3.141592653589;
    int n,m,t;
    scanf("%d %d",&n,&m);
    int a[n][m], b[m], ans[n];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
       }
    }
    for(int i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
    for(int i=0;i<n;i++){
        t=0;
        for(int j=0;j<m;j++){
            t+=(a[i][j]*b[j]);
        }
        ans[i]=t;
    }
    for(int i=0;i<n;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}



Measured memory_bytes: 2108
s = list(map(lambda x: ord(x),list(input())))
t = list(map(lambda x: ord(x),list(input())))
s.sort()
t.sort(reverse=True)
p = len(s)
q = len(t)

for i in range(min(p,q)):
    if s[i] > t[i]:
        print("No")
        exit()
    elif s[i] < t[i]:
        print("Yes")
        exit()

if p >= q:
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main()
{
    int n,count=0;
    cin>>n;
    long long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    long long int ans=1;
    for(int i=n-2;i>=0;i--)
    {
        if(a[i]==a[i+1])
        {
            ans*=a[i];
            i--;
            count++;
        }
        if(count==2)
            break;
    }
    if (count==2)
        cout<<ans;
    else
        cout <<0;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
    int N;
    int W[100];
    int i;
    int T;
    int S1;
    int S2;
    int diff;
    int min;

    scanf("%d", &N);

    min = 0;
    for(i = 0; i < N; i++) {
        scanf("%d", &W[i]);
        min += W[i];
    }

    for(T = 0; T <= N; T++) {
        S1 = 0;
        for(i = 0; i <= T; i++) {
            S1 += W[i];
        }
        S2 = 0;
        for(; i < N; i++) {
            S2 += W[i];
        }
        diff = S1 - S2;
        if(diff < 0) {
            diff *= -1;
        }
        if(diff < min) {
            min = diff;
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	ll a, b, c;
	cin >> a >> b >> c;
	ll x = c - a - b;
	if (x > 0 && x * x > 4 * a * b) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u)
{
  for (int v = nt[u]; v < n; v++)
  {
    nt[u] = v + 1;
    if (M[u][v])
    {
      return v;
    }
  }
  return -1;
}

void dfs_visit(int r)
{
  for (int i = 0; i < n; i++)
  {
    nt[i] = 0;
  }

  stack<int> S;
  S.push(r);
  color[r] = GRAY;
  d[r] = ++tt;

  while (!S.empty())
  {
    int u = S.top();
    int v = next(u);
    if (v != -1)
    {
      if (color[v] == WHITE)
      {
        color[v] = GRAY;
        d[v] = ++tt;
        S.push(v);
      }
    }
    else
    {
      S.pop();
      color[u] = BLACK;
      f[u] = ++tt;
    }
  }
}

void dfs()
{
  for (int i = 0; i < n; i++)
  {
    color[i] = WHITE;
    nt[i] = 0;
  }
  tt = 0;

  for (int u = 0; u < n; u++)
  {
    if (color[u] == WHITE)
      dfs_visit(u);
  }

  for (int i = 0; i < n; i++)
  {
    cout << i + 1 << " " << d[i] << " " << f[i] << endl;
  }
}

int main()
{
  int u, k, v;

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

  for (int i = 0; i < n; i++)
  {
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j++)
    {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}


Measured memory_bytes: 3132
N = int(input())
A = list(map(int,input().split()))
B = [0] * N # 踏み台の高さ
ans = 0
h = 0
for i in range(1,N):
    if A[i] < A[i-1]+B[i-1]:
        h = B[i-1]+A[i-1] - A[i]
    else:
        h = 0
    B[i] = h

for i in range(N):
    ans += B[i]

# print(B)
print(ans)
# 一個前しか見てない

Measured memory_bytes: 32208
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;

int a[100010]; 

int main() {
	int n;
	cin >> n;
	rep(i,n) cin >> a[i];
	sort(a,a+n);
	int ans = 1;
	ll sum = 0;
	rep(i,n-1) {
		sum += a[i];
		if (sum *2 >= a[i+1]) ans++;
		else ans = 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char arr[100],a='a';
int main()
{
    ll n;
    for(int i=0;i<26;i++)
{
    arr[i]=a;
    a++;
}
    cin>>n;
    string ans="";
    while(n>0)
    {
        n-=1;
        ans+=arr[n%26];
        n=n/26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}

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

namespace CompetitiveProgramming
{
    class Program
    {
        static void Main(string[] args)
        {
            string d = Console.ReadLine();

            switch(d)
            {
                case "25":
                    Console.WriteLine("Christmas");
                    break;
                case "24":
                    Console.WriteLine("Christmas Eve");
                    break;
                case "23":
                    Console.WriteLine("Christmas Eve Eve");
                    break;
                case "22":
                    Console.WriteLine("Christmas Eve Eve Eve");
                    break;
                default:
                    break;
            }

        }

    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

int main(){
  int N, K; ll S; cin >> N >> K >> S;
  if(S==1e9){
    rep(i, K){
      cout << S;
      cout << " ";
    }
    rep(i, N-K){
      cout << S-1;
      if(i!=N-K-1) cout << " ";
    }
    cout << endl;
    return 0;
  }
  rep(i, K){
    cout << S;
    cout << " ";
  }
  rep(i, N-K){
    cout << S+1;
    if(i!=N-K-1) cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1280
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = scanInt()
	}
	sort.Ints(A)
	A = append(A, 0)

	ans := 0
	tmp := 1
	for i := 1; i <= N; i++ {
		if A[i] == A[i-1] {
			tmp++
		} else {
			if tmp%2 == 1 {
				ans++
			}
			tmp = 1
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5224
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C = MAP()

if A == B and A != C:
    print('Yes')
elif A == C and A != B:
    print('Yes')
elif B == C and B != A:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5584
use std::fmt::Debug;
use std::io;
use std::io::{Read, Stdin};
use std::str;
use std::str::FromStr;
use std::usize;
use std::cmp;
use std::collections::vec_deque::VecDeque;
use std::i64::MAX;
use std::collections::HashSet;

fn main() {
    let mut sc = Scanner::new();

    let n = sc.parse::<usize>();
    let mut v = vec![0;n];
    for i in (0..n) {
        v[i] = sc.parse::<i32>();
    }
    v.sort();

    let mut kuso = 0;
    let mut set = HashSet::new();
    for a in &v {
        if a < &400 {
            set.insert(400);
        } else if a < &800 {
            set.insert(800);
        } else if a < &1200 {
            set.insert(1200);
        } else if a < &1600 {
            set.insert(1600);
        } else if a < &2000 {
            set.insert(2000);
        } else if a < &2400 {
            set.insert(2400);
        } else if a < &2800 {
            set.insert(2800);
        } else if a < &3200 {
            set.insert(3200);
        } else {
            kuso += 1;
        }
    }

    let min = cmp::max(set.len(), 1);
    let max = set.len() + kuso;

    println!("{} {}", min, max);

}

struct Scanner {
    stdin: Stdin,
    buf: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            buf: Vec::with_capacity(256),
        }
    }

    fn parse<T: FromStr>(&mut self) -> T
        where <T as FromStr>::Err: Debug
    {
        self.buf.clear();
        let mut it = self.stdin.lock().bytes();
        let mut c = it.next().unwrap().unwrap();
        while c == ' ' as u8 || c == '\n' as u8 {
            c = it.next().unwrap().unwrap();
        }
        while !(c == ' ' as u8 || c == '\n' as u8) {
            self.buf.push(c);
            c = it.next().unwrap().unwrap();
        }
        str::from_utf8(&self.buf).unwrap().parse::<T>().unwrap()
    }
}

Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int R, G, B, N;

int main() {
    cin >> R >> G >> B >> N;

    int ans = 0;
    for (int r = 0; r <= N / R; r++) {
        for (int g = 0; g <= N / G; g++) {
            if ((N - R * r - G * g) % B != 0) continue;
            if ((N - R * r - G * g) < 0) continue;
            ans++;
        }
    }

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


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

int main(){
  int a,b;
  cin >> a >> b;
  int out = 0;
  if(a == 1) out += 300000;
  if(b == 1) out += 300000;
  if(a == 2) out += 200000;
  if(b == 2) out += 200000;
  if(a == 3) out += 100000;
  if(b == 3) out += 100000;
  if(a == 1 & b == 1) out += 400000;
  cout << out;
}

Measured memory_bytes: 256