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

const int N = 2e5 + 100;

int n, k, h[N];
long long dp[N];

int main(){
    # ifdef FILEs
        freopen( "input.txt", "r" ,stdin );
        freopen( "output.txt", "w", stdout );
    # endif
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    for( int i = 1; i <= n; i++ ){
        cin >> h[i];
    }
    for( int i = 2; i <= n; i ++ ){
        dp[i] = 2e9;
        for( int j = 1; j <= min(i-1,k); j ++ ){
            dp[i] = min( dp[i], dp[i-j] + abs(h[i]-h[i-j]) );
        }
    }
    cout << dp[n];
    return 0;
}   

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a;
    vector<int> tmp(n);
    for(int i=0;i<n;i++){
        cin>>a;
        tmp[a-1]++;
    }
    sort(tmp.begin(),tmp.end(),greater<int>());
    int ansD=0;
    for(int i=0;i<k;i++){
        ansD+=tmp[i];
    }
    cout<<n-ansD<<endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
using namespace std;
int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
int a[200005];
int v1[200005], v2[200005];
int main() {
    int n = read();
    for (int i = 1; i <= n; ++i) a[i] = read();
    int mx11 = 1, mx12 = 0;
    for (int i = 1; i <= n; i += 2) {
        v1[a[i]]++;
    }
    for (int i = 2; i <= 100005; ++i) {
        if (v1[mx11] < v1[i]) {
            mx12 = mx11;
            mx11 = i;
            continue;
        }
        if (v1[mx12] < v1[i]) mx12 = i;
    }
    int mx21 = 1, mx22 = 0;
    for (int i = 2; i <= n; i += 2) {
        v2[a[i]]++;
    }
    for (int i = 2; i <= 100005; ++i) {
        if (v2[mx21] < v2[i]) {
            mx22 = mx21;
            mx21 = i;
            continue;
        }
        if (v2[mx22] < v2[i]) mx22 = i;
    }
    int res;
    if (mx11 == mx21) {
        res = max(v1[mx11] + v2[mx22], v2[mx21] + v1[mx12]);
    } else res = v1[mx11] + v2[mx21];
    printf("%d\n", n - res);
    return 0;
}

Measured memory_bytes: 1408
import itertools
n = int(input())
p = tuple(((map(int,input().split()))))
q = tuple(((map(int,input().split()))))

num = []
for i in range(1,n+1):
    num.append(i)
ans = []
for i in itertools.permutations(num,n):
    ans.append(i)

print(abs(ans.index(p)-ans.index(q)))

Measured memory_bytes: 44656
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let x: i64 = read();
    let d: usize = read();
    let mut ms = vec![0 as i64; n];
    let mut parents = vec![0 as usize; n];
    ms[0] = read();
    for i in 1..n {
        ms[i] = read();
        parents[i] = read();
        parents[i] -= 1;
    }
    let mut weights = vec![0 as i64; n];
    let mut values = vec![1 as usize; n];
    for i in (1..n).rev() {
        weights[i] += ms[i];
        weights[parents[i]] += weights[i];
        values[parents[i]] += values[i];
    }
    weights[0] += ms[0];
    let mut items2 = vec![(0 as f64, 0 as usize); n];
    for i in 0..n {
        items2[i] = (values[i] as f64 / weights[i] as f64, i);
    }
    items2.sort_by(|a, b| a.partial_cmp(b).unwrap());
    items2.reverse();
    let mut need_weights = vec![x + 1; n * n * n];
    need_weights[0] = 0;
    let mut max_index = 0;
    for i in (0..n).rev() {
        for value in (0..max_index + 1).rev() {
            let usable = if i == 0 { n } else { std::cmp::min(n, d) };
            for cnt in 1..usable + 1 {
                let nvalue = value + cnt * values[i];
                let nweight = need_weights[value] + cnt as i64 * weights[i];
                need_weights[nvalue] = std::cmp::min(need_weights[nvalue], nweight);
                max_index = std::cmp::max(max_index, nvalue);
            }
        }
    }

    let mut ans = 0;
    for value in 0..max_index + 1 {
        let mut rest_weights = x - need_weights[value];
        if rest_weights < 0 {
            continue;
        }
        let mut sum = value;
        for i in 0..n {
            let index = items2[i].1;
            let usable = if index == 0 {
                x
            } else {
                std::cmp::max(0, d as i64 - n as i64)
            };
            let cnt = std::cmp::min(usable, rest_weights / weights[index]);
            sum += cnt as usize * values[index];
            rest_weights -= cnt * weights[index];
        }
        ans = std::cmp::max(ans, sum);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4476
import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

private func gcd(_ a: Int, _ b: Int) -> Int {
    var (a, b) = a <= b ? (a, b) : (b, a)
    while b != 0 {
        (a, b) = (b, a % b)
    }
    return a
}

func main() {
    let nk = readWords { Int($0)! }
    let n = nk[0]
    let k = nk[1]
    let A = readWords { Int($0)! }

    guard k <= A.max()! else {
        print("IMPOSSIBLE")
        return
    }

    let g = A[1...].reduce(A[0], gcd)

    if k % g == 0 {
        print("POSSIBLE")
    } else {
        print("IMPOSSIBLE")
    }

}


main()

Measured memory_bytes: 18876
#include <bits/stdc++.h>
#define rep(i,n); for(ll i = 0; i < ll(n); i++)
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}



int main(){
  int n;
  cin>>n;
  int ans =0;
  rep(i,n){
    int a;
    cin>>a;
    while(a%2==0){
      ans++;
      a/=2;
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

int N1, N2, N3, N4;

void solve()
{
	map<int,int> f;
	f[N1]++,f[N2]++,f[N3]++,f[N4]++;
	if(f.count(1)==1 && f.count(9)==1 &&f.count(7)==1 &&f.count(4)==1) cout << "YES" << endl;
	else cout << "NO" << endl;
}

int main()
{
	cin >> N1 >> N2 >> N3 >> N4;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

int main(){
    int64_t n, k;
    cin >> n >> k;

    vector<int64_t> a(n), b(n, 0);
    for (auto i = 0; i < n; i++) cin >> a[i];

    for (auto i = 0; i < k; i++) {
        bool flg = true;
        for (auto j = 0; j < n; j++) {
            auto left = max(j - a[j], 0L);
            auto right = min(j + a[j], n - 1);
            b[left]++;
            if(right + 1 < n) b[right + 1]--;
        }
        for (auto j = 1; j < n; j++) {
            b[j] += b[j - 1];
            if(b[j] != n) flg = false;
        }
        a = b; b.assign(n, 0);
        if(flg) break;
    }

    for (auto j = 0; j < n; j++) cout << a[j] << " ";
    cout << endl;

    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<vector<pair<int, int>>> child(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    child.at(u).push_back(make_pair(v, w % 2));
    child.at(v).push_back(make_pair(u, w % 2));
  }
  vector<int> d(n, -1);
  vector<pair<int, int>> dfs;
  vector<bool> visited(n);
  d.at(0) = 0;
  dfs.push_back(make_pair(0, 0));
  while (!dfs.empty()) {
    pair<int, int> k = dfs.at(dfs.size() - 1);
    dfs.pop_back();
    if (visited.at(k.first)) continue;
    visited.at(k.first) = true;
    for (auto x : child.at(k.first)) {
      d.at(x.first) = d.at(k.first) + x.second;
      dfs.push_back(x);
    }
  }
  for (auto x : d) cout << x % 2 << endl;
}


Measured memory_bytes: 6784
L, R = map(int, input().split())
mod = 2019
ans = 2018
for i in range(L, R):
    for j in range(i+1, R+1):
        if ans >= i*j%mod:
            ans = i*j%mod
        if ans == 0:
            break

    if ans == 0:
        break

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define uni(v) v.erase(unique(v.begin(), v.end()), v.end())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (ll) a / __gcd(a, b) * b
#define what_is(x) cerr << #x << " is " << x << endl;

using namespace std;

void write();
template <typename T, typename... Args>
void write(T x, Args... args);
template <typename T>
void print_all(vector<T>& a);

void solve() {
    int a, b;
    cin >> a >> b;
    int l = 0, r = 1e8, res = -1;
    while (l <= r) {
        int m = l + r >> 1;
        // write(m * 8 / 100, m / 10, m);
        if ((m * 8 / 100) >= a && (m / 10) >= b) {
            res = m;
            r = m - 1;
        } else
            l = m + 1;
    }
    // cout << res << '\n';
    cout << ((res * 8 / 100) == a && (res / 10) == b ? res : -1) << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

void write() { cout << "\n"; }
template <typename T, typename... Args>
void write(T x, Args... args) {
    cout << x << ' ';
    write(args...);
}
template <typename T>
void print_all(vector<T>& a) {
    for (int i = 0; i < a.size(); ++i) cout << a[i] << " \n"[i == a.size() - 1];
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<functional>
#include<cstring>
#define MAX_N 100000
#define F first
#define S second
using namespace std;
typedef pair<long long int, long long int> P;
typedef pair<long long int, P> PP;
long long int INF = 1e16;

long long int n, m, c, sum = 0, sum2 = 0, ans = INF;
P flag[MAX_N + 1] = {};
vector<P> g[MAX_N + 1];
vector<int> vec;
priority_queue<PP>pq;
int main() {
	cin >> n >> m >> c;
	for (int i = 0; i < m; i++) {
		int a, b, e;
		scanf("%d%d%d", &a, &b, &e);
		g[a].push_back(P(b, e));
		g[b].push_back(P(a, e));
		sum += e;
	}

	for (int i = 0; i < g[1].size(); i++) {
		pq.push(make_pair(-g[1][i].S, make_pair(1, g[1][i].F)));
	}

	while (!pq.empty()) {
		PP a = pq.top();
		pq.pop();
		if (!flag[a.S.S].F) {
			if (a.S.S == 1) {
				flag[a.S.S].S = 1;
				continue;
			}
			flag[a.S.S].F = -a.F;
			flag[a.S.S].S = a.S.S;
			for (int i = 0; i < g[a.S.S].size(); i++) {
				pq.push(make_pair(-flag[a.S.S].F - g[a.S.S][i].S, make_pair(a.S.S, g[a.S.S][i].F)));
			}
		}
	}
	sort(flag + 1, flag + n + 1);
	for (int i = 1; i < n + 1; i++) {
		for (int j = 0; j < g[flag[i].S].size(); j++) {
			if (binary_search(vec.begin(), vec.end(), g[flag[i].S][j].F)) {
				sum2 += g[flag[i].S][j].S;
			}
		}
		vec.insert(upper_bound(vec.begin(), vec.end(), flag[i].S), flag[i].S);
		if (flag[i].F == flag[i + 1].F) {
			continue;
		}
		ans = min(ans, sum + c*flag[i].F - sum2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 23176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }

long long MAX_E = 500005;
long long MAX_V = 100005;
long long INF = 1e10;

struct edge {long long to, cost; };
typedef pair<long long, long long> P;

vector<vector<edge>> G(MAX_V);
vector<long long> d(MAX_V);
long long V;

// s 番目の頂点から各頂点への最短距離を求める
void dijkstra(long long s) {
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d.begin(), d.end(), INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();

        long long v = p.second;
        if (d[v] < p.first) continue;

        for (long long i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(){
    ll v, e, r; cin >> v >> e >> r;
    vector<ll> s(e), t(e), dis(e);
    rep(i, e) cin >> s[i] >> t[i] >> dis[i];
    rep(i, e) G[s[i]].push_back({t[i], dis[i]});
    dijkstra(r);
    rep(i, v){
        if(d[i] == INF) cout << "INF" << endl;
        else cout << d[i] << endl;
    }
}


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

int main(){
    string s, t;
    cin >> s >> t;
    int N = s.length();
    int M = t.length();

    vector<vector<int>> dp(N+1, vector<int>(M+1,0));
    for(int i=1; i<=N; i++) for(int j=1; j<=M; 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]);
        }
    }
    
    string ans = "";
    int n = N,  m = M;
    while(n>0 && m > 0){
        if(dp[n-1][m-1] == dp[n][m]){
            n--;
            m--;
        }else if(dp[n-1][m] == dp[n][m]){
            n--;
        }else if(dp[n][m-1] == dp[n][m]){
            m--;
        }else{
            ans = s[n-1] + ans;
            n--;
            m--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 35584
# abc157 b
def ans():
    a = []
    bingo_card = [[0] * 3,[0] * 3,[0] * 3]
    a.append(list(map(int, input().split())))
    a.append(list(map(int, input().split())))
    a.append(list(map(int, input().split())))
    n = int(input())
    b =[]
    for i in range(n):
        b.append(int(input()))
    for i, v in enumerate(a):
        for j, vv in enumerate(v):
            for k, bingo_value in enumerate(b):
                if vv == bingo_value:
                    bingo_card[i][j] = 1

    for i in range(len(bingo_card)):
        if bingo_card[i][0] * bingo_card[i][1] * bingo_card[i][2] == 1:
            print('Yes')
            return 
    for i in range(len(bingo_card)):
        if bingo_card[0][i] * bingo_card[1][i] * bingo_card[2][i] == 1:
            print('Yes')
            return 
    if bingo_card[0][0]*bingo_card[1][1]*bingo_card[2][2]==1:
        print('Yes')
        return 
    if bingo_card[0][2]*bingo_card[1][1]*bingo_card[2][0]==1:
        print('Yes')
        return 
    print('No')

if __name__ == '__main__':
    ans()

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int main(void) {
  int i, j, k, n, h = 0, t;
  char h2;
  scanf("%d", &n);
  t = 2 * n - 2;
  char a[30][20];
  int b[30];
  printf("0\n");
  fflush(stdout);
  scanf("%s", a[0]);
  if(a[0][0] == 'V') return 0;
  b[0] = 0;
  for(i = 1; i < 20; ++i) {
    int temp = (h + t + 1) / 2;
    if(temp >= n) temp -= n;
    printf("%d\n", temp);
    fflush(stdout);
    scanf("%s", a[i]);
    b[i] = temp;
    if(a[i][0] == 'V') return 0;
    int te = temp - h, fl = 0;
    if(a[i][0] == h2) fl = 1;
    if(te % 2) fl = (fl + 1) % 2;
    //printf("%c %d\n", h2, fl);
    if(!fl) t = (h + t + 1) / 2;
    else {
      h = (h + t + 1) / 2;
      h2 = a[i][0];
    }
    if(i == 1) h = 0, t = temp, h2 = a[0][0];
  }
  return 0;
}

Measured memory_bytes: 760
import sys
input = sys.stdin.readline

def main():
	#N = int(input())
	#S = input().rstrip()
	N,M,X = map(int,input().split())
	vA = set(map(int,input().split()))
	#N = int(input())
	
	L1 = sum(i in vA for i in range(0,X))
	L2 = sum(i in vA for i in range(X,N))
	res = min(L1,L2)
	print(res)
	
main()


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)


int main(void)
{
	string s;
	li k;
	cin >> s >> k;

	set<string> st;

	li n = s.size();
	rep(i, n) {
		rep(j, min(k, n - i)) {
			st.insert(s.substr(i, j + 1));
		}
	}
	rep(i, k - 1) {
		st.erase(*st.begin());
	}
	cout << *st.begin() << endl;



	return 0;
}

Measured memory_bytes: 4816
import sys
import math
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#######ここから天ぷら########
n=int(input())
A=list(map(int,input().split()))
SA=[0 for i in range(n)]
for i in range(n):
    SA[i]=A[i]-i-1
SA.sort()

if n%2==0:
    geta=(SA[n//2]+SA[n//2-1])//2
else:
    geta=SA[n//2]
ans=0
for i in range(n):
    ans+= abs(A[i]-(geta+i+1))
print(ans)


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

int main(void) {
    int K, A, B; cin >> K >> A >> B;
    bool isMultipleOfK = false;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            isMultipleOfK = true;
        }
    }
    if (isMultipleOfK) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
#define N (int)3e3
#define f1 first
#define s2 second
#define INF 9999999
#define pb push_back
#define ll long long
#define mod (int)1e9+7
#define ull unsigned long long;
#define all(a) a.begin(),a.end()
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);

int n;
double dizi[N],dp[N][N];

double dpf(int i,int j){
	double ans=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(j==0)dp[i][j]=dp[i-1][j]*(1-dizi[i-1]);
			else if(i==j)dp[i][j]=dp[i-1][j-1]*dizi[i-1];
			else dp[i][j]=dp[i-1][j-1]*dizi[i-1]+dp[i-1][j]*(1-dizi[i-1]);
			//cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
		}
	}
	for(int i=(int)ceil(double(n)/2.0);i<=n;i++){
		//cout<<i<<" "<<" "<<dp[n][i]<<endl;
		ans+=dp[n][i];
	}
	return ans;
}

int main(){
	//fri("in.txt");
	//fro("out.txt");
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>dizi[i];
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			dp[i][j]=1;
		}
	}
	printf("%.10f",dpf(0,0));
	return 0;
}

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

int main(){
 string str;
 cin >> str;
 int num;
 cin >> num;

 string command;
 while( num-- ){
  cin >> command;
  if( command == "print" ){
   int a,b;
   cin >> a >> b;
   for( int i=a; i<=b; i++ ){
    if( i!=b ){
      cout << str[i];
    }else{
      cout << str[i] << endl;
    }
   }
  }

  if( command == "reverse" ){
   int a,b;
   cin >> a >> b;
   int i,j;

   for( i=a, j=b; i<j; i++,j-- ){
     swap(str[i],str[j]);
   }
  }

  if( command == "replace" ){
   int a,b;
   string rep;
   cin >> a >> b >> rep;
   str.replace(a, b-a+1, rep);
  }
 }

 return 0;
}


Measured memory_bytes: 3172
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF INT32_MAX / 2
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

template <class T>
class SegmentTree {
  private:
    int n = 1;
    vector<T> segtree;
    function<T(T, T)> operation;
    T ie;

    T _query(int a, int b, int k, int l, int r) {
        if (a >= r || b <= l)
            return ie;
        else if (a <= l && b >= r)
            return segtree[k];
        else {
            int vl = _query(a, b, 2 * k + 1, l, (l + r) / 2);
            int vr = _query(a, b, 2 * k + 2, (l + r) / 2, r);
            return operation(vl, vr);
        }
    }

  public:
    SegmentTree(vector<T> v, function<T(T, T)> _operation, T _ie)
        : operation(_operation), ie(_ie) {
        while (v.size() > n)
            n *= 2;
        segtree.resize(2 * n - 1, ie);
        for (int i = 0; i < v.size(); i++)
            segtree[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; i--)
            segtree[i] = operation(segtree[2 * i + 1], segtree[2 * i + 2]);
    }

    T operator[](int i) {
        return segtree[i + n - 1];
    }

    void update(int i, T x) {
        i += n - 1;
        segtree[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            segtree[i] = operation(segtree[2 * i + 1], segtree[2 * i + 2]);
        }
    }

    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }
};

signed main() {
    int n, q, p, x, y;
    cin >> n >> q;
    auto f = [](int a, int b) -> int { return a + b; };
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    SegmentTree<int> s(a, f, 0);
    while (q--) {
        cin >> p >> x >> y;
        if (!p)
            s.update(x, y + s[x]);
        else
            cout << s.query(x, y) << endl;
    }
}

Measured memory_bytes: 19256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = pow(10, 5) + 1;//+1しないとREになる(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };
int main(void) {
	int H, W;
	cin >> H >> W;
	vector<string> maze(H);
	for (int i = 0; i < H; i++) cin >> maze[i];

	VVI far(H, vector<int>(W, INF));
	far[0][0] = 0;
	queue<P> q;
	q.push(P(0, 0));
	while (!q.empty()) {
		int now_x = q.front().first;
		int now_y = q.front().second;
		q.pop();
		for (int i = 0; i < 4; i++) {
			int next_x = now_x + dx[i];
			int next_y = now_y + dy[i];
			if (next_x < 0 || H <= next_x || next_y < 0 || W <= next_y) continue;
			if (maze[next_x][next_y] == '#') continue;
			if (far[next_x][next_y] != INF) continue;
			far[next_x][next_y] = far[now_x][now_y] + 1;
			q.push(P(next_x, next_y));
		}
	}

	//////////////////解1////////////////////////////////////////
	//int ans = 0;
	//int forcus_num = 1;//forcus_num
	//for (int forcus_num = 1; forcus_num <= H * W; forcus_num++) {
	//	int count = 0;
	//	for (int i = 0; i < H; i++) {
	//		for (int j = 0; j < W; j++) {
	//			if (far[i][j] == forcus_num) {
	//				if (forcus_num > far[H - 1][W - 1]) ans++;			
	//				else{
	//					count++;
	//					if (count >= 2) {
	//						ans++;
	//						//far[i][j] = -1*ans;
	//					}
	//				}
	//			}
	//		}
	//	}
	//}
	////cout << " tmp ans " << ans << endl;
	//int num_INF = 0;
	//for (int i = 0; i < H; i++) {
	//	for (int j = 0; j < W; j++) {
	//		if (maze[i][j] != '#') {
	//			if (far[i][j] == INF) num_INF++;
	//		}

	//	}
	//}
	////cout << "num_INF : " << num_INF << endl;
	//ans += num_INF;

	///////////////////解2////////////////////////////////////////
	int num_sharp = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (maze[i][j] == '#') num_sharp++;
		}
	}
	//cout << " num_sharp : " << num_sharp << endl;
	//int ans = H * W - num_sharp - far[H - 1][W - 1]-1;
	int ans = H * W - num_sharp - (far[H - 1][W - 1]+1);
	

	if (far[H - 1][W - 1] == INF) {
		cout << "-1" << endl;
		return 0;
	}
	cout << ans << endl;
	/*
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << maze[i][j] << "        ";
		}
		cout << endl;
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << far[i][j] << "        ";
		}
		cout << endl;
	}*/
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define min(a,b) (a)<(b)?(a):(b)
int main(void)
{
  int n,t,a,h[1010]={},ans;
  double tem[1010]={},min=100000;
  scanf("%d%d%d",&n,&t,&a);
  for(int i=0;i<n;i++){
    scanf("%d",&h[i]);
    tem[i]=t-h[i]*0.006;
  }
  for(int i=0;i<n;i++){
    min=min(min,fabsf(tem[i]-a));
    if(min==fabsf(tem[i]-a)){
      ans=i;
    }
  }
  printf("%d",ans+1);
  return 0;
}


Measured memory_bytes: 256
from collections import *
from copy import *
H,W = map(int,input().split())
S = [(W+2)*["#"]]+[["#"]+list(input())+["#"] for h in range(H)]+[(W+2)*["#"]]
D = [[1,0],[-1,0],[0,1],[0,-1]]
ans = 0
P = deque([])
Q = deque([])
 
for h in range(1,H+1):
  for w in range(1,W+1):
    if S[h][w]==".":
      P+=[[h,w]]
 
while P:
  T = deepcopy(S)
  sx,sy = P.popleft()
  T[sx][sy] = 0
  Q = deque([[sx,sy]])
  while Q:
    x,y = Q.popleft()
    for dx,dy in D:
      if T[x+dx][y+dy]==".":
        T[x+dx][y+dy] = T[x][y]+1
        Q+=[[x+dx,y+dy]]
        ans = max(ans,T[x+dx][y+dy])
 
print(ans)

Measured memory_bytes: 9620
import java.util.Scanner;

public class Main {

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

		while(true){
			int H = in.nextInt();
			int W = in.nextInt();

			if(H == 0 && W== 0){break;}

			for(int i = 0; i < H; i++){
				for(int j = 0; j < W; j++){
					if(i % 2 == 0 && j % 2 == 0 || i % 2 != 0 && j % 2 != 0){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
					/*if(i % 2 == 0){
						if(j % 2 == 0){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}else{
						if(j % 2 == 0){
							System.out.print(".");
						}else{
							System.out.print("#");
						}
					}*/
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 34928
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

void c()
{
    string s, t;
    cin >> s >> t;
    vector<int> start_index;
    if(s.size() < t.size())
    {
        cout << "UNRESTORABLE" << endl;
        return;
    }
    for(int i = 0; i < s.size(); i++)
    {
        bool flag = true;
        for(int j = 0; j < t.size(); j++)
        {
            if(s[i + j] == '?')continue;
            if(s[i + j] != t[j]) flag = false;
        }
        if(flag)
        {
            start_index.push_back(i);
        }
    }
    if(start_index.size() == 0)
    {
        cout << "UNRESTORABLE" << endl;
        return;
    }
    vector<string> results;
    for(auto index : start_index)
    {
        string result;
        for(int i = 0; i < s.size(); i++)
        {
            if(i != index)
            {
                if(s[i] == '?')
                {
                    result.push_back('a');
                }else{
                    result.push_back(s[i]);
                }
            }else{
                for(int j = 0; j < t.size(); j++)
                {
                    result.push_back(t[j]);
                }
                i += t.size() - 1;
            }
        }
        results.push_back(result);
    }
    string minimum = results[0];
    for(auto e : results)
    {
       if(minimum > e)
       {
           minimum = e;
       }
    }
    cout << minimum << endl;
}

void d()
{

}

int main() {
    c();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INF = (1 <<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra(){
    int minv;
    int d[MAX], color[MAX];

    for(int i=0; i<n; i++){
        d[i] = INF;
        color[i] = WHITE;
    }

    d[0] = 0;
    color[0] = GRAY;
    while(true){
        minv = INF;
        int u = -1;
        for(int i=0; i<n; i++){
            if(minv > d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u == -1) break;
        color[u] = BLACK;
        for(int v=0; v<n; v++){
            if(color[v] != BLACK && M[u][v] != INF){
                if(d[v] > d[u] + M[u][v]){
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    for(int i=0; i<n; i++){
        cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
    }
}


int main() 
{
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            M[i][j] = INF;
        }
    }
    
    int k, c, u, v;
    for(int i=0; i<n; i++){
        cin >> u >> k;
        for(int j=0; j<k; j++){
            cin >> v >> c;
            M[u][v] = c;
        }
    }
    
    dijkstra();
    
    return 0;
}

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

using namespace std;

const int MAX_VALUE = (1 << 31) - 1;

int main() {
	// your code goes here
	//cout << MAX_VALUE << endl;
	int  n, i, j, k;
	cin >> n;
	vector<int> h(n), ans(n, MAX_VALUE);
	for (i = 0; i < n; i++)
	{
		cin >> h[i];
	}
	ans[0] = 0;
	for (i = 0; i < n; i++)
	{
		//cout << ans[i] << " ";
		if ((i+1 < n) && (ans[i+1] > (ans[i] + abs(h[i] - h[i+1]))))
		{
			ans[i+1] = ans[i] + abs(h[i] - h[i+1]);
		}
		if ((i+2 < n) && (ans[i+2] > (ans[i] + abs(h[i] - h[i+2]))))
		{
			ans[i+2] = ans[i] + abs(h[i] - h[i+2]);
		}
	}
	cout << ans[n-1];
	return 0;
}

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

constexpr int nax = 500;

const pair< int, int > adj[] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

int n, res;
pair< int, int > tab[nax * nax]; // cords sorted by order of leaving cinema
bool gone[nax][nax]; // is certain viewer gone
int dis[nax][nax]; // distances from exit

pair< int, int > operator+(const pair< int, int >& a, const pair< int, int >& b)
{ return {a.first + b.first, a.second + b.second}; }

bool valid(const pair< int, int >& v)
{ return 0 <= v.first and v.first < n and 0 <= v.second and v.second < n; }

void dfs(const pair< int, int > v)
{
    int old_dis = dis[v.first][v.second];
    
    for (auto off : adj)
    {
        auto s = off + v;
        if (not valid(s))
            continue;
        dis[v.first][v.second] = min(
            dis[v.first][v.second], dis[s.first][s.second] + !gone[s.first][s.second]
        );
    }

    if (old_dis > dis[v.first][v.second])
        for (auto off : adj)
            if (valid(off + v))
                dfs(off + v);
}

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

    cin >> n;

    for (int i = 0; i < n * n; ++i)
    {
        int v; cin >> v; --v;
        tab[i] = {v / n, v % n};
    }

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            dis[i][j] = min({i, j, n - 1 - i, n - 1 - j});

    for (int i = 0; i < n * n; ++i)
    {
        pair< int, int > v = tab[i];
        res += dis[v.first][v.second];
        gone[v.first][v.second] = true;

        for (auto off : adj)
            if (valid(off + v))
                dfs(off + v);
    }

    cout << res << '\n';
}


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

int main()
{
    string s;
    cin >> s;

    for (int x = 0; x < 8; x++)
    {
        int sum = s.at(0) - '0';
        string ans;
        ans += s.at(0);

        for (int i = 0; i < 3; i++)
        {
            if ((x & (1 << i)))
            {
                sum += s.at(i + 1) - '0';
                ans += '+';
                ans += s.at(i + 1);
            }
            else
            {
                sum -= s.at(i + 1) - '0';
                ans += '-';
                ans += s.at(i + 1);
            }
        }

        if (sum == 7)
        {
            cout << ans << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<bitset>
#include<iomanip>
#include<cctype>
using namespace std;
const int inf = 1001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

int main(){
    int q; cin >> q;
    for (int i = 0; i < q; i++){
        string a, b; cin >> a >> b;
        vector<vector<int>> dp(a.size()+1,vector<int>(b.size()+1,0));
        for (int k = 1; k < a.size()+1; k++){
            for (int l = 1; l < b.size()+1; l++){
                if (a[k-1] == b[l-1]){
                    dp[k][l] = max({dp[k-1][l-1]+1,dp[k-1][l],dp[k][l-1]});
                }
                else dp[k][l] = max(dp[k-1][l],dp[k][l-1]);
            }
        }
        cout << dp[a.size()][b.size()] << endl;
    }

    return 0;
}


Measured memory_bytes: 6828
#include <iostream>
#include <cstdlib>
#include <stack>
using namespace std;
int main(){
  int a,b;
  string ch;
  stack<int> S;
  while(cin>>ch){
    if(ch[0]=='+'){
      a=S.top();S.pop();
      b=S.top();S.pop();
      S.push(a+b);
    } else if(ch[0]=='-'){
      b=S.top();S.pop();
      a=S.top();S.pop();
      S.push(a-b);
    } else if(ch[0]=='*'){
      a=S.top();S.pop();
      b=S.top();S.pop();
      S.push(a*b);
    } else {
      S.push(atoi(ch.c_str()));
    }
  }
  cout<<S.top()<<endl;
  return 0;
}

Measured memory_bytes: 3152
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int a,b, s;
    while(scanf("%d%d", &a, &b)!=EOF){
        s=__gcd(a, b);
        printf("%d %d\n", s, (a/s)*b);              
                        
    }  
    return 0;
}

Measured memory_bytes: 1188
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int num[114514];
bool aru[114514];
int main()
{
	int n,m,x,y,out=0;
	memset(aru,0,sizeof(aru));
	scanf("%d %d",&n,&m);
	rep(i,n) num[i]=1;
	aru[0]=true;
	rep(i,m){
		scanf("%d %d",&x,&y);
		x--;y--;
		if(aru[x]) aru[y]=true;
		if(aru[x] && num[x]==1) aru[x]=false;
		num[x]--;num[y]++;
	}
	rep(i,n){
		if(aru[i]) out++;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 768
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var S = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var q = int.Parse(Console.ReadLine());
            var T = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var count = 0;
            foreach (var t in T)
            {
                if (S.Contains(t)) count++;
            }

            Console.WriteLine(count);
        }
    }
}



Measured memory_bytes: 18380
a = int(input())
s = str(a)
c = 0
for i in range(len(s)-1):
    # print(c)
    if i%2 == 0:
        c += 10**(i+1) - 10**i 

if len(s) %2 == 1 and len(s)> 1:
    c += int(s[1:])+1 + (int(s[0])-1)*(10**(len(s)-1))
elif len(s)==1:
    c +=a

print(c)

Measured memory_bytes: 3060
#include <stdio.h>

char str[1005];
char p[1005];

int main()
{
    int q, a, b;
    char op[10], *x, *y, c;
    
    scanf("%s%d", str, &q);
    while (q--) {
        scanf("%s%d%d", op, &a, &b);
        if (op[2] == 'i') {             // print
            b++, c = *(str+b), *(str+b) = 0, puts(str+a), *(str+b) = c;
        } else if (op[2] == 'v') {      // reverse
            x = str+a, y = str+b;
            while (x < y) {
                c = *x, *x = *y, *y = c;
                x++, y--;
            }
        } else {                        // replace
            scanf("%s", p);
            x = str+a, y = p;
            while (*y) *x++ = *y++;
        }
    }
    return 0;
}


Measured memory_bytes: 2104
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    cout << max({a + b, a - b, a * b}) << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 10*1024)
	sc.Buffer(bf, 20*1024)
	sc.Split(bufio.ScanWords)

	sc.Scan()

	s := sc.Text()

	if s[0] >= 'A' && s[0] <= 'Z' {
		fmt.Printf("%c\n", 'A')
	} else if s[0] >= 'a' && s[0] <= 'z' {
		fmt.Printf("%c\n", 'a')
	}
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll a[3],ans=1000;
    rep(0,i,3)cin>>a[i];
    rep(0,i,3){
        rep(i+1,j,3)ans=min(ans,a[i]+a[j]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include<stdio.h>
#include <functional>
#include<algorithm>
#define PI 3.14159265
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define SZ(x) ((int)(x).size())

using namespace std;

int main() {
	string n;
	cin >> n;
	int s = 0;
	int a;
	a = stoi(n);
	REP(i, SZ(n)) {
		s += n[i] - '0';
	}
	if (a%s == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main()
{
    int a[3],count=0,min0,Max,min1,i0,i1;
    cin>>a[0]>>a[1]>>a[2];

   sort(a,a+3);
   while( a[1]!=a[2])
   {
       a[0]++;
       a[1]++;
       count++;
   }
   while(a[0]<a[2])
   {
       a[0]+=2;
       count++;
   }
   if(a[0]>a[2])
   {
       a[1]++;
       a[2]++;
    count++;
   }


    cout<<count<<endl;


}


Measured memory_bytes: 256
import sys
from bisect import bisect, bisect_left


class BinaryIndexedTree:
    def __init__(self, n):
        self.size = n
        self.INF = 10 ** 18
        self.tree = [self.INF] * (n + 1)

    def get_min(self, i):
        s = self.INF
        while i > 0:
            s = min(s, self.tree[i])
            i -= i & -i
        return s

    def update(self, i, x):
        while i <= self.size:
            if self.tree[i] <= x:
                break
            self.tree[i] = x
            i += i & -i


def solve(n, e, t, xxx):
    if n == 1:
        return e + t

    dp1 = [0] * (n + 1)
    dp2 = BinaryIndexedTree(n + 1)
    dp2.update(1, -xxx[0] * 2)

    for i in range(n):
        x = xxx[i]
        j = bisect_left(xxx, x - t // 2, hi=i)
        ex_time = dp1[j] + t
        if j > 0:
            ex_time = min(ex_time, x * 2 + dp2.get_min(j))
        dp1[i + 1] = ex_time
        if i < n - 1:
            dp2.update(i + 2, ex_time - xxx[i + 1] * 2)

    return e + dp1[-1]


n, e, t, *xxx = map(int, sys.stdin.buffer.read().split())
print(solve(n, e, t, xxx))


Measured memory_bytes: 21176
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;

int main(){
    int n; cin >> n;
    vector<double> v(n);
    rep (i, n) cin >> v[i];
    sort(v.begin(), v.end());
    double vi = (v[0] + v[1]) / 2;
    for (int i = 2; i < n; i++) {
        vi = (vi + v[i]) / 2;
    }

    cout << vi << endl;

    return 0;
}

Measured memory_bytes: 3776
/* 
 * Project: AtCoder Beginners Contest 162 A - Lucky 7
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/04/12
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string n;

void solve() {

    if (n[0] == '7' || n[1] == '7' || n[2] == '7')
        cout << "Yes\n";
    else
        cout << "No\n";
}

int main() {

    cin >> n;

    solve();

}


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

using namespace std;

const int dx[] = { -1,0,1,0 };
const int dy[] = { 0,-1,0,1 };

const int ddx[] = { 0,1,1,  0,2, 1,-1,-2, 2, 2, -2,-2,1,-1,1,-1,2,2,-2,-2 };
const int ddy[] = { 2,1,-1,-2,0, 1, 1, 0,2, -2,  2,-2,2,2, -2,-2, 1,-1,1,-1 };


int main() {
	int H, W;
	cin >> H >> W;
	int ch, cw, dh, dw;
	cin >> ch >> cw >> dh >> dw;
	ch--; cw--; dh--; dw--;
	vector<string> S(H);
	for (int n = 0; n < H; ++n) {
		cin >> S[n];
	}

	vector<vector<int>> D(H, vector<int>(W, 1e9));//回数
	deque<pair<int, int>> q;
	q.push_front(make_pair(ch, cw));
	D[ch][cw] = 0;

	while (!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop_front();
		//範囲内かつ0を4セット
		for (int l = 0; l < 4; ++l) {
			int x1 = x + dx[l];
			int y1 = y + dy[l];
			if ((0 <= x1) && (H > x1) && (0 <= y1) && (W > y1) && ('.' == S[x1][y1])) {
				if (D[x1][y1] > D[x][y]) {
					D[x1][y1] = D[x][y];
					q.push_front(make_pair(x1, y1));
				}
			}
		}
		//範囲内かつ0を20セット
		for (int l = 0; l < 20; ++l) {
			int x1 = x + ddx[l];
			int y1 = y + ddy[l];
			if ((0 <= x1) && (H > x1) && (0 <= y1) && (W > y1) && ('.' == S[x1][y1])) {
				if (D[x1][y1] > D[x][y] + 1) {
					D[x1][y1] = D[x][y] + 1;
					q.push_back(make_pair(x1, y1));
				}
			}
		}
	}
	if (1e9 == D[dh][dw]) {
		cout << -1 << endl;
	}
	else {
		cout << D[dh][dw] << endl;
	}
	return 0;
}

Measured memory_bytes: 9504
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (ll i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    ll N;
    cin >> N;
    ll cnt = 0;
    for(int i=1; i<N-1; ++i){
        cnt+=(N-1)/i;
    }
    cout << cnt+1 << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

class UnionFind {
private:
  vector<int> parent;
  vector<int> rank;

public:
  UnionFind(int size) : parent(size), rank(size, 0) {
    for (int i = 0; i < size; i++) {
      parent[i] = i;
    }
  }

  int find(int x) {
    if (parent[x] == x) {
      return x;
    } else {
      return parent[x] = find(parent[x]);
    }
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (rank[x] < rank[y]) {
      parent[x] = y;
    } else {
      parent[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

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

  int n, m;
  cin >> n >> m;
  vector<int> p(n), x(m), y(m);
  rep(i, n) cin >> p[i];
  rep(i, m) cin >> x[i] >> y[i];

  UnionFind uf(n+1);
  rep(i, m) {
    uf.unite(x[i], y[i]);
  }

  int ans = 0;
  rep(i, n) {
    if (uf.same(p[i], i+1)) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 2176
function Main(input) {
input = input.split(" ");
var a = parseInt(input[0], 10);
var b = parseInt(input[1], 10);
var c = parseInt(input[2], 10);
var d = parseInt(input[3], 10);
var e = parseInt(input[4], 10);
var f = parseInt(input[5], 10);
var s = 0;
var s1 = 0;
var s2 = 0;
for (i=0; i*100*a<=f; i++){
  for (j=0; i*100*a+j*100*b<=f; j++){
    for (k=0; i*100*a+j*100*b+k*c<=f; k++){
      for (l=0; i*100*a+j*100*b+k*c+l*d<=f; l++){
        if((k*c+l*d) <= (a*i+b*j)*e){
          if((100*(k*c+l*d)/(i*100*a+j*100*b+k*c+l*d)>s)){
            s=100*(k*c+l*d)/(i*100*a+j*100*b+k*c+l*d);
            s1=i*100*a+j*100*b+k*c+l*d;
            s2=k*c+l*d;
          }
        
        }

      }
    }
  }
}
if(s1==0){
  s1=a*100;
}
  console.log('%s %d', s1, s2);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {

    int n,x;
    cin >> n >> x;
    vector<int> a(n);

    for(int i = 0; i < n; i++){
          cin >> a.at(i);
    }

    sort(a.begin(), a.end());
    
    int children = 0;
    for( int i = 0; i < n ; i++ ){

        if( i == n-1 ){
            if( a.at(i) == x )
              children++;
            break;  
        }
        
        if( x >= a.at(i) ){
            children++;
            x -= a.at(i);
        }else{
            break;
        }

    }
    

    cout << children << endl;


}



Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	for(int i=0;i<19;i++){
		char c ; cin >> c ;
		cout << (c==','?' ':c) ;
	}
	cout << endl ;
}


Measured memory_bytes: 256