akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
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 (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W, N; cin >> H >> W >> N;
	int sr, sc; cin >> sr >> sc;
	sr--, sc--;
	string S, T; cin >> S >> T;

	bool yes = true;
	{
		int l = 0, r = W;
		rrep(i, 0, N) {
			dump(l, r);
			if (T[i] == 'L')r = min(W, r + 1);
			if (T[i] == 'R')l = max(0LL, l - 1);
			if (S[i] == 'L')l++;
			if (S[i] == 'R')r--;
			if (l == r)yes = false;
		}
		dump(l, r);
		yes &= (l <= sc && sc < r);
	}
	{
		int l = 0, r = H;
		rrep(i, 0, N) {
			dump(l, r);
			if (T[i] == 'U')r = min(H, r + 1);
			if (T[i] == 'D')l = max(0LL, l - 1); 
			if (S[i] == 'U')l++;
			if (S[i] == 'D')r--;
			if (l == r)yes = false;
		}
		dump(l, r);
		yes &= (l <= sr && sr < r);
	}

	cout << (yes ? "YES" : "NO") << endl;


	return 0;
}

Measured memory_bytes: 920
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.TreeMap;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            TreeMap<Long, Long> qty = new TreeMap<>();
            qty.put(in.nextLong(), 1L);
            long ans = 0;
            while (!qty.isEmpty()) {
                long curH = qty.firstKey();
                long curQty = qty.get(curH);
                ans += curQty;
                qty.remove(curH);
                curQty *= 2;
                curH /= 2;
                if (curH > 0) {
                    qty.put(curH, curQty);
                }
            }
            out.println(ans);
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 21716
int H[100010];
int ng[100010];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",H+i);
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		if(H[a]<=H[b])ng[a]=1;
		if(H[a]>=H[b])ng[b]=1;
	}
	int ans=0;
	for(int i=1;i<=n;i++)if(!ng[i])ans++;
	printf("%d\n",ans);
}

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

using namespace std;
#define pb push_back
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef set<char> setc;
typedef set<int> seti;
map<char,int> mp;
void solve(){
	//write solution here
	int n;
	cin>>n;
	map<char,int> mp[n];
	map<char,int> maxim;
	for(int i = 0; i < n; i++){
		string s;
		cin>>s;
		for(int j = 0; j < s.length(); j++){
			mp[i][s[j]] += 1;
		}
	}
	vi counts(26);
	for(int i = 0; i < 26; i++){
		int minim = 10000;
		char ch = 'a'+i;
		for(int j = 0; j < n; j++){
			int p = mp[j]['a'+i];
			if(minim>p) minim = p;
		}
		for(int i = 0; i < minim; i++){
			cout<<ch;
		}
	}
	cout<<endl;
}

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

Measured memory_bytes: 3692
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N, D, A;
	cin >> N >> D >> A;
	pair<int, int> XH[200001];
	rep(i, N) {
		cin >> XH[i].first >> XH[i].second;
	}
	XH[N] = mp(21e8, 2e9);
	sort(XH, XH + N);

	ll imos[200001] = {};
	ll ima = 0;
	ll kotae = 0;

	rep(i, N) {
		ima += imos[i];
		int nokori = XH[i].second - ima;
		if (nokori > 0) {
			ll kaisuu = (nokori + A - 1) / A;

			int k = lower_bound(XH, XH + N, mp(XH[i].first + min(1000000000, 2 * D) + 1, 0)) - XH;
			ima += kaisuu * A;
			imos[k] -= kaisuu * A;
			kotae += kaisuu;
		}
	}

	co(kotae);



	Would you please return 0;
}

Measured memory_bytes: 3328
use std::io;

fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

fn main(){
    let line = read_line();
    let split : Vec<&str> = line.trim().split(' ').collect();
    let n : i32= split[0].parse().unwrap();
        
    if ((n/10)%111==0) || ((n%1000)%111==0){
        println!("Yes");
    }else{
        println!("No");
    }
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
def main():
    A,B=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
    flag = 0
    if A <= -1:
        flag = 1
    if A >= 10:
        flag = 1
    if B <= -1:
        flag = 1
    if B >= 10:
        flag = 1
    if flag == 1:
        print("-1")
    else:
        print(A * B)

if __name__ == '__main__':
    main()


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

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

#define INF (1e9)

int A, B, C;

int main() {
    cin >> A >> B >> C;

    int ans;
    ans = min(B / A, C);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define rep(i,n) for (int i = 0; i < n; i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;

ll merge_cnt(vector<int> &a) {
	int n = a.size();
	if (n <= 1) { return 0; }

	ll cnt = 0;
	vector<int> b(a.begin(), a.begin() + n / 2);
	vector<int> c(a.begin() + n / 2, a.end());

	cnt += merge_cnt(b);
	cnt += merge_cnt(c);

	int ai = 0, bi = 0, ci = 0;
	while (ai < n) {
		if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) {
			a[ai++] = b[bi++];
		}
		else {
			cnt += n / 2 - bi;
			a[ai++] = c[ci++];
		}
	}
	return cnt;
}

int n; vector<int> a;

ll cnt2(int x) {
	vector<int> b(n + 1, 0);
	rep(i, n) b[i + 1] = b[i] + (a[i] >= x ? 1 : -1);
	return merge_cnt(b);
}

int main() {
	cin >> n;
	a.resize(n);
	rep(i, n) cin >> a[i];
	int l = 1, r = 1e9+1;
	ll over = (ll)(n) * (ll)(n + 1) / 2 / 2 + 1;
	while (abs(l - r) > 1) {
		int mid = (l + r) / 2;
		if (cnt2(mid) >= over) r = mid;
		else l = mid;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 1864
{-# LANGUAGE FlexibleContexts #-}

module Main where

import Debug.Trace
import Data.List
import qualified Data.Set as Set
import qualified Data.Sequence as Seq
import qualified Data.ByteString.Char8 as B
import Data.Int
import Data.Word
import Data.Char
import Data.Bits
import Data.Array
-- import Data.Array.Unboxed
-- import Data.Array.IO
import Data.Maybe
-- import qualified Data.Map as M
import qualified Data.IntMap as M
-- import Control.Monad.ST
-- import Data.STRef
import Data.Ord
import Data.Functor
import Control.Applicative
import Control.Monad
import Text.Printf

size = 3 
sqSize = size*size
maxAdr = sqSize -1
mask = 0xF
shiftSize = 4
shiftTimes= 16

solver :: [[Int]] -> Int
solver lst
    | start == goal = 0
    | otherwise = iter (initialQueue, initialVisited) where
        iter (que, visited) = case Seq.viewr que of
            Seq.EmptyR -> error "No path found."
            que Seq.:> path@(board, distance, forward) -> case next path visited of
                (_, Just d)  -> distance + d +1
                (nextPaths, Nothing) -> iter (insertPaths que visited nextPaths) where
                    insertPaths q v [] = (q, v)
                    insertPaths q v (p@(x, d, f):ps) = insertPaths insertQue insertVisited ps where
                        insertQue = p Seq.<| q
                        insertVisited = M.insert x (d, f) v
        next path@(board, distance, forward) visited = iter [] Nothing nextBoards where
            iter ac af [] = (ac, af)
            iter ac af (x:xs) = case M.lookup x visited of
                Nothing -> iter ((x, distance+1, forward):ac) af xs
                Just (d', f') -> if forward == f' then iter ac af xs else (ac, Just d')
            boards = [swapWith (valueAt p board) board | p <- dest!(searchZero board)]
            nextBoards = [x| x <- boards]

        initialQueue = (goal, 0, False) Seq.<| (Seq.singleton (start, 0, True))
        initialVisited = M.insert goal (0, False) $ M.singleton start (0, True)
        goal    = toBits [1,2,3,4,5,6,7,8,0]
        start   = toBits $ concat lst
        dest    = listArray (0, maxAdr) [[1,3],[0,2,4],[1,5],[0,4,6],[1,3,5,7],[2,4,8],[3,7],[4,6,8],[5,7]]
        toBits = foldl' (\b a-> shiftL b shiftSize .|. a) 0
        valueAt i w = mask .&. shiftR w (shiftSize*i)

searchZero :: Int -> Int
searchZero = iter 0 where
    iter c w = case mask .&. w of 
        hb  | hb == 0 -> c
            | otherwise -> iter (c+1) (rotateR w shiftSize)

swapWith :: Int -> Int -> Int
swapWith v = iter sqSize where
    iter 0 w = rotateR w (shiftSize*(shiftTimes-sqSize))
    iter c w = iter (c-1) $ rotateR (case mask .&. w of
        hb  | hb == 0 -> w .|. v
            | hb == v -> w `xor` v
            | otherwise -> w) shiftSize

readIntLn:: IO Int
readIntLn = (fst . fromJust . B.readInt) <$> B.getLine

readIntList:: IO [Int]
readIntList = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

main :: IO() 
main = do
    l <- replicateM size readIntList
    print $ solver l



Measured memory_bytes: 8720
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    H,W,D=pin()
    precal_magicalresource=[]#D series
    places_num=[None]*(H*W+1)
    for h in range(1,H+1):
        temp=tupin()
        for w in range(1,W+1):
            places_num[temp[w-1]]=(h,w)
    places_num[0]=(0,0)
    #print(places_num)

    for d in range(D):#about Li%D
        d_mag=[]
        d_mag.append(0)
        temp=places_num[d]
        p=0
        while(1):
            d+=D
            if d>H*W:break
        
            s=abs(temp[0]-places_num[d][0])
            t=abs(temp[1]-places_num[d][1])
            p+=s+t
            d_mag.append((p))
            temp=places_num[d]
        precal_magicalresource.append(d_mag)
        #print(precal_magicalresource)
    Q=int(input())    
    for q in range(Q):
        l,r=pin()
        lm=l%D
        rd=r//D
        ld=l//D
        print(precal_magicalresource[lm][rd]-precal_magicalresource[lm][ld])
#%%submit!
resolve()

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

int main(){

  int n,min=1000,ans=0;
  int s[110];

  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> s[i];
    ans += s[i];
    if(s[i] % 10 != 0 && min > s[i]) min = s[i];
  }
  if(ans % 10){
    cout << ans << endl;
  }else{
    if(min == 1000){
      cout << "0" << endl;
    }else{
      cout << ans - min << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes) if b else print(no)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
n=n0()
a=[0]
a.extend(n1())

b=[0]
b.extend(n1())
c=[0]
c.extend(n1())

ans=0
for i in range(1,n+1):
    ans+=b[a[i]]
    if i<n:
        if a[i]+1==a[i+1]:
            ans+=c[a[i]]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>  
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N =  1e5 + 10;  
#define FI first
#define SE second
typedef pair<int, int>pii;
 
int main()  
{  
  // freopen("in.txt","r",stdin);
	string s;
	while (cin >> s)
	{
		set<char>S;
		for (int i = 0; i < s.size(); i++)
			S.insert(s[i]);
		printf("%s\n", S.size() == s.size()?"yes":"no");

	}   
   return 0;  
}  

Measured memory_bytes: 256
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

a = LIST()
for i in range(5):
    if a[i] == 0:
        print(i+1)
        sys.exit()

Measured memory_bytes: 72556
def assign(s, n, k, c):
    res = []
    i = 0
    while k > 0 and i < n:
        if s[i] == 'o':
            res.append(i)
            k -= 1
            i += c
        i += 1
    return res


n, k, c = map(int, input().split())
s = input()
a = assign(s, n, k, c)
b = assign(s[::-1], n, k, c)[::-1]
c = [n-x-1 for x in b]

for x, y in zip(a, c):
    if x == y:
        print(x + 1)


Measured memory_bytes: 33032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

ll mod = 1e9+7;

const int N = 5000000;
ll f[N], inv_f[N];

inline ll mod_pow(ll x, ll n)
{
    ll r = 1;
    while(n)
    {
        if(n&1) (r*=x)%=mod;
        (x*=x)%=mod;
        n>>=1;
    }
    return r;
}

inline ll mod_inv(ll x)
{
    return mod_pow(x,mod-2);
}


inline ll C(int n, int r)
{
    if(n<0 || r<0 || n-r<0) return 0;
    ll ret = f[n];
    (ret*=inv_f[r])%=mod;
    (ret*=inv_f[n-r])%=mod;
    return ret;
}

inline ll H(int n, int r)
{
    if(n==0 && r==0) return 1;
    return C(n+r-1,r);
}

int main()
{
    f[0]=1;
    for(int i=1; i<N; ++i) f[i]=(f[i-1]*i)%mod;

    inv_f[N-1] = mod_inv(f[N-1]);
    for(int i=N-2; i>=0; --i) inv_f[i] = (inv_f[i+1]*(i+1))%mod;

    int a,b,c,sx,sy;
    while(cin >>a >>b >>c >>sx >>sy)
    {
        if(a+b+c+sx+sy==0) break;
        ll ans = 0;
        rep(i,sx+1)
        {
            ll add = 1;
            int j = sy-sx+i;
            (add*=H(a,i-a))%=mod;
            (add*=H(b,j-b))%=mod;
            (add*=H(a+b+c,sx-i))%=mod;

            (ans += add)%=mod;
        }
        (ans*=C(a+b+c,a))%=mod;
        (ans*=C(b+c,b))%=mod;
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 81208
#include <iostream>
using namespace std;
struct node{
	int key;
	node *left = NULL;
	node *right = NULL;
	node(int k, node*l = NULL, node*r = NULL) : key(k), left(l), right(r) {}
};
node *Tree;

void insert(node z)
{
	node *y = NULL;
	node *x = Tree;
	while(x != NULL){
		y = x;
		if(z.key < x->key)
			x = x->left;
		else
			x = x->right;
	}
	if(y == NULL)
		Tree = new node(z.key);
	else if(z.key < y->key)
		y->left = new node(z.key);
	else
		y->right = new node(z.key);
}

void midprint(node *root)
{
	if(root == NULL) return;
	midprint(root->left);
	cout << " " << root->key;
	midprint(root->right);
}

void preprint(node *root)
{
	if(root == NULL) return;
	cout << " " << root->key ;
	preprint(root->left);
	preprint(root->right);
}


void print(node *root)
{
	midprint(root);
	cout << endl;
	preprint(root);
	cout << endl;
}

int main()
{
	int n;
	cin >> n;
	while(n--){
		string s;
		cin >> s;
		if(s[0] == 'i'){
			int k;
			cin >> k;
			node leaf(k);
			insert(leaf);
		}
		else if(s[0] == 'p')
			print(Tree);
	}
	return 0;
}

Measured memory_bytes: 18724
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,mx=0,cnt=0;
    string s;
    cin>>s;
    for(i=0; i<3; i++)
    {
        if(s[i]=='R')
            cnt++;
        if(s[i]!='R' || i==2)
        {
            if(cnt>=mx)
                mx=cnt;
            cnt=0;
        }
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	cin>>n>>s;
	int E[300009]={},W[300009]={};
	for(int i=1;i<=n;i++){
		W[i]=W[i-1];
		if(s[i-1]=='W') W[i]++;
	}
	for(int i=n;i>=1;i--){
		E[i]=E[i+1];
		if(s[i-1]=='E') E[i]++;
	}
	int ans=n;
	for(int i=1;i<=n;i++){
		ans=min(ans,W[i-1]+E[i+1]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 2948
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int n,q; cin >> n >> q;
    vector<int>a(n);
    rep(i,n) cin>>a[i];
    vector<int> l(q),r(q),id(q);
    rep(i,q){
        id[i]=i;
        cin >> l[i] >> r[i];
        l[i]--;
    }
    sort(id.begin(), id.end(),[&](int i,int j) {return r[i]<r[j];});
    BIT<int> bit(n+5);
    vector<int> pre(1001001, -1);
    vector<int> res(q,0);
    int idx=0;
    for(auto i:id){
        for (;idx<r[i];idx++){
            bit.add(pre[a[idx]]+2,idx+2,1);
            pre[a[idx]]=idx;
        }
        int resp=bit.sum(l[i]+1,l[i]+2);
        chmax(res[i],resp);
    }
    rep(i,q)cout<<res[i]<<endl;
}


Measured memory_bytes: 21348
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
	int r, d, x;
	scanf("%d%d%d", &r, &d, &x);
	rep(i, 10) {
		printf("%d\n", r * x - d);
		x = r * x - d;
	}
	return 0;
}

Measured memory_bytes: 3756
#include<stdio.h>
#define MAX 200000

int max(int,int);
int min(int,int);

int main(){
int R[MAX],n,i;

scanf("%d", &n);
 for ( i = 0; i < n; i++ ){
   scanf("%d", &R[i]);
 }

 int maxv=-2000000000;
 int minv=R[0];

 for ( i = 1; i < n; i++ ){
   maxv=max(maxv,R[i]-minv);
   minv=min(minv,R[i]);
 }
 printf("%d\n",maxv);

 return 0;
}


int max(int x, int y) {
  if ( x > y ) {
    return x;
  } else {
    return y;
  }
}

int min(int x, int y) {
  if ( x < y ) {
    return x;
  } else {
    return y;
  }
}

Measured memory_bytes: 1376
N,X,Y = map(int,input().split())
D= [0]*(N-1)

# print(X,Y)
for i in range(1,N+1):
    for j in range(i+1,N+1): # i<j
        # print((i,j))
        # ver 1
        if j<=X or Y<=i:
            d = j-i
            
        # ver 2
        elif i<=X and Y<=j:
            d = X-i + 1 + j-Y
            
        # ver 3
        else:
            d = min(j-i,abs(X-i)+abs(Y-j)+1)
        # print(d)
        D[d-1] += 1
# print(D)

for d in D:
    print(d)

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

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n * n + 1);
    std::map<int, int> pos;
    for (int i = 1; i <= n; i++) {
        int t;
        std::cin >> t;
        pos[t] = i;
        a[t] = i;
    }
    
    auto it = a.begin() + 1;
    // auto bit = a.end() - 1;
    for (auto& el : pos) {
        auto cpos = el.first;
        auto cval = el.second;
        for (int i = 0; i < cval - 1; i++) {
            while (*it && it != a.end()) it++;
            if (it - a.begin() > cpos) {
                std::cout << "No" << std::endl;
                return 0;
            }
            *it = cval;
        }
    }

    it = a.end() - 1;
    for (auto el = pos.rbegin(); el != pos.rend(); el++) {
        auto cpos = el->first;
        auto cval = el->second;
        for (int i = 0; i < n - cval; i++) {
            while (*it && it != a.begin()) it--;
            if (it - a.begin() < cpos) {
                std::cout << "No" << std::endl;
                return 0;
            }
            *it = cval;
        }
    }

    std::cout << "Yes\n";
    for (int i = 1; i <= n * n; i++) std::cout << a[i] << " ";
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  if (a > b) {
    swap(a, b);
  }
  cout << (c + b - 1) / b << '\n';
} 

Measured memory_bytes: 3592
S=int(input())
A=S//100
B=S-100*A
if A<=12 and A!=0:
    if B<=12  and B!=0:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif B<=12 and B!=0:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include <iomanip>

using namespace std;

using LL=long long;

double a, b, x,y,xx;

double res;

const double p = 3.14159265358979323846;

int main() {

	cin >> a >> b >> x;

	if (x <= a * a * b / 2) {
		y = b;
		xx = x;
	}
	else {
		y = 2 * (b - x / a / a);
		xx = x - (b - y) * a * a;
	}

	res = 180 * atan(a * y * y / xx / 2) / p;

	if (a * a * b > x) {
		cout << fixed << setprecision(10) << res << endl;
	}
	else
		cout << 0 << endl;

	return 0;

}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
	int H, W, i, j;
	
	while(1){
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0){
			break;
		}
		for(i = 0;i < H;i++){
			for(j = 0;j < W;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int n,m,q;
vector<vector<int>> queries;
ll max_point = 0;

ll calc_point(vector<int> &lst){
    ll point = 0;
    rep(i,q){
        int a = queries.at(i).at(0)-1;
        int b = queries.at(i).at(1)-1;
        int c = queries.at(i).at(2);
        int d = queries.at(i).at(3);
        if(lst.at(b) - lst.at(a) == c){
            point += d;
        }
    }
    max_point = max(max_point, point);
    return point;
}

// N個の数列を全列挙
// a[i] <= a[i+1]
// a[i] = 1-m
void dfs(vector<int> lst, int i){
    if(i==n){
        // rep(j,lst.size()) cout << lst.at(j) << " ";
        // cout << endl;
        calc_point(lst);
        return;
    }

    int st;
    if(i==0){
        st = 1;
    }else {
        st = lst.at(i-1);
    }
    for(int j=st;j<=m;j++){
        lst.at(i) = j;
        dfs(lst, i+1);
    }
}

int main(){
    cin >> n >> m >> q;
    rep(i,q){
        vector<int> qrow(4);
        rep(j,4) cin >> qrow.at(j);
        queries.push_back(qrow);
    }
    vector<int> a(n);
    a[0] = 1;
    dfs(a,0);
    cout << max_point << endl;
    return 0;
} 

Measured memory_bytes: 3596
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1000000000
#define LLINF 1145141919810LL
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

signed main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, K; cin >> N >> K;
  int ans = 0;
  for(int b = K+1; b <= N; b++){
    int times = (N+1) / b, rem = (N+1) % b;
    ans += max(0LL, b-K) * times + max(0LL, rem-K);
  }
  cout << (K==0 ? ans-(N-K) : ans) << endl;
}

Measured memory_bytes: 256
def main():
    s = input()

    def kaibun(seq):
        l = len(seq)
        for i in range(l//2):
            if seq[i] != seq[-i-1]:
                return False
        return True
    n = len(s)
    if kaibun(s) and kaibun(s[:(n-1)//2]) and kaibun(s[(n+3)//2-1:]):
        print("Yes")
    else:
        print("No")


main()

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>



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


map<string, int> mp;
#define ll long long

int main() {
    string x;
    cin >> x;
    int ans = x.size();
    int sc = 0;
    rep(i, x.size()) {
        if (x[i] == 'S')sc++;
        else if (x[i] == 'T'&&sc > 0) {
            ans -= 2;
            sc--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main() {

	int x;
	int h;
	int m;
	int s;

	scanf( "%d" , &x );
	h = x/3600;
	m = x/60 %60;
	s = x%60;

	printf( "%d:%d:%d\n" , h , m , s );
	return 0 ;

}


Measured memory_bytes: 2740
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int fee = 0;

		if(A<=5) {
			fee = 0;
		}if(6<=A && A<=12) {
			fee = B/2;
		}if(13<=A) {
			fee = B;
		}

		System.out.println(fee);
	}

}


Measured memory_bytes: 20948
#include <stdio.h>

main()
{
	int   a,b,mawari,menseki;
	
	scanf("%d %d" , &a, &b);
	mawari=a+a+b+b;
	menseki=a*b;
	printf("%d %d\n",menseki,mawari);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

vector<long long> fact(100001,1);
void factorial(int N){
    for(int i=1; i<N; i++){
        fact[i+1]=(i+1)*fact[i]%MOD;
    }
}

map<long long, long long> inv_fact;
long long inv_factorial(long long x){
    if (inv_fact.count(x)){
        return inv_fact[x];
    }
    long long p=MOD-2;
    long long ret=1;
    long long tmp=x;
    while(p>0){
        if(p%2==1)ret=ret*tmp%MOD;
        tmp=tmp*tmp%MOD;
        p/=2;
    }
    inv_fact[x]=ret;
    return ret;
}

vector<ll> harmonic(int N){
    vector<ll> ret(1,0);
    for(int i=0; i<N; i++){
        ret.push_back(ret[i]+inv_factorial(i+1));
        ret[i+1]%=MOD;
    }
    return ret;
}

int main(){
    int N;
    cin >> N;
    vector<ll> slime(N,0);
    for(auto &x:slime){
        cin >> x;
    }

    factorial(100000);
    vector<ll> hm=harmonic(100000);

    ll ans=0;
    for(int i=1; i<N; i++){
        ans+=(slime[i]-slime[i-1])*hm[i];
        ans%=MOD;
        //cout << ans << endl;
    }
    ans*=fact[N-1];
    ans%=MOD;
    cout << ans << endl;
}

Measured memory_bytes: 8820
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int H,W;cin>>H>>W;
    vector<string> s(H);
    REP(i,H) cin>>s[i];
    using P=pair<int,int>;
    vector<vector<P>> graph(H*W);
    int dx[]={1,0},dy[]={0,1};
    REP(i,H) REP(j,W){
        REP(k,2){
            int nx=dx[k]+i, ny=dy[k]+j;
            if(0<=nx&&nx<H&&0<=ny&&ny<W){
                if(s[i][j]==s[nx][ny]||s[i][j]=='#') graph[i*W+j].push_back(P(0,nx*W+ny));
                else graph[i*W+j].push_back(P(1,nx*W+ny));
            }
        }
    }
    vector<ll> dist(H*W,1LL<<50);
    priority_queue<P,vector<P>,greater<>> que;
    dist[0]=0;
    if(s[0][0]=='#') dist[0]++;
    que.push(P(dist[0],0));
    while(!que.empty()){
        P p=que.top();que.pop();
        int u=p.second;
        if(dist[u]<p.first) continue;
        REP(j,graph[u].size()){
            int v=graph[u][j].second;
            ll alt=dist[u]+graph[u][j].first;
            if(dist[v]>alt){
                dist[v]=alt;
                que.push(P(alt,v));
            }
        }
    }
    cout<<dist[H*W-1]<<endl;
}


Measured memory_bytes: 896
from itertools import product

N, M = map(int, input().split())
XYZ = [tuple(map(int, input().split())) for _ in range(N)]

ans = -10**18
for sign in product((1, -1), repeat=3):
    S = [0, 0, 0]
    for xyz in sorted(XYZ, key=lambda xyz: sum(a * s for a, s in zip(xyz, sign)), reverse=True)[:M]:
        for i, (a, s) in enumerate(zip(xyz, sign)):
            S[i] += a * s
    ans = max(ans, sum(abs(a) for a in S))
print(ans)


Measured memory_bytes: 3276
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]
total = 0
pre = 0

for i in a:
    total += abs(i-pre)
    pre = i

for i in range(1, len(a)-1):
    print(total + abs(a[i+1]-a[i-1]) - abs(a[i]-a[i+1]) - abs(a[i]-a[i-1]))


Measured memory_bytes: 20400
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
    int n;
    scanf("%d", &n);

    char c[n];
    scanf("%s", c);

    int left[26], right[26];    // 左右それぞれの各文字の個数
    for (int i = 0; i < 26; i++) {
        left[i] = right[i] = 0;
    }

    for (int i = 0; i < n; i++) {
        int index = c[i] - 'a';
        right[index]++;
    }

    int numCommon = 0, ans = 0;
    for (int i = 0; i < n; i++) {   // 切断位置をiとi+1の間とする
        int index = c[i] - 'a';
        right[index]--;
        if (left[index] == 0 && right[index] > 0) { // 左が0→1, 右がk+1→k(k>0)のとき共通の文字が増加
            numCommon++;
            ans = max(ans, numCommon);
        } else if (left[index] > 0 && right[index] == 0) {  // 左がk→k+1(k>0), 右が1→0のとき減少
            numCommon--;
        }
        left[index]++;
    }

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        if (a == b) {
            System.out.println(c);
        } else {
            if (a == c) {
                System.out.println(b);
            } else {
                System.out.println(a);
            }
        }
        scanner.close();
    }
}


Measured memory_bytes: 22100
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  ll N;

  cin >> N;

  vector<ll> as(N, 0);
  vector<ll> bs(N, 0);
  vector<ll> cs(N, 0);

  for (int i = 0; i < N; i++) {
    cin >> as[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> bs[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> cs[i];
  }

  sort(as.begin(), as.end());
  sort(bs.begin(), bs.end());
  sort(cs.begin(), cs.end());

  vector<ll> amap(N + 1, 0);
  vector<ll> bmap(N + 1, 0);

  ll acc = 0;
  int bidx = N - 1;
  for (int i = N - 1; i >= 0; i--) {
    if (bs[bidx] < cs[i])
      acc++;
    else {
      bmap[bidx] = acc;
      bidx--;
      i++;
      if (bidx < 0) break;
    }
  }
  while(bidx >= 0){
    bmap[bidx] = acc;
    bidx--;
  }

  ll acc2 = 0;
  int aidx = N - 1;
  for (int i = N - 1; i >= 0; i--) {
    if (as[aidx] < bs[i])
      acc2 += bmap[i];
    else {
      amap[aidx] = acc2;
      aidx--;
      i++;
      if (aidx < 0) break;
    }
  }
  while(aidx >= 0){
    amap[aidx] = acc2;
    aidx--;
  }

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ans += amap[i];
  }

  cout << ans << endl;  

  return 0;
}


Measured memory_bytes: 4224
//
// Created on 2020/06/21.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;

int main() {
    int n;
    cin>>n;
    vector<int>a(n);
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    int all = a[0];
    for (int j = 1; j < n; ++j) {
        all ^= a[j];
    }
    for (int k = 0; k < n; ++k) {
        int ans = a[k] ^ all;
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 3912
import Control.Monad
import Data.List

f :: Int -> Int -> Int
f l r
    | l < 0 && r < 0 = -l
    | l > 0 && r > 0 = r
    | otherwise = r - l + min r (-l)

main = do
    [n, k]  <- map read . words <$> getLine
    xs <- map read . words <$> getLine
    let l = take (n - k + 1) xs
    let r = drop (k - 1) xs
    print $ foldr min maxBound $ zipWith f l r


Measured memory_bytes: 71036
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> mochi(N);
    rep(i,N){
        cin >> mochi[i];
    }
    sort(all(mochi));
    int count = 1;
    rep(i,N - 1){
        if(mochi[i] < mochi[i + 1]){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        BigDecimal x = scanner.nextBigDecimal();
        BigDecimal y = scanner.nextBigDecimal();

        if (x.subtract(y).abs().compareTo(BigDecimal.ONE) > 0) {
            System.out.println("Alice");
        }
        else {
            System.out.println("Brown");
        }
    }
}



Measured memory_bytes: 25172
N = int(input())
ans = 0
a = N // 100
N -= 100*a
b = N // 10
N -= 10*b
c = N

if max(a, b, c) == a:
    ans = 100*a + 10*a + a
elif max(a, b, c) == b:
    a_ = a + 1
    ans = 100*a_ + 10*a_ + a_
else:
    if a > b:
        ans = 111 * a
    elif a == b:
        a_ = a + 1
        ans = 111 * a_
    else:
        a_ = a + 1
        ans = 100*a_ + 10*a_ + a_

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();

        int[] a = { 1, 2, 3 };

        sc.close();

        if (x == 2) {
            x = 3;
        } else if (x == 4 || x == 6 || x == 9 || x == 11) {
            x = 2;
        } else {
            x = 1;
        }

        if (y == 2) {
            y = 3;
        } else if (y == 4 || y == 6 || y == 9 || y == 11) {
            y = 2;
        } else {
            y = 1;
        }

        if (x == y) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23764
alfa=input().split()
N=int(alfa[0])
X=int(alfa[1])
#L=[int(input().split()) for i in range(N)]
L=input().split()

#print(N,X,L)
D=0
count=1
for i in range(N):
    D+=int(L[i])
    if D>X:
        print(count)
        break
    else:
        count+=1

if D<=X:
    print(count)

Measured memory_bytes: 3060
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
#define pb(X) push_back(X)
#define x first
#define y second
#define all(x) (x).begin(), (x).end()
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
using namespace std;

typedef pair<int, int> pii;

const int INF = 1e9 + 7;
int q;

int main() {
	INIT
	string s;
	cin >> s >> q;
	int f = 0;
	vector<char> l, r;
	while (q--) {
		int t;
		cin >> t;
		if (t == 1) {
			f ^= 1;
		} else {
			int d;
			char c;
			cin >> d >> c;
			if (d == 1) {
				if (f) {
					r.pb(c);
				} else {
					l.pb(c);
				}
			} else {
				if (f) {
					l.pb(c);
				} else {
					r.pb(c);
				}
			}
		}
	//	cout << s << ' ' << f << endl;
	}
	if (f) {
		for (auto it = r.rbegin(); it != r.rend(); ++it) cout << *it;
		for (int i = s.size() - 1; i >= 0; --i) cout << s[i];
		for (auto &it : l) cout << it; 
	} else {
		for (auto it = l.rbegin(); it != l.rend(); ++it) cout << *it;
		cout << s;
		for (auto &it : r) cout << it; 
	}

	return 0;
}

Measured memory_bytes: 976
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	vector<int> index(N + 1);
	for (auto i = 0; i < N; ++i)
	{
		cin >> a[i];
		index[a[i]] = i;
	}

	auto result = 0ll;
	set<int> s;
	for (auto i = 1ll; i <= N; ++i)
	{
		auto j = index[i];
		auto it = s.lower_bound(j);
		auto left = -1;
		auto right = N;
		if (it == s.end())
		{
			if (s.size() > 0)
			{
				--it;
				left = *it;
			}
		}
		else if (it == s.begin())
		{
			right = *it;
		}
		else
		{
			right = *it;
			--it;
			left = *it;
		}

		result += i * (right - j) * (j - left);
		s.insert(j);
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 11136
s = input()
 
kouho = ["dream", "dreamer", "erase", "eraser"]
 
s = s.replace(kouho[3], "").replace(kouho[2], "").replace(kouho[1], "").replace(kouho[0], "")
 
if s == "":
    print("YES")
else:
    print("NO")

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

int distance (int x,int y){
  if (x > y) return x-y;
  else return y-x;
}

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int a_b = distance (a,b);
  int a_c = distance (a,c);
  int b_c = distance (b,c);
  
  if (a_c <= d) cout << "Yes" << endl;
  else if ((((a < b) && (b < c)) || ((a > c) && (b < c))) && ((a_b <= d) && (b_c <= d)))
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))
r = 0
mode = "0"
for i in range(1, N):
  if mode == "-" and As[i] > As[i-1]:
    r += 1
    mode = "0"
  elif mode == "+" and As[i] < As[i-1]:
    r += 1
    mode = "0"
  elif As[i] < As[i-1]:
    mode = "-"
  elif As[i] > As[i-1]:
    mode = "+"
r += 1
print(r)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
vector<vector<ll>> v(1000010);
bool prime(ll num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;

  double sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
    {
      return false;
    }
  }
  return true;
}

int main()
{
ll n ;
cin >> n ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
ll te=a[0];
rep(i,n-1){
  te=__gcd(te,a[i+1]);
}
if(te!=1){
  cout << "not coprime" << endl;
  return 0;
}
rep(i,1000005){
  if(!prime(i))continue;
  for (ll j = i; j < 1000005; j+=i)
  {
    v[j].push_back(i);
  }
  
}
set<ll> s;
rep(i,n){
  rep(j,v[a[i]].size()){
    if(s.find(v[a[i]][j])!=s.end()){
      cout << "setwise coprime" << endl;
      return 0;
    }
    s.insert(v[a[i]][j]);
  }
}
cout << "pairwise coprime" << endl;
return 0;
}

Measured memory_bytes: 81120
#include<bits/stdc++.h>
using namespace std;
vector<int>v[200001],vv;
pair<int,int>p[200001];
int n,x,y,ans[200001];
void dfs1(int x,int pre,pair<int,int>ma)
{
    if(x>ma.second) ma.second=x;
    if(ma.second>ma.first) swap(ma.first,ma.second);
    p[x]=ma;
    for(int i=0;i<v[x].size();i++)
        if(v[x][i]!=pre) dfs1(v[x][i],x,ma);
}
void dfs2(int x,int pre)
{
    vv.push_back(x);
    if(x==1) ans[1]++;
    else
    {
        int l=0,r=vv.size()-1,m;
        while(r-l>1)
        {
            m=l+r>>1;
            int t=vv[m];
            if(p[t].first!=t&&p[t].first==p[x].first||p[t]==p[x]) r=m;
            else l=m;
        }
        ans[vv[r]]++;
    }
    for(int i=0;i<v[x].size();i++)
        if(v[x][i]!=pre) dfs2(v[x][i],x);
    vv.pop_back();
}
void dfs3(int x,int pre)
{
    ans[x]+=ans[pre];
    for(int i=0;i<v[x].size();i++)
        if(v[x][i]!=pre) dfs3(v[x][i],x);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++) scanf("%d%d",&x,&y),v[x].push_back(y),v[y].push_back(x);
    dfs1(1,0,make_pair(0,0));
    dfs2(1,0);
    dfs3(1,0);
    for(int i=2;i<=n;i++) printf(i==n?"%d\n":"%d ",ans[i]-1);
}


Measured memory_bytes: 31352
#include<stdio.h>
using namespace std;

int main(){
    int n;
    scanf("%d", &n);

    while(n){
        if(n%10==7){
            printf("Yes\n");
            return 0;
        }
        else{
            n = n/10;
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

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

    pair<int, int> ans;

    for (int i = -121; i < 122; i++)
    {
        for (int j = -121; j < 122; j++)
        {
            if (pow(i, 5) - pow(j, 5) == x)
            {
                ans.first = i;
                ans.second = j;
                goto end;
            }
        }
    }

end:
    cout << ans.first << " " << ans.second << endl;

    return 0;
}

Measured memory_bytes: 4036
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>

using namespace std;

int main(){
	int a,b;
	while(scanf("%d%d",&a,&b)==2){
		int x=a+b;
		printf("%d\n",x%24);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const double PI = 3.14159265358979323846;

int main() {
  vector<int> abc(3);
  rep(i, 3) cin >> abc[i];
  sort(abc.rbegin(), abc.rend());
  int ans = abc[0] * 10 + abc[1] + abc[2];
  cout << ans << endl;
}

Measured memory_bytes: 3584