akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define NMAX 200000

int len, part, rank[NMAX+1];
int compare_sa(const void *a, const void *b);
void construct_sa(char *string, int n, int *sa);
int main(void)
{
  int i, n, k, l, lo, hi, sa[NMAX];
  char s[NMAX+1];
  scanf("%d%*c", &k);
  scanf("%s%*c", s);
  n = strlen(s);
  l = (n + k) / (k + 1);
  lo = 1;
  hi = n;
  construct_sa(s, n, sa);
  if (n % (k + 1) == 0) {
    int res = 0;
    for (i = 0; i < k; i++) {
      if (rank[n/(k+1)*(i+1)] > rank[res]) res = n / (k + 1) * (i + 1);
    }
    s[res+n/(k+1)] = '\0';
    printf("%s\n", s + res);
  } else {
    while (hi >= lo) {
      int mid = (lo + hi) / 2, pos = 0, res = 0;
      while (pos < n) {
        pos += rank[pos] <= mid ? l : l - 1;
        res++;
      }
      if (res <= k + 1) hi = mid - 1;
      else lo = mid + 1;
    }
    s[sa[lo]+l] = '\0';
    printf("%s\n", s + sa[lo]);
  }
}

int compare_sa(const void *a, const void *b)
{
  int i = *(int*)a, j = *(int*)b;
  if (rank[i] != rank[j]) return rank[i] - rank[j];
  else {
    int ri = (i + part <= len ? rank[i+part] : -1), rj = (j + part <= len ? rank[j+part] : -1);
    return ri - rj;
  }
}

void construct_sa(char *string, int n, int *sa)
{
  int i, tmp[NMAX+1];
  len = n;
  for (i = 0; i <= len; i++) {
    sa[i] = i;
    rank[i] = i < n ? string[i] : -1;
  }
  for (part = 1; part <= len; part *= 2) {
    qsort(sa, len + 1, sizeof(int), compare_sa);
    tmp[sa[0]] = 0;
    for (i = 1; i <= len; i++) {
      tmp[sa[i]] = tmp[sa[i-1]] + (compare_sa(&sa[i-1], &sa[i]) ? 1 : 0);
    }
    for (i = 0; i <= len; i++) rank[i] = tmp[i];
  }
}


Measured memory_bytes: 1780
import java.util.*;

public class Main {
	int [] vx = {0,1,1,0,-1,-1};
	int [] vy = {1,1,0,-1,-1,0};
	
	class C {
		int x,y,s;

		public C(int x, int y,int s) {
			this.x = x;
			this.y = y;
			this.s = s;
		}
		
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		int sub = 200;
		while(true){
			int t = sc.nextInt();
			int n = sc.nextInt();
			if( t == 0 && n == 0) break;
			LinkedList<C> open = new LinkedList<Main.C>();
			
			boolean [][] close = new boolean[sub* 2+1][sub * 2+1];
			
			for(int i = 0; i < n; i++){
				int x = sc.nextInt() + sub;
				int y = sc.nextInt() + sub;
				close[y][x] = true;
			}
			int sx = sc.nextInt() + sub;
			int sy = sc.nextInt() + sub;
			close[sy][sx] = true;
			open.add(new C(sx, sy,0));
			int ans = 0;
			while(! open.isEmpty()){
				C now = open.removeFirst();
				//System.out.println(now.x + " " + now.y);
				ans++;
				if(now.s == t){
					continue;
				}
				for(int i = 0; i < 6; i++){
					int xx = now.x + vx[i];
					int yy = now.y + vy[i];
					if(close[yy][xx]) continue;
					
					open.add(new C(xx,yy,now.s+1));
					close[yy][xx] = true;
				}
			}
			System.out.println(ans);
		}
		
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 16000
s = input()
h, w = map(int, s.split())
a = [list(map(int, input().split())) for i in range(h)]
b = [[[-1,-1]]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        a[i][j] %= 2
count = 0
for i in range(h-1):
    for j in range(w):
        if a[i][j] == 1:
            a[i][j] = 0
            a[i+1][j] = (a[i+1][j]+1)%2
            b[i][j] = [i+1, j]
            count += 1
for i in range(w-1):
    if a[h-1][i] == 1:
        a[h-1][i] = 0
        a[h-1][i+1] = (a[h-1][i+1]+1)%2
        b[h-1][i] = [h-1, i+1]
        count += 1
print(count)
for i in range(h):
    for j in range(w):
        if not b[i][j] == [-1,-1]:
            print(i+1, j+1, b[i][j][0]+1, b[i][j][1]+1)


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<bool>> a(n, vector<bool>(m, false));
  rep(i, n) {
    int k;
    cin >> k;
    rep(j, k) {
      int aa;
      cin >> aa;
      aa--;
      a.at(i).at(aa) = true;
    }
  }

  int res = 0;
  rep(i, m) {
    bool like = true;
    rep(j, n) {
      if (!a.at(j).at(i)) {
        like = false;
        break;
      }
    }
    if (like) {
      res++;
    }
  }
  cout << res << endl;
  return 0;
}


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

int main() {
  vector<int> num(3);
  cin >> num[0] >> num[1] >> num[2];
  sort(num.begin(), num.end());
  int ans = 0;
  while (num[1]-num[0] > 1) {
    num[0] += 2;
    ans++;
  }
  if (num[1]-num[0] == 0) ans += num[2]-num[1];
  else ans += num[2]-num[0]+1;
  cout << ans << endl;
}


Measured memory_bytes: 3592
<?php
while (fscanf(STDIN, "%d %d %d", $n, $m, $a) && ($n | $m | $a)) {
  $w = array();

  for ($i = 0; $i < $m; $i++) {
    fscanf(STDIN, "%d %d %d", $h, $p, $q);
    $w[$i] = array($h, $p - 1, $q - 1);
  }
  
  rsort($w);

  $amida = array();
  for ($i = 0; $i < $n; $i++) {
    $amida[$i] = $i + 1;
  }

  foreach ($w as $w) {
    list($amida[$w[2]], $amida[$w[1]]) = array($amida[$w[1]], $amida[$w[2]]);
  }
  
  $ans = -1;
  foreach ($amida as $key => $value) {
    if ($value == $a) {
      $ans = $key + 1;
    }
  }

  print $ans . "\n";
}

Measured memory_bytes: 7648
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;

int A[200010];
vector<int> a_copy;

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


    for (int i = 0; i < N; ++i) {
        int a;
        cin>>a;
        A[i] = a;
        a_copy.push_back(a);
    }

    sort(a_copy.begin(), a_copy.end(),std::greater<int>());

    if(a_copy[0]==a_copy[1]){
        for (int i = 0; i < N; ++i) {
            cout<<a_copy[0]<<endl;
        }
        return 0;
    }else{
        int max_index;
        int max_temp = -1;
        
        for (int i = 0; i < N; ++i) {
            if(max_temp<A[i]){
                max_temp = A[i];
                max_index = i;
            }
        }

        for (int i = 0; i < N; ++i) {
            if(i == max_index){
                cout<<a_copy[1]<<endl;
            }else{
                cout<<a_copy[0]<<endl;
            }
        }

        return 0;

    }


    return 0;
}

Measured memory_bytes: 3316
# 解説コード
N = int(input())

def dfs(s): # 文字列 s で始まる七五三数の個数
  if int(s) > N:
    return 0
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
  for c in '753':
    ret += dfs(s + c)
  return ret

print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく

Measured memory_bytes: 2940
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
#define SORT(v, n) sort(v, v+n);
#define ALL(v) v.begin(),v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v),greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF 999999999
#define mins(a,b) a = min(a,b)
#define maxs(a,b) a = max(a,b)

//4近傍
//int dy[]={0, 0, 1, -1};
//int dx[]={1, -1, 0, 0};

//8近傍
int dy[]={0,0,1,-1,1,1,-1,-1};
int dx[]={1,-1,0,0,1,-1,1,-1};

ll mod = 1000000007;

void solve() {
    vector<int> a(3);
    rep(i,3) cin >> a[i];
    VSORT(a);
    if(a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
template<typename T>
inline T mod(T n, T mod){ T res = n%mod; if(res < 0) res += mod; return res; }

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){
	fastio;
	int n;
	cin >> n;
	map<int, int> freq;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		freq[x]++;
	}	
	bool flag = false;
	for(auto it = freq.begin(); it != freq.end(); it++){
		if(it->second > 1) flag = true;
	}
	if(flag) cout << "NO\n";
	else cout << "YES\n";
	return 0;
}

Measured memory_bytes: 9600
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
10 9
0 1
0 2
3 4
5 7
5 6
6 7
6 8
7 8
8 9
3
0 1
5 9
1 3

output:
yes
yes
no

"""

import sys


def assign_color():
    current_color = 1
    for v in range(v_num):
        if color[v] == -1:
            graph_dfs(v, current_color)
            current_color += 1
    return None


def graph_dfs(current, current_color):
    stack = list()
    stack.append(current)
    color[current] = current_color

    while stack:
        current = stack.pop()
        for v in adj_table[current]:
            if color[v] == -1:
                color[v] = current_color
                stack.append(v)
    return None


def solve():
    for edge in edges:
        source, target = map(int, edge)
        adj_table[source].append(target)
        adj_table[target].append(source)

    assign_color()

    for question in questions:
        q_source, q_target = map(int, question)
        if color[q_source] == color[q_target]:
            print("yes")
        else:
            print("no")
            
    return color


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    v_num, r_num = map(int, _input[0].split())

    edges = map(lambda x: x.split(), _input[1:r_num + 1])

    q_num = int(_input[r_num + 1])
    questions = map(lambda x: x.split(), _input[r_num + 2:])

    adj_table = tuple([] for _ in range(v_num))
    color = [-1] * v_num
    ans = solve()

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

int solve(string s, char c) {
    int i, im, m, k, n = s.size();
    for (k = 0; k < n; k++) {
        im = 1;
        for (i = 0; i < s.size(); i++) if (s[i] != c) im = 0;
        if (im) return k;

        string ns = "";
        m = s.size()-1;
        for (i = 0; i < m; i++) {
            if ((i+1 < m+1 && s[i+1] == c) || (s[i] == c)) {
                ns.push_back(c);
            } else {
                ns.push_back(s[i]);
            }
        }
        s = ns;
    }
    return 200000000;
}

int main() {
    string s;
    cin >> s;
    int res = (int)2e5;
    for (char c = 'a'; c <= 'z'; c++) {
        res = min(res, solve(s, c));
    }
    cout << res << '\n';
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
    int n, m;
    scanf("%d", &n);
    scanf("%d", &m);
    int num;
    int ac = 0, wa = 0;
    char ans[10];

    int WA[100007];
    bool AC[100007];
    for(int i = 1; i <= n; i++) {
        AC[i] = 0;
        WA[i] = 0;
    }
    while(m--){
        scanf("%d", &num);
        scanf("%s", ans);
        if (AC[num]) {
            continue;
        }
        if (ans[0] == 'A') {
            AC[num] = true;
            ac++;
            wa += WA[num];
        } else { // if (ans[0] == 'W'){
            WA[num] += 1;
        }
    }
    printf("%d %d\n", ac, wa);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define xx first
#define yy second
#define ll long long
using namespace std;

const int N = 200000 + 5;
int a[N], n, cnt;
int ans[N];

int main () {
	scanf ("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf ("%d", &a[i]);
	}
	for (int i = n; i >= 1; --i) {
		int tmp = 0;
		for (int j = n / i; j >= 1; --j) {
			tmp ^= ans[j * i];
		}
		ans[i] = tmp ^ a[i];
		cnt += ans[i];
	}
	printf ("%d\n", cnt);
	for (int i = 1; i <= n; ++i) {
		if (!ans[i]) {continue;}
		printf ("%d ", i);
	}
	return 0;
}






















Measured memory_bytes: 2432
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
 
int main() {
        int n, s;
        scanf("%d%d", &n, &s);
        vector<long long> x(n), p(n);
        int th = -1;
        for (int i = 0; i < n; i ++) {
                scanf("%lld%lld", &x[i], &p[i]);
                if (x[i] > s && th == -1) th = i;
        }
        if (th == -1) th = n;
        function<long long (int, int, int)> calc = [&](int l, int r, int dir) {
                if (r == th - 1) return s - x[l];
                if (l == th) return x[r] - s;
                if (p[l] >= p[r]) {
                        p[l] += p[r];
                        return calc(l, r - 1, 1) + (dir == 1 ? 0 : (x[r] - x[l]));
                } else {
                        p[r] += p[l];
                        return calc(l + 1, r, -1) + (dir == -1 ? 0 : (x[r] - x[l]));
                }
        }; 
        printf("%lld\n", calc(0, n - 1, 0));
        return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
ll cnt = 0;
void merge(ll A[], ll lv, ll mid, ll rv){
    ll n1 = mid - lv;
    ll n2 = rv - mid;
    vector<ll> L(n1+1), R(n2+1);
    rep(i,0,n1) L[i] = A[lv+i];
    rep(i,0,n2) R[i] = A[mid+i];
    L[n1] = INF;
    R[n2] = INF;
    ll i = 0, j = 0;
    rep(k, lv, rv){
        cnt++;
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        }else{
            A[k] = R[j];
            j++;
        }

    }


}

void mergeSort(ll A[], ll lv, ll rv){
    if(rv - lv > 1){
        ll mid = (rv + lv) / 2;
        mergeSort(A, lv, mid);
        mergeSort(A, mid, rv);
        merge(A, lv, mid, rv);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[500010];
    rep(i,0,N) cin >> A[i];
    mergeSort(A, 0, N);
    printa(A,N);
    print(cnt);


}


Measured memory_bytes: 10596
n,m,c=map(int,input().split())
b=[int(x) for x in input().split()]
a=[]
for i in range(n):
    a.append([int(x) for x in input().split()])

cnt=0
for i in range(n):
    p=0
    for j in range(m):
        p+=a[i][j]*b[j]
    if p+c>0:
        cnt+=1
print(cnt)
        





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

/*============================ DEBUGGING =============================*/

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*============================= DEFINES ==============================*/

#define eps 1e-9
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x)
#define fib(n) ceil(pow((1+sqrt(5),n)-pow((1-sqrt(5),n)/(float)(pow(2,n)*sqrt(5)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define dig(n) (int)(log10(n)+1)
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define set(x,k) memset(x,k,sizeof x)

/*============================== TYPEDEFS ============================*/

typedef long long ll;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<bool> vb;
typedef queue<int> qi;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;

/*============================ START FROM HERE =======================*/

int main(){
	FIO
	
	int n;cin>>n;
	map<int,int> mapp;
	rep(i,1,n+1){
		int a;cin>>a;
		mapp.ins({a,i});
	}
	for(int i=1;i<=n;i++)cout<<mapp[i]<<" ";
	return 0;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const int maxn=110000;
ll a[maxn];
int n;
ll l;
ll q;
int f[maxn][35]={};
inline void init()
{
  scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",a+i); scanf("%d%d",&l,&q);
  for(int i=1;i<=n;i++)
  {
    int x=(int)(upper_bound(a+1,a+n+1,a[i]+l)-a-1);
    f[i][0]=x;
  }
  for(int j=1;j<=30;j++) for(int i=1;i<=n;i++)  f[i][j]=f[f[i][j-1]][j-1];
}
int main()
{
	init();
	while(q--)
    {
      ll a,b;
      scanf("%lld %lld",&a,&b);
      if(a>b)
        swap(a,b);
      int ans=0;
      int cur=a;
      for(int i=30;i>=0;i--)
	    if(f[cur][i]<b)
	    {
	      ans+=1<<i;
	      cur=f[cur][i];
	    }
      printf("%d\n",ans+1);
    }
	return 0;
}


Measured memory_bytes: 16000
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
#include <stdbool.h>
//#include <limits.h>
#include <math.h>

#define MOD 1000000007
#define N 1000001 //size of array
#define max(a, b) (a > b ? a : b)

long inv[N];

void com_init()
{
  inv[1] = 1;
  for (int i = 2; i < N; i++)
  {
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
  }
}

int main() {
  int n;
  scanf("%d", &n);
  int a[n], p[N] = {0};
  long ans = 0, b = 1;
  for (int i=0; i<n; i++) {
    scanf("%d", a+i);
    int j, m = a[i];
    for (j = 2; j <= sqrt((double)m)+1; j++)
    {
      if (m == 1)
        break;
      if (m % j != 0)
        continue;
      int cnt = 0;
      while (m % j == 0)
      {
        m /= j;
        cnt++;
      }
      p[j] = max(cnt, p[j]);
    }
    if (m != 1) {
      p[m] = max(1, p[m]);
    }
  }
  for (int i=2; i<N; i++) {
    int j = p[i];
    while (j != 0) {
      b *= i;
      b %= MOD;
      j--;
    }
  }
  com_init();
  for (int i=0; i<n; i++) {
    ans += (b * inv[a[i]]) % MOD;
    ans %= MOD;
  }
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 11904
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

unordered_set<ll> primes(ll n) {
  ll p = 0;
  unordered_set<ll> ret;
  vector<bool> is_prime(n + 1, true);
  is_prime[0] = is_prime[1] = false;
  for (ll i = 2; i <= n; i++) {
    if (is_prime[i]) {
      ret.insert(i);
      for (int j = 2 * i; j <= n; j += i) {
        is_prime[j] = false;
      }
    }
  }
  return ret;
}

int main() {
  //
  unordered_set<ll> p = primes(1e5);
  vl nums;
  for (ll i = 3; i <= 1e5; i += 2) {
    if (p.find(i) != p.end() && p.find((i + 1) / 2) != p.end()) {
      nums.push_back(i);
    }
  }
  ll q;
  cin >> q;
  rep(i, q) {
    ll l, r;
    cin >> l >> r;
    vl::iterator lb = lower_bound(ALL(nums), l);
    vl::iterator ub = upper_bound(ALL(nums), r);
    cout << ub - lb << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
signed main()
{
    fast;
    int n;
    cin>>n;
    cout<<(n*(n-1))/2;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n = ni()
a = list(li())
ans = 0

for i in range(n-2):
    p0, p1, p2 = a[i:i+3]
    st = sorted([p0, p1, p2])

    if p1 == st[1]:
        ans += 1

print(ans)

Measured memory_bytes: 3316
from functools import reduce
def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)
def lcm(a, b):
    return a*b//gcd(a, b)
N, M = map(int, input().split())
A = [int(a)//2 for a in input().split()]
B = [a & -a for a in A]
if min(B) != max(B):
    print(0)
else:
    l = reduce(lcm, A)
    print(M // l - M // l // 2)


Measured memory_bytes: 64228
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
signed main()
{   
      senky_bansal
      IIIT_ALLAHABAD
       
      ll n,d;
      cin>>n>>d;
      ll a[n][d];
      for(int i=0;i<n;i++)
      {
          for(int j=0;j<d;j++)
          {
              cin>>a[i][j];
          }
      }
      ll ans=0;
      for(int i=0;i<n;i++)
      {
          for(int j=i+1;j<n;j++)
          {
              ll final=0;
              for(int k=0;k<d;k++)
           final+=pow(abs(a[i][k]-a[j][k]),2);
            ll p1 = sqrt(final);
            if(p1*p1==final)
            ans++;
          }
      }
      cout<<ans;
}









Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n,z,w;cin>>n>>z>>w;
  vector<int> a(n+1,0);
  rep(i,n)cin>>a[i];
  int Max=z;int Min=z;int sub=z;
  rep(i,n){
    Max=a[i];
    Min=a[i];
  }
  rep(i,n-1){
    sub=a[i];
  }
  int res=abs(Max-w);
  res=max(res,abs(Min-w));
  res=max(res,min(abs(sub-a[n-1]),abs(sub-inf*1000)));
  if(n==1){
    res=abs(a[0]-w);
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

struct Team
{
	char name[2];
	int win;
	int lose;
};

class team_comparator
{
public:
	bool operator() (Team t1, Team t2)
	{
		if(t1.win != t2.win) return t1.win > t2.win;
		else return t1.lose < t2.lose;
	}
};

Team S[10];

int main(int argc, char** argv)
{
	int n, r;
	while(cin >> n, n)
	{
		for(int i=0; i<n; i++)
		{
			cin >> S[i].name;
			S[i].win = 0;
			S[i].lose = 0;
			for(int j=0; j<n-1; j++)
			{
				cin >> r;
				switch(r)
				{
					case 0:
						S[i].win++;
						break;
					case 1:
						S[i].lose++;
						break;
				}
			}
		}

		sort(&S[0], &S[n], team_comparator());

		for(int i=0; i<n; i++)
		{
			cout << S[i].name << endl;
		}
	}

	return 0;
}

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

int main(){

  int n,a,d,m,k;
  cin >> n;
  cin >> a >> d;
  cin >> m;
  vector<int> x(m),y(m),z(m);
  for(int i=0; i<m; i++){
    cin >> x[i] >> y[i] >> z[i];
    y[i]--;
    z[i]--;
  }
  cin >> k;
  k--;
  vector<int> com;
  for(int i=m-1; i>=0; i--){
    if(x[i]==0 && (y[i]<=k && k<=z[i])){
      k = y[i]+z[i]-k;
      //cout << "1 " << i << endl;;
    }else{
      if(y[i]<=k && k<=z[i]){
        com.push_back(x[i]);
      }
    }
  }
  //cout << k << endl;
  int num = a+d*k;
  //cout << com.size() << endl;
  for(int i=com.size()-1;i>=0;i--){
      if(com[i]==1){
          num++;
      }else if(com[i]==2){
          num/=2;
      }
  }
  
  cout << num << endl;

  return 0;
}

Measured memory_bytes: 5252
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int N = 0;

void dfs(string s, char mx){
    if(s.length() == N){
        pr(s);
    }else{
        // REP(i, s.length()+1){                           
        //     dfs(s+(char)('a'+i));
        // }
        for (char c = 'a'; c <= mx; c++)
        {
            dfs(s+c, (c==mx)?(char)(mx+1):mx);
        }
        
    }
}

int main(void)
{
    cin>>N;
    dfs("", 'a');
}

Measured memory_bytes: 1536
// Five Antennas

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    char b;
    cin >> b;
    switch (b) {
    case 'A':
        cout << "T" << endl;
        break;
    case 'T':
        cout << "A" << endl;
        break;
    case 'C':
        cout << "G" << endl;
        break;
    default:
        cout << "C" << endl;
        break;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<deque>
#include<string>
#include<random>
#include<stack>
#include<limits.h>
#define int long long
using namespace std;

int b[10];
signed main() {
	int a; cin >> a;
	for (int c = 0; c < a; c++) {
		cin >> b[c];
	}
	int ans = 0;
	for (int i = 0; i < a; i++) {
		int k = 1;
		for (int j = 0; j < i; j++) {
			if (b[j] % 2 == 0)k *= 2;
		}
		if (b[i] & 1)k *= 2;
		for (int j = i + 1; j < a; j++)k *= 3;
		ans += k;
 	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k,a,b;
    cin >> k >> a  >> b;
    bool chk = false;
    for(int i=a;i<=b;i++){
        if(i%k==0)chk=true;
    }
    if(chk)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  int l = 1000;
  int r = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    l = min(l, a);
    r = max(r, a);
  }
  cout << r - l << endl;
}

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

int N,M;
int bit[100010] = {0}, ans[100010] = {0};
vector<pair<LL, PLL>> r;

void update(int hi, int add){
    while(hi <= M) bit[hi] += add, hi += hi & -hi;
}

int query(int x){
    int ret = 0;
    while(x) ret += bit[x], x -= x & -x;
    return ret;
}

int main(){
    cin >> N >> M;
    for(int i=0,li,ri; i<N;i++) cin >> li >> ri, r.push_back({ri-li+1, {li,ri}});
    sort(r.begin(), r.end());

    for(int d=1,i=0; d<=M; d++){
        for(i; r[i].first < d && i<N; i++){
            update(r[i].second.first, 1);
            update(r[i].second.second+1, -1);
        }
        ans[d-1] += N-i;
        for(int j=d; j<=M; j+=d){
            ans[d-1] += query(j);
        }
    }
    for(int i=0; i<M; i++) cout << ans[i] << endl;

    return 0;
}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] arr = Console.ReadLine().Trim().Split(' ').Select(hogehoge => int.Parse(hogehoge)).ToArray<int>();

			if (arr[0] == arr[1])
			{
				Console.WriteLine("Yes");
			}
			else {
				Console.WriteLine("No");

			}

		}


	}


}


Measured memory_bytes: 13396
#include <bits/extc++.h>

#ifndef DUMP
#define DUMP(...) void(0)
#endif

using namespace std;

template <class T, class Op = multiplies<>>
constexpr T power(T a, uint64_t n, T init = 1, Op op = Op{}) {
  while (n) {
    if (n & 1) init = op(init, a);
    if (n >>= 1) a = op(a, a);
  }
  return init;
}

template <uint32_t Mod>
struct modular {
  using T = modular;
  static constexpr uint32_t mod = Mod;
  uint32_t v;
  modular(int64_t x = 0) : v((x %= mod) < 0 ? x + mod : x) {}
  T operator-() const { return T() - *this; }
  T& operator+=(T b) { return v += int(v += b.v - mod) < 0 ? mod : 0, *this; }
  T& operator-=(T b) { return v += int(v -= b.v) < 0 ? mod : 0, *this; }
  T& operator*=(T b) { return v = uint64_t(v) * b.v % mod, *this; }
  T& operator/=(T b) { return *this *= power(b, mod - 2); }
  friend T operator+(T a, T b) { return a += b; }
  friend T operator-(T a, T b) { return a -= b; }
  friend T operator*(T a, T b) { return a *= b; }
  friend T operator/(T a, T b) { return a /= b; }
  friend bool operator==(T a, T b) { return a.v == b.v; }
};

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  using mint = modular<power(10, 9) + 7>;
  int n;
  cin >> n;
  mint res, sum;
  while (n--) {
    int a;
    cin >> a;
    res += sum * a;
    sum += a;
  }
  cout << res.v << '\n';
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

ll n,j=LLONG_MAX;
vector<pl>v;
void update(vector<ll> &ans, int i){
	j=min(j,v[i].se);
	if(i==0){
		ans[j]+=(n-i)*(v[i].fi);
		return;
	}
	ans[j]+=(n-i)*(v[i].fi-v[i-1].fi);

	update(ans,i-1);
}
 
int main(){
	cin>>n;
	vector<ll>a(n),ans(n);
	rep(i,n)cin>>a[i];
	rep(i,n)v.pb(mp(a[i],i));
	sort(all(v));
	update(ans,n-1);
	rep(i,n){
		cout<<ans[i]<<endl;
	}

    return 0;
}

Measured memory_bytes: 4336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<Pi> Ai(N);

    rep(i,N){
        ll a;
        cin >>a;
        Ai[i] = mp(a,i+1);
    }

    sort(all(Ai));

    rep(i,N){
        cout<<Ai[i].second<<" ";
    }
    cout<<endl;
    


    return 0;
    

}

Measured memory_bytes: 4768
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 1000000007
using namespace std;
//ll visit[100001]={0};
//vector<ll> adj[1000001];

    
int main(){
   IOS;
int t;t=1;//cin>>t;
while(t--){
ll d,t,s;
cin>>d>>t>>s;
if(d<=t*s) cout<<"Yes\n";
else cout<<"No\n";

}
    
    

    
    





return 0;}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define _overload4(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload4(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)
#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))
#define d(a) cerr<<#a<<":"<<a<<endl
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl


int main(){
    int n,T;
    cin>>n>>T;
    int mc=INF;
    REP(i,n){
        int c,t;
        cin>>c>>t;
        if(t<=T){
            chmin(mc,c);
        }
    }
    if(mc==INF){
        cout<<"TLE"<<endl;
    }else cout<<mc<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 int main()
 {
     int a,b,c,d,e,f,g,h,i,j;
     cin>>a;
     int ar[a];
     vector<int>v;
     vector<int>v1;
     for(i=0;i<a;i++)
     {
         cin>>c;
         if((i+1)%2==0)
         {
             v.push_back(c);
         }
         else{
            v1.push_back(c);
         }
     }
     if(a%2==0)
     {
     reverse(v.begin(),v.end());
         for(i=0;i<v.size();i++)
         {
             cout<<v[i]<<" ";
         }
         for(i=0;i<v1.size();i++)
         {
             cout<<v1[i]<<" ";
         }
        cout<<endl;
     }
     else{
     reverse(v1.begin(),v1.end());
        for(i=0;i<v1.size();i++)
        {
            cout<<v1[i]<<" ";
        }
        for(i=0;i<v.size();i++)
        {
            cout<<v[i]<<" ";
        }
        cout<<endl;
     }
     return 0;
 }


Measured memory_bytes: 3188
import heapq
n, m = (int(x) for x in input().split())
A = [-int(x) for x in input().split()]
heapq.heapify(A)
for i in range(m):
  a = (-1)*heapq.heappop(A)
  a //= 2
  heapq.heappush(A, -a)
print(-sum(A))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size() + 1;
  V<> l(n - 1);
  for (int i = 0; i < n - 1; ++i) {
    if (s[i] == '<') {
      l[i] = (i ? l[i - 1] : 0) + 1;
    }
  }
  V<> r(n - 1);
  for (int i = n - 2; i >= 0; --i) {
    if (s[i] == '>') {
      r[i] = 1 + (i < n - 2 ? r[i + 1] : 0);
    }
  }
  lint res = 0;
  for (int i = 0; i < n; ++i) {
    int crr = 0;
    if (i) {
      crr = max(crr, l[i - 1]);
    }
    if (i < n - 1) {
      crr = max(crr, r[i]);
    }
    res += crr;
  }
  cout << res << '\n';
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
#define ri register int
typedef long long ll;
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// input a letter
	template <class I>
	inline void get (I &x) {
		for (c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		x = c;
	}
	// input a string
	inline void read (char *s){
		for(c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		for(; c >= 'A' && c <= 'Z'; c = gc()) *++s = c;
		*++s = '\0';
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: get;
using io :: read;
using io :: putc;
using io :: print;
const int N=1<<18|1,mod=998244353;
inline int _add(ri x,ri y){
	return (x+=y)>=mod?x-mod:x;
}
inline int _sub(ri x,ri y){
	return (x-=y)<0?x+mod:x;
}
inline int fpow(ri a,ri b){
	ri ans=1;
	for(;b;b>>=1,a=(ll)a*a%mod)
		if(b&1)
			ans=(ll)ans*a%mod;
	return ans;
}
int inv;
inline void fwt_xor(int *a,ri n,ri opt){
	ri i,j,k,p,x,y;
	for(i=1;i<n;i<<=1)
		for(p=i<<1,j=0;j<n;j+=p)
			for(k=0;k<i;++k){
				int *b=a+j+k;
				x=_add(b[0],b[i]);
				y=_sub(b[0],b[i]);
				b[0]=x;b[i]=y;
			}
	if(opt==-1)
		for(i=0;i<n;++i)
			a[i]=(ll)a[i]*inv%mod;
}
int a[N],b[N];
int main(){
	ri n,m,i,s;
	gi(n);
	m=1<<n;
	inv=fpow(m,mod-2);
	s=0;
	for(i=0;i^m;++i) gi(a[i]),s+=a[i];
	s=fpow(s,mod-2);
	for(i=0;i^m;++i) a[i]=(ll)a[i]*s%mod;
	a[0]=_sub(a[0],1);
	b[0]=m-1;
	for(i=1;i^m;++i) b[i]=mod-1;
	fwt_xor(a,m,1);
	fwt_xor(b,m,1);
	for(i=0;i^m;++i) b[i]=(ll)b[i]*fpow(a[i],mod-2)%mod;
	fwt_xor(b,m,-1);
	for(i=0;i^m;++i) print(_sub(b[i],b[0])),putc('\n');
	return 0;
}

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

#define ll long long int

int main(){
ll a,b,k;cin>>a>>b>>k;
if(a>=k)
  cout<<a-k<<" "<<b<<endl;
else
{
  if(b>=(k-a))
    cout<<"0"<<" "<<b-k+a;
  else
  {
     cout<<"0"<<" "<<"0"<<endl;
  }  
}
}

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

ll numTastyCookies(ll a, ll b, ll c){
	ll res = 0;
	ll min_ca = min(a,c);
	res += min_ca;
	a -= min_ca;
	c -= min_ca;
	if(c > 0){
		ll min_cb = min(c,b);
		res += 2*min_cb;
		c -= min_cb;
		b -= min_cb;
	}
	res += b;
	if(c > 0){
		res += 1;
	}
	return res;
}

int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  cout<<numTastyCookies(a,b,c)<<endl;
  return 0;
}


Measured memory_bytes: 256
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
#define exist_in(list, value) (list.end() != std::find(all(list),value))
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
//template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
//template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
//template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
//template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
//template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }
//template<class T1, class T2> bool exist_in(const T1& list, const T2& v) { return (list.end() != std::find(list.begin(), list.end(), v)); }
//template<class T> bool exist_in(const T& c, const typename T::value_type& v) {	return (c.end() != std::find(c.begin(), c.end(), v));}

/*****/

void Main()
{
	string s;
	cin >> s;
	int cnt = 0;
	rep(i, 3)
	{
		if (s[i] == '1')
			cnt++;
	}
	cout << cnt;
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256
s = input()

s = list(s)

test = 0

for i in range(len(s)):
	if i%2 == 0:
		if s[i]=='L':
			test = test + 1
			#print(i)
		
	else:
		if s[i]=='R':
			test = test + 1
			#print(i)

print('Yes' if test == 0 else 'No')


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

t = [(i,val) for i, val in enumerate(a)]
#print(t)
sorted_tup = sorted(t, key=lambda x: x[1])
#print(sorted_tup)
for tup in sorted_tup:
  print(tup[0]+1, end=' ')

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

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);

		int price = sc.nextInt();
		int k = sc.nextInt();

		boolean[] use = new boolean[11];
		Arrays.fill(use, true);

		for (int i = 0; i < k; i++) {
			use[sc.nextInt()] = false;
		}

		for (int i = price; i <= price * 10; i++) {
			boolean f = true;
			int p = i;
			while (p > 0) {
				if (!use[p % 10]) {
					f = false;
					break;
				}
				p /= 10;
			}
			if (f) {
				System.out.println(i);
				return;
			}
		}

	}

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

}


Measured memory_bytes: 8916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  int n, d, x;
  cin >> n >> d >> x;
  vec1 a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
    a.at(i)++;
  }
  int c = n;
  for(int i = 0; i < n; i++) {
    int tmp = a.at(i);
    for(int j = 0; j < d; j++) {
      if(tmp <= d) {
        c++;
        tmp = tmp + (a.at(i)-1);
      } else {
        break;
      }
    }
  }
  int ans = c + x;
  cout << ans << endl;
}
  

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

ll tableF[200010];
ll tableI[200010];

ll modfact(ll a,ll m){
   if(tableF[a] != -1){
      return tableF[a];
   }
   if(a == 1){
      tableF[a] = 1;
      return tableF[a];
   }
   ll res = 1;
   res = a * modfact(a-1,m);
   res %= m;
   tableF[a] = res;
   return res;
}

ll modpow(ll a,ll n,ll m){//modpow(a,n,m) := a ^ n (mod m)
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a,ll p){//modinv(a,p) := pを法とするaの逆元(※pは素数でなければならない)
    ll res = modpow(a,p-2,p);
    return res;
}

ll modCON(ll n,ll r,ll m){
   if(n < 200010){
   ll res = 1;
   if(n == 0 || r == 0){
      return 1;
   }
   res *= tableF[n];
   res %= m;
   res *= tableI[r];
   res %= m;
   res *= tableI[n-r];
   res %= m;
   return res;
   }else{
   ll res = 1;//tableを持ってないときよう
   for(int i = 1;i <= n;i++){
      res *= i;
      res %= m;
   }
   for(int i = 1;i <= r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   for(int i = 1;i <= n-r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   return res;
   }
}

void modfill(ll m){//忘れない　約300ms
   fill(tableF,tableF+200010,-1);
   fill(tableI,tableI+200010,-1);
   tableF[0] = 1;
   tableI[0] = 1;
   for(int i = 1;i < 200010;i++){
      tableF[i] = modfact(i,m);
      tableI[i] = modinv(tableF[i],m);
   }
}


int main(){
  string S;cin >> S;
  int N = S.size();
  int ans = 0;
  int p = 0,g = 0;
  for(int i = 0;i < N;i++){
    if(S[i] == 'g'){
      if(g > p){
        p++;
        ans++;
      }else{
        g++;
      }
    }else{
      if(g > p){
        p++;
      }else{
        g++;
        ans--;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512