akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N,Q,S,T;
int A[222222];
signed main(){
    scanf("%lld%lld%lld%lld",&N,&Q,&S,&T);
    rep(i,N+1)scanf("%lld",&A[i]);
    rep(i,N)A[i]=A[i+1]-A[i];

    int ans=0;
    rep(i,N){
        if(A[i]<0)ans+=A[i]*T;
        else ans+=A[i]*S;
    }


    rep(i,Q){
        int l,r,x;
        scanf("%lld%lld%lld",&l,&r,&x);
        l--;
        if(A[l]<0)ans-=A[l]*T;
        else ans-=A[l]*S;

        A[l]+=x;
        if(A[l]<0)ans+=A[l]*T;
        else ans+=A[l]*S;

        if(r!=N){
            if(A[r]<0)ans-=A[r]*T;
            else ans-=A[r]*S;

            A[r]-=x;
            if(A[r]<0)ans+=A[r]*T;
            else ans+=A[r]*S;
        }
        printf("%lld\n",-ans);

    }
    return 0;
}

Measured memory_bytes: 4784
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    x = int(input().strip())
    temp=100
    for i in range(1000000000):
        if temp>=x:
            print(i)
            return
        temp=int(temp*1.01)


if __name__ == '__main__':
    main()

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  string s;
  cin >> s;
  int minn = s.size();
  for(int i = 1; i < s.size(); i++){  
    if(s[i-1] != s[i]) minn = min(minn , max(i, (int)s.size()-i)); 
  }
  cout << minn <<endl;
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    ll n,m;
    cin>>n>>m;
    if(2*n>m)cout<<m/2<<endl;
    else cout<<n+(m-2*n)/4<<endl;
}


Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(M),B(M),d(M+10,INF);
  rep(i,M)cin >> A[i] >> B[i];
  d[1]=0;
  vector<vector<int>> r(M+10);
  rep(i,M){
    r.at(A[i]).push_back(B[i]);
    r.at(B[i]).push_back(A[i]);
  }
  queue<int> q;
  q.push(1);
  while(!q.empty()){
    rep(j,r.at(q.front()).size()){
      if(d[r[q.front()][j]]==INF){
        q.push(r[q.front()][j]);
        d[r[q.front()][j]] = q.front();
      }
    }
    q.pop();
  }

   bool hantei = true;
  for(int i = 2;i <= N;i++){
    if(d[i]==INF){
      hantei = false;
      break;
    }
  }
  if(hantei){
    cout << "Yes" << endl;
    for(int i = 2;i <= N;i++){
      cout << d[i] << endl;
    }
  }else{
    cout << "No" << endl;
  }


}


Measured memory_bytes: 14476
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 922337203685477580
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
double dp[3005][3005];
double pro[3005];
ll n;
double func(ll head,ll tail)
{
//	cout<<head<<" "<<tail<<endl;
	if(dp[head][tail]!=-1)
		return dp[head][tail];
	ll i=head+tail;
	if(i>=n)
	{
		if(head>tail)
		{
			dp[head][tail]=1;
			return 1;
		}
		else
		{
			dp[head][tail]=0;
			return 0;
		}
	}
	double ans1=pro[i]*func(head+1,tail);
	double ans2=(1-pro[i])*func(head,tail+1);
	dp[head][tail]=ans1+ans2;
	return dp[head][tail];
}
int main()
{
	boost
	cin>>n;
	ll i,j;
	for(i=0; i<3005; i++)
		for(j=0; j<3005; j++)
			dp[i][j]=-1;
	for(i=0; i<n; i++)
		cin>>pro[i];
	double ans=func(0,0);
	std::cout << std::fixed;
	cout<<std::setprecision(9)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 70912
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[][] k = new char[9][];
        for (int i = 0; i < 9; i++)
            k[i] = ".,!? :abc:def:ghi:jkl:mno:pqrs:tuv:wxyz".split(":")[i].toCharArray();
        while (n-- > 0) {
            for (String s : sc.next().split("0"))
                if (s.length() > 0)
                    System.out.print(k[s.charAt(0) - '1'][(s.length() - 1) % k[s.charAt(0) - '1'].length]);
            System.out.println();
        }
    }
}



Measured memory_bytes: 30268
n,m = map(int,input().split())
py = []
for i in range(m):
    py.append(list(map(int,input().split())))
    py[i].append(i)
py.sort(key=lambda x:x[1])
py.sort(key=lambda x:x[0])
x = py[0][0]
j=0
for i in range(m):
    if x != py[i][0]:
        j = 1
        x = py[i][0]
    else:
        j+=1
    s = str(py[i][0]).zfill(6) + str(j).zfill(6)
    py[i].append(s)
py.sort(key=lambda x:x[2])
for i in range(m):
    print(py[i][3])

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

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

int n, m;
bool s[92][92];
int dx[4] = { 1, 0,-1, 0};
int dy[4] = { 0, 1, 0,-1};

int len(int i, int j) {
	if(!s[i][j])return 0;
	s[i][j]=false;
	int r=0;
	rep(k, 4) {
		r= max(r, len(i+dx[k], j+dy[k]));
	}
	s[i][j]=true;
	return r+1;
}

int main() {
	ios::sync_with_stdio(false);
	
	while(cin>>n>>m,n|m) {
		rep(i, m+1) s[n+1][i]=false;
		rep(i, n+1) s[i][m+1]=false;
		rep(i, m) {
			rep(j, n) {
				cin >> s[j+1][i+1];
			}
		}
		int l=0;
		rep(i, m) {
			rep(j, n) {
				l = max(l, len(j+1, i+1));
			}
		}
		cout << l << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

string s;

int main() {
    cin >> s;
    ll n = s.size();
    bool flag = false;
    ll res = 0;
    Rep(i,n-1){
        if(s[i]==s[i+1]){
            flag=true;
            res = i+1;
            break;
        }
    }
    if(flag){
        cout << res << " " << res+1 << endl;
        return 0;
    }
    Rep(i,n-2){
        if(s[i]==s[i+2]){
            flag=true;
            res = i+1;
            break;
        }
    }
    if(flag){
        cout << res << " " << res+2 << endl;
        return 0;
    }
    put("-1 -1");
}


Measured memory_bytes: 512
#include<iostream>
#include<queue>

using namespace std;

int main(){
  priority_queue<int> que;
  for(int i = 0; i < 10; i++){
    int x;
    cin >> x;
    que.push(x);
  }
  for(int i = 0; i < 3; i++){
    cout << que.top() << "\n";
    que.pop();
  }

  return 0;
}

Measured memory_bytes: 3056
import heapq
 
X, Y, Z, K = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)
 
heap = []
heapq.heappush(heap, (-(A[0] + B[0] + C[0]), 0, 0, 0))
added = set([(0, 0, 0)])
for _ in range(K):
    p, i, j, k = heapq.heappop(heap)
    if (i + 1, j, k) not in added and i + 1 < X:
        heapq.heappush(heap, (-(A[i + 1] + B[j] + C[k]), i + 1, j, k))
        added.add((i + 1, j, k))
    if (i, j + 1, k) not in added and j + 1 < Y:
        heapq.heappush(heap, (-(A[i] + B[j + 1] + C[k]), i, j + 1, k))
        added.add((i, j + 1, k))
    if (i, j, k + 1) not in added and k + 1 < Z:
        heapq.heappush(heap, (-(A[i] + B[j] + C[k + 1]), i, j, k + 1))
        added.add((i, j, k + 1))
    print(-p)

Measured memory_bytes: 4852
# -*- coding: utf-8 -*-
from itertools import accumulate
def inpl(): return map(int, input().split())

N, K, Q = inpl()
A = " " + input()
S = sorted(map(int, A.split()))
ans = S[Q-1] - S[0]
S = S[::-1]

while S:
    s = S.pop()
    A = A.replace(" {} ".format(s), " x ")

    OK = 0
    Que = A.split("x")

    tmp = []
    for q in Que:
        tmp.extend(sorted([int(x) for x in q.split()])[::-1][K-1:])
    if len(tmp) < Q:
        break
    tmp = sorted(tmp)
    ans = min(ans, tmp[Q-1] - tmp[0])

print(ans)

Measured memory_bytes: 74972
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  char X;cin>>X;
  if(X >= 'a')
  {
    cout<<'a'<<endl;
  }
  else
  {
    cout<<'A'<<endl;
  }

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3604
def msb(x) # returns 0-32
	return 0 if x == 0
	x |= x>>1
	x |= x>>2
	x |= x>>4
	x |= x>>8
	x |= x>>16
	x += 1
	return [
		31,  0, 22,  1, 28, 23, 18,  2, 29, 26, 24, 10, 19,  7,  3, 12,
		30, 21, 27, 17, 25,  9,  6, 11, 20, 16,  8,  5, 15,  4, 14, 13
	][((x*0x076be629)&0xFFFFFFFF) >> 27] + 1
end

N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

A.sort!.reverse!

MSB = []
bottom = 0
ticket = 0
(0...N).each{|i|
	MSB << msb(A[i])
	break if MSB.last < bottom
	ticket += MSB.last - bottom
	if M < ticket
		up = (ticket-M+i)/(i+1)
		bottom += up
		ticket -= up*(i+1)
	end
}
A.map!.with_index{|a, i|
	(MSB[i]||0) <= bottom ? a : a>>(MSB[i]-bottom)
}
MSB.size.times.sort_by{|i| -A[i] }.take(M-ticket).each{|i|
	A[i] >>= 1
} if ticket < M

p A.inject(&:+)


Measured memory_bytes: 30216
#include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define int long long
#define mod 1000000007

void solve() {
        int ar[4] = {};
        int a; cin >> a;
        ar[a]++;
        cin >> a;
        ar[a]++;
        for (int i = 1; i < 4; i++) if (!ar[i]) cout << i<< "\n";
        return;
}

int32_t main() {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 256
A, B, K = list(map(int,input().split()))

common_divisors = []
if A < B:
    for i in range(1, B + 1):
        if A % i == 0 and B % i ==0:
            common_divisors.append(i)
else :
    for i in range(1, A + 1):
        if A % i == 0 and B % i ==0:
            common_divisors.append(i)

# print(common_divisors)
print(common_divisors[-K])

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    // Your code here!
    char S[5];
    scanf("%s",S);
    int ans = 0;

    for(int i = 0; i < 4; i++){
        if(S[i]=='+'){
            ans += 1;
        }
        else{
            ans-=1;
        }
                   //printf("%d\n",ans);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

vec q(300001,0);
int main() 
{

 fast();
  
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt","w",stdout);
  // #endif
  ll a,b,n,c,d,s=0;
  str s1,s2;
  cin>>s1>>s2;
  f(i,0,3)
  {
    if(s1[i]!=s2[i])
      s++;
  }
  cout<<3-s;

 
  cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 2560
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X, Y = map(int, read().split())

nums = [2 * X + 2 * t for t in range(X + 1)]
answer = 'Yes' if Y in nums else 'No'
print(answer)

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    char a[3],b[3];
    for(int i=0;i<=2;i++) cin>>a[i];
    for(int i=0;i<=2;i++) cin>>b[i];
    if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0]) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let a: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let A = {
        let mut A = a.clone();
        A.sort();
        A.reverse();
        A
    };

    let ans = (0..N).map(|i| A[2 * i + 1]).sum::<i64>();

    println!("{}", ans);
}

Measured memory_bytes: 15088
H,W=map(int,input().split())
campus=[]
for _ in range(H):
    campus.append(input())
    
def ok(y,x):
    if campus[y][x]==".":
        return(True)
    else:
        TRUE=0
        if y==0:
            pass
        else:
            if campus[y-1][x]=="#":
                TRUE=1
        if y==H-1:
            pass
        else:
            if campus[y+1][x]=="#":
                TRUE=1
        if x==0:
            pass
        else:
            if campus[y][x-1]=="#":
                TRUE=1
        if x==W-1:
            pass
        else:
            if campus[y][x+1]=="#":
                TRUE=1
        if TRUE==1:
            return(True)
        else:
            return(False)

achievement=0            
for i in range(H):
    for j in range(W):
        if ok(i,j):
            pass
        else:
            achievement+=1
            
if achievement==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import copy
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.pop(0)
for i in range(n-1):
  t=list(map(int,input().split()))
  k=t.pop(0)
  b=copy.deepcopy(a)
  for j in range(0,len(a)):
    if not b[j] in t:
      a.remove(b[j])
print(len(a))
  

Measured memory_bytes: 3444
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

import math
n = readint()
c = readstr()

r = c.count('R')
w = c.count('W')
ans = 0
for i in range(r):
    if c[i]=='W':
        ans += 1
for i in range(r+1,n):
    if c[i]=='R':
        ans += 1
print(math.ceil(ans/2))


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

int main() {
    int N; cin >> N;
    vector<long long> B(N-1);
    for (int i = 0; i < N-1; ++i) cin >> B[i];

    long long res = B[0] + B.back();
    for (int i = 0; i + 1 < B.size(); ++i) {
        res += min(B[i], B[i+1]);
    }
    cout << res << endl;
}

Measured memory_bytes: 3608
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.stream.Stream;
import java.util.Collection;
import java.util.Scanner;
import java.util.ArrayList;

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

    static class BKagamiMochi {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = Integer.parseInt(in.next());
            List<Integer> l = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                l.add(Integer.parseInt(in.next()));
            }
            long ans = l.stream().sorted().distinct().count();
            out.println(ans);
        }

    }
}



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

int main() {
  int n,t, sum=0;
  cin>>n;
  t=n;
  for(int i=1;i<10;i++){
    sum+=n%10;
    n/=10;
  }
  if(t%sum==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
module Geometry
  EPS = 1e-11
  COUNTER_CLOCKWISE = 1
  CLOCKWISE = -1
  ONLINE_BACK = 2
  ONLINE_FRONT = -2
  ON_SEGMENT = 0

  Point = Struct.new(:y, :x) do
    def +(point)
      Point.new(y + point.y, x + point.x)
    end

    def -(point)
      Point.new(y - point.y, x - point.x)
    end
  end

  Circle = Struct.new(:c, :r)
  Line = Struct.new(:p1, :p2)

  def norm(v)
    v.x ** 2 + v.y ** 2
  end

  def abs(v)
    Math.sqrt(norm(v))
  end

  def dot(v1, v2)
    v1.x * v2.x + v1.y * v2.y
  end

  def cross(v1, v2)
    v1.x * v2.y - v1.y * v2.x
  end

  def arg(v)
    Math.atan2(v.y, v.x)
  end

  def polar(a, r)
    Point.new(Math.sin(r) * a, Math.cos(r) * a)
  end

  def ccw(p0, p1, p2)
    a = p1 - p0
    b = p2 - p0

    return COUNTER_CLOCKWISE if cross(a, b) > EPS
    return CLOCKWISE if cross(a, b) < -EPS
    return ONLINE_BACK if dot(a, b) < -EPS
    return ONLINE_FRONT if norm(a) < norm(b)

    ON_SEGMENT
  end

  def intersect(p1, p2, p3, p4)
    ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0
  end

  def get_circle_cross_point(c1, c2)
    d = abs(c1.c - c2.c)
    a = Math.acos(Rational(c1.r ** 2 + d ** 2 - c2.r ** 2, 2 * c1.r * d))
    t = arg(c2.c - c1.c)
    [c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a)]
  end
end

include Geometry

c1x, c1y, c1r = gets.split.map(&:to_i)
c2x, c2y, c2r = gets.split.map(&:to_i)

c1 = Circle.new(Point.new(c1y, c1x), c1r)
c2 = Circle.new(Point.new(c2y, c2x), c2r)

p1, p2 = get_circle_cross_point(c1, c2)

list = [[p1.x, p1.y], [p2.x, p2.y]].sort_by { |a, b| [a, b] }.flatten

puts "%.8f %.8f %.8f %.8f" % list



Measured memory_bytes: 7064
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<int,int>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int INF=1000000007;
using ll=long long;

int n,m,u[55],v[55],necessary=0;
P p[55];
bool f[55]={},g[55][55]={};
void dfs(int cur){
	f[cur]=true;
	rep(i,1,n+1){
		if(!f[i]&&g[i][cur]){
			dfs(i);
		}
	}
}

int main(){
	cin>>n>>m;
	rep(i,0,m){
		cin>>u[i]>>v[i];
		g[u[i]][v[i]]=g[v[i]][u[i]]=true;
	}
	rep(i,0,m){
		rep(j,0,55)f[j]=false;
		g[u[i]][v[i]]=g[v[i]][u[i]]=false;
		dfs(1);
		rep(j,1,n+1)if(!f[j]){
			necessary++;
			break;
		}
		g[u[i]][v[i]]=g[v[i]][u[i]]=true;
	}

	print(necessary);
}

Measured memory_bytes: 256
from itertools import product
n = int(input())
Ct = [i for i in range(101)]
Cli = list(product(Ct,Ct))
XY = []
sx,sy,sh = 0,0,0
for i in range(n):
    x,y,h = map(int,input().split())
    XY.append([x,y,h])
    if h != 0: sx,sy,sh = x,y,h
for (cx,cy) in Cli:
    #cx,cyが候補。XYが実測値のリスト
    ht = sh + abs(sx-cx) + abs(sy-cy)
#    print(cx,cy,"ht=",ht)
    for i in XY:
        ht2 = max(ht-abs(i[0]-cx)-abs(i[1]-cy),0)
#        print(i[0],i[1],i[2],"ht2=",ht2,"と比較中")
        if ht2 != i[2]: break
    else:
        print(cx, cy, ht)
        break



Measured memory_bytes: 3700
//C
#include <bits/stdc++.h>
using namespace std;
const int INF = pow(10,9);

int main(){
    int N,K; cin >> N >> K;
    vector<int> h(N);
    for(int i=0;i<N;i++) cin >> h[i];
    sort(h.begin(),h.end());
    int ans = INF;
    for(int i=0;i<=N-K;i++){
        ans = min(ans,h[i+K-1]-h[i]);
    }
    cout << ans << endl;
}

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

ll dampode (int n,int k, vector<vector<ll>> dp, vector<ll> ht);

ll bottoms_up(int n, int k,vector<ll> ht)
{
    ll dp[n];
    dp[0] = 0;
    dp[1] = abs(ht[1] - ht[0]);
    
    for(int i=2;i<n;i++)
    {
        ll res = INT_MAX;
        for(int j=1;j<=k;j++)
        {
            if(i-j >= 0)
            {
                res = min(res, dp[i-j] + abs(ht[i] - ht[i-j]));
            }
        }
        dp[i] = res;
    }
    return dp[n-1];
}

int main()
{
    int n,k;
    cin>>n>>k; 
    
    vector<ll> ht(n);
    for(int i=0;i<n;i++)
    {
        cin>>ht[i];
    }
    vector<vector<ll>> dp (n+1,vector<ll> (k+1,-1));
    //cout<<dampode(n,k, dp, ht)<<endl;
    cout<<bottoms_up(n, k, ht)<<endl;
}

Measured memory_bytes: 87456
#include<stdio.h>
int main(){
  int n,m,i,j,k,l,min,d;
  int ic[150],is[2][150][10];
  int c[80][150][11];
  while(scanf("%d %d",&n,&m),n||m){
    int c[80][150][11]={0};
    for(i=0;i<80;i++){
      for(j=1;j<150;j++){
	for(k=0;k<11;k++)c[i][j][k]=2100000000;
      }
    }
    for(i=0;i<11;i++)c[1][1][i]=0;
    for(i=0;i<n;i++){
      scanf("%d",&ic[i]);
      for(j=0;j<ic[i];j++){
	scanf("%d %d",&is[0][i][j],&is[1][i][j]);
      }
    }
    for(i=0;i<=m;i++){
      for(j=0;j+1<n;j++){
	for(k=0;k<ic[j];k++){
	  for(l=0;l<ic[j+1];l++){
	    d=(is[1][j][k]+is[1][j+1][l])*abs(is[0][j][k]-is[0][j+1][l]);
	    //printf("d%d from %d %d to %d %d\n",
	    //	   d,is[0][j][k],is[1][j][k],is[0][j+1][l],is[1][j+1][l]);
	    if(c[i][j+1][l]>c[i][j][k]+d)c[i][j+1][l]=c[i][j][k]+d;
	  }
	  if(j+2==n)continue;
	  for(l=0;l<ic[j+2];l++){
	    d=(is[1][j][k]+is[1][j+2][l])*abs(is[0][j][k]-is[0][j+2][l]);
	    //printf("d%d from %d %d to %d %d\n",
	    //	   d,is[0][j][k],is[1][j][k],is[0][j+2][l],is[1][j+2][l]);
	    if(c[i+1][j+2][l]>c[i][j][k]+d)c[i+1][j+2][l]=c[i][j][k]+d;
	  }
	}
      }
    }
    /*for(i=0;i<=m;i++){
      for(j=0;j<n;j++){
	for(k=0;k<ic[j];k++)printf("%d ",c[i][j][k]);printf("\n");
      }printf("\n");
      }//*/
    min=2100000210;
    for(i=0;i<=m;i++){
      for(j=0;j<ic[n-1];j++){
	if(min>c[i][n-1][j])min=c[i][n-1][j];
      }
      if(m==i)continue;
      for(j=0;j<ic[n-2];j++){
	if(min>c[i][n-2][j])min=c[i][n-2][j];
      }
    }
    printf("%d\n",min);
  }
  return 0;
}

Measured memory_bytes: 1136
def main():
    N = int(input())
    word_list=[input() for i in range(N)]
    already_list = []
    for i, word in enumerate(word_list):
        if(i==0):
            already_list.append(word)
            continue
        if(word not in already_list and word[0] == word_list[i-1][len(word_list[i-1])-1]):
            already_list.append(word)
        else:
            print('No')
            return
    print('Yes')




if __name__ == "__main__":
    main()

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

using lli = long long int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

  for(int i = 1; i < b; i++) {
    if(i*a%b==c) {
      cout << "YES" <<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
//B
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<set>
#define ld long double 
#define ll long long
#define lll __int128 
//#define int ll
#define eps 1e-11
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
typedef pair<int, int> P;

const int maxn = 1e5 + 5;

set<int> t;
int arr[maxn];

signed main()
{
	fastio;
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	for (int i = n - 1; i >= 0; i--)
	{
		if (m == 0)
			break;
		if (!t.insert(arr[i]).second)
			continue;
		cout << arr[i] << endl;
		m--;
	}
}


Measured memory_bytes: 6012
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
def p(a):print(" ".join(list(map(str,a))))
from collections import Counter

s=S()
t=S()
x=0
for i in range(len(s)):
    if s[i]!=t[i]:x+=1
print(x)


Measured memory_bytes: 9720
def souwa(n):
  return n * (n + 1) // 2

arr = input().replace('><', "> <").split()
res = 0
for s in arr:
  a = s.count("<")
  b = len(s) - a
  if(a < b):
    res += souwa(a - 1)
    res += souwa(b)    
  else:
    res += souwa(a)
    res += souwa(b - 1)
print(res)

Measured memory_bytes: 12464
#include <bits/stdc++.h>
using namespace std ;
 int main()
 {
   int a;int b;
   cin>>a>>b;
   int product=a*b;bool flag=false;
   for(int i=1;i<=3;i++){
     if((i*product)%2==1){cout<<"Yes";bool flag=true;
   break;}
     if(i==3 && flag==false){cout<<"No";}
   }
   return 0;
 }


Measured memory_bytes: 256
fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val s = readLine()!!
    if(n % 2 == 0){
        var ok = true
        for(i in 0 until n / 2){
            if(s[i] != s[i + n / 2]) ok = false
        }
        println(if(ok) "Yes" else "No")
    }
    else{
        println("No")
    }
}


Measured memory_bytes: 31772
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;

int n,k,s;

int main()
{
    scanf("%d%d%d",&n,&k,&s);
    for(int i=0;i<k;i++)
        printf("%d ",s);
    n-=k;
    int MAX=1e9;
    if(s==MAX)
        --s;
    else
        ++s;
    for(int i=0;i<n;i++)
        printf("%d ",s);
    putchar('\n');
    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0)
    cout<<1;
  if(b==0)
    cout<<2;
  if(c==0)
    cout<<3;
  if(d==0)
    cout<<4;
  if(e==0)
    cout<<5;
}


Measured memory_bytes: 3196
//                        Bismillahir Rahmanir Rahim
//ALGO:
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF INT_MAX
#define mx 1000010
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<pair<int, int>, null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update>
*/
const double Pi=acos(-1);
using namespace std;
int debug=01;

int main() {
    double x;
    cin>>x;
    x/=3;
    cout<<fixed<<setprecision(10)<<x*x*x;
}


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

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


int main() {
  int k;
  int ans = 0;
  cin >> k;
  for (int i = 1; i <= k; ++i) {
      for (int j = 1; j <= k; ++j) {
          for (int l = 1; l <= k; ++l) {
              ans += gcd(gcd(i, j), l);
          }
      }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(int)(n);i++)
#define foi(i,k,n) for(int i=(k); i<(int)(n); i+=1)
#define fod(i,n,k) for(int i=k; i>=(int)n; i-=1)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define endl "\n"

#define int long long
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long llint;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<llint> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
llint toint(string s) {stringstream ss(s); llint x; ss >> x; return x;}
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//gp_hash_table<string, llint> table;


//int mpow(llint base, llint exp) {
  //base %= MOD;
  //llint result = 1;
  //while (exp > 0) {
    //if (exp & 1) result = ((llint)result * base) % MOD;
    //base = ((llint)base * base) % MOD;
    //exp >>= 1;
  //}
  //return result;
//}


//void makegraph(int n, int m){
	//int i, u, v;
	//while(m--){
		//cin>>u>>v;
		//u--, v--;
		//g[u].pb(v);
		//g[v].pb(u);
	//}
//}

//void dfs(int u, int par){
	//for(int v:g[u]){
		//if (v == par) continue;
		//dfs(v, u);
	//}
//}


// ------------------------------------------------------------------ILB----------------------------------------------------------------  //



void solve(){
	int a, b;
	cin >> a >> b;
	int ans = 0;
	loop(i, a){
		int x, y;
		cin >> x >> y;
		ans += (ceil(sqrt(x*x + y*y)) <= b);
	}
	cout << ans;
}




int32_t main() {
	fast_io;
    int t = 1;
    //cin >> t;
    //int xx = 0
    while(t--) {
		//xx++;
		//cout << "Case ";
      solve();
    }
    return 0;
}



Measured memory_bytes: 3692
N,K = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)

b = Array.new(N, 0)
a.map { |a| b[a-1] += 1 }
b.sort!.select! {|b| b > 0}

c = b.size
t = 0

if c <= K
  puts 0
else
  until c <= K
    c -= 1
    t += b.shift
  end
  puts t
end


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a,b,c,d,cmp,cmpp,data,m,h,x,y,xcmp=0,ycmp=0,sum=0;

string s,w;

vector<int> z;

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

   cin >> a >> b >> c >> d >> n;
   cmp=min(a*4,b*2);
   cmp=min(cmp,c);
   //cmpp=min(cmp*2,d);
   if(cmp*2<=d){
       Cout(cmp*n);
   }
   else{
       if(n%2!=0){
       cmpp=d*(n/2);
       Cout(cmpp+cmp);
       }
       else{
           Cout(d*(n/2));
       }
   }
return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[]
    for i in range(1,int((n**0.5))+1):
        if n%i==0:
            a,b=i,n//i
            l.append(a+b-2)
    print(min(l))
resolve()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=1e9+7;

int main(){
    ll x;
    cin>>x;
    ll h=100;
    ll ans=0;
    while(h<x){
        h*=1.01;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))

#define INF 200000000

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

vector<int> G[10000];
vector<int> L;
bool checked[10000];

void visit(int n)
{
	if (!checked[n])
	{
		checked[n] = true;
		for (auto& m : G[n])
		{
			visit(m);
		}
		L.push_back(n);
	}
}

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

	int V, E;
	scanf("%d %d", &V, &E);

	for (int i = 0; i < E; i++)
	{
		int u, v;
		scanf("%d %d", &u, &v);

		G[u].push_back(v);
	}

	for (int i = 0; i < V; i++)
	{
		visit(i);
	}

	reverse(L.begin(), L.begin() + V);
	for (int i = 0; i < V; i++)
	{
		printf("%d\n", L[i]);
	}
	return 0;
}


Measured memory_bytes: 4004
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int X;
    cin>>X;

    X-=599;
    int k=8;

    while(X>0){
        X-=200;
        k--;
    }

    cout<<k<<endl;
}


Measured memory_bytes: 3192
#include <stdio.h>

#define MAX 100005

typedef struct{
  char name[10];
  int t;
} P;

P Q[MAX+1];
int head,tail,N;

void enqueue(P);
P dequeue(void);
int mini(int,int);

int main(){
  int fullt = 0;
  int c,i,prot;
  P pro;

  scanf("%d %d",&N,&prot);

  for(i=1;i<=N;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }

  head = 1;
  tail = N + 1;

  while(head != tail){
    pro = dequeue();
    c = mini(prot,pro.t);
    pro.t -= c;
    fullt += c;

    if(pro.t > 0){
      enqueue(pro);
    }

    else{
      printf("%s %d\n",pro.name,fullt);
    }
  }

  return 0;
}

void enqueue(P pro){
  Q[tail] = pro;
  tail = (tail + 1) % MAX;
}

P dequeue(void){
  P pro = Q[head];

  head = (head + 1) % MAX;

  return pro;
}

int mini(int a,int b){

  if(a > b)return b;

  else return a;
}
             



Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
typedef set <int> S;

int skip(string str,int i){
  int cnt=str[i++]=='(';
  while(cnt) cnt+=(str[i]=='(')-(str[i++]==')');
  return i-1;
}

void calc(char ch,S a,S b, S &res){
  S::iterator i,j;
  for(i=a.begin();i!=a.end();i++)
    for(j=b.begin();j!=b.end();j++){
      int I=*i,J=*j;
      if(ch=='+') I+=J;
      else if(ch=='-') I-=J;
      else if(ch=='*') I*=J;
      else if(ch=='/'&&J)I/=J;
      else continue;
      res.insert(I);
    }
}

int num[1<<8];
S solve(string str){
  S res;
  int len=str.size();
  if(len==1){res.insert(num[str[0]]);return res;}
  if(skip(str,0)==len-1)res=solve(str.substr(1,len-2));

  for(int i=0;(i=skip(str,i))<len-1;i+=2)
    calc(str[i+1],solve(str.substr(0,i+1)),solve(str.substr(i+2,len-i-2)),res);

  return res;
}

int main(){
  while(1){
    string str;
    cin>>str;
    if(str=="#")break;

    string siki;
    char ch='A';
    for(int i=0;i<str.size();){
      int b=0;
      while('0'<=str[i]&&str[i]<='9') b=b*10+str[i++]-'0';
      if(b)num[ch]=b,siki+=ch++;
      else siki+=str[i++];
    }
    cout <<solve(siki).size()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    ll N, X; cin >> N >> X;
    ll now = 0;

    ll res = 1;
    rep(i, 0, N) {
        ll L; cin >> L;
        now += L;
        if (now > X) break;
        ++res;
    }

    cout << res << endl;
}

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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int L = 0, R = 0;
    rep(i,N) if (S[i] == '.') R++;
    ll mi = L + R;
    rep(i,N) {
        if (S[i] == '#') L++;
        else R--;
        if (mi > L+R) {
            mi = L+R;
        }
    }
    cout << mi << endl;
}


Measured memory_bytes: 3764
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    s = [0]*(n+1)
    for i in range(n):
        s[i+1] = a[i] + s[i]
    d = {}
    for i in s:
        if d.get(i):
            d[i] += 1
        else:
            d[i] = 1
    ans = 0
    for k in d.keys():
        ans += d[k] * (d[k] - 1) // 2
    print(ans)
resolve()

Measured memory_bytes: 112848
N= int(input()) 
B = list(map(int,input().split()))
A = [0 for i in range(N)]
A[0] = B[0]
A[-1] = B[-1]
for i in range(1,N-1):
    if B[i]>= B[i-1]:
        A[i] = B[i-1]
        A[i+1] = B[i]
    else:
        A[i] = B[i]
        A[i+1] = B[i]
print(sum(A))

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

using namespace std;
const int INF = 1000000;

struct Node{
	vector<int>to;
	vector<int>cost;
};
struct node{
	int cost;
	bool visited;
};
Node nodes[101];
int dist[101][101];

void dijkstra(int x,int y){
	int targetNode;
	int cost[101];//xからの距離を保存する
	node mawariNodes[101];
	
	for(int i=0;i<101;i++){
		cost[i] = INF;
		mawariNodes[i].cost = INF;
		mawariNodes[i].visited = false;
	}
	
	targetNode = x;
	
	cost[targetNode] = 0;
	mawariNodes[targetNode].visited = true;
	mawariNodes[targetNode].cost = 0;
	
	while(true){
		
		for(int i=0;i<nodes[targetNode].to.size();i++){
			int now = nodes[targetNode].to[i];//nowは頂点番号　iはnodesに使う
			if(mawariNodes[now].visited)continue;//行ったことがあればぶち込まない
			mawariNodes[now].cost = min(mawariNodes[now].cost,cost[targetNode] + nodes[targetNode].cost[i]);//targetNodeの周りの頂点をぶち込む
		}
		
		int min=INF;
		int nodeNumber = -1;
		for(int i=0;i<101;i++){
			if(mawariNodes[i].visited)continue;//確定してないノード
			if(min > mawariNodes[i].cost){//で一番コストが低いノード
				min = mawariNodes[i].cost;
				nodeNumber = i;
			}
		}
		if(nodeNumber == -1)break;
		if(mawariNodes[y].visited)break;
		
		mawariNodes[nodeNumber].visited = true;
		cost[nodeNumber] = mawariNodes[nodeNumber].cost;
		targetNode = nodeNumber;
	}
	dist[x][y] = cost[y];
	dist[y][x] = cost[y];
}
int main(){
	int N,M;
	int a[1001],b[1001],c[1001];
	
	
	for(int i=0;i<101;i++){
		for(int j=0;j<101;j++){
			if(i == j){
				dist[i][j] = 0;
			}else{
				dist[i][j] = INF;
			}
		}
	}
	
	cin >> N >> M;
	for(int i=0;i<M;i++){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--;
		b[i]--;
		dist[a[i]][b[i]] = c[i];
		dist[b[i]][a[i]] = c[i];
		nodes[a[i]].to.push_back(b[i]);
		nodes[a[i]].cost.push_back(c[i]);
		nodes[b[i]].to.push_back(a[i]);
		nodes[b[i]].cost.push_back(c[i]);
	}

	for(int i=0;i<N;i++){
		for(int j=i;j<N;j++){
			if(i==j)continue;
			dijkstra(i,j);
		}
	}

	int answer = M;
	for(int i=0;i<M;i++){//全ての辺について
		bool isShortest = false;
		for(int j=0;j<N;j++){
			if(dist[j][a[i]] + c[i] == dist[j][b[i]]){
				isShortest = true;
			}
		}
		if(isShortest){
			answer = answer - 1;
		}
	}
	
	cout << answer << endl;
	
	return 0;
}


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

const int INF = 2e9;

int main(){
    int x;
    cin >> x;
    if(x < 600)cout << 8 << endl;
    else if(x < 800) cout << 7 << endl;
    else if(x < 1000)cout << 6 << endl;
    else if(x < 1200)cout << 5 << endl;
    else if(x < 1400)cout << 4 << endl;
    else if(x < 1600)cout << 3 << endl;
    else if(x < 1800)cout << 2 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
long long dp[N];
int main(){
	int n, k;
	cin >> n >> k;
	vector<int> arr(n);
	for(int i = 0; i < n; ++i)
		cin >> arr[i];
	for(int i = n-2; i >= 0; --i){
		dp[i] = 1e9+7;
		for(int j = 1; j <= k; ++j)
			if(i+j < n)
				dp[i] = min(dp[i], abs(arr[i] - arr[i+j]) + dp[i+j]);
	}
	cout << dp[0];
	return 0;
}


Measured memory_bytes: 1408
// https://atcoder.jp/contests/abc119/tasks/abc119_b
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    double total_worth = 0;
    ll no_of_gifts;
    cin >> no_of_gifts;
    while (no_of_gifts--)
    {
        double amount;
        string currency;
        cin >> amount >> currency;
        if (currency == "BTC")
        {
            total_worth += (amount * 380000.0);
        }
        else
        {
            total_worth += amount;
        }
    }
    cout << total_worth << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if (U == S) cout << A - 1 << " " << B << endl;
    else cout << A << " " << B - 1 << endl;
}


Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,boundary=1,search=[],replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,boundary=1,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):return [[tb//(n**bt)%n for bt in range(k)] for tb in range(n**k)]
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)
def show2d(g,h,w):
    for i in range(h):show(g[i*w:i*w+w])

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

def gcj(t,*x):
    print("Case #"+str(t)+":",*x)
    return

n,t=LI()
N=6001
N=31
dp=[[0]*t for i in range(n+1)]
c=[]
for i in range(n):
    a,b=LI()
    c+=[(a,b)]
c.sort(key=lambda x:x[0]*4000-x[1])
for i in range(n):
    a,b=c[i]
    ans=max(ans,dp[i][-1]+b)
    for j in range(t):
        dp[i+1][j]=max(dp[i+1][j],dp[i][j])
        if j+a<t:
            dp[i+1][j+a]=max(dp[i][j]+b,dp[i][j+a])

print(ans)

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

int main()
{
	int m, f, b;
	cin >> m >> f >> b;

	if (m >= b)
	{
		cout << 0 << endl;
	}
	else if (m + f >= b)
	{
		cout << b - m << endl;
	}
	else
	{
		cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 3072
#include<iostream>
using namespace std;
void output(){
    int a,b;
    char op;
    while(1){
        cin>>a>>op>>b;
        if(op=='?')break;
        if(op=='+') cout<<a+b<<endl;
        else if(op=='-') cout<<a-b<<endl;
        else if(op=='*') cout<<a*b<<endl;
        else if(op=='/') cout<<a/b<<endl;
    }
}
int main(){
    output();
    return 0;
}

Measured memory_bytes: 3088