akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
} 

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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b, x;
  cin >> a >> b >> x;
  if (a <= x && a + b >= x) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
  return 0;
}

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

vector<ll> b;
bool del[501000] = {};
ll a[1010];
int cnt[100];

int main(){
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      b.push_back(a[j] - a[i - 1]);
      ll tmp = b[b.size() - 1];
      int kk = 0;
      while (tmp > 0) {
        if (tmp & 1) {
          cnt[kk]++;
        }
        kk++;
        tmp >>= 1;
      }
    }
  }

  ll ans = 0;
  for (int i = 50; i >= 0; i--) {
    if (cnt[i] >= k) {
      ans += (1LL << (ll)i);
      for (ll j = 0; j < b.size(); j++) {
        if (del[j]) continue;
        if (((b[j] >> i) & 1) == 0) {
          del[j] = true;
          ll tmp = b[j];
          int kk = 0;
          while (tmp > 0) {
            cnt[kk] -= (tmp & 1);
            kk++;
            tmp >>= 1;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6128
X=int(input())
def dp(N,seq):
    if N!=0:
        if min(seq.count("3"),seq.count("5"),seq.count("7"))!=0:
            if int(seq)<=X:
                p.append(seq)
    if N<10:
        dp(N+1,seq+"3")
        dp(N+1,seq+"5")
        dp(N+1,seq+"7")
p=[]
dp(0,"")
print(len(p))

Measured memory_bytes: 4988
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
template <typename Int, Int MOD, int N>
struct comb_util {
	std::array<Int, N + 1> fc, ifc;

	comb_util() {
		fc[0] = 1;
		for (int i = 1; i <= N; i++) fc[i] = fc[i - 1] * i % MOD;
		ifc[N] = inv(fc[N]);
		for (int i = N - 1; i >= 0; i--) ifc[i] = ifc[i + 1] * (i + 1) % MOD;
	}

	Int fact(Int n) { return fc[n]; }

	Int inv_fact(Int n) { return ifc[n]; }

	Int inv(Int n) { return pow(n, MOD - 2); }

	Int pow(Int n, Int a) {
		Int res = 1, exp = n;
		for (; a; a /= 2) {
			if (a & 1) res = res * exp % MOD;
			exp = exp * exp % MOD;
		}
		return res;
	}

	Int perm(Int n, Int r) {
		if (r < 0 || n < r)
			return 0;
		else
			return fc[n] * ifc[n - r] % MOD;
	}

	Int binom(Int n, Int r) {
		if (n < 0 || r < 0 || n < r) return 0;
		return fc[n] * ifc[r] % MOD * ifc[n - r] % MOD;
	}

	Int homo(Int n, Int r) {
		if (n < 0 || r < 0) return 0;
		return r == 0 ? 1 : binom(n + r - 1, r);
	}
};

using comb = comb_util<long long, 1000000007, 300000>;
comb cb;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, A, B, C;
	cin >> N >> A >> B >> C;

	int AA = A * cb.inv(100) % MOD;
	int BB = B * cb.inv(100) % MOD;
	int CC = C * cb.inv(100) % MOD;

	int res = 0;
	int inv = cb.inv((MOD + 1 - CC) % MOD);
	//cerr << inv << endl;

	for (int xx = 0; xx < 2; xx++) {
		for (int i = 0; i <= N - 1; i++) {
			int num = N - 1 + i;
			int t = (cb.pow(AA, N - 1) * cb.pow(BB, i)) % MOD;
			t = (t * cb.binom(num, i)) % MOD;
			t = (t * AA) % MOD;
			t = (t * (num + 1)) % MOD;
			t = (t * cb.pow(inv, num + 2)) % MOD;
			res = (res + t) % MOD;
		}
		swap(AA, BB);
	}


	cout << res << endl;
}

Measured memory_bytes: 4992
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<ll> a;
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    ll now=0;
    a.push_back(0);
    ll count=1;
    ll sum = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i]=='>'){
            now--;
            count++;
        }
        else{
            if(count!=1&&now<0){
                sum+=-now*count;
                count=1;
                now=0;
            }
            else if(count!=1){
                sum-=now*(count-1);
                now=0;
                count=1;
            }
            now++;
        }
        a.push_back(now);
        //cout<<sum<<" "<<i<<"\n";
    }
    if(count!=1&&now<0){
        sum += -now * count;
        count = 1;
    }
    else if(count!=1){
        sum -= now*(count - 1);
        now = 0;
        count = 1;
    }
    //ll mina=INF;
    for(int i=1;i<a.size();i++){
        sum+=a[i];
    }
    //debug(a);
    cout << sum << "\n";
}


Measured memory_bytes: 7316
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll mod = 1000000007;

ll memo[4][4][4][101];

bool ok(string s){
    if(s[0] == 'A' && s[1] == 'G' && s[2] == 'C'){
        return false;
    }
    if(s[0] == 'A' && s[1] == 'C' && s[2] == 'G'){
        return false;
    }
    if(s[0] == 'G' && s[1] == 'A' && s[2] == 'C'){
        return false;
    }
    if(s[1] == 'A' && s[2] == 'G' && s[3] == 'C'){
        return false;
    }
    if(s[1] == 'A' && s[2] == 'C' && s[3] == 'G'){
        return false;
    }
    if(s[1] == 'G' && s[2] == 'A' && s[3] == 'C'){
        return false;
    }
    if(s[0] == 'A' && s[2] == 'G' && s[3] == 'C'){
        return false;
    }
    if(s[0] == 'A' && s[1] == 'G' && s[3] == 'C'){
        return false;
    }
    return true;
}
ll c[128];

ll n;
string aa = "AGCT";
ll dfs(string s,ll x){
    ll count = 0;

    if( memo[c[s[0]]][c[s[1]]][c[s[2]]][x] != -1 ){
        return memo[c[s[0]]][c[s[1]]][c[s[2]]][x]%mod;
    }
    
    if(x == 1){
        for (int i = 0; i < 4; i++) {
            if( ok(s + aa[i]) ){
                count++;
            }
        }
        count %= mod;
        return memo[c[s[0]]][c[s[1]]][c[s[2]]][x] = count;
    }else{
        for (int i = 0; i < 4; i++) {
            string next_s = "";
            
            next_s += s[1];
            next_s += s[2];
            next_s += aa[i];
            if( ok( s + aa[i]) ){
                count += dfs( next_s, x-1) % mod;
            }
            count %= mod;
        }
        count %= mod;
        return memo[c[s[0]]][c[s[1]]][c[s[2]]][x] = count;
    }
}

int main() {
    Fill(memo,-1);
    
    c['A'] = 0;
    c['T'] = 1;
    c['G'] = 2;
    c['C'] = 3;
    
    std::cin >> n;
    
    std::cout << dfs("TTT",n)%mod << std::endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>

#include <iomanip>

using std::cin;
using std::cout;
using std::endl;

using std::setprecision;

int
main()
{
  int L;
  cin >> L;
  double l = double(L) / 3;
  cout << std::showpoint << setprecision(10) << l * l * l << endl;
  return 0;
}


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

int main(){
    int64_t X, K, D;
    cin >> X >> K >> D;
    if(X == 0){
        if(K % 2 == 0) cout << 0 << endl;
        else cout << D << endl;
    }
    else{
        if(X < 0) X = -X;
        if(X / K < D){
            int64_t shou = X / D;
            X -= shou * D;
            K -= shou;
            if(K % 2 == 0) cout << X << endl;
            else cout << D - X << endl;
        }
        else{
            cout << X - K * D << endl;
        }
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>

#define INF 1010001000

using namespace std;

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

    vector<vector<int> > tree(n);

    for (int i = 0; i < n-1; i++) {
        cin >> a >> b;
        tree[--a].push_back(--b);
        tree[b].push_back(a);
    }

    vector<int> data(n, INF);
    priority_queue<pair<int, int> > priQue;

    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
        cin >> a >> b;
        data[--a] = b;
        priQue.push(pair<int, int>(b, a));
    }

    while (!priQue.empty()) {
        pair<int, int> p = priQue.top();
        priQue.pop();
        for (int i = 0; i < tree[p.second].size(); i++) {
            if (data[tree[p.second][i]] == INF) {
                data[tree[p.second][i]] = data[p.second] - 1;
                priQue.push(pair<int, int>(data[tree[p.second][i]], 
                            tree[p.second][i]));
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < tree[i].size(); j++) {
            if (abs(data[i] - data[tree[i][j]]) != 1) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    for (int i = 0; i < n; i++) {
        cout << data[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 7924
num, bricks, count, smash = int(input()), [int(x) for x in input().split(" ")], 1, 0
for x in bricks:
    if count == x: count += 1
    else: smash += 1
print(smash if smash != len(bricks) else 0 if len(bricks) == 1 else -1)

Measured memory_bytes: 24744
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int size = Integer.parseInt(scanner.next());
        Value[] arrayForBubble = new Value[size];
        Value[] arrayForSelection = new Value[size];
        for (int i = 0; i < size; i++) {
            Value value = new Value(scanner.next());
            arrayForBubble[i] = value;
            arrayForSelection[i] = value;
        }

        bubbleSort(arrayForBubble);
        System.out.println(concat(arrayForBubble));
        System.out.println("Stable");
        selectionSort(arrayForSelection);
        System.out.println(concat(arrayForSelection));
        System.out.println(same(arrayForBubble, arrayForSelection) ? "Stable"
                : "Not stable");
    }

    private static boolean same(Value[] array1, Value[] array2) {
        for (int i = 0; i < array1.length; i++) {
            if (array1[i].character != array2[i].character) {
                return false;
            }
        }
        return true;
    }

    private static void bubbleSort(Value[] values) {
        boolean flag = true;
        while (flag) {
            flag = false;
            for (int j = values.length - 1; j > 0; j--) {
                if (values[j].number < values[j - 1].number) {
                    swap(j, j - 1, values);
                    flag = true;
                }
            }
        }
    }

    private static void selectionSort(Value[] values) {
        for (int i = 0; i < values.length; i++) {
            int mini = i;
            for (int j = i; j < values.length; j++) {
                if (values[j].number < values[mini].number) {
                    mini = j;
                }
            }
            if (i != mini) {
                swap(i, mini, values);
            }
        }
    }

    private static String concat(Value[] array) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Value value : array) {
            joiner.add(value.toString());
        }
        return joiner.toString();
    }

    private static void swap(int i, int j, Value[] array) {
        Value temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }

    private static class Value {
        char character;
        int number;

        Value(String value) {
            character = value.charAt(0);
            number = Integer.parseInt(String.valueOf(value.charAt(1)));
        }

        @Override
        public String toString() {
            return character + String.valueOf(number);
        }
    }
}

Measured memory_bytes: 26256
import numpy as np
N, C = map(int, input().split())
X,V = [],[]
for _ in range(N):
    x,v = map(int, input().split())
    X.append(x)
    V.append(v)

r1,r2,l1,l2 = [0],[0],[0],[0]
sum = 0
#原点から時計回りに行ってくる、行って戻ってくるパターン。前の奴と比較して、それより小さかったら無視
for i in range(N):
    sum += V[i]
    #print(r1, r2)
    r1.append(max(r1[i], sum-X[i]))
    r2.append(max(r2[i], sum-2*X[i]))
sum = 0
for i in range(N,0,-1):
    #print('hogehoge',i,V[i-1],X[i-1])
    sum += V[i-1]
    #print(l1, l2)
    l1.append(max(l1[-1], sum-(C-X[i-1])))
    l2.append(max(l2[-1], sum-2*(C-X[i-1])))
#print(l1, l2)
a = max(np.array(r1) + np.array(l2)[::-1])
b = max(np.array(r2) + np.array(l1)[::-1])
print(max(a,b))


Measured memory_bytes: 34964
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in);) {
			
			while(true) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				
				if(x == 0 && y == 0) break;
				
				if(x < y) {
					System.out.println(x + " " + y);
				} else {
					System.out.println(y + " " + x);
				}
			}
		}
	}
}


Measured memory_bytes: 36288
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif


#ifdef L_JUDGE
#pragma warning(disable:4996)
#endif

using namespace std;

template <typename T>
inline bool read(T& ret) {
    T x = 0, f = 1; char ch = getchar();
    while(ch!=EOF && (ch > '9' || ch < '0')) { if(ch == '-') f = -1; ch = getchar();  }
    if(EOF==ch)return false;
    do x = x * 10 + ch - 48, ch = getchar(); while(ch >= '0' && ch <= '9');
    ret = x * f;
    return true;
}


inline char nc() {
    static char buf[100000], *p1 = buf, *p2 = buf;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;
}
template <typename T>
bool rn(T& v) {
    static char ch;
    while (ch != EOF && !isdigit(ch)) ch = nc();
    if (ch == EOF) return false;
    for (v = 0; isdigit(ch); ch = nc())
        v = v * 10 + ch - '0';
    return true;
}

template <typename T>
void o(T p) {
    static int stk[70], tp;
    if (p == 0) { putchar('0'); return; }
    if (p < 0) { p = -p; putchar('-'); }
    while (p) stk[++tp] = p % 10, p /= 10;
    while (tp) putchar(stk[tp--] + '0');
}


LL bin(LL x, LL n, LL MOD) {
    LL ret = MOD != 1;
    for (x %= MOD; n; n >>= 1, x = x * x % MOD)
        if (n & 1) ret = ret * x % MOD;
    return ret;
}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }



void Solve(){
}


int main(){
#ifdef L_JUDGE
    freopen("in1.txt","r",stdin);
    //		freopen("out.txt","w",stdout);
#endif
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    string S,T;
    while(cin>>S>>T){
        int ns=S.size();
        int nt=T.size();
        int ans=1e9;
        for(int si=0;si+nt<=ns;si++){
            int tmp=0;
            for(int j=0;j<nt;j++){
                if(S[si+j]!=T[j]){
                    tmp++;
                }
            }
            ans = min(tmp, ans);
        }
        cout<<ans<<endl;
    }
    return 0;

#ifdef L_JUDGE
    fclose(stdin);
    fclose(stdout);
    //		system("out.txt");
#endif

	return 0;
}


Measured memory_bytes: 3200
import itertools
import math

N = int(input())
n1 = math.factorial(N)
athen = N - 1
henall =  n1 // (math.factorial(N - 2) * math.factorial(2))
#print(henall)

P = []
for i in range(N):
    P.append([int(j) for j in input().split()])
con1 = itertools.combinations(P, 2)

L = []
for j, k in con1:
    l = ((j[0]-k[0])**2 + (j[1]-k[1])**2)**0.5
    L.append(l)
#print(L)

times = (n1 * athen) // henall
#print(times)

aver = (sum(L) * times) / n1
print(aver)

Measured memory_bytes: 3064
def LI(): return list(map(int, input().split()))
def I(): return map(int, input().split())
mod = 10**9 + 7

def main():
  n, x, t = I()
  if n % x == 0:
    print((n//x)*t)
  else:
    print(((n//x) + 1)*t)
if __name__ == '__main__':
  main()

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
const int md = 1e9 + 7;
inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  const int BSM = (1 << n);
  vector<int> dp(BSM, 0);
  dp[0] = 1;
  stack<int> stk;
  for (int bs = 0; bs < BSM; bs++) {
    int j = 0;
    for (int i = 0; i < n; i++) {
      if (bs & (1 << i)) {
        stk.push(i);
        j++;
      }
    }
    j--;
    while (!stk.empty()) {
      int i = stk.top();
      stk.pop();
      if (a[i][j]) {
        add(dp[bs], dp[bs - (1 << i)]);
      }
    }
  }
  cout << dp[BSM - 1] << '\n';
  return 0;
}

Measured memory_bytes: 8448
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>

void swap(int * a, int * b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

void print_int(int n)
{
    printf("%d\n",n);
    
}

void sort(int a[], int n)
{
    int h, i, j;

    for(h = 1; h < n / 9; h = h * 3 + 1)
        continue;

    for(; h > 0; h /= 3)
    {
        for(i = h; i < n; i++)
        {
            j = i;
            while(j >= h && a[j] < a[j-h])
            {
                swap(&a[j], &a[j-h]);
                j -= h;
            }
        }
    }
}

void print_list(int a[], int n)
{
    for(int i = 0; i < n; i++)
    {
        printf("%d ", a[i]);
    }
}

void intcpy(int a[], const int b[], int count)
{
    for(int i = 0; i < count; i++)
    {
        a[i] = b[i];
    }
}

int list_sum(int a[], int n)
{
    int sum = 0;

    for(int i = 0; i < n; i++)
    {
        sum += a[i];
    }

    return sum;
}


void permutate(int s[], int count, int n)
{
    if(n == count)
        return;

    for(int i = n; i < count; i++)
    {
        swap(&s[i], &s[n]);

        if(i != n)
        {
            //intcpy(result[j++], s, count);
        }
        
        permutate(s, count, n+1);
        swap(&s[i], &s[n]);
    }
}



int main(void)
{
    int a,b,ans;
    scanf("%d %d", &a, &b);
    if(a >= 13)
    {
        ans = b;
    }
    else if(a >= 6)
    {
        ans = b /2;
    }
    else
    {
        ans = 0;
    }
    printf("%d", ans);
    
    
 
    return 0;
}



Measured memory_bytes: 128
using System;
using System.Drawing;
using System.Linq;
using System.Text.RegularExpressions;
using System.Text;


namespace aizu
{
	public class EntryPoint
	{
		public static int[] SplitToInt(string line)
		{
			return Regex.Split(line, " ").Select(x => int.Parse(x)).ToArray();
		}
		public static double[] SplitToDouble(string line)
		{
			return Regex.Split(line, " ").Select(x => double.Parse(x)).ToArray();
		}
		public static long[] SplitToLong(string line)
		{
			return Regex.Split(line, " ").Select(x => long.Parse(x)).ToArray();
		}
		public static void Main()
		{
			var line = Console.ReadLine();
			var v = SplitToDouble(line);
			
			var r = v[0];
			
			Console.WriteLine(string.Format("{0} {1}", Math.PI * r * r, Math.PI * r * 2));
		}
	}


}

Measured memory_bytes: 7420
#!/usr/bin/env python3
n,k,s = map(int,input().split())
# 誤読してた。1,2,3,,,n-1と言う並びとは限らない。同じ数字が何回きてもOK
# 日本語問題だった
# 誤読がなければ 数列はSをそのまま要素に持つことができるので、KこのsとSより大の数で埋めればOK
# 例外はS ==10**9の時であと全てを1とかにすればN<=10**5なのでS以外の総和を区間にできても10**9は超えない
if s == 10**9:

    print((str(s)+" ")*k+"1 "*(n-k))
else:
    print((str(s)+" ")*k+(str(s+1)+" ")*(n-k))

Measured memory_bytes: 51312
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

type robot struct {
	x, d int
}

type robots []robot

func (p robots) Len() int {
	return len(p)
}

func (p robots) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p robots) Less(i, j int) bool {
	return p[i].x < p[j].x
}

const mod = 998244353

func dfs(n int, e [][]int) int {
	ret := 1
	for _, v := range e[n] {
		ret *= dfs(v, e)
		ret %= mod
	}
	ret = (ret + 1) % mod
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	r := make(robots, N)
	for i := 0; i < N; i++ {
		x, d := getInt(), getInt()
		r[i] = robot{x, d}
	}
	sort.Sort(r)
	// out(r)

	e := make([][]int, N)
	s := make([][2]int, 0)
	for i := N - 1; i >= 0; i-- {
		x := r[i].x
		d := r[i].d
		for len(s) > 0 && s[len(s)-1][0] < x+d {
			e[i] = append(e[i], s[len(s)-1][1])
			s = s[:len(s)-1]
		}
		s = append(s, [2]int{x, i})
	}
	// out(s)
	// out(e)
	ans := 1
	for _, v := range s {
		ans *= dfs(v[1], e)
		ans %= mod
	}
	out(ans)
}


Measured memory_bytes: 65536
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main(){
	string a, b;
	cin >> a >> b;
	if(a.size() < b.size()){
		cout << "LESS" << endl;
		return 0;
	}else if(a.size() > b.size()){
		cout << "GREATER" << endl;
		return 0;
	}
	for(int i = 0; i < a.size(); ++i){
		if(a[i] < b[i]){
			cout << "LESS" << endl;
			return 0;
		}else if(a[i] > b[i]){
			cout << "GREATER" << endl;
			return 0;
		}
	}
	cout << "EQUAL" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int N = 0;
	int X[100];

	int num1 = 0;
	int num2 = 0;

	scanf("%d", &N);

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

	int P1 = num1 / N;
	int P2 = num1 / N + 1;
	int power1 = 0;
	int power2 = 0;

	for(int i = 0; i < N; i++) {
		power1 += (X[i] - P1) * (X[i] - P1);
		power2 += (X[i] - P2) * (X[i] - P2);
	}

	int answer = 0;

	if(power1 < power2) {
		answer = power1;
	} else {
		answer = power2;
	}

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

	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int N;
string S;

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

  if (N % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  for (int i = 0; i < N / 2; i++) {
    if (S[i] != S[i + N / 2]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll n;
  cin >> n;
  vll v(n);
  bool flag = true;
  map<ll, ll> m0, m1;
  vector<Pll> A0(0), A1(0);
  for(int i = 0; i < n; i++){
    cin >> v.at(i);
    if(v.at(i) != v.at(0)) flag = false;

    if(i % 2 == 0){
      if(!m0.count(v.at(i))){
        m0[v.at(i)] = A0.size();
        A0.push_back(Pll(1, v.at(i)));
      }
      else{
        A0.at(m0.at(v.at(i))).first++;
      }
    }
    else{
      if(!m1.count(v.at(i))){
        m1[v.at(i)] = A1.size();
        A1.push_back(Pll(1, v.at(i)));
      }
      else{
        A1.at(m1.at(v.at(i))).first++;
      }
    }
  }
  if(flag){
    cout << n/2 << endl;
    return 0;
  }

  sort(ALL(A0), greater<Pll>());
  sort(ALL(A1), greater<Pll>());
  ll X = A0.at(0).first, Y = A1.at(0).first;
  if(A0.at(0).second == A1.at(0).second){
    if(A0.size() == 1) Y = A1.at(1).first;
    else if(A1.size() == 1) Y = A0.at(1).first;
    else{
      if(A0.at(1).first > A1.at(1).first) Y = A0.at(1).first;
      else Y = A1.at(1).first;
    }
  }
  cout << n - X - Y << endl;

}


Measured memory_bytes: 8808
#ifdef __cplusplus
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#else
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#endif

#define rep(i,n) for(int i = 0; i < (n); ++i)
 
#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF (1 << 30)
#define INF_NEG (INF * -1)
#define INF_LONG (1LL << 62)
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef char str255[256];
int StrLen(char *s) { for(int ptr = 0;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
int StrDel(char *s, int n) { int l = StrLen(s); s[l - n + 1] = '\0'; return l - n; }

int NumDigits(int i){ char s[20]; return sprintf(s, "%d", i); }
int NumDigitsLL(long long l){ char s[30]; sprintf(s, "%lld", l); return strlen(s); }

int is1stAns = 1;
#ifdef __cplusplus
template <class T> 
void print(T t) { if (is1stAns) cout << t, is1stAns = 0; else cout << " " << t; }
#else
void printI(int    i) { if (is1stAns) printf(  "%d", i), is1stAns = 0; else printf(  " %d", i); }
void printL(ll     l) { if (is1stAns) printf("%lld", l), is1stAns = 0; else printf(" %lld", l); }
void printD(double d) { if (is1stAns) printf("%.9f", d), is1stAns = 0; else printf(" %.9f", d); }
void printC(char   c) { if (is1stAns) printf(  "%c", c), is1stAns = 0; else printf(  " %c", c); }
void printS(char  *s) { if (is1stAns) printf(  "%s", s), is1stAns = 0; else printf(  " %s", s); }
#endif

signed main()
{
#ifdef __cplusplus
    cout << fixed << setprecision(9);
#endif

    ll r; scanf("%lld", &r);
    printf("%lld\n", 3 * r * r);

    return 0;
}


Measured memory_bytes: 128
def main(s, K):
    l = list()
    for i in range(len(s)):
        for k in range(1, K + 1):
            sub = s[i:i + k]
            if sub not in l:
                l.append(sub)
    l = sorted(l)
    return l[K-1]

s = input()
K = int(input())
res = main(s, K)
print(res)


Measured memory_bytes: 4084
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll a[4],ans=3;
int32_t main(){
CODE_START;
cin >> a[0] >> a[1] >> a[2];
sort(a,a+3);
for(ll i=0;i<=1;i++)
if(a[i]==a[i+1]){
    ans--;
}
cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	string s; cin >> s;
	if(s.size()%2==1){
		cout << "No" << endl;
	}
	else{
		REP(i,s.size()){
			if(i%2){
				if(s[i]!='i'){
					cout << "No" << endl;
					return 0;
				}
			}
			else{
				if(s[i]!='h'){
					cout << "No" << endl;
					return 0;
				}
			}
		}
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  string N;
  cin>>N;
  string S=N;
  reverse(begin(S),end(S));
  if(S==N)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3616
import math


def is_prme_number(num):
    if num == 1:
        return False

    for i in range(2, int(math.sqrt(num)) + 1):
        if num % i == 0:
            return False

    return True


def main():
    x = int(input())
    while True:
        if is_prme_number(x):
            break
        x += 1
    print(x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#define LL long long

LL a,b;

int main(){
#ifdef DEBUG
	freopen("D.in","r",stdin);
#endif
	scanf("%lld%lld",&a,&b);
	if(a==b){
		puts("1");
		return 0;
	}
	for(LL i=1LL<<61;i;i>>=1)
		if((a^b)&i){
			b^=i;
			LL ans=i-a;
			for(LL j=i;j;j>>=1)
				if(b&j){
					b=(j<<1)-1;
					break;
				}
			if(b>=a) ans+=i;
			else ans+=i-(a-b-1);
			printf("%lld\n",ans);
			return 0;
		}else if(a&i){
			a^=i; b^=i;
		}
}


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

using namespace std;

struct dat{
	int d,p,id;
	bool operator<(const dat& a) {
		return p<a.p;
	}
};

int main() {
	int n,l;
	while(cin >> n >> l,n) {
		vector<dat> dats(n);
		for(int i=0;i<n;++i) {
			char d;
			cin >> d >> dats[i].p;
			dats[i].d=(d=='L'?1:0);
			dats[i].id=i+1;
		}
		int sec=0,ans;
		while(true) {
			ans=0;
			++sec;
			bool flag=true;
			for(int i=0;i<n;++i) {
				if(dats[i].p==0||dats[i].p==l) continue;
				if(dats[i].d) --dats[i].p;
				else ++dats[i].p;
				if(dats[i].p==0||dats[i].p==l) {
					if(ans==0||(ans&&dats[i].p==0)) ans=dats[i].id;
				} else flag=false;
			}
			if(flag) break;
			sort(dats.begin(),dats.end());
			for(int i=0;i<n;++i) {
				if(dats[i].p==0) continue;
				if(dats[i].p==l) break;
				if(i>0&&dats[i-1].p==dats[i].p) {
					dats[i-1].d=1-dats[i-1].d;
					dats[i].d=1-dats[i].d;
				}
			}
		}
		cout << sec << " " << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
using namespace std;

using int64 = long long;
using int128 = __int128;

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

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

  int64 K, A, B;
  cin >> K >> A >> B;

  if (A + 2 >= B) {
    cout << K + 1 << endl;
    return 0;
  }

  if (1 + K <= A) {
    cout << K + 1 << endl;
    return 0;
  }

  int64 ans = A;
  K -= A - 1;
  ans += (B - A) * (K / 2) + K % 2;

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

typedef tuple<int, string, int> restaurant;

bool mycompare( const restaurant &lhs, const restaurant &rhs ) {
    // if (get<0>(lhs) != get<0>(rhs)) return get<0>(lhs) < get<0>(rhs);
    if (get<1>(lhs) != get<1>(rhs)) return get<1>(lhs) < get<1>(rhs);
    return get<2>(lhs) > get<2>(rhs);
}

void print_vector( vector<restaurant>& vec ) {
    for( auto& element : vec ) {
        std::cout << std::get<0>(element) + 1 << std::endl;
    }
}

int main(void) {
    int N;
    cin >> N;
    vector<restaurant> vec;
    for(int i=0; i<N; i++) {
        string S;
        int P;
        cin >> S >> P;
        vec.push_back(make_tuple(i, S, P));
    }
    sort(vec.begin(), vec.end(), mycompare);
    print_vector(vec);
    return 0;
}

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

int main(){
  string s;
  cin>>s;
  int l=s.size();
  int k;
  long long int ans=0;
  for(int i=0;i<l;i++){
    k=s[i]-48;
    for(int j=0;j<l-i-1;j++){
      ans += pow(10,j)*k*pow(2,l-2-j);
    }
    ans += k*pow(10,l-1-i)*pow(2,i);
  }
  cout << ans << endl;
}
    

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

typedef long long ll;
typedef unsigned long long ull;

class BIT{
    long long *tree;
    int depth;

    public:
    BIT(unsigned int n){
        for(depth=0;(1<<depth)<n;depth++) ;
        tree = new long long[1<<depth]();
    }

    void add(unsigned int index, long long value){
        index++;
        for(;index<=(1<<depth);index+=index&-index){
            tree[index-1]+=value;
        }
    }

    long long sum(unsigned int index){
        index++;
        long long s=0;
        for(;index>0;index-=index&-index){
            s+=tree[index-1];
        }

        return s;
    }

    ~BIT(){
        delete[] tree;
    }
};

int main(){
    int N, A[100];
    cin >> N;
    BIT bit(101);
    for(int i=0;i<N;i++) cin >> A[i];

    ll cnt=0;
    for(int j=0;j<N;j++){
        cnt += j-bit.sum(A[j]);
        bit.add(A[j], 1);
    }

    sort(A,A+N);
    for(int i=0;i<N;i++) cout << A[i] << (i<N-1?' ':'\n');
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3140
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n, w;
	cin >> n >> w;
	vector<vector<int > > items(n, vector<int> (2));// 0 = weight 1 = value
	for(int i = 0; i < n; i++){
		cin >> items[i][0];
		cin >> items[i][1];
	}
	vector<vector<long long int > > dp(n, vector<long long int> (w+1));// n = choose before n w = bag volume
	for(int i = 0; i < n; i++){
		dp[i][0] = 0;
	}
	for(int j = 0; j <= w; j++){
		if(j >= items[0][0]){
			dp[0][j] = items[0][1];
		}
		else{
			dp[0][j] = 0;
		}
	}
	for(int i = 1; i < n; i++){
		for(int j = 0; j <= w; j++){
			if((j - items[i][0]) >= 0){
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-items[i][0]] + items[i][1]);
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	cout << dp[n-1][w] << endl;
}


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

using namespace std;
#define ll long long
#define f(i,l,u) for(ll i=l;i<u;i++)
int main() {
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll at[2];
ll bt[2];
at[0]=a;
at[1]=b;
bt[0]=c;
bt[1]=d;
ll ans=-1e18;
//cout<<ans<<endl;
ans--;
//cout<<ans<<endl;
f(i,0,2)
{
f(j,0,2)

{
    //cout<<"I= "<<i<<" j= "<<j<<endl;
    ans=max(ans,at[i]*bt[j]);
//cout<<ans<<endl;
    
}
}
cout<<ans<<endl;


}

Measured memory_bytes: 3616
#include<iostream>
        #include<cstdio>
        #include<math.h>
        #include<string>
        #include<algorithm>
        #include<functional>
        #include<vector>
        #include<set>
        #include<map>
        #define INF 999999
        #define EPS 1.0e-6
         
        using namespace std;
         
        typedef long long ll;
        typedef pair<int, int> P;
        typedef pair<int, P> PP;
         
         
        ll a[2100];
         
        int main()
        {
        	int n;
        	int z, w;
        	cin >> n >> z >> w;
        	for (int i = 0; i < n; i++) {
        		cin >> a[i];
        	}
        	if (n == 1) {
        		ll cur = abs(z - w);
        		ll ne = abs(a[0] - w);
        		cout << ne << endl;
        		return 0;
        	}
        	if (n >= 2) {
        		ll s = abs(z - w);
        		ll k = a[n - 2];
        		ll l = a[n - 1];
        		cout << max(abs(k - l), abs(l - w)) << endl;
        		return 0;
        	}
         
         
        	return 0;
        }

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){
    
    string s,t;
    cin >> s;
    cin >> t;

    bool ans = true;

    rep(i, s.size()){
        ans = ans && s[i] == t[i];
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3596
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#include <bits/stdc++.h>
using namespace std;


int main() {
	int X;


	cin >> X;
	
	for(int A = 125; A>-125; A--){
		for(int B = 125; B>-125; B--){
			if(pow(A, 5) - pow(B, 5) == X){
				cout << A << " " << B << endl;
				return 0;
			}
		}
	}
	
	
	return 0;
}

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

int main(){
  string o, e;
  cin >> o >> e;
  
  int i = 0;
  
  while(i < e.size()){
    cout << o.at(i) << e.at(i);
    i++;
  }
  if(o.size() > e.size()){
    cout << o.at(o.size() - 1);
  }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A = [0] + A[:] + [0]
D = [abs(A[i] - A[i+1]) for i in range(N+1)]
S = sum(D)
for i in range(1, N+1):
  if (A[i] - A[i-1])*(A[i+1] - A[i]) < 0:
    X = S - abs(A[i+1] - A[i]) - abs(A[i] - A[i-1]) + abs(abs(A[i+1] - A[i]) - abs(A[i] - A[i-1]))
    print(X)
  else:
    X = S
    print(X)

Measured memory_bytes: 14172
n = int(input())

before = str(input())
use = [str(before)]
check = 0
for i in range(n-1):
    w = str(input()) 
    if w in use or before[-1] != w[0]:
        check = 1
        break
    use.append(w)

    before = w

if check == 0:
    print('Yes')
else:
    print('No')




Measured memory_bytes: 3060
n = int(input())
t, a = map(int, input().split())
h = list(map(int,input().split()))
min_city = 10**5
ans =0
for i in range(n):
    temp = abs(t - h[i] * 0.006 -a)
    if min_city > temp:
        ans = i+1
        min_city = temp
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    for(int i = 1; i < s.size(); i++) {
        if(s.at(i-1)=='B' && s.at(i)=='C') {
            s.at(i-1) = 'X';
            s.at(i) = 'Y';
        }
    }
    
    long long now = 0;
    long long ans = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s.at(i)=='A') now++;
        if(s.at(i)=='X') ans += now;
        if(s.at(i)=='B' || s.at(i)=='C') now = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n, k; cin >> n >> k;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int ans = INT_MAX;
    rep(i,n-k+1){
        ans = min(ans,min(v[i+k-1]-v[i]+abs(v[i]),v[i+k-1]-v[i]+abs(v[i+k-1])));
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	int num[100001] = {0};
	bool a = false;
	for(int i = 0; i < n; i++){
		if(s[i] == 'A')a = true;
		else{
			if(i && a && s[i] == 'C')num[i+1]+=1;
			a = false;
		}
		num[i+1] += num[i];
	}
	//for(int i = 0; i <= n; i++)cout << num[i] << endl;
	for(int i = 0; i < q; i++){
		int l, r;
		cin >> l >> r;
		cout << num[r]-num[l] << endl;
	}
    return 0;
}

Measured memory_bytes: 1408
import heapq
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))


def c():
    if sum(a) < sum(b):
        return - 1

    ans = 0
    ok = []
    sum_ = 0
    for i, j in zip(a, b):
        if i >= j:
            heapq.heappush(ok, j-i)
        else:
            ans += 1
            sum_ -= i - j

    while sum_ > 0 and ok:
        ans += 1
        sum_ += heapq.heappop(ok)
    return ans


print(c())


Measured memory_bytes: 19384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  rep (i, N) cin >> S.at(i);
  sort(S.begin(), S.end());
  rep (i, N-1) cout << S.at(i);
  cout << S.at(N-1) << endl;
}

Measured memory_bytes: 256
import bisect
N = int(input())
L = sorted([int(_) for _ in input().split()])

ans = 0
for i in range(N):
    for j in range(i+1, N):
        tmp = L[i] + L[j]
        ans += bisect.bisect_left(L, tmp) - j - 1
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
	set<int> s;
	int n,a,t=0,it;

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		s.insert(a);
	}

	set<int>::iterator itr = s.begin(),itl=s.end();
	itl--;

	while(*itr!=*itl) {
	     it=*itr;
	     ++itr;
	     t+=*itr-it;
        }  	   
	 cout << t << "\n";
return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b,sum=0;
    cin>>a>>b;
    if(a+b==4)
    {
        cout<<2;
    }
    else if(a+b==5)
    {
        cout<<1;
    }
    else
    {
        cout<<3;
    }
}

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

int main(){
  int n;
  cin >> n;
  double ans;
  if (n%2==0) ans=0.5;
  else if (n==1) ans=1;
  else
  ans=double(n/2+1)/double(n);
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



double dp[3000][3001];


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

	rep(i, 3000)rep(j, 3001)dp[i][j] = 0;
	dp[0][0] = 1;

	int n;
	cin >> n;
	double p[3000];
	rep(i, n)cin >> p[i];

	rep(i, n) rep(j, i + 1) {
		dp[i + 1][j + 1] += dp[i][j] * p[i];
		dp[i + 1][j] += dp[i][j] * (1 - p[i]);
	}

	double ans = 0;
	for (int i = (n + 1) / 2; i <= n; i++) {
		ans += dp[n][i];
	}
	printf("%.9f\n", ans);

	
	return 0;
}


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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<P,int>;
constexpr ll MOD = ll(1e9)+7;

ll dp[301][301][301];

int main(){
    ll N, M;
    cin >> N >> M;
    vector<vector<P> > a(N+1);
    for(int i=0;i<M;i++){
        int l, r, x;
        cin >> l >> r >> x;
        a[r].emplace_back(l,x);
    }
    dp[0][0][0] = 1;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++){
                int r = max({i,j,k})+1;
                dp[r][j][k] += dp[i][j][k];
                dp[i][r][k] += dp[i][j][k];
                dp[i][j][r] += dp[i][j][k];
                dp[r][j][k] %= MOD;
                dp[i][r][k] %= MOD;
                dp[i][j][r] %= MOD;
                for(auto p : a[r]){
                    int l = p.first, x = p.second;
                    if(x==1){
                        if(max(j,k)>=l) dp[r][j][k] = 0;
                        if(max(i,k)>=l) dp[i][r][k] = 0;
                        if(max(j,i)>=l) dp[i][j][r] = 0;
                    }
                    if(x==2){
                        if(max(j,k)<l || min(j,k)>=l) dp[r][j][k] = 0;
                        if(max(i,k)<l || min(i,k)>=l) dp[i][r][k] = 0;
                        if(max(j,i)<l || min(j,i)>=l) dp[i][j][r] = 0;
                    }
                    if(x==3){
                        if(min(j,k)<l) dp[r][j][k] = 0;
                        if(min(i,k)<l) dp[i][r][k] = 0;
                        if(min(j,i)<l) dp[i][j][r] = 0;
                    }
                }
            }
        }
    }
    ll ans = dp[0][0][N] + dp[0][N][0] + dp[N][0][0];
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            ans += dp[i][j][N];
            ans += dp[j][i][N];
            ans += dp[i][N][j];
            ans += dp[j][N][i];
            ans += dp[N][i][j];
            ans += dp[N][j][i];
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 213376
/*i-=-1*/
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define in(n) for(int i=0;i<n;i++)
#define inj(n) for(int j=0;j<n;j++)
#define itn int
#define ll long long 
#define ull unsigned ll
#define int ll int
#define S second 
#define F first 
#define mod 1000000007
#define globalbool 2000000
#define pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
using namespace std::chrono;
int dp[3001][3001]={0};
int n;
int ans=0;
int winningStratergy(itn A[],int st=0,int end=n-1,int chance=0)
{
	if(st>end)
		return 0;
	if(dp[st][end]!=0)
		return dp[st][end];
	//if(chance==0)
	//{
		int a=A[st]-winningStratergy(A,st+1,end,1);
		int b=A[end]-winningStratergy(A,st,end-1,1);
		dp[st][end]=max(a,b);
		return dp[st][end];
	//}
	//else
	//{

	//}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	auto start = high_resolution_clock::now();
	//int n;
	cin>>n;
	int A[n];
	in(n)
		cin>>A[i];
	itn sum=accumulate(A,A+n,0ll);
	cout<<winningStratergy(A);
	auto stop = high_resolution_clock::now();
    //auto duration = duration_cast<microseconds>(stop - start); 
  
    //cout << "Time taken by function: "
    //<< duration.count() << " microseconds" << endl;
}

Measured memory_bytes: 70144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll mod = 1e9+7;
ll INF = 1e17;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
/*ll power(ll a,ll b,ll p)
{
	ll res=1;
	a%=p;
	while(b>0)
	{
		if(b&1)
		res=res*a%p;
		a=a*a%p;
		b>>=1;
	}
	return(res);
}*/
/*void dfs(ll x)
{
	vis[x]=true;
	for(ll i=0;i<v[x].size();i++)
	{
		if(vis[v[x][i]]==false)
		dfs(v[x][i]);
	}
}*/
/*ll b_search(ll arr[],ll n,ll s)
{
	ll l=0,r=n-1;
	while(l<=r)
	{
		ll mid=l+(r-l)/2;
		if(arr[mid]==s)
		return(mid);
		if(arr[mid]<s)
		l=mid+1;
		else
		r=mid-1;
	}
	return(-1);
}*/
 
void solve()
{
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<endl;
}
 
int main()
{
	IOS
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
    return(0);
}


Measured memory_bytes: 256