akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    C = sorted(zip(A, B))
    ans = 0
    for a, b in C:
        if b >= M:
            return ans + a * M
        ans += a * b
        M -= b
    raise


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    print(solve(N, M, A, B))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 18520
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
n = int(input())
#n, k = map(int, sys.stdin.readline().split())
#s = input()
#p = list(map(int, sys.stdin.readline().split()))

x = [chr(ord('a') + i) for i in range(26)]
ans = []
while (n != 0):
    p = n // 26
    q = n % 26
    ans.append(x[q-1])
    r = (n-1) // 26
    n = r


for i in range(len(ans)):
    print(ans[-i-1], end="")
sys.exit()




















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

using namespace std;

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

    int a, b;
    char c;
    cin >> a >> c >> b;
    if(c == '-')
        cout << a - b;
    else
        cout << a + b;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int n,ans=0;

int main()
{
	scanf("%d",&n);
	int now=0;
	for (int i=1;i<=n;i++) {
		int x; scanf("%d",&x);
		if (x>now) {
			ans+=x-now;
			now=x;
		} else {
			now=x;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import sys


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


def next_int() -> int:
    return int(next_str())


def main() -> None:
    n = next_int()
    a = next_int()
    b = next_int()
    print(max(0, (b - a) * (n - 2) + 1))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
// 一次元リバーシ
#include <iostream>
#include <string>
using namespace std;
string s;
int main(){
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++){
        if(i+1<s.size()&&s[i]!=s[i+1]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}
#ifdef LOCAL
	#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
	#define debug(...) 3
#endif

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using ull = uint64_t; using ld = long double;
using pii = pair<int, int>; using pll = pair<ll, ll>;

// -----------------------------------------------------------------------------

const int N = 1e5 + 5;
int n, l[N], r[N];

void func() {
	cin >> n;
	int max_l = 0, min_r = INT_MAX, max_len = 0;
	for (int i = 0 ; i < n; ++i) {
		cin >> l[i] >> r[i];
		max_l = max(max_l, l[i]);
		min_r = min(min_r, r[i]);
		max_len = max(max_len, r[i] - l[i] + 1);
	}
	int ans = max_len + max(0, min_r - max_l + 1);
	vector<pii> p(n);
	for (int i = 0; i < n; ++i) {
		p[i] = {min_r - l[i] + 1, r[i] - max_l + 1};
	}
	sort(p.begin(), p.end());
	int val = INT_MAX;
	for (int i = 0; i < n - 1; ++i) {
		val = min(val, p[i].second);
		ans = max(ans, p[i + 1].first + val);
	}
	cout << ans << endl;
}

int main() {
	fast_io; cout_precision;
	int t = 1; // cin >> t;
	for (int i = 1; i <= t; ++i) {
		func();
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    for(int i=1; i<=n; ++i){
        if(i*108/100==n){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
}


Measured memory_bytes: 256
#
# abc051 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 2"""
        output = """6"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5 15"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    K, S = map(int, input().split())
    ans = 0
    for i in range(K+1):
        for j in range(K+1):
            if 0 <= S-i-j <= K:
                ans += 1
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16240
#include<stdio.h>
#include<string.h>
int main(void)
{
    int a,b;
    char s1[10],s2[10];

    scanf("%d %d",&a,&b);
    //printf("%d\n",'1');

    for(int i=0;i<a;i++){
        s1[i]=48+b;
    }
    s1[a]='\0';
    for(int i=0;i<b;i++){
        s2[i]=48+a;
    }
    s2[b]='\0';
    if(strcmp(s1,s2)<0){
        printf("%s\n",s1);
    }
    else{
        printf("%s\n",s2);
    }
    return 0;
}

Measured memory_bytes: 128
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 1LL<<60
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 5e5 + 3;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes"); exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No"); exit(0); }
void one() { puts("-1"); exit(0); }

typedef long long i64;

i64 mem[20];

i64 dfs(int l, int r, i64 d) 
{
	if (l >= r)
	{
		return d ? 0 : (l == r ? 10 : 1);
	}
	int t = (10 - d % 10) % 10;
	i64 v = d - t * mem[r - l] + t;
	return ((l ? 10 : 9) - t) * dfs(l + 1, r - 1, llabs(v) / 10);
}

int main()
{
	mem[0] = 1;
	for (int i = 1; i <= 18; ++i) mem[i] = 10 * mem[i - 1];
	int d;
	scanf("%d", &d);
	i64 ans = 0;
	for (int i = 0; i <= 18; ++i)
	{
		ans += dfs(0, i, d);
	}
	printf("%lld\n", ans);
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ri register int
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int rlen=1<<18|1;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read(){
	int ans=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return ans;
}
const int N=4e5+5;
int n,a[N],b[N],_a[N],_b[N];
inline bool check(){
	for(ri i=1;i<=n+1;++i)_a[i]=a[i],_b[i]=b[i];
	sort(_a+1,_a+n+2);
	sort(_b+1,_b+n+2);
	for(ri i=1;i<=n+1;++i)if(_a[i]^_b[i])return 0;
	return 1;
}
int vl[N<<1],sig=0;
inline int Find(int x){return lower_bound(vl+1,vl+sig+1,x)-vl;}
int ft[N<<1];
inline int find(int x){return x^ft[x]?ft[x]=find(ft[x]):x;}
int main(){
	#ifdef ldxcaicai
	freopen("lx.in","r",stdin);
	#endif
	n=read();
	for(ri i=1;i<=n;++i)a[n+1]^=(a[i]=read());
	for(ri i=1;i<=n;++i)b[n+1]^=(b[i]=read());
	if(!check()){
		cout<<-1;
		return 0;
	}
	int res=0;
	vl[++sig]=a[n+1];
	vl[++sig]=b[n+1];
	for(ri i=1;i<=n;++i){
		if(a[i]==b[i])continue;
		vl[++sig]=a[i];
		vl[++sig]=b[i];
		++res;
	}
	if(!res){
		cout<<0;
		return 0;
	}
	sort(vl+1,vl+sig+1),sig=unique(vl+1,vl+sig+1)-vl-1;
	for(ri i=1;i<=sig;++i)ft[i]=i;
	for(ri i=1;i<=n+1;++i){
		if(a[i]==b[i])continue;
		a[i]=find(Find(a[i]));
		b[i]=find(Find(b[i]));
		if(a[i]^b[i])ft[b[i]]=a[i];
	}
	for(ri i=1;i<=sig;++i)if(ft[i]==i)++res;
	cout<<res-1;
	return 0;
}

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

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}
long double d,mi;
long  long op,g,h,v[9999999+100]; 
int k,kk,s,tt,o[9999999-10];
int main()
{
	k=read();
	g=0; op=1;
	for(int i=1;i<=999;++i)v[++tt]=i;
	for(int i=3; i<=17; ++i){
		g=g*10+9; op*=10;
		for(int j=100; j<=999; ++j)v[++tt]=op*j+g;
	}
//	cerr<<v[tt]<<endl; //cerr throw re?
	mi=1e18;
	for(int i=tt; i; --i){
		h=v[i];
		s=0;
		while(h){
			s+=h%10;
			h/=10;
		}//double
		d=(long double)v[i]/s;
		if(d>mi+1e-10)o[i]=1;else mi=d;
	}//int+ll   (ll) ???
	for(int i=1; i<=tt; ++i)if(!o[i]){
		++kk;
		printf("%lld\n",v[i]);
		if(kk==k)return 0; 
	}
}
//999999999999999
//999999999999999

//9999999999999999

Measured memory_bytes: 2304
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		String N = sc.next();
		int answer = 700;
		for(int i = 0; i < N.length(); i++) {
			if(N.charAt(i) == 'o') {
				answer += 100;
			}
		}
		System.out.println(answer);
	}
}

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

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

    int n;
    cin >> n;

    if(n/100 == 7 || n%100/10 == 7 || n%10 == 7) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){
    string N; cin >> N;
    int K; cin >> K;
    int n = N.size();
    vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(2, vector<ll>(105, 0)));
    dp[0][0][0] = 1;
    rep(i,n){
        // 前回の桁の数
        rep(j, 10){

            rep(k,10){
                if (k != 0){
                    dp[i+1][1][j+1] += dp[i][1][j];
                }
                else{
                    dp[i+1][1][j] += dp[i][1][j];
                }
            }

            int num = (N[i] - '0');

            rep(k, num){
                if (k != 0){
                    dp[i+1][1][j+1] += dp[i][0][j];
                }
                else{
                    dp[i+1][1][j] += dp[i][0][j];
                }
            }

            if (num != 0){
                dp[i+1][0][j+1] += dp[i][0][j];
            }
            else{
                dp[i+1][0][j] += dp[i][0][j];
            }
        }
    }

    ll ans = 0;
    ans += (dp[n][0][K]);
    ans += (dp[n][1][K]);
    
    cout << ans << endl;

}

Measured memory_bytes: 384
#include<iostream>

int main(){
	int a,b,c,d,i,n;
	
	while(std::cin>>n){
	i=0;
	for(a=0;a<=9;a++){
		for(b=0;b<=9;b++){
			for(c=0;c<=9;c++){
				for(d=0;d<=9;d++){
					if(a+b+c+d==n){
						i++;
					}
				}
			}
		}
	}
	std::cout<<i<<std::endl;
		}
	return 0;
}

Measured memory_bytes: 1160
def solve():
    c = [[int(i) for i in input().split()] for _ in range(3)]
    for i in range(2):
        for j in range(2):
            if not c[i][j]-c[i+1][j] == c[i][j+1]-c[i+1][j+1]:
                return 'No'
    for i in range(2):
        for j in range(2):
            if not c[i][j]-c[i][j+1] == c[i+1][j]-c[i+1][j+1]:
                return 'No'
    return 'Yes'

if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 3064
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

const int mod = 1e9 + 7;
const int N = 1e4 + 10;
vector <int> a(N);
vector <int> prime(1000000, 0);

long long power(long long res, long long x, long long y) {
	while (y) {
		if (y % 2) {
			res = (res*x) % mod;
		}

		x = (x*x) % mod;
		y >>= 1;
	}

	return res;
}

long long lcm(long long n) {
	return power(1, n, mod - 2);
}

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

	for (int i = 0; i < n; i++)
		cin >> a[i];

	for (int i = 0; i < n; i++) {
		int m = a[i];
		int cnt = 0;
		while (m % 2 == 0) {
			m /= 2;
			cnt++;
		}
		prime[2] = max(prime[2], cnt);
		for (int j = 3; j*j <= m; j += 2) {
			cnt = 0;
			while (m%j == 0) {
				m /= j;
				cnt++;
			}
			prime[j] = max(prime[j], cnt);
		}
		prime[m] = max(prime[m], 1);
	}

	long long llcm = 1;
	for (int i = 2; i < prime.size(); i++) {
		if (prime[i] != 0) {
			llcm = power(llcm, i, prime[i]);
		}
	}

	long long res = 0;
	for (int i = 0; i < n; i++) {
		long long m = a[i];
		long long ans = llcm;
		int cnt = 0;
		while (m % 2 == 0) {
			m /= 2;
			cnt++;
		}

		ans = power(ans, lcm(2), cnt);
		for (int j = 3; j*j <= m; j += 2) {
			cnt = 0;
			while (m % j == 0) {
				m /= j;
				cnt++;
			}
			if (cnt != 0)
				ans = power(ans, lcm(j), cnt);
		}

		ans = power(ans, lcm(m), 1);
		res += ans;
		res %= mod;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 4224
import java.util.*;

public class Main{
	static Scanner s=new Scanner(System.in);

	public static void main(String[]$){
		int n=s.nextInt(),m=s.nextInt();
		int x=s.nextInt(),y=s.nextInt();
		int[]a=new int[n];
		int[]b=new int[m];
		Arrays.setAll(a,i->s.nextInt());
		Arrays.setAll(b,i->s.nextInt());
		int max=Arrays.stream(a).max().getAsInt();
		int min=Arrays.stream(b).min().getAsInt();
		
		int c=Math.max(x,max);
		int d=Math.min(y,min);
		
		System.out.println(c<d?"No War":"War");
	}
}

Measured memory_bytes: 27984
/*
 *
 * maximum profit
 *
 */

#include <stdio.h>

#define MAX_N 200000
#define MIN -1000000000

int main(void) {
    int n, R[MAX_N+1], maxv, minv;
    
    scanf("%d", &n);

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

    minv = R[0];
    maxv = MIN;
    for(i=1;i<n;i++){
        if(maxv < (R[i]-minv)){
            maxv = R[i]-minv;
        }

        if(minv > R[i]){
            minv = R[i];
        }
    }

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

    return 0;
}



Measured memory_bytes: 2520
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
typedef pair<ll, ll> pll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  int n;cin >> n;
  priority_queue<pll, vector<pll>, greater<pll>> q;
  repi(i,0,n){
    ll t; cin >> t;
    q.push(make_pair(t,1));
  }
  while(q.size()>1){
    pll val = q.top();
    q.pop();
    pll val_next = q.top();
    q.pop();
    ll val_cnt = val_next.second;
    if(val_next.first<=2*val.first) val_cnt += val.second;
    q.push(make_pair(val_next.first + val.first, val_cnt));
  }
  cout << q.top().second << endl;
  return 0;
}


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int a = sc.nextInt();
			String strA = sc.next();
			int b = sc.nextInt();

			if(strA == "?") {
				break;
			}
			switch(strA) {
			case "+":
				System.out.println(a+b);
				break;
			case "-":
				System.out.println(a-b);
				break;
			case "*":
				System.out.println(a*b);
				break;
			case "/":
				System.out.println(a/b);
				break;
			}
		 }
	}
}

Measured memory_bytes: 26292
import java.util.Scanner;

/**
 *
 * @author mustafa
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        String s = sc.nextLine();
        
        String alphabet = "qwertyuopasdfghjklizxcvbnm";
        int[] c = new int[26];
        
        for (int i = 0; i < alphabet.length(); ++i)
        {
            for (int j = 0; j < s.length(); ++j)
            {
                if (alphabet.charAt(i) == s.charAt(j))
                {
                    c[i]++;
                }
            }
        }
        
        long t = 0;
        
        for (int i = 0; i < c.length; ++i)
        {
            t += c[i];
        }
        
        long toplam = 0;
        
        for (int i = 0; i < c.length; ++i)
        {
            if (t - c[i] == 0)
                toplam += 1;
            else
                toplam += c[i] * (t - c[i]);
        }
        
        System.out.print((long)toplam/2 + 1);
        
//        long sayac = 1;
//        
//        for (int i = 0; i < s.length() - 1; ++i)
//        {
//            for (int j = i + 1; j < s.length(); ++j)
//            {
//                if (s.charAt(i) == s.charAt(j))
//                    continue;
//                else
//                    sayac++;
//            }
//        }
//        
//        System.out.println(sayac);
    }
    
}

Measured memory_bytes: 25620
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int w, s;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> s >> w;
	if (w >= s)
		cout << "unsafe";
	else cout << "safe";
	return 0;
}

Measured memory_bytes: 3648
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int mod=998244353;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=9e18;
typedef pair<ll,ll> P;
const ll M=2147483647;
int seg[400005]={};
int N;
void update(int x,int y) {
  x+=N-1;
  seg[x]=y;
  while(x>0) {
    x=(x-1)/2;
    seg[x]=min(seg[x*2+1],seg[x*2+2]);
  }
}
int query(int x,int y,int k,int l,int r) {
  if(r<=x||l>=y) {
    return M;
  }
  if(x<=l&&r<=y) {
    return seg[k];
  }
  else {
    int c1=query(x,y,2*k+1,l,(l+r)/2);
    int c2=query(x,y,2*k+2,(l+r)/2,r);
    return min(c1,c2);
  }
}
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,q,com,x,y;
  cin >> n >> q;
  N=1;
  while(N<n) {
    N*=2;
  }
  for(int i=0; i<2*N-1; i++) {
    seg[i]=M;
  }
  for(int i=0; i<q; i++) {
    cin >> com;
    if(com) {
      cin >> x >> y;
      cout << query(x,y+1,0,0,N) << endl;
    }
    else {
      cin >> x >> y;
      update(x,y);
    }
  }
}


Measured memory_bytes: 4192
#include <iostream>

using namespace std;
 
char g[10] = {'w','a','k','s','t','n','h','m','y','r'};
char t[5] = {'a','i','u','e','o'};
 
string change(string key){
    string s = "";
    if(key[0]=='0'&&key[1]=='U') s += "nn";
 
    else{
	if(g[key[0]-'0']!='a') s += g[key[0]-'0'];
     
	switch(key[1]){
	case 'T':
	    s += t[0];
	    break;
	case 'L':
	    s += t[1];
	    break;
	case 'U':
	    s += t[2];
	    break;
	case 'R':
	    s += t[3];
	    break;
	case 'D':
	    s += t[4];
	    break;
	}
    }
   
    return s;
}
 
int main(){
    string str,ans;
 
    ans = "";
 
    cin >> str;
    for(int i = 0 ; i < str.length() ; i++){
	string key = str.substr(i,2);
	if(i%2==0){
	    ans += change(key);
	}
    }
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
//ll N,W;
 //ll dp[1000000001];
int main(){
    ll N,W;
    cin>>N>>W;
    vector<ll> d[5];
    ll w1,v1;
    cin>>w1>>v1;
   /* d[0].push_back(0);
    d[1].push_back(0);
    d[2].push_back(0);
    d[3].push_back(0);*/
    d[0].push_back(v1);
    rep(i,N-1){
        ll w2,v2;
        cin>>w2>>v2;
        d[w2-w1].push_back(v2);
    }
    rep(i,5){sort(d[i].begin(),d[i].end());}
    rep(i,5){d[i].push_back(0);
        reverse(d[i].begin(),d[i].end());
    }
    
    ll ans=-10000000;
    rep(i,5){
        for(int j=1;j<d[i].size();j++){
            d[i][j]+=d[i][j-1];
        }
    }
    
    for(int i=0;i<d[0].size() ; i++){
        for(int j=0;j<d[1].size() ;j++){
            for(int k=0;k<d[2].size() ;k++){
                for(int l=0;l<d[3].size();l++){
                    
                    ll val_sum = d[0][i]+d[1][j]+d[2][k]+d[3][l];
                    ll sumW = w1*i+(w1+1)*j+(w1+2)*k+(w1+3)*l;
                    if(sumW<=W){
                        ans=max(ans,val_sum);
                    }

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


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

char* stolower(char *s) {
  int i;

  for (i = 0; s[i]; i++) {
    s[i] = tolower(s[i]);
  }

  return s;
}

int main(void) {
  int r = 0;
  char W[11], T[1001];

  scanf("%s", W);

  while (scanf("%s", T) != EOF && strcmp(T, "END_OF_TEXT") != 0) {
    if (strcmp(stolower(T), W) == 0) {
      r++;
    }
  }

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

  return 0;
}

Measured memory_bytes: 552
S = input()

abc = [chr(i) for i in range(97,97+26)]
abc2 = abc
end = 0

if len(S) == 26:
    if S == 'zyxwvutsrqponmlkjihgfedcba':
        print(-1)#
    else:
        for i in range(1, 26):
            for j in abc[abc.index(S[-(i+1)])+1:]:
                if j in S[-i:]:
                    print(S[:-(i+1)]+j)
                    end = 1
                    break
            if end == 1:
                break
        else:
            print(-1)#
                
    
else:
    for i in S:
        abc.remove(i)
    print(S+abc[0])


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

typedef long long ll;
using namespace std;

int main() {
    string n;
    cin >> n;
    for (char c : n) {
        if (c== '7') {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


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

using namespace std;

int main() {
	int n;

	cin >> n;

	vector <int> L(n);

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

	sort(L.begin(), L.end());

	int ans = 0;

	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			if (L[i] == L[j]) {
				continue;
			}
			for (int k = j+1; k < n; k++) {
				if (L[j] == L[k]) {
					continue;
				}
				if (L[i] + L[j] > L[k]) {
					ans++;
				}
			}
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3628
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n,k,q,ans=1e18;
  cin >> n >> k >> q;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    vector<ll> c;
    vector<ll> use;
    for(int j=0;j<n;j++){
      if(a[i]<=a[j]){
        c.push_back(a[j]);
      }else{
        sort(c.begin(),c.end());
        ll usable = max(0ll,(ll)c.size()-k+1);
        for(int l=0;l<usable;l++){
          use.push_back(c[l]);
        }
        c.clear();
      }
    }
    sort(c.begin(),c.end());
    ll usable = max(0ll,(ll)c.size()-k+1);
    for(int l=0;l<usable;l++){
      use.push_back(c[l]);
    }
    if((ll)use.size()<q){
      continue;
    }
    sort(use.begin(),use.end());
    ans = min(ans,use[q-1]-use[0]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########

N = i_inpl()
A = l_inpl()

ans = []
tmp = 0
for i, Ai in enumerate(A[:N-1]):
    tmp += Ai *(-1)**(i)
a1 = (tmp+A[N-1])
ans.append(a1)
t_ans = []
r_A = A[::-1]
for i in range(N-1):
    ans.append(2*r_A[i]-ans[i])
ans = [ans[0]] + ans[1:][::-1]
print(" ".join([ str(i) for i in ans]))

# L, R = l_inpl()
# L %= 2019
# R %= 2019

# if R<=L:
#     R+=2019

# ans = INF
# for i in range(L, R+1):
#     for j in range(i+1, R+1):
#         print(i, j)
#         ans = min(ans, i*j%2019)

# print(ans)


Measured memory_bytes: 21320
#include <bits/stdc++.h>
using namespace std;
int main(){
	multiset<int> l;
	int n,i,sum=0,a;
	cin>>n;
	for(i=0;i<n*2;i++)
	{
		cin>>a;
		l.insert(a);
	}
	i=0;
	for(multiset<int>::iterator it=l.begin();it!=l.end();it++)
	{
		if(i%2==0)
			sum+=*it;
		i++;
	}
	cout<<sum<<endl;
	return 0;
}

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

using namespace std;

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

int main(){
	int n,m;
	cin >> n >> m;

	bool solved[n+1];
	int wa[n+1];
	for(int i=1;i<=n;i++){
		solved[i] = false;
		wa[i] = 0;
	}

	for(int i=0;i<m;i++){
		int p;
		string s;
		cin >> p >> s;
		if(s=="AC"){
			solved[p] = true;
		}else{
			if(!solved[p]) wa[p]++;
		}
	}
	int ac = 0;
	int wa2 = 0;
	for(int i=1;i<=n;i++){
		if(solved[i]){
			ac++;
			wa2+=wa[i];
		}
	}
	cout << ac << " " << wa2 << endl;

	return 0;
}

Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main() {
    //cout<<"Hello World!";
    int n,k,q;
    cin>>n>>k>>q;
    int arr[n];
    int arr1[n];
    for(int i=0;i<n;i++)
    {
        arr[i]=k;
        arr1[i]=0;
    }
    for(int i=0;i<q;i++)
    {
        int a;
        cin>>a;
        arr1[a-1]++;
    }
    for(int i=0;i<n;i++)
    {
        if(k+arr1[i]-q>0)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n,m;
  cin >> n >> m;
  bool a[n][m];
  rep(i,n){
    rep(j,m){
      a[i][j] = false;
    }
  }
  ll k,l;
    rep(i,n){
      cin >> k;
        rep(j,k){
          cin >> l;
            a[i][l-1] = true;
        }
    }
  ll ans=0;
  bool chk[m];
  rep(i,m){
    chk[i] = true;
  }
  rep(i,m){
    rep(j,n){
      if(a[j][i] != true){
        chk[i] = false;
      }
      
    }
  }
  rep(i,m){
    if(chk[i]){
      ans++;
    }
  }
  cout << ans;
 return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_081_B
{
    class Program
    {
        static void Main(string[] args)
        {
			int a = int.Parse(Console.ReadLine());
			string[] strs = null;
			int[] intArray = null;
			int breakFlag = 0;
			int count = 0;
			strs = Console.ReadLine().Split(new char[] { ' ' });

			intArray = new int[strs.Length];

			for (int i = 0; i < strs.Length; i++)
			{
				intArray[i] = int.Parse(strs[i]);
			}

			while (true)
			{
				for (int i = 0; i < strs.Length; i++)
				{
					if (intArray[i] % 2 != 0)
					{
						breakFlag = 1;
						break;
					}
					intArray[i] = intArray[i] / 2;
				}
				if (breakFlag == 1) break;
				count++;
			}
			
			Console.WriteLine(count);

			//// スペース区切りの整数の入力
			//string[] input = Console.ReadLine().Split(' ');
			//int b = int.Parse(input[0]);
			//int c = int.Parse(input[1]);
			//// 文字列の入力
			//string s = Console.ReadLine();
			////出力
			//Console.WriteLine((a + b + c) + " " + s);
		}
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std ;
const int N = 2e5 + 10 ;
typedef long long ll ;
ll a[N] , b[N] ;
int cnt1 = 0 , cnt2 = 0 , n ;
ll k ;
bool check(ll t)
{
  ll ans = 0 ;
  // cout << "T " << t << endl ;
  // for(int i = 1; i <= cnt1 ;i ++) cout << a[i] << " " ;
  // puts("") ;
  // for(int i = 1; i <= cnt2 ;i ++) cout << b[i] << " " ;
  // puts("") ;
  for(int i = 1 ; i <= cnt1 ;i ++)
   {
     ll l = i , r = cnt1 ;
     while(l < r)
      {
        ll mid = l + r + 1 >> 1 ;
        if(a[i] * a[mid] <= t) l = mid ;
        else r = mid - 1 ;
      }
     if(r > i) ans += r - i ; //, cout << i << " " << r << " a " << r - i << endl ;;
   }
   reverse(b + 1 , b + cnt2 + 1) ;
   for(int i = 1; i <= cnt2 ;i ++)
    {
      ll l = i , r = cnt2 ;
      while(l < r)
       {
         ll mid = l + r + 1 >> 1 ;
         if(b[i] * b[mid] <= t) l = mid ;
         else r = mid - 1 ;
       }
       if(r > i) ans += r - i ; //, cout << i << " " << r << " b " << r - i << endl ;
    }
    reverse(b + 1 , b + cnt2 + 1) ;
    for(int i = 1 ;i <= cnt1 ;i ++)
     {
       ll l = 0 , r = cnt2 ;
       while(l < r)
        {
          ll mid = l + r + 1 >> 1 ;
          if(a[i] * b[mid] <= t) l = mid ;
          else r = mid - 1;
        }
       ans += r ; //, cout << i << " ab " << r << endl ;;
     }
  //   cout << "ANS " << ans << endl ;
     return ans >= k ;
}
int main()
{
   scanf("%d%lld" , &n , &k) ;
   for(int i = 1; i <= n ;i ++)
    {
      ll x ;
      scanf("%lld" , &x) ;
      if(x < 0) b[++ cnt2] = x ;
      else a[++ cnt1] = x ;
    }
    sort(a + 1, a + cnt1 + 1) ;
    sort(b + 1, b + cnt2 + 1) ;
    ll l = -1e18 , r = 1e18 ;
    while(l < r)
     {
       ll mid = l + r >> 1 ;
       if(check(mid)) r = mid ;
       else l = mid + 1 ;
     }
    cout << r << endl ;
   return 0 ;
}


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

int main(){
    int n,W;
    cin>>n>>W;

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

    vector<vector<long>> M(W,vector<long>(n));
    for(int i=0; i<W; i++){
        if(i+1>=w[0]){
            M[i][0]=v[0];
        }else{
            M[i][0]=0;
        }
    }    
    
    for(int i=0; i<W; i++){
        for(int j=1; j<n; j++){
            if(i-w[j]<0){
                M[i][j]=M[i][j-1];
            }else{
                M[i][j]=max(M[i][j-1],M[i-w[j]][j-1]+v[j]);
            }
        }
    }

    cout<<M[W-1][n-1]<<endl;
}

Measured memory_bytes: 85376
#include<stdio.h>
#define M 100000
#define SENTINEL 2000000000

typedef struct{
  char suit;
  int value;
}Card;

Card L[M/2+2], R[M/2+2];

void merge(Card *, int, int, int, int);
void mergeSort(Card *, int, int, int);
int partition(Card *, int, int, int);
void quickSort(Card *, int, int, int);

int main(){
  int n, i, v;
  Card A[M], B[M];
  char S[10];
  int stable = 1;
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n-1);

  for ( i = 0; i < n; i++ ){
    if ( A[i].suit != B[i].suit ) stable = 0;
  }

  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for ( i = 0; i < n; i++ ) {
    printf("%c %d\n", B[i].suit, B[i].value);
  }

  return 0;
}

void merge(Card A[], int n, int l, int m, int r){
  int i, j, k;
  int n1 = m - l;
  int n2 = r - m;
  for ( i = 0; i < n1; i++ ) L[i] = A[l + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[m + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for ( k = l; k < r; k++ ){
    if ( L[i].value <= R[j].value ){
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(Card A[], int n, int l, int r){
  int m;
  if (l + 1 < r){
    m = (l + r)/2;
    mergeSort(A, n, l, m);
    mergeSort(A, n, m, r);
    merge(A, n, l, m, r);
  }
}

int partition(Card A[], int n, int p, int r){
  int i, j;
  Card t, x;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ ){
    if ( A[j].value <= x.value ){
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i+1]; A[i+1] = A[r]; A[r] = t;
  return i+1;
}

void quickSort(Card A[], int n, int p, int r){
  int q;
  if ( p < r ){
    q = partition(A, n, p, r);
    quickSort(A, n, p, q - 1);
    quickSort(A, n, q + 1, r);
  }
}



Measured memory_bytes: 4060
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		if(N%500 <= A){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

		sc.close();
	}
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(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)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

int a[100001];

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

    REP0(i, N)
    {
        cin >> a[i];
    }

    map<int, int> m;

    REP0(i, N)
    {
        m[a[i]]++;
    }

    int ans = 0;

    for (auto p : m)
    {
        int x = p.first;
        int n = p.second;
        if (n < x)
            ans += n;
        else
            ans += (n - x);
    }
    cout << ans << endl;
}

// void solve()
// {
//     int N;
//     cin >> N;
//     vector<LL> a(N);
//     REP0(i, N)
//     {
//         cin >> a[i];
//     }

//     sort(a.begin(), a.end());

//     LL curr_a = a[0];
//     LL curr_cnt = 0;
//     LL ans = 0;

//     REP0(i, N)
//     {
//         if (a[i] == curr_a)
//         {
//             curr_cnt++;
//         }

//         if (a[i] != curr_a or i == N - 1)
//         {

//             // a[i] が a[i]未満しか出てこなければ, 全部除く
//             if (curr_cnt < curr_a)
//                 ans += curr_cnt;
//             // a[i] が a[i] 回より多く出たら, 余剰を削る
//             // これは全部除くより真にマシ
//             if (curr_a < curr_cnt)
//                 ans += (curr_cnt - curr_a);

//             curr_a = a[i];
//             curr_cnt = 1;
//         }
//     }

//     std::cout << ans << endl;
// }

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

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

int main(){
    int m,n;
    int tmp;
    int com;
    cin >> m >> n;
    int point[m][n];
    tmp = 0;
    for(int i=0;i<m;i++){
        com = 0;
        for(int j=0;j<n;j++){
            cin >> point[i][j];
            if(i == 0) tmp += point[i][j];
            else com += point[i][j];
        }
        if(tmp < com) tmp = com;
    }
    cout << tmp << endl;
}

Measured memory_bytes: 1160
#include <stdio.h>
int main(void){
    int n,k;
    int x[9<<14];
    
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    int min=9<<25;
    for(int j=0;j<n-k+1;j++){
        min=fmin(x[j+k-1]-x[j]+fmin(abs(x[j]),abs(x[j+k-1])),min);
    }
    printf("%d",min);
}

Measured memory_bytes: 2500
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
ll delx[]={0,0,1,-1};
ll dely[]={1,-1,0,0};
ll n,m;
char grid[1009][1009];
bool is(ll x,ll y){
    if(x>0&&y>0&&x<=n&&y<=m&&grid[x][y]=='.')
    return true;
    
    return false;
}
void solve()
{
     
      
      cin>>n>>m;
      
      ll sx,sy;
      
      cin>>sx>>sy;
      
      ll dx,dy;
      
      cin>>dx>>dy;
      
      ll ans=0;
      
      ll dis[n+1][m+1];
      
      for(ll i=0;i<n+1;i++){
          for(ll j=0;j<m+1;j++)
          dis[i][j]=INF;
      }
      
      dis[sx][sy]=0;
      
      deque<pii>dq;
      
      dq.pb(mk(sx,sy));
      
      
     
      for(ll i=1;i<=n;i++){
          for(ll j=1;j<=m;j++)
          cin>>grid[i][j];
      }
      
   
      
      while(!dq.empty()){
          pii x=dq.front();
          
          dq.pop_front();
          
         for(ll i=0;i<4;i++){
             ll xx=x.ff+delx[i];
             ll yy=x.ss+dely[i];
             
             if(is(xx,yy)&&dis[xx][yy]>dis[x.ff][x.ss]){
                 dq.push_front({xx,yy});
                 
                 dis[xx][yy]=dis[x.ff][x.ss];
             }
         }
         
         for(ll i=-2;i<=2;i++){
             for(ll j=-2;j<=2;j++){
                 
                 if(abs(i)+abs(j)<2)
                 continue;
                 
                 ll xx,yy;
                 xx=x.ff+i;
                 yy=x.ss+j;
                 
                  if(is(xx,yy)&&dis[xx][yy]>1+dis[x.ff][x.ss]){
                 dq.push_back({xx,yy});
                 
                 dis[xx][yy]=1+dis[x.ff][x.ss];
             }
             
             }
         }
      }
      
      if(dis[dx][dy]==INF)
      ans=-1;
      else
      ans=dis[dx][dy];
      
      
      cout<<ans<<endl;
      
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  if(n/100==7){
    cout<<"Yes"<<endl;
    return 0;
  }
  n%=100;
  if(n/10==7){
    cout<<"Yes"<<endl;
    return 0;
  }
  n%=10;
  if(n==7){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3632
S=input()
length=len(S)

wk=length
bk=length
for i, s in enumerate(S):
    cost=max(i, length-(i+1))
    if s == "0":
        wk = min(wk, cost)
    else:
        bk = min(bk, cost)
print(max(wk, bk))

Measured memory_bytes: 3188
#include<iostream>
#include<fstream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<unordered_map>
#include<map>
#include<string>
#include<cstring>
#include<stack>
#include<cmath>

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define sf scanf
#define sfd(n) scanf("%d", &n)
#define sflf(n) scanf("%lf", &n)
#define sfll(n) scanf("%lld", &n)
#define pfd(n) printf("%d", n)
#define pflf(n) printf("%lf", n)
#define pfll(n) printf("%lld", n)
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")
#define PI 3.1415926
#define MAX 100000
#define M 1e18

using namespace std;

int main() {
	int n;
	cin >> n;
	int sum = 0;
	int num;
	for( int i=0; i<n; i++ ) {
		sfd(num);
		sum += num-1;

	}
	cout << sum;
	
	return 0;
}

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

using namespace std;

#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 DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);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 REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  int h, w, n;
  cin >> h >> w >> n;
  int si, sj;
  cin >> si >> sj;
  string s, t;
  cin >> s >> t;

  rep (aaa, 2) {
    int l = 0, r = w + 1;
    rrep (i, n) {
      if (s[i] == 'L') {
        if (l == 0) {
          l += 1;
        }
        else if (t[i] != 'R') {
          l += 1;
        }
      }
      else {
        if (t[i] == 'R') {
          l -= 1;
          chmax(l, 0);
        }
      }
    
      if (s[i] == 'R') {
        if (r == w + 1) {
          r -= 1;
        }
        else if (t[i] != 'L') {
          r -= 1;
        }
      }
      else {
        if (t[i] == 'L') {
          r += 1;
          chmin(r, w + 1);
        }
      }
      if (l + 1 >= r) {
        cout << "NO" << endl;
        return 0;
      }
    }
    if (sj <= l || r <= sj) {
      cout << "NO" << endl;
      return 0;
    }
    swap(h, w);
    swap(si, sj);
    map<char, char> mp;
    mp['L'] = 'U';
    mp['U'] = 'L';
    mp['R'] = 'D';
    mp['D'] = 'R';
    rep (i, n) {
      s[i] = mp[s[i]];
      t[i] = mp[t[i]];
    }
  }
  cout << "YES" << endl;
  return 0;
} 


Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
void intToA(int n,int radix)
{
    string ans="";
    do{
        int t=n%radix;
        if (t>=0&&t<=9)
		{
			ans+=t+'0';
		}
        else
		{
			ans+=t-10+'a';
		}
        n/=radix;
    }while (n!=0);
    reverse(ans.begin(),ans.end());
    cout<<ans.length()<<endl;
	return ;  
}
int main()
{
	int n,k;
	cin>>n>>k;
	intToA(n,k);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int MAX=101;
const int INF=(1<<21);

int main(){

  int n, k;
  int zero_one;
  int a, b;
  int c, d, e;
  int w_f[MAX][MAX];

  

  while( cin >> n >> k, n + k ) {

    for(int i=0; i<n; i++) {
      for(int j=0; j<n; j++) {
	w_f[i][j] = INF;
      }
      w_f[i][i] = 0;
    }
    
    for(int i=0; i<k; i++) {
    cin >> zero_one;
    if( zero_one == 1 ) {
      cin >> c >> d >> e;
      if(w_f[c-1][d-1] > e) {
	w_f[c-1][d-1] = e;
	w_f[d-1][c-1] = e;
	for(int j=0; j<n; j++) {
	  for(int k=0; k<n; k++) {
	    for(int l=0; l<n; l++) {
	      w_f[j][k] = w_f[k][j] = min(w_f[j][k], w_f[j][l]+w_f[l][k]);
	    }
	  }
	}
      }
    } 
    else {
      cin >> a >> b;
      if( w_f[a-1][b-1] == 1<<21 ){
	cout << "-1" << endl;
      } 
      else {
	cout << w_f[a-1][b-1] << endl;
      }
    }
    }
  }
}

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

int main() {
    int N, L;
    cin >> N >> L;

    int sum = 0;
    int minDist = 1000;
    vector<int> Ap(N);
    for (int i = 0; i < N; i++) {
        Ap[i] = L + i;
        sum += Ap[i];
        if (abs(Ap[i]) < abs(minDist)) {
            minDist = Ap[i];
        }
    }

    sum -= minDist;

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    char s[55];
    int i,k=0;

    scanf("%s",s);
    for(i=0; i<4; i++)
    {
        if(s[i] == '+')
            k++;
        else if(s[i] == '-')
            k--;


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


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

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

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

int main()
{
    int n;

    std::cin >> n;

    std::vector<ll> p(n + 1), pos(n + 1);

    rep(i, n)
    {
        std::cin >>
            p[i];
        pos[p[i]] = i;
    }

    ll ans = 0;

    std::multiset<ll> set;

    set.insert(0);
    set.insert(n + 1);
    set.insert(pos[n]);

    for (int i = n - 1; i >= 1; --i)
    {
        ll x = pos[i];
        auto it1 = set.lower_bound(x);
        it1--;
        auto it3 = set.upper_bound(x);
        if (it1 != set.begin())
        {
            auto it2 = it1;
            it2--;

            ans += i * (*it3 - x) * ((*it1) - (*it2));
        }

        auto it4 = it3;
        ++it4;

        if (it4 != set.end())
        {

            ans += i * (x - *it1) * ((*it4) - (*it3));
        }

        set.insert(pos[i]);
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 9592