akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

int D[10005];
int used[10005];
int main(void) {
    //priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    int ans[10005];
    int N; cin >> N;
    vector<vector<int>> edge(N);
    for (int i = 0; i < N-1; i++) {
        int a, b; cin >> a >> b;
        a--;
        b--;
        D[a]++;
        D[b]++;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<int> c(N);
    for (int i = 0; i < N; i++) {
        cin >> c[i];
    }
    int sum = 0;
    sort(c.begin(), c.end());
    for (int i = 0; i < N; i++) {
        int mi = 10000000;
        int v;
        for (int j = 0; j < N; j++) {
            if (mi > D[j] && used[j] == 0) {
                v = j;
                mi = D[j];
            }
        }
        used[v] = 1;
        ans[v] = c[i];
        if (i != N-1) sum += c[i];
        for (int j = 0; j < edge[v].size(); j++) {
            D[v]--;
            D[edge[v][j]]--;
        }
        
    }
    cout << sum << endl;
    for (int i = 0; i < N; i++) {
        cout << ans[i] << " ";
    }
    cout << endl;
}   


Measured memory_bytes: 1024
f=lambda:map(int,input().split())
N,X=f()
*A,=f()

B=[a if a<=X else X for a in A]
c=sum(A)-sum(B)
for i in range(N-1):
 t=B[i]+B[i+1]
 if X < t:
    d=t-X
    B[i+1]-=d
    c+=d
print(c)

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

using namespace std;

typedef long long LL;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define fin "\n"


#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

template <typename T>
inline void chmin(T &l,T r){l=min(l,r);}

template <typename T>
inline void chmax(T &l,T r){l=max(l,r);}

LL deq[300000];
void ch(vector<LL>& a,vector<LL>& b,vector<LL>& A,LL M,LL m){
    int N=A.size();
    int s=0,t=0;
    REP(i,N){
        while(s<t&&i-deq[s]>M)s++;
        if(s==t)b[i]=-1e16;
        else{
            b[i]=a[deq[s]]+A[i]*m;
        }
        while(s<t&&a[deq[t-1]]<=a[i])t--;
        deq[t++]=i;
    }
}

int main(){
    LL N,M,K;
    cin>>N>>M>>K;
    vector<LL> A(N);
    for(auto &it:A)cin>>it;
    vector<LL> dp=A;
    FOR(i,1,K){
        //for(auto &it:dp)cout<<it<<" ";cout<<endl;
        vector<LL> nxt(N);
        ch(dp,nxt,A,M,i+1);
        swap(dp,nxt);
    }
    LL res=0;
    for(auto &it:dp)chmax(res,it);
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3056
n = gets.to_i
arr = gets.split.map(&:to_i)
m = gets.to_i
arr2 = []
m.times do
  arr2 << gets.split.map(&:to_i)
end

m.times do |i|
  index = arr2[i][0]
  value = arr2[i][1]
  puts arr.inject(&:+) - arr[index-1] + value
end

Measured memory_bytes: 1788
A,B = map(int,input().split())
S = input()
flag = True
for i in range(len(S)):
    if i == (A):
        if S[i] != "-":
            flag = False
            break
    else:
        if S[i] == "-":
            flag = False
            break
        a = int(S[i])
        if not (0<=a):
            flag = False
            break
        if not (a<=9):
            flag = False
            break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    rep(i, 0, n){
        cin >> a[i];
        mp[a[i]]++;
    }
    int MAX = 0, ans = 1;
    for(auto it = mp.begin(); it != mp.end(); it++){
        if(it -> second >= 2){
            MAX = it -> first;
        }
    }
    mp[MAX] -= 2;
    ans *= MAX;
    MAX = 0;
    for(auto it = mp.begin(); it != mp.end(); it++){
        if(it -> second >= 2){
            MAX = it -> first;
        }
    }
    ans *= MAX;
    cout << ans << endl;
}

Measured memory_bytes: 7296
fun main(args: Array<String>) {
    readLine()?.toInt()?.let {
        // 3つの数字を出す
        var res = 0
        for (x in 1..it) {
            for (y in 1..it) {
                for (z in 1..it) {
                    res += gcd(gcd(x, y), z)
                }
            }
        }
        //gcdメソッドを呼ぶ
        println(res)
    }
}

private fun gcd(a: Int, b: Int): Int {
    if (a % b == 0) return b
    return gcd(b, a % b)
}

Measured memory_bytes: 34768
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>

// type alias
using lint = long long;
using ldouble = long double;
template <class T>
using greater_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T>>;


/* ----- class ----- */

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Edges = std::vector<Edge<Cost>>;

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;


/* ----- debug ----- */

#if __has_include("../setting/source/debug.hpp")
#include "../setting/source/debug.hpp"
#endif


/* ----- short functions ----- */

template <class T>
inline T sq(T a) { return a * a; }

template <class T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <class T>
T gcd(T a, T b) {
    while (b > 0) {
        a %= b;
        std::swap(a, b);
    }
    return a;
}

template <class T, class U>
T ipow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

// 0-indexed
template <class T, class U>
inline T kthbit(T a, U k) { return (a >> k) & 1; }

template <class T, class U>
inline T mask(T a, U k) { return a & ((1 << k) - 1); }

template <class T>
std::map<T, int> compress(std::vector<T>& v) {
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    std::map<T, int> rev;
    for (int i = 0; i < v.size(); ++i) rev[v[i]] = i;
    return rev;
}

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}


/* ----- constants ----- */

// const int INF = std::numeric_limits<int>::max() / 3;
// const lint INF = std::numeric_limits<lint>::max() / 3;
// const ldouble PI = acos(-1);
// const ldouble EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));


using namespace std;

int main() {
    int X, A;
    cin >> X >> A;
    cout << (X < A ? 0 : 10) << endl;
    return 0;
}


Measured memory_bytes: 256
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 1024;

int main(void) {
//	in = fopen("A.in", "rt");
	
	int n;
	fscanf(in, "%d", &n);
	int ans = n / 2;
	if (n % 2 == 0) ans--;
	fprintf(out, "%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
// Last Change: 10/17/2019 18:31:09.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

void solve(int N) {
  ll ans = 0;
  for (int i = 1; i < N; ++i) {
    for (int j = i + 1; j <= N; ++j) {
      int res = (i + j) * (j - i + 1) / 2;
      if (res == N) {
        ++ans;
      }
    }
  }
  cout << ans << endl;
}

int main() {
  int n;
  while (cin >> n and n > 0) {
    solve(n);
  }
}



Measured memory_bytes: 3052
#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> h(n);
	rep(i,n) cin >> h[i];
	int k = h[0];
	int counts = 0;
	rep(i,n){
		if(h[i] >= k){
			k = h[i];
			counts++;
		}
	}
	cout << counts << endl;
}

Measured memory_bytes: 3580
//-fexec-charset=CP932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 100
#define THOU 1000
#define FIVEMAX 100000
#define NINEMAX 1000000000
#define TWEMAX 1000000000000
#define rep(i,n) for (int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define darep(i,a,n) for(int i=n,i>=a;i--)

ll gcd(ll x,ll y){
    if(x<y) swap(x,y);
 
    ll r;
    while(y>0){
        r=x%y;
        x=y;
        y=r;
    }
    return x;
}

ll solve(int n, ll m, vector<ll> &a) {
    // 2 で割れるだけ割る (割れる回数が異なったらダメ)
    bool same = true;
    while (a[0] % 2 == 0) {
        for (int i = 0; i < n; ++i) {
            if (a[i] % 2 != 0) return 0;
            a[i] /= 2;
        }
        m/= 2;
    }
    for (int i = 0; i < n; ++i) if (a[i] % 2 == 0) return 0;

    // lcm
    ll lcm = 1;
    for (int i = 0; i < n; ++i) {
        ll g = gcd(lcm, a[i]);
        lcm = lcm / g * a[i];
        if (lcm > m) return 0;
    }
    return (m / lcm + 1) / 2;
}

int main(){
 cin.tie(0);
 ios::sync_with_stdio(false);
 string str;
 vector<int>v;
 //map<string,int>m;
 pair<int,int>p;
 int n;
 ll m;
 cin>>n>>m;
 vector<ll>a(n);
 for (int i = 0; i < n; ++i) cin >> a[i], a[i] /= 2;
    cout << solve(n,m,a) << endl;
//auto ans=
//cout<<ans<<endl;
return 0;
}



Measured memory_bytes: 3992
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <cfloat>
#include <cmath>

struct Building {
	int id;
	int x;
	int y;
	std::vector<int> edge_to;
	std::vector<double> dist_to;
};

int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n==0) break;
		Building* bldgs = new Building[n];
		std::map<int,int> m_index;
		for (int i=0; i<n; i++) {
			std::cin >> bldgs[i].id >> bldgs[i].x >> bldgs[i].y;
			m_index.insert( std::make_pair(bldgs[i].id, i) );
		}
		for (int i=0; i<n; i++) {
			for (int j=i+1; j<n; j++) {
				int d = (bldgs[i].x - bldgs[j].x) * (bldgs[i].x - bldgs[j].x)
					+ (bldgs[i].y - bldgs[j].y) * (bldgs[i].y - bldgs[j].y);
				if (d <= 2500) {
					bldgs[i].edge_to.push_back(j); bldgs[i].dist_to.push_back(std::sqrt((double)d));
					bldgs[j].edge_to.push_back(i); bldgs[j].dist_to.push_back(std::sqrt((double)d));
				}
			}
		}
		double* dist = new double[n];
		int* p = new int[n];
		int m; std::cin >> m;
		for (int m_=0; m_<m; m_++) {
			int s, g;
			std::cin >> s >> g;
			for (int i=0; i<n; i++) { dist[i] = DBL_MAX; p[i] = -1; }
			int s_index = m_index[s];
			dist[s_index] = 0;
			p[s_index] = s_index;
			for (int k=0; k<n-1; k++) {
				for (int i=0; i<n; i++) {
					for (int j=0; j<bldgs[i].edge_to.size(); j++) {
						int v = bldgs[i].edge_to[j];
						int d = bldgs[i].dist_to[j];
						if (dist[v] - d > dist[i]) {
							dist[v] = dist[i] + d;
							p[v] = i;
						}
					}
				}
			}
			int g_index = m_index[g];
			std::stack<int> st;
			int index = g_index;
			bool reachable = true;
			while (true) {
				st.push(index);
				if (index == s_index) break;
				else if (p[index] == -1) {reachable = false; break; }
				index = p[index];
			}
			if (reachable) {
				std::cout << s; st.pop();
				while (!st.empty()) { std::cout << " " << bldgs[st.top()].id; st.pop(); }
			}
			else std::cout << "NA";
			std::cout << std::endl;
		}
		delete[] dist;
		delete[] p;
		delete[] bldgs;
	}
	return 0;
}



Measured memory_bytes: 3152
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int a, b; cin >> a >> b;
    cout << (6 - a - b) << endl;
    return 0;
}

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

int main(){
    long N, K;
    cin >> N >> K;
    if(!K){
        cout << N * N << endl;
        return 0;
    }
    long ans = 0;
    for(long i = K + 1; i <= N; i++){
        ans += (N + i) / i * (i - K) - min((i * N - N - 1) % i, i - K);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    //整数の入力
    int K = sc.nextInt();
    int S = sc.nextInt();
    
    int count = 0;
    // 計算
    for (int x=0; x<=K; x++) {
      for (int y=0; y<=K; y++) {
        int z = S - x - y;
        if (z>=0 && z<=K) {
          count += 1;
        }
      }
    }
    // 出力
    System.out.println(count);
  }
}

Measured memory_bytes: 22608
#include<bits/stdc++.h>
 
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back

#include <iostream>
int main(){
    string s;
    int a,b,c,d,e;

    cin>>s;

    cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
}

Measured memory_bytes: 256
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!(a: i64, b: i64, c: i64);
    let ans = b * (c / a);
    println!("{}", ans);
}


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

using namespace std;

int main()
{   long long n ;
    cin >> n;
    long long a[n];
    long long sum = 0;
    for (int i = 1; i <= n; ++i)
    {
        if ((i % 3 == 0 || i % 5 == 0))
            a[i] = 0;
        else
            a[i] = i;
            sum = sum + a[i];
        }
        cout << sum;

}





Measured memory_bytes: 11368
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <set>

using namespace std;

int main(){
	int n;
	cin >> n;
	
	int a[n];
	for(int i=0; i<n; i++) cin >> a[i];
	
	set<int> s;
	
	for(int i=0; i<n; i++){
		if(s.count(a[i])==0){
			s.insert(a[i]);
		}
		else{
			s.erase(a[i]);
		}
	}
	
	cout << s.size() << endl;
	
	return 0;
}
	
	


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    map<ll, int> mp;
    vector<bool> p(1<<12, true);
    p[0] = p[1] = false;
    vector<ll> ps;
    rep(i, 1<<12){
        if(!p[i]) continue;
        ps.pb(i);
        for(int j = 2; i*j < (1<<12); j++) p[i*j] = false;
    }
    rep(i, N){
        ll s;
        cin >> s;
        for(auto &e: ps){
            ll j = e*e*e;
            while(s%j == 0) s /= j;
        }
        mp[s]++;
    }
    map<ll, ll> s;
    for(ll i = 1; i < (1LL<<17); i++){
        s[i*i] = i;
    }
    int ans = N;
    ll MAX = 1LL<<34;
    for(auto &e: mp){
        if(e.first == 1) {ans -= e.second-1; continue;}
        ll j = 1, memo = e.first;
        for(auto &u: ps){
            if(memo%u == 0){
                memo /= u;
                j *= u;
                if(j > MAX) break;
                if(memo%u != 0) j *= u;
                else memo /= u;
            }
        }
        if(s.count(memo) && j < MAX) j *= s[memo];
        elif(j <= MAX/(memo*memo)) j *= memo*memo;
        else j = MAX;
        if(e.first < j && mp.count(j)) ans -= min(e.second, mp[j]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 18080
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
//    return *(int*)a - *(int*)b;
    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int main()
{
  int a ,b, c, d, e, X, Y;
//  long long  b, c, d, e, X, Y;
  //  double  c;
  int  A[100003]={};
  int  B[100003]={};
  int  C[100003]={};

  int  flag[103]={};

//  long long  a, b, c, d, X, Y;
  char s[101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
//  int flag=0;
  int tmp=0;
//  int min=1000000;
  long long min=100000001;
  int len=0;
  int l=0;
  int r=1000001;
  double cnt=0;
  int num=0;
  double ans=0;
  int max=0;
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
//  scanf("%d%d", &a,&c);
//  cnt = strlen(t);
// printf("%d\n",a);
    scanf("%d%d", &a,&b);
  for(i=0;i<b;i++){
    scanf("%d%d", &A[i],&B[i]);
    if(l<A[i]) l=A[i];
    if(B[i]<r) r=B[i];
  }
  
  
//  printf("%d\n", r-l+1);
  if( 0<(r-l+1) )printf("%d\n", r-l+1);
  else printf("%d\n", 0);
  
//  printf("%lf\n",ans);
  //  //  if(flag==0)   printf("TLE\n");
//    if(max < cnt - max)  printf("Yes\n");
//    else  printf("No\n");
  
return 0;
}


Measured memory_bytes: 896
import java.util.*;
    public class Main {
    	public static void main(String[] args){
    		Scanner sc = new Scanner(System.in);
    		// 整数の入力
    		int N = sc.nextInt();
    		int M = sc.nextInt();
    		int C = sc.nextInt();

            int[][] ar = new int[N][M];
            int[] arB= new int[M];
            
            for(int i=0; i<M; i++){
                arB[i]= sc.nextInt();
            }

            for(int i=0; i<N; i++){
                for(int j=0; j<M; j++){
                    ar[i][j] = sc.nextInt();
                }
            }

            int rslt=0;
            int ans =0;
            for(int i=0; i<N; i++){
                for(int j=0; j<M; j++){
                    rslt = rslt + arB[j]*ar[i][j];
                }
                if((rslt + C) >0){
                    ans++;
                }
                rslt=0;
            }

            // 出力
    		System.out.println(ans);
    	}
    }


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> A(n);
    rep(i, n) A[i] = a[i] - (i + 1);
    sort(all(A));
    
    vector<ll> mid;
    if (A.size() % 2 == 1) {
        mid.push_back(A[A.size() / 2]);
    }
    else  {
        mid.push_back((A[A.size() / 2] + A[A.size() / 2 - 1]) / 2 - 1);
        mid.push_back((A[A.size() / 2] + A[A.size() / 2 - 1]) / 2);
        mid.push_back((A[A.size() / 2] + A[A.size() / 2 - 1]) / 2 + 1);
    }

    ll mi = 1e18;
    rep (j, mid.size()) {
        ll score = 0;
        rep(i, n) score += abs(A[i] - mid[j]);
        mi = min(mi, score);
    }


    put(mi);

    return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);
struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  bool findSet(int x,int y){
    return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

bool used[100005];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,m;
    cin >> n >> m;
    UnionFind uni(n);
    rep(i,m){
        int x,y,z;
        cin >> x >> y >> z;
        x--;y--;
        uni.unite(x,y);
    }
    int ans = 0;
    rep(i,n){
        if(used[uni.find(i)])continue;
        ans++;
        used[uni.find(i)] = 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int sz=2e5+2;
map<ll,ll>cnt;
vector<ll>v;
 
ll bigmod(ll a, ll b, ll m)
{
  if(b==0) return 1;
 
  ll x=bigmod(a,b/2,m);
  x=(x*x)%m;
  if(b%2==1)x=(x*a)%m;
 
  return x;
}


ll sum(ll a, ll b)
{
  a--;
  ll ans=(((b%mod)*((b%mod)+1)-(a%mod*(a%mod+1)))%mod*bigmod(2,mod-2,mod)%mod)%mod;
  return ans;
}
void pre()
{
    ll ans;
    v.push_back(0);
    for(int i=1; i<=sz; i++)
    {
        ans=sum(1,i);
        v.push_back(ans);
    }
}

int main()
{
    vector<ll>vec;
 pre();
  ll n, m, x=0, i, sum=0, mx;

  cin>>n>>m;

  for(i=n; i>=1; i--)
  {
    x+=i;
    vec.push_back(x);
  }
  for(i=m; i<=n; i++)
  {
    mx=vec[i-1];
    //cout<<mx<<endl;
    sum=(sum+(mx-v[i-1]+1))%mod;
  }
  cout<<sum+1<<endl;
}

Measured memory_bytes: 7892
//
//  main.c
//  Practice
//
//  Created by hoshino on 2015/10/19.
//  Copyright ?? 2015??´ hoshino. All rights reserved.
//

#include <stdio.h>

int main(void) {
    int a,b;
    
    scanf("%d %d", &a,&b);
    if(a==b){
        printf("a == b\n");
    }else if(a>b)
    {printf("a > b\n");
    }else
    {
    printf("a < b\n");
    }
    
    // insert code here...
    
    return 0;
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int INF = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  vector<char> ans;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      ans.push_back('0');
    } else if (s[i] == '1') {
      ans.push_back('1');
    } else {
      if (ans.size() != 0) {
        ans.pop_back();
      }
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void){
    int N;
    cin >> N;
    int weight[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
        cin >> weight[i];
        sum += weight[i];
    }
    int suma = 0;
    int sumb = 0;
    int ans = 100000;
    for(int i = 0; i < N; i++){
        suma+= weight[i];
        sumb = sum - suma;
        ans = min(ans, abs(sumb-suma));
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

#define ff first
#define ss second

const int maxn = 1e5+10;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int k;
	string s;
	cin >> k >> s;
	if(k>=s.size()){
		cout << s << '\n';
	}
	else{
		for(int i=0;i<k;++i){
			cout << s[i];
		}
		cout << "...\n";
	}
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
using namespace std;
int main(void){
  string s;
  cin>>s;
  size_t size=s.length();
  int f(0);
  for(int i(1);i<size;i++){
    for(int j(0);j<i;j++){
      if(s[j]==s[i])f=1;
    }
  }
  if(f==0)cout<<"yes"<<endl;
  else cout<<"no"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int n, l;
	cin >> n >> l;
	
	int tot = 0;
	for(int i = 1; i <= n; i++) {
		tot += l + i - 1;
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		int curr = tot - (l + i - 1);
		if(abs(tot - curr) < abs(tot - ans)) ans = curr;
	}
	
	cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;
    //abc047 c
    static void solve(InputReader in, PrintWriter out){
        char[] s = in.ns().toCharArray();
        int m = 0;
        for (int i = 1; i < s.length; i++) {
            if(s[i]!=s[i-1]) m++;
        }
        out.println(m);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}


Measured memory_bytes: 25044
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i = 0; i < N; i++){
    cin >> a[i];
    a[i] *= N;
  }

  int ave = 0;
  for(int i = 0; i < N; i++) ave += a[i];
  ave /= N;

  int ind = 0;
  int mn = 1000000000;
  for(int i = 0; i < N; i++){
    if(abs(a[i] - ave) < mn){
      mn = abs(a[i] - ave);
      ind = i;
    }
  }

  cout << ind << endl;
  return 0;
}


Measured memory_bytes: 256
a,b,x,y=map(int,input().split())
ans="UD"[b>y]*abs(b-y)+"LR"[a<x]*abs(a-x)
ans+="UD"[b<y]*abs(b-y)+"LR"[a>x]*abs(a-x)
ans+="LR"[a>x]+"UD"[b>y]*(abs(b-y)+1)+"LR"[a<x]*(abs(a-x)+1)+"UD"[b<y]
ans+="LR"[a<x]+"UD"[b<y]*(abs(b-y)+1)+"LR"[a>x]*(abs(a-x)+1)+"UD"[b>y]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <climits>
#include <set>
#include <deque>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {

	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";

    return out;

}

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {

	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}

		out << "\n";
	}
		
    return out;

}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int a, b;
	cin >> a >> b;

	if (a >= 10 || b >= 10) {
		cout << "-1\n";
		return 0;
	}

	cout << a * b << "\n";

	return 0;

}

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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;

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

    ll h = sz(s), w = sz(t);

    vector<vector<ll>> dp(h+1, vector<ll>(w+1, 0));

    for(ll i=0; i<=h; i++)
    {
        dp[i][0] = 0;
    }

    for(ll j=0; j<=w; j++)
    {
        dp[0][j] = 0;
    }

    for(ll i=1; i<=h; i++)
    {
        for(ll j=1; j<=w; j++)
        {
            if(s[i-1] == t[j-1])
            {
                dp[i][j] = dp[i-1][j-1] + 1;
            }

            else
            {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }  

    // cout << dp[h][w] << endl;

    string ans = "";

    ll i=h, j=w;

    while(i > 0 || j > 0)
    {
        if(i > 0 && dp[i][j] == dp[i-1][j])
        {
            i--;
        }

        else if(j > 0 && dp[i][j] == dp[i][j-1])
        {
            j--;
        }

        else if(i > 0 && j > 0 && dp[i][j] == dp[i-1][j-1] + 1)
        {
            i--, j--;
            ans += s[i];
        }

    }

    reverse(all(ans));
    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 70784
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
l=[0]*10**5
for i in range(n):
    a,b=map(int,input().split())
    l[a-1]+=b
m=0
for i in range(10**5):
    if m+l[i]>=k:print(i+1);break
    else: m+=l[i]

Measured memory_bytes: 5748
unittest
{
	assert( [ "7", "abcdbbd", "6", "2 3 6", "1 5 z", "2 1 1", "1 4 a", "1 7 d", "2 1 7" ].solve == "3\n1\n5" );
}



import core.bitop;
import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto s = input.front.map!( ( a ) => 1L << ( a - 'a' ) ).array;		// 文字をbitに変換
	input.popFront;
	auto q = input.front.to!( long );
	auto qss = new long[ 3 ][ q ];
	foreach( ref qs; qss )
	{
		input.popFront;
		auto as = input.front.split;
		if( as[ 0 ] == "1" ) qs = [ 1L, as[ 1 ].to!( long ) - 1, 1L << ( as[ 2 ][ 0 ] - 'a' ) ];		// 文字をbitに変換
		else                 qs = [ 2L, as[ 1 ].to!( long ) - 1, as[ 2 ].to!( long ) ];
	}
	
	// クエリを処理
	long[] anss;
	auto st = SegmentTree!( long, ( a, b ) => a | b )( s );
	foreach( qs; qss )
	{
		if( qs[ 0 ] == 1 ) st.set( qs[ 1 ], qs[ 2 ] );
		else               anss ~= st.query( qs[ 1 ], qs[ 2 ] ).popcnt;
	}
	return anss.to!( string[] ).join( "\n" );
}

// セグメント木
struct SegmentTree( T, alias op = ( ( a, b ) => a + b ), T I = T.init )
{
	T[] ts;
	
	this( long n )
	{
		ts = new T[ n << 1 ];
		static if( I != T.init ) ts[] = I;
	}
	
	this( T[] qs )
	{
		ts = new T[ qs.length << 1 ];
		ts[ $ >> 1 .. ( $ >> 1 ) + qs.length ] = qs;
		foreach_reverse( i; 1L .. ts.length.signed >> 1 )
		{
			ts[ i ] = op( ts[ i << 1 ], ts[ i << 1 | 1 ] );
		}
	}
	
	void set( long i, T v )
	{
		i += ts.length.signed >> 1;
		ts[ i ] = v;
		for( i >>= 1; 0 < i; i >>= 1 )
		{
			ts[ i ] = op( ts[ i << 1 ], ts[ i << 1 | 1 ] );
		}
	}
	
	auto get( long i )
	{
		i += ts.length.signed >> 1;
		return ts[ i ];
	}
	
	auto query( long l, long r )
	{
		l += ts.length.signed >> 1;
		r += ts.length.signed >> 1;
		auto x = I;
		auto y = I;
		for( ; l < r; l >>= 1, r >>= 1 )
		{
			if( l & 1 )
			{
				x = op( x, ts[ l ] );
				l++;
			}
			if( r & 1 )
			{
				r--;
				y = op( ts[ r ], y );
			}
		}
		return op( x, y );
	}
	
	auto length()
	{
		return ts.length >> 1;
	}
	
	auto toString()
	{
		return format( "ST(%s)", ts[ $ >> 1 .. $ ] );
	}
}


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

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
	IOS;
	long long int a,b,c,k;
	int index1;
	while(cin>>a>>b>>c>>k){
		index1=0;
		long long int max;
		if(a>b){
			max=a;
			index1=1;
		}
		else{
			max=b;
			index1=2;
		}
		if(max>c){
			max=max;
		}
		else{
			max=c;
			index1=3;
		}
		
		if(index1 == 1){
			cout<<a*pow(2,k)+b+c<<endl;
		}
		else if (index1 == 2){
			cout<<a+b*pow(2,k)+c<<endl;
		}
		else{
			cout<<a+b+c*pow(2,k)<<endl;
		}
	}
	return 0;
}

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

public class Main {

	void submit() {
		int n = nextInt();
		int total = 1;
		int bad = 1;
		for (int i = 0; i < n; i++) {
			int x = nextInt();
			total *= 3;
			if ((x & 1) == 0) {
				bad *= 2;
			}
		}
		
		out.println(total - bad);
		
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define FOR(i,a,b) for(long long i=(a);i<=(b);i++)

int main() {
  string N;
  cin >> N;
  int ans = 0;
  REP(i, 4) {
    if(N[i] == '2') ans++;
  }
  cout << ans << endl;
  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string S;cin>>S;
    int s=0;
    rep(i,S.size())s+=S[i]-'0';
    if(s==1)s=10;
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
const int N = 100000 + 5;char s1[N],s2[N];int n,t=0; long long a=1;
int main(){scanf("%d",&n);scanf("%s",s1+1);scanf("%s",s2+1);for(int i=1;i<=n;i++){if(s1[i]==s2[i]){if(t==0)a*=3;if(t==1)a*=2;if(t==2)a*=1;t=1;a%=mod;}if(s1[i]==s1[i+1]){if(t==0)a*=6;if(t==1)a*=2;if(t==2)a*=3;t=2;a%=mod;i++;}}printf("%d\n",a);}

Measured memory_bytes: 256
// In the name of GOD
 
#include <bits/stdc++.h>
#define ll long long
#define pp pair <int, int>
using namespace std;
const int N = 2e5 + 10, MOD = 1e9 + 7;
const ll INF = 1e18;

void solve() {
	string s;
	string t;
	cin >> s >> t;
	map <char, vector <int>> mp;
	int i = 0;
	for (char c : s) {
		mp[c].push_back(i);
		++i;
	}

	int id = -1;
	ll freq = 0;
	for (int i = 0; i < t.length(); ++i) {
		char c = t[i];
		if (mp[c].empty()) {
			cout << -1;
			return;
		}

		if (upper_bound(mp[c].begin(), mp[c].end(), id) == mp[c].end()) {
			freq++;
			id = mp[c][0];
		}
		else
			id = mp[c][upper_bound(mp[c].begin(), mp[c].end(), id) - mp[c].begin()];
		// cout << freq << " " << id << "\n";
	}
	ll ans = 1LL*(int)s.length() * freq + id + 1;
	cout << ans;
}

int main () {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    }
}                                  

Measured memory_bytes: 1228
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<tuple<string, int, int>> v;
    for (int i = 0; i < n; ++i) {
        string s; int p;
        cin >> s >> p;
        v.emplace_back(s, -p, i+1);
    }
    sort(v.begin(),v.end());
    for (int i = 0; i < n; ++i) {
        string s; int p, q;
        tie(s, p, q) = v[i];
        cout << q << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

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

    sort(a.begin(), a.end(), greater<ll>());

    ll ans=1;
    int cnt=0;

    rep(i,n){
        
        if(a[i]==a[i+1]){
            ans*=a[i];
            cnt++;
            ++i;
        }
        if(cnt==2){
            cout<<ans<<endl;
            return 0;
        }
        //cout<<a[i]<<" "<<cnt<<" "<<ans<<endl;
    }
    cout<<0<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	int n, m, l;
	cin >> n >> m >> l;
	int A[101][101], B[101][101];
	long int C[101][101] = { 0 };
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			cin >> A[i][j];
		}
	}
	for (int k = 1; k <= m; k++){
		for (int o = 1; o <= l; o++){
			cin >> B[k][o];
		}
	}
	for (int p = 1; p <= n; p++){
		for (int q = 1; q <= l; q++){
			for (int r = 1; r <= m; r++){
				C[p][q] += A[p][r] * B[r][q];
			}
		}
	}
	for (int s = 1; s <= n; s++){
		cout << C[s][1];
		for (int t = 2; t <= l; t++){
			cout << " " << C[s][t];
		}
		cout << endl;
	}
	return 0;
	}


Measured memory_bytes: 3248
#include<iostream>
#include<numeric>
#include<algorithm>
typedef long long LL;
using namespace std;

int gcdlist[201][201][201];

int _GCD(int a,int b,int c){
  if(gcdlist[a][b][c]!=1<<30) return gcdlist[a][b][c];
  return gcd(gcd(a,b),c);
}

int main(){
  int N,i,j,k,temp[3],ans=0;
  cin>>N;
  for(i=1;i<=N;i++){
    for(j=1;j<=N;j++){
      for(k=1;k<=N;k++){
        gcdlist[i][j][k]=1<<30;
      }
    }
  }
  for(i=1;i<=N;i++){
    for(j=1;j<=N;j++){
      for(k=1;k<=N;k++){
        temp[0]=i;temp[1]=j;temp[2]=k;
        sort(temp,temp+3);
        ans+=_GCD(temp[0],temp[1],temp[2]);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 35136
// abc054a: One Card Poker
#include <bits/stdc++.h>
using namespace std;

#define in(x) cin>>(x)
#define oute(x) cout<<(x)<<endl

int main(){
  int a,b;in(a);in(b);
  if(a==1) a+=13;
  if(b==1) b+=13;
  if(a==b) oute("Draw");
  else if(a>b) oute("Alice");
  else if(a<b) oute("Bob");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

using VLL = vector <long long>;
using VPILL = vector < pair<long long, int> >;
using VB = vector <bool>;
int N;
VLL X;
VLL Y;
VLL P;
VLL ans;
VPILL PX;
VPILL PY;
VB xcho;
VB ycho;

const long long INF = 1000000000LL * 1000000000LL;

void solve(int now, int chosen) {
    if (now == N) {
        VLL minDist(N, INF);

        long long res = 0;
        long long lastX = -INF;
        long long lastY = -INF;

        for (int i = 0; i < N; ++i) {
            // default
            minDist[i] = min(minDist[i], min(abs(X[i]), abs(Y[i])));

            // x axis
            if (xcho[PX[i].second]) {
                lastX = PX[i].first;
            }

            minDist[PX[i].second] = min(minDist[PX[i].second], PX[i].first-lastX);

            // y axis
            if (ycho[PY[i].second]) {
                lastY = PY[i].first;
            }

            minDist[PY[i].second] = min(minDist[PY[i].second], PY[i].first-lastY);
        }

        // backward
        lastX = INF;
        lastY = INF;

        for (int i = N-1; i >= 0; --i) {
            // x axis
            if (xcho[PX[i].second]) {
                lastX = PX[i].first;
            }

            minDist[PX[i].second] = min(minDist[PX[i].second], lastX-PX[i].first);

            // y axis
            if (ycho[PY[i].second]) {
                lastY = PY[i].first;
            }

            minDist[PY[i].second] = min(minDist[PY[i].second], lastY - PY[i].first);
        }

        for (int i = 0; i < N; ++i) {
            res += P[i] * minDist[i];
        }

        ans[chosen] = min(ans[chosen], res);
        return ;
    }

    solve(now+1, chosen);

    xcho[now] = true;
    solve(now+1, chosen+1);
    xcho[now] = false;

    ycho[now] = true;
    solve(now+1, chosen+1);
    ycho[now] = false;
}

int main() {
    cin >> N;

    X = VLL(N);
    Y = VLL(N);
    P = VLL(N);

    PX = VPILL(N);
    PY = VPILL(N);

    for (int i = 0; i < N; ++i) {
        cin >> X[i] >> Y[i] >> P[i];
        PX[i] = make_pair(X[i], i);
        PY[i] = make_pair(Y[i], i);
    }

    ans = VLL(N+1, INF);
    xcho = VB(N);
    ycho = VB(N);

    sort(PX.begin(), PX.end());
    sort(PY.begin(), PY.end());
    solve(0, 0);

    for (int k = 0; k <= N; ++k) {
        cout << ans[k] << endl;
    }

    return 0;
}

Measured memory_bytes: 3612
/*
title:C - Modulo Summation

url:https://abc103.contest.atcoder.jp/tasks/abc103_c

方針
与えらえれた数字の最小公倍数-1のとき、f(m)は最大になる。
このときの最大値は、各数字-1 の和であるので、それを出力するだけでいい
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    int res = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        res += a[i] - 1;
    }
    cout << res << endl;
}

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

int main() {
	int sumPrice = 700;
	string s;
	cin >> s;
	if (s[0] == 'o')sumPrice += 100;
	if (s[1] == 'o')sumPrice += 100;
	if (s[2] == 'o')sumPrice += 100;
	cout << sumPrice << endl;
	return 0;
}

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昇順
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll N, A, B;
vector<ll> X(100000);

int main() {
    cin >> N >> A >> B;
    ll cost = 0;
    ll walk;
    rep(i,N) {
        cin >> X.at(i);
        if (i > 0) {
            walk = abs(X[i] - X[i-1]) * A;
            cost += (walk < B) ? walk : B;
        }
    } 
    cout << cost << '\n';
}


Measured memory_bytes: 1024