akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if( b - a == c - b ) cout << "YES" << endl;
  else cout << "NO" << endl;  
}


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

public class Main {

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

		BigDecimal A =new BigDecimal(sc.nextLong());
		BigDecimal B =new BigDecimal(sc.nextLong());
		BigDecimal oldTax =new BigDecimal("0.08");
		BigDecimal newTax =new BigDecimal("0.10");
		BigDecimal A_ans = A.divide(oldTax,RoundingMode.HALF_UP);
		BigDecimal B_ans = B.divide(newTax,RoundingMode.HALF_UP);
		MathContext mc = new MathContext(0,RoundingMode.HALF_UP);
		if (A_ans.compareTo(B_ans) >= 0) {
			if (B_ans.multiply(oldTax,mc).setScale(0, RoundingMode.DOWN).compareTo(A) == 0 && B_ans.multiply(newTax,mc).setScale(0, RoundingMode.DOWN).compareTo(B) == 0) {
				System.out.println(B_ans);
			}else if(A_ans.multiply(oldTax,mc).setScale(0, RoundingMode.DOWN).compareTo(A) == 0 && A_ans.multiply(newTax,mc).setScale(0, RoundingMode.DOWN).compareTo(B) == 0) {
				System.out.println(A_ans);
			}else {
				System.out.println(-1);
			}
		}else {
			if (A_ans.multiply(oldTax,mc).setScale(0, RoundingMode.DOWN).compareTo(A) == 0 && A_ans.multiply(newTax,mc).setScale(0, RoundingMode.DOWN).compareTo(B) == 0) {
				System.out.println(A_ans);
			}else if(B_ans.multiply(oldTax,mc).setScale(0, RoundingMode.DOWN).compareTo(A) == 0 && B_ans.multiply(newTax,mc).setScale(0, RoundingMode.DOWN).compareTo(B) == 0) {
				System.out.println(B_ans);
			}else {
				System.out.println(-1);
			}
		}

	}
}

Measured memory_bytes: 36096
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n string
	fmt.Scan(&n)

	sn := strings.Split(n, "")
	sum := 0
	for _, v := range sn {
		i, _ := strconv.Atoi(v)
		sum += i
	}
	intN, _ := strconv.Atoi(n)
	if intN%sum == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
	int N, i, m[1000], min;
	long X, sumeach;
	
	scanf("%d %ld",&N,&X);
	scanf("%d", &m[0]);
	sumeach = min = m[0];
	for(i=1;i<N;i++)
	{
		scanf("%d", &m[i]);
		sumeach += m[i];
		if(m[i] < min) min = m[i];
	}
	
	printf("%ld\n", N+(X-sumeach)/min);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#define PI 3.14159265258979
using namespace std;


double distance(double x1, double y1, double x2, double y2) {
  return sqrt((x1-x2) * (x1-x2) + (y1-y2) * (y1-y2));
}

int main() {
  double P2Q[2],P2P1[2],lq2,l12,theta,x1,x2,y1,y2,xq,yq,P2R[2],OR[2];
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq) == 6) {
    P2Q[0] = xq - x2;
    P2Q[1] = yq - y2;
    P2P1[0] = x1 - x2;
    P2P1[1] = y1 - y2;
    lq2 = distance(xq,yq,x2,y2);
    l12 = distance(x1,y1,x2,y2);
    theta = acos((P2Q[0] * P2P1[0] + P2Q[1] * P2P1[1]) / (lq2 * l12));
    //全て反時計回りにまわしてしまっている。
    // if(theta >= PI / 2) theta = PI - theta;
    if((yq-y1)*(x2-x1) - (y2-y1)*(xq-x1) < 0) {
    P2R[0] = cos(-2 * theta) * P2Q[0] - sin(-2 * theta) * P2Q[1];
    P2R[1] = sin(-2 * theta) * P2Q[0] + cos(-2 * theta) * P2Q[1];
    }
    else {
    P2R[0] = cos(2 * theta) * P2Q[0] - sin(2 * theta) * P2Q[1];
    P2R[1] = sin(2 * theta) * P2Q[0] + cos(2 * theta) * P2Q[1];
    }
    OR[0] = x2 + P2R[0];
    OR[1] = y2 + P2R[1];
    printf("%.6lf %.6lf",OR[0],OR[1]);
    cout << endl;
  }
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
int main()
{
  int N,K,KK,i,num;
  scanf("%d%d",&N,&K);
  KK=1;
  num=0;
  for(i=0;i<=1000000000;i++)
  {
    KK=KK*K;
    num=num+1;
    if(N<KK)
    {
      printf("%d",num);
      exit(0);
    }
  }
}
    

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
char a[105][105];
int main() {
	ll h, w;
	cin >> h >> w;
	vector<string>a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}
	
	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}


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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    string s;
    cin >> s;
    int m = 0;
    int n = s.size();
    rep(i, n) {
        int t = 0;
        for(int j = i; j < n; j++) {
            if(s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T') {
                t++;
            } else {
                break;
            }
        }
        m = max(t,m);
    }
    cout << m <<endl;
}

Measured memory_bytes: 3532
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7
    from collections import defaultdict
    
    N = II()
    countS = defaultdict(int)
    max_count = 0
    max_words = []
    for _ in range(N):
        s = input()
        countS[s] += 1
        if countS[s] > max_count:
            max_words = [s]
            max_count = countS[s]
        elif countS[s] == max_count:
            max_words.append(s)
    
    max_words.sort()
    for w in max_words:
        print(w)

if __name__ == '__main__':
    main()

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

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

  vector<int> a(n);
  rep(i,n) cin >> a[i];

  int h = 0;
  ll ans = 0;
  rep(i,n) {
    h = max(h,a[i]);
    ans += h - a[i];
  }
  cout << ans << endl;
}


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

#define ll long long
using namespace std;

ll mod = 1000000007;

static ll Calc_pow(ll x, ll pow) {
    if (pow == 0) return 1;
    ll a = Calc_pow(x, pow / 2);
    a = a * a % mod;
    if (pow % 2 == 1) a *= x;
    return a % mod;
}

vector<ll> fact;

static void Init_fact(int n) {
    fact = vector<ll>(n);
    fact[0] = 1;
    for (int i = 1; i < n; i++) fact[i] = fact[i - 1] * i % mod;
}

ll Combination(ll n, ll r) {
    return fact[n] * Calc_pow(fact[r] * fact[n - r] % mod, mod - 2) % mod;
}

int main() {
    Init_fact(300000);
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    ll ret = Combination(h + w - 2, h - 1);
    for (int i = 0; i < a; i++) {
        ret -= Combination(h - i + b - 2, b - 1) * Combination(i + w - b - 1, i) % mod;
        ret = (ret + mod) % mod;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 2560
// 場合分けなどもせずただ3重ループを回す.
#include<iostream>
using namespace std;
int main(){
  int ans=0;
  int a,b,c,x; cin >> a >> b >> c >> x;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(500*i+100*j+50*k==x) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	var s string
	fmt.Scan(&s)
	if s == "ABC" {
		fmt.Println("ARC")
		return
	}
	fmt.Println("ABC")
}

// =================================
// I/O util
// =================================

var sc = bufio.NewScanner(os.Stdin)

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

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

Measured memory_bytes: 1752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int x,a,b; cin >> x >> a >> b;
    cout << (x-a)%b << endl;
}

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

#define rep(i,n) for(long long i = 0; i < (n); i++)
#define MOD 998244353

using namespace std;

long long pow(long long x, long long n) {
  long y = 1;
  while (n) {
    if (n%2 == 1) y = (y * x) % MOD;
      x = x*x % MOD;
      n /= 2;
  }
  return y;
}

int main(){
  long long n;
  cin>>n;
  vector<long long> d;
  map<long long, long long> m;
  long long max = 0;
  long long t;
  cin>>t;
  
  if(t!=0){
    cout<<0;
    return 0;
  }
  m[t]++;

  rep(i, n-1){
    cin>>t;
    m[t]++;
    if(max<t)max=t;
  }

  if(m[0]!=1){
    cout<<0;
    return 0;
  }

  long long result = 1;
  rep(i,max){
//    cout<<m[i]<<' '<<m[i+1]<<endl;
    result = (result * pow(m[i],m[i+1])) % MOD;
  }
  
  cout<<result%MOD;

  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int i,n,sum=0;
	cin >> n;
	vector<int> s(n);
	for(i=0;i<n;i++){
		cin >> s[i];
		sum += s[i];
	}

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

	for(i=0;!(sum % 10) && i<n;i++){
		if(!(s[i] % 10))
			continue;
		sum -= s[i];
	}
	
	if(i < n)
		cout << sum << endl;
	else
		cout << "0" << endl;
}

Measured memory_bytes: 256
X,K,D=map(int,input().split())
if abs(X) >=K*D:
  if X>=0:
    print(abs(X-K*D))
  else:
    print(abs(X+K*D))
  exit(0)
k=abs(X)//D
if X>=0:
  if k%2==K%2:
    print(abs(X-D*k))
  else:
    print(abs(D*(k+1)-X))
else:
  if k%2==K%2:
    print(abs(X+D*k))
  else:
    print(abs(D*(k+1)+X))

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

int main() {
  int N = 3;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());
  cout << ((A.size() == 2) ? "Yes" : "No") << "\n";
}

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

int main(){
	int N;
	cin >> N;
	int A[N];
	rep(i,N) cin >> A[i];
	sort(A, A+N);
	int ans = 0;
	int c = 1;
	int now = A[0];
	for (int i = 1; i < N; i++) {
		if (A[i] == now) c++;
		else {
			ans += c%2;
			now = A[i];
			c = 1;
		}	
	}
	ans += c%2;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 4012
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, M = map(int, input().split())

ans = (N - M) * 100 + M * 1900
r = 2 ** M
print(ans * r)

Measured memory_bytes: 3572
n = int(input())
a = [int(input()) for i in range(n)]

memo = {}
for i in range(n):
    memo[a[i]] = i
ans = 0
pos = -1
cnt = 0
for i in range(n):
    if pos < memo[i+1]:
        cnt += 1
        pos = memo[i+1]
    else:
        ans = max(ans, cnt)
        cnt = 1
        pos = memo[i+1]
print(n - max(ans, cnt))

Measured memory_bytes: 83160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int cnt = 0;
    REP(i,S.length()){
        if(S[i] == 'x')  cnt++;
    }
    if(cnt >= 8) cout << "NO" << endl;
    else cout << "YES" << endl;

}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, usize, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};

fn main() {
    input! {
        n: usize,
        t: i64,
        push_at: [i64; n],
    }
    println!("{}", push_at.windows(2).map(|interval| min(t, interval[1] - interval[0])).sum::<i64>() + t)
}



Measured memory_bytes: 8444
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = int(input())
A = readInts()
ans = 1
if A.count(0):
    print(0)
    exit()
A = sorted(A)
for i in range(n-1,-1,-1):
    ans *= A[i]
    #print(ans)
    if ans > 10**18:
        print(-1)
        exit()
    if ans == 0:
        print(0)
        exit()
print(ans)


Measured memory_bytes: 23984
#include<stdio.h>
#define MAX_N 246912
int prime[MAX_N];
bool is_prime[MAX_N+1];

int sieve(int n);

int main(void){
	int n=1;
	int a;


	for(;;){
		scanf("%d",&n);
		if(n==0) break;
		a=sieve(2*n)-sieve(n);
		printf("%d\n",a);
	}
	return 0;
}

int sieve(int n){
	int p = 0;
	for(int i = 0; i <= n; i++) is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i <= n; i++){
		if(is_prime[i]){
			prime[p++] = i;
			for(int j = 2*i; j <= n; j += i) is_prime[j] = false;
		}
	}
	return p;
}

Measured memory_bytes: 1352
def main():
    n, k = map(int, input().split(' '))
    result = [n//i*max(0,i-k) + max(0, n%i-k+1) for i in range(1, n+1)]
    if k != 0:
        print(sum(result))
    else:   
        print(sum(result)-n)
main()

Measured memory_bytes: 7012
if __name__ == '__main__':
    N = int(input())
    ab_list = [list(map(int, input().split())) for i in range(N)]
    cd_list = [list(map(int, input().split())) for i in range(N)]

    ab_list = sorted(ab_list, key=lambda x : x[1], reverse=True)
    cd_list = sorted(cd_list, key=lambda x : x[0])

    answer = 0
    for b in cd_list:
        for r in ab_list:
            if b[0]>r[0] and b[1]>r[1]:
                answer += 1
                ab_list.remove(r)
                break
    print(answer)

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	long long a,b,border,cost = 0,minv = 999999999;
    cin >> a >> b >> border;
  vector<vector<int>> alg(a,vector<int>(b));
  vector<int> value(a);
  vector<int> sum(b,0);
  froop1(0,a){
    cin >> value.at(i);
    for(int j = 0;j < b;j++){
      cin >> alg.at(i).at(j);
    }
  }
  int all = 1 << a;
  for(int bit = 0;bit < all;bit++){
    cost = 0;
    sum.assign(b,0);
    froop1(0,a){
      if((bit >> i) & 1){
        cost += value.at(i);
        for(int j = 0;j < b;j++){
          sum.at(j) += alg.at(i).at(j);
        }
      }
    }
    bool check = true;
    for(int j = 0;j < b;j++){
      if(sum.at(j) < border){
        check = false;
        break;
      }
    }
    if(check){
      if(cost < minv) minv = cost;
    }
  }
  if(minv != 999999999) cout << minv << endl;
  else cout << -1 << endl;
return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
constexpr lnt INF = 2e18;
/*-*/

int main() {
	lnt n;
	std::cin >> n;
	lnt sum=0;
	for(lnt i=2;i*i<=n;i++) {
		if(n%i) continue;
		lnt count=0;
		while(n%i==0) {
			n/=i;
			count++;
		}
		sum+=(lnt)(std::sqrt((long double)count*2+0.25)-0.5);
	}
	if(n!=1) sum+=1;
	print(sum);
}


Measured memory_bytes: 3680
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <bitset>
#include <complex>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl;
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

int main() {
	double t1, t2;
	VS s = { "AAA","AA","A","B","C","D","E" ,"NA" };
	while (cin >> t1 >> t2) {
		int ty;
		if (t1 < 35.50&&t2 < 71.00)ty = 0;
		else if (t1 < 37.50&&t2 < 77.00)ty = 1;
		else if (t1 < 40.00&&t2 < 83.00)ty = 2;
		else if (t1 < 43.00&&t2 < 89.00)ty = 3;
		else if (t1 < 50.00&&t2 < 105.00)ty = 4;
		else if (t1 < 55.00&&t2 < 116.00)ty = 5;
		else if (t1 < 70.00&&t2 < 148.00)ty = 6;
		else ty = 7;

		Cout(s[ty]);
	}
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

void sum_2D(vector<vector<int>> &v) {
    int h = v.size(), w = v[0].size();
    rep(i, h) FOR(j, 1, w) v[i][j] += v[i][j - 1];
    rep(j, w) FOR(i, 1, h) v[i][j] += v[i - 1][j];
}

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

    int N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<int>> sum1(N + 1, vector<int>(M + 1)), sum2 = sum1,
                                                         sum3 = sum1;
    FOR(i, 1, N + 1) {
        FOR(j, 1, M + 1) {
            char c;
            cin >> c;
            sum1[i][j] = c - '0';
            if(sum1[i][j] && sum1[i - 1][j]) sum2[i][j] = 1;
            if(sum1[i][j] && sum1[i][j - 1]) sum3[i][j] = 1;
        }
    }

    sum_2D(sum1);
    sum_2D(sum2);
    sum_2D(sum3);

    int ans;
    rep(i, Q) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        ans = sum1[c][d] + sum1[a - 1][b - 1] - sum1[a - 1][d] - sum1[c][b - 1];
        ans -= sum2[c][d] + sum2[a][b - 1] - sum2[a][d] - sum2[c][b - 1];
        ans -= sum3[c][d] + sum3[a - 1][b] - sum3[a - 1][d] - sum3[c][b];
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 49408
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll a,b;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>a>>b;
	if(a<=8&&b<=8)
	cout<<"Yay!";
	else
	cout<<":(";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int n;
	int a[100] = { 0 };

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

	for (int i = n; i != 0; --i)
	{
		cout << a[i-1];
		if (i != 1)
		{
			cout << " ";
		}
		else
		{
			cout << endl;
		}
	}

}


Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define ALL(x) x.begin(),x.end()

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	ll int ans = 1;
	rep(i, 0, m)
		ans *= 2;
	ans *= (n * 100 + m * 1800);
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define ll long long
#define ff first
#define ss second

ll n, a[300009], ans[64], mod = 1000000007;
ll freq[64];

void func(ll x)
{
    for(ll i = 0; x; i++)
    {
        freq[i] += (x&1);
        x = x >> 1;
    }
}

ll po(ll a, ll b)
{
    if(b == 0)
        return 1;
    ll x = 1;
    if(b&1)
        x = a%mod;
    ll y = po(a, b/2);
    return (((y*y)%mod)*x)%mod;
}

int main()
{
    ll i, j;
    cin >> n;

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

//    for(auto u : freq)
//        cout << u.ff << " " << u.ss << endl;

    for(i = 0; i <= 62; i++)
    {
        for(j = 0; j < n; j++)
        {
            if(a[j] & (1LL << i))
            {
                ans[i] += (n-j) - freq[i];
                freq[i]--;
            }
            else
                ans[i] += freq[i];
        }
    }

    ll x = 0;
    for(i = 0; i <= 62; i++)
        x = (x + (ans[i]%mod)*po(2LL, i))%mod;
    cout << x;
}


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

using namespace std;
#define ll long long int
#define vv vector<int>

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    if(n+1 != m){
      cout<<"No";
      return 0;
    }
    for(int i = 0; i<n; i++){
      if(s[i] != t[i]){
        cout<<"No";
        return 0;
      }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3576
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    a, b, c, d = il()
    print(max(b * d, a * c, a * d, b * c))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9912
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007;
//ユークリッドの互除法
int LCM(int a,int b){
    int x=a*b;
    int tmp;
    if(a<b){
        tmp=a;
        a=b;
        b=tmp;
    }
    int r;
    r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a*b;
    }
    return x/b;
}
//最大公約数
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
signed main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int a,b;
    int kai=0;
    int ans=0;
    for(int i=0;i<n-1;i++){
        for(char j='a';j<='z';j++){
            a=0,b=0;
            for(int k=0;k<=i;k++){
                if(s[k]==j){
                    a=1;
                }
            }
            for(int k=i+1;k<n;k++){
                if(s[k]==j){
                    b=1;
                }
            }
            if(a==1&&b==1){
                kai++;
            }
        }
        ans=max(ans,kai);
        kai=0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
INF = 0

class MaxSegTree:
    """
    0-indexed
    query : [L, R)
    """
    def __init__(self, size):
        self.size = 1 << (size.bit_length())  # 完全二分木にする
        self.data = [-INF] * (2 * self.size - 1)

    def build(self, rawData):
        self.data[self.size - 1: self.size - 1 + len(rawData)] = rawData
        for i in range(self.size - 1)[:: -1]:
            self.data[i] = max(self.data[2 * i + 1], self.data[2 * i + 2])

    def update(self, index, value):
        index += self.size - 1
        if self.data[index] >= value:
            return
        self.data[index] = value
        while index >= 0:
            index = (index - 1) // 2
            self.data[index] = max(self.data[2 * index + 1], self.data[2 * index + 2])

    def query(self, left, right):
        L = left + self.size
        R = right + self.size
        ret = -INF
        while L < R:
            if R & 1:
                R -= 1
                ret = max(ret, self.data[R - 1])
            if L & 1:
                ret = max(ret, self.data[L - 1])
                L += 1
            L >>= 1
            R >>= 1
        return ret

N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]
mxA = max(A)
tree = MaxSegTree(mxA + 10)

for a in A:
    nx = tree.query(max(0, a - K), min(mxA + 1, a + K + 1))
    tree.update(a, nx + 1)

print(tree.query(0, mxA + 1))


Measured memory_bytes: 117884
#include<bits/stdc++.h>
using namespace std;
const int N=5e3+2;
int mod;
int mul(int x,int y){
	return (1ll*x*y)%mod;
}
void add(int &x,int y){
	x+=y;
	if(x>=mod){
		x-=mod;
	}
}
int dp[N];
int main(){
	int n,i,j,k,l,ans=0;
	cin>>n>>mod;
	dp[0]=1;
	for(i=2;i<=n;i++){
		j=min(i-1,n+2-i);
		for(k=j;k<=n;k++){
			add(dp[k],dp[k-j]);
		}
	}
	for(i=0;i<=n;i++){
		add(ans,mul(n-i,dp[i]));
	}
	cout<<ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * 解説通り実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.next().toCharArray();
			if ((0 == (s.length & 1)) == (s[0] == s[s.length - 1])) {
				System.out.println("First");
			} else {
				System.out.println("Second");
			}
		}
	}
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

const ll MOD = 1e9 + 7;
const int N = 1e5 + 5;

vi adj[N];
ll dp[N][4];

ll sol(int nd, int prv, int p) {

    ll &ret = dp[nd][prv];
    if(ret != -1) return ret;

    ret = 1;
    ll ch1 = 1;
    int f = 1;
    for(auto ch : adj[nd]) {
        if(ch == p) continue;
        f = 0;
        if(prv == 1) {
            ret *= (sol(ch, 2, nd) % MOD);
            ret %= MOD;
            ch1 = 0;
        }
        else {
            ret *= (sol(ch, 1, nd) % MOD);
            ret %= MOD;
            ch1 *= (sol(ch, 2, nd) % MOD);
            ch1 %= MOD;
        }
    }

    if(f) {
        if(prv == 1) ret = 1;
        else ret = 2;
    }else {
        ret += ch1;
        ret %= MOD;
    }

    return ret % MOD;
}

int main(){
    fIO
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    memset(dp, -1, sizeof(dp));

    int n;
    cin >> n;

    for(int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;


        adj[x].pb(y);
        adj[y].pb(x);
    }

    cout << sol(0, 2, 0);

}








Measured memory_bytes: 18560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

int main() {
  int n;
  cin >> n;
  vector< vector<int> > v(2, vector<int>(n/2));
  vector< vector<pair<int, int> > > ans_cnt(2);
  rep(i, n/2) cin >> v[0][i] >> v[1][i];

  sort(all(v[0]));
  sort(all(v[1]));

  int ans = 0;
  rep(k, 2) {
    int cnt = 1, tmp_ans = 1;
    for (int i = 1; i < n/2; i++) {
      if (v[k][i] == v[k][i-1]) {
        cnt++;
        tmp_ans = max(tmp_ans, cnt);
      } else {
        ans_cnt[k].push_back(make_pair(cnt, v[k][i-1]));
        cnt = 1;
      }
    }
    if (cnt != 1) ans_cnt[k].push_back(make_pair(cnt, v[k][n/2-1]));
    ans += tmp_ans;
  }

  sort(all(ans_cnt[0]));
  sort(all(ans_cnt[1]));
  reverse(all(ans_cnt[0]));
  reverse(all(ans_cnt[1]));

  if (ans_cnt[0][0].second == ans_cnt[1][0].second) {
    if (ans == n) {
      ans = n / 2;
    } else {
      ans = n - max(abs(ans_cnt[0][0].first+ans_cnt[1][1].first),
                    abs(ans_cnt[0][1].first+ans_cnt[1][0].first));
    }
  } else {
    ans = n - ans;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1848
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int x;
    cin >> x;
    cout << (x + 1) % 2 << endl;
}


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

int main() {
	int X[3][3] = {}, SUM;
	cin >> X[0][0] >> X[0][1] >> X[1][1];
	SUM = X[1][1] * 3;
	X[0][2] = SUM - X[0][0] - X[0][1];
	X[2][0] = SUM - X[0][2] - X[1][1];
	X[2][2] = SUM - X[0][0] - X[1][1];
	X[1][0] = SUM - X[0][0] - X[2][0];
	X[1][2] = SUM - X[0][2] - X[2][2];
	X[2][1] = SUM - X[2][0] - X[2][2];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cout << X[i][j];
			if (j < 2) cout << " ";
			else cout << endl;
		}
	}
}

Measured memory_bytes: 256
dish = []
for i in range(5):
    dish.append(int(input()))

min_time = 999999
for i in range(5):
    time_sum = 0
    for j in range(5):
        if j == i:
            time_sum += dish[j]
        else:
            time_sum += dish[j] + ((10 - (dish[j] % 10)) % 10)
    if min_time > time_sum:
        min_time = time_sum

print(min_time)


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll cnt[200005];
ll cmb[200005];
ll A[200005];

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

    ll N; cin >> N;

    for (int i = 0;i < N;i++){
        cin >> A[i];
        cnt[A[i]]++;
    }

    ll sum = 0;

    for (int i = 0;i <= N;i++){
        sum += cnt[i]*(cnt[i]-1)/2;
    }

    for (int i = 0;i < N;i++){
        ll ans = sum;
        ans -= cnt[A[i]]*(cnt[A[i]]-1)/2;
        ans += (cnt[A[i]]-1)*(cnt[A[i]]-2)/2;
        cout << ans << endl;
    }

    return 0;

}

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

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

  int ans = 1;
  int i = 2;
  while (true) {
    if (i*i > x) {
      break;
    }
    int j = 2;
    while (true) {
      int tmp = pow(i, j);
      if (tmp > x) {
        break;
      }
      if (ans < tmp && tmp <= x) {
        ans = tmp;
      }
      j++;
    }
    i++;
  }

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

Measured memory_bytes: 384
#include <stdio.h>
int main()
{
  char s[200];
  gets(s);
  int l=strlen(s);int c=0;
  for(int i=0,j=l-1;i<l/2;i++,j--)
  {
    if(s[i]!=s[j])
      ++c;
  }
  printf("%d",c);
}

Measured memory_bytes: 1588
import java.io.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _err = new PrintWriter(System.err);

    private long count;

    private void solve(Scanner sc, PrintWriter out) {
        long x = sc.nextLong();
        long y = sc.nextLong();

        if (x < 0 && y < 0) {
            if (x > y) {
                ++count; // B
                count += Math.abs(y) - Math.abs(x); // A
                ++count; // B
            } else {
                count += Math.abs(x) - Math.abs(y); // A
            }
        } else if (x >= 0 && y < 0) {
            if (x > Math.abs(y)) {
                ++count; // B
                count += x - Math.abs(y); // A
            } else {
                count += Math.abs(y) - x; // A
                ++count; // B
            }
        } else if (x < 0 && y > 0) {
            if (Math.abs(x) > y) {
                count += Math.abs(x) - y; // A
                ++count; // B
            } else {
                ++count; // B
                count += y - Math.abs(x); // A
            }
        } else if (x < 0 && y == 0) {
            count += Math.abs(x); // A
        } else if (x > 0 && y == 0) {
            ++count; // B
            count += x; // A
        } else {
            if (x > y) {
                ++count; // B
                count += x - y; // A
                ++count; // B
            } else {
                count += y - x; // A
            }
        }

        out.println(count);
    }
    private long C(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        for (long i = r; i > 1; --i) {
            res /= i;
        }
        return res;
    }
    private long P(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        new Main().solve(sc, out);
        out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 10192
#include<cstdio>
#include<list>
#include<algorithm>
 
int main(){
    int q, x;
    char com[20];
    std::list<int> v;
    scanf("%d", &q);
    for (int i = 0; i < q; ++i){
        scanf("%s", com);
        if (com[0] == 'i'){
            scanf("%d", &x);
            v.push_front(x);
        }
        else if (com[6] == 'L'){
            v.pop_back();
        }
        else if(com[6] == 'F'){
            v.pop_front();
        }
        else if(com[0] == 'd'){
            scanf("%d", &x);
            for (auto it = v.begin(); it != v.end(); ++it){
                if (*it == x){
                    v.erase(it);
                    break;
                }
            }
        }
    }
    int i = 0;
    for (auto it = v.begin(); it != v.end(); ++it){
        if (i++)printf(" ");
        printf("%d", *it);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 32216
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    tmp = input[0].split(" ");
    var a = Number(input[0])
    var s = input[1]

    if(a>=3200){
        console.log(s)
    }else{
        console.log('red')
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cassert>
#include <map>
#include <list>
#include <set>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
#define pb push_back
#define mp make_pair

char a[11];


int main()
{
  scanf("%s", a);
  ll ans = 0;
  int len = strlen(a);
  for (int i = 0; i < len; ++i)
    {
      ll cur = 0;
      for (int j = i; j < len; ++j)
	{
	  cur = cur*10+(a[j]-'0');
	  ans += cur<<(max(0, i-1)+max(0, len-2-j));
	}
    }
  printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pi 3.14159265358979323846264
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vl vector <long long>
#define vpii vector <pair <int, int> >
#define ll long long
#define fi first
#define se second
#define FOR(i, x, y) for (int i=x; i<=y; i++)
#define FORI(i, x, y) for (int i=y; i>=x; i--)
#define debug printf("OK\n")
int n, a[100005], ans;
map <int, int> m;
int main() {
    cin >> n;
    for (int i=0; i<n; i++) cin >> a[i];
    for (int i=0; i<n; i++) {
        auto it = m.upper_bound(-a[i]);
        if (it == m.end()) ans++;
        else {
            int k = it->first;
            m[k]--;
            if (m[k] == 0) m.erase(it);
        }
        //CODE
        m[-a[i]]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, X, M;
    cin >> N >> X >> M;

    vector<int> ord(M, -1);
    vector<ll> rireki, syu;
    ll res = 0;
    for (int n = 0; n < N; n++) {
        if (ord[X] != -1) {
            int p = ord[X];
            for (int i = p; i < n; i++) {
                syu.push_back(rireki[i]);
            }
            break;
        }
        ord[X] = n;
        rireki.push_back(X);
        res += X;
        X = (X * X) % M;
    }
    N -= rireki.size();
    if (N == 0)
    {
        cout << res << endl;
        return 0;
    }

    vector<ll> sum(syu.size() + 1, 0);
    for (int i = 0; i < syu.size(); i++)
        sum[i + 1] = sum[i] + syu[i];

    ll q = N / syu.size();
    ll r = N % syu.size();
    res += sum[syu.size()] * q + sum[r];
    cout << res << endl;
    return 0;
}


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

int main(void) 
{
	int i ;
	int counter=0;	
	char eitango[100]={0}; 
	char shouryaku[10]={0};

	scanf("%s",eitango);

	counter = strlen(eitango);

	
	sprintf (shouryaku,"%c%d%c",eitango[0],counter-2,eitango[counter-1]);
	printf ("%s\n",shouryaku);



	return 0;
}


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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==5&&b==5&&c==7){
        cout<<"YES"<<endl;
    }
    else if(a==5&&b==7&&c==5){
        cout<<"YES"<<endl;
    }
    else if(a==7&&b==5&&c==5){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int map[100005];
long long flag[100005];
int main()
{
	int n,sum=0;
	long long k;
	cin>>n>>k;
	for(int i=0; i<n; i++)
	{
		int a,ant;
		cin>>a>>ant;
		if(flag[a])
			flag[a]+=ant;
		else
		{
			map[sum++]=a;
			flag[a]=ant;
		}
	}
	sort(map,map+sum);
	long long cnt=0;
	int i;
	for( i=0; i<sum; i++)
	{
		cnt+=flag[map[i]];
		if(cnt>=k)
			break;
	}
	cout<<map[i]<<endl;
	return 0;
}

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

struct edge
{
	int u, v, w;
	
	edge(void) {};
	edge(int a, int b, int c) :
		u(a), v(b), w(c) {};
		
	friend bool operator < (const edge &a, const edge &b)
	{
		return a.w < b.w;
	}
	
	friend bool operator > (const edge &a, const edge &b)
	{
		return a.w > b.w;
	}
};

class MCA
{
	private:
		
		const static int inf = 2e9;
		const static int maxn = 505;
		const static int maxm = 50005;
		
		edge inEdge[maxn];
		
		int vis[maxn], id[maxn];
	
	public:
		
		int MinCostArb(int n, int r, vector<edge> E)
		{
			int minCost = 0;
			
			while (true)
			{
				for (int i = 0; i < n; ++i)
					inEdge[i].w = inf;
					
				for (auto e : E)
					if (e.u != e.v
					&&  inEdge[e.v] > e)
						inEdge[e.v] = e;
						
				inEdge[r].w = 0;
				
				for (int i = 0; i < n; ++i)
					if (inEdge[i].w == inf)
						return inf;
						
				int cnt = 0;
				
				memset(id, -1, sizeof(id));
				memset(vis, -1, sizeof(vis));
				
				for (int i = 0; i < n; ++i)
				{
					minCost += inEdge[i].w;
					
					register int v = i;
					
					while (vis[v] != i && id[v] == -1 && v != r)
						vis[v] = i, v = inEdge[v].u;
						
					if (v != r && id[v] == -1)
					{
						register int u = inEdge[v].u;
						
						while (u != v)
							id[u] = cnt, u = inEdge[u].u;
							
						id[v] = cnt++;
					}
				}
				
				if (cnt == 0)break;
				
				for (int i = 0; i < n; ++i)
					if (id[i] == -1)id[i] = cnt++;
					
				for (auto &e : E)if (e.u != e.v)
				{
					e.w -= inEdge[e.v].w;
					e.u = id[e.u];
					e.v = id[e.v];
				}
				
				n = cnt, r = id[r];
			}
			
			return minCost;
		}
}mca;

signed main(void)
{
	int n, m, r;
		cin >> n >> m >> r;
		
	vector<edge> e;
		for (int i = 0; i < m; ++i)
		{
			int u, v, w;
				cin >> u >> v >> w;
			if (u != v)
				e.push_back(edge(u, v, w));
		}
		
	cout << mca.MinCostArb(n, r, e) << endl;
}

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

#define int           long long 
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v){
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}


void solve(int &test) {
	string s, t;
	cin >> s >> t;

	int ans = inf;

	for(int i = 0; i < si(s)-si(t)+1; i++) {
		int cur = si(t);
		for(int j = 0; j < si(t); j++) {
			if(s[i+j] == t[j])cur--;
		}
		ans = min(ans, cur);
	}

	cout << ans << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   
    start = clock(); 

    
  
    int test = 1;
    // cin >> test;

    cout << fixed << setprecision(2);
     
    for(int i = 1; i <= test; ++i){
        solve(i); 
    }

    cerr << time(start);
    return 0;
}

Measured memory_bytes: 3848