akhauriyash/Code-Regression huggingface dataset:
#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#根なら-size,子なら親の頂点
n,m,k = [int(i) for i in input().split()]
par = [-1]*n
ans = [-1]*n

import sys
input = sys.stdin.readline

for _ in range(m):
  a,b = [int(j) for j in input().split()]
  unite(a-1,b-1)
  ans[a-1] -= 1
  ans[b-1] -= 1

for _ in range(k):
  c,d = [int(i) for i in input().split()]
  if same(c-1,d-1):
    ans[c-1] -= 1
    ans[d-1] -= 1
    
for i in range(n):
  ans[i] += size(i)
  
ans = list(map(str,ans))
print(' '.join(ans))

Measured memory_bytes: 17312
s = input()
l = len(s)

first_s = s[:int((l - 1) / 2)]
second_s = s[int((l - 1) / 2 + 1):]


def isPalindrome(s):
    for i in range(int((l - 1) / 2)):
        if s[i] != s[-(i + 1)]:
            return False

    return True


if isPalindrome(s) and isPalindrome(first_s) and isPalindrome(second_s):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>

int main()
{
  long long a,v,b,w,t;
  scanf("%lld%lld%lld%lld%lld",&a,&v,&b,&w,&t);
  puts(std::abs(a-b)<=(v-w)*t?"YES":"NO");
  return 0;
}


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

int main(){
  int h1,m1,h2,m2, k;
  cin >> h1>>m1>> h2>>m2>>k;

  int cost = (h2*60+m2) - (h1*60+m1);
  int ans = max(0, cost-k);
  cout << ans <<endl;
}


Measured memory_bytes: 3560
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
        int int2 = Integer.parseInt(scan.next());
        int int3 = Integer.parseInt(scan.next());
//        String str1 = scan.next();

//        String str1 = scan.next();

        int ans_int = 0;
        double ans_dob = 0;
        String ans = "";

        ans_int = int1 * int3 - int2;

        PrintWriter out = new PrintWriter(System.out);
        out.println(ans_int);
        out.flush();
        for(int i  = 1; i <10 ; i++){
            ans_int = ans_int * int1 -int2;
            out.println(ans_int);
            out.flush();
        }

        scan.close();
    }
}


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

int main() {
  char c;
  cin >> c;

  if (c=='A') {
    cout << 'T';
  } else if (c=='T') {
    cout << 'A';
  } else if (c=='G') {
    cout << 'C';
  } else {
    cout << 'G';
  }
  cout << endl;
}

Measured memory_bytes: 256
n = int(input())
ans = 0
add = [i for i in range(n+1) if i%2 ==1]
for i in add:
    num = 0
    for j in range(1,n+1):
        if i%j ==0:
            num += 1
    if num == 8:
        ans +=1
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
int main(){
  int a,b;
  std::scanf("%d%d",&a,&b);
  
  if(a < b){
    std::printf("a < b\n");
  }
  else if(a > b){
    std::printf("a > b\n");
  }
  else {
    std::printf("a == b\n");
  }
  return 0;
}


Measured memory_bytes: 2680
#include <stdio.h>

int main(){
    char number[1001];
    int i, sum;
    while(1){
        scanf("%s", number);
        if(number[0]=='0')break;
        sum=0;
        for(i=0;number[i]!='\0';i++){
            sum+=number[i]-'0';
        }
        printf("%d\n", sum);
    }

    return 0;
}
//*/


Measured memory_bytes: 2704
/***************************************************
	> File Name: Unkown_Error.cpp
	> Author: Zcorpio
	> Mail: 1113043195@qq.com 
	> Created Time: [Data_Deleted]
***************************************************/
#include<bits/stdc++.h>
//#define int long long
#define rint register int
#define mst(a,b) memset(a,b,sizeof(a))
#define go(u) for(int i=head[u],v=to[i];i;v=to[i=nxt[i]])
#define F(i,a,b) for(register int i=(a),i##_end=(b);i<=i##_end;++i)
#define R(i,a,b) for(register int i=(a),i##_end=(b);i>=i##_end;--i)
#define File(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
using namespace std;
//const int mod=1e9+7;
//const int mod=998244353;
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
/*
template<typename T> inline T max(T a,T b){return a>b?a:b;}
template<typename T> inline T min(T a,T b){return a<b?a:b;}
template<typename T> inline T abs(T a){return a>0?a:-a;}
template<typename T> inline bool chkmin(T &a,T b){return a<b?a=b,1:0;}
template<typename T> inline bool chkmax(T &a,T b){return a>b?a=b,1:0;}
template<typename T> inline T gcd(T a,T b){T t;if(a<b)
{while(a){t=a;a=b%a;b=t;}return b;}else{while(b){t=b;b=a%b;a=t;}return a;}}
template<typename T> inline T sqr(T x){return x*x;}
inline void write(T k,char ch=0)
{
	if(k<0)k=-k,putchar('-');
	if(k>=10)write(k/10);
	putchar(k%10+'0');
	if(ch)putchar(ch);
}
inline void add(int u,int v)
{
	cnt++;
	nxt[cnt]=head[u];
	to[cnt]=v;
	head[u]=cnt;
}
*/
inline ll read()
{
	ll x=0;
	bool f=0;
	char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') f=1;
		ch=getchar();
	}
	while(isdigit(ch))
	{
		x=(x<<3)+(x<<1)+(ch^48);
		ch=getchar();
	}
	return f?-x:x;
}
int main()
{
	//File("");
	ll n=read();
	ll ans=0x3f3f3f3f3f3f3f3f;
	F(i,1,sqrt(n))
	{
		if(!(n%i)) if((ll)i+(ll)n/i-2<ans) ans=(ll)i+(ll)n/i-2;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import fractions
a, b = map(int,input().split())
g = fractions.gcd(a,b)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
if g == 1:
     print(1)
else:
     print(len(factorization(g))+1)

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

int main()
{
	char s[100010];
	int i, c;

	scanf("%s", s);

	i = 0;
	while(s[i]){
		if(s[i] == 'd'){
			if(s[i+1] == 'r'&& s[i+2] == 'e' && s[i+3] == 'a' && s[i+4] == 'm') i = i+5;
			else break;
		}
		else if(s[i] == 'e'){
			if(s[i+1] == 'r' && s[i+2] == 'a'){
				if(s[i+3] == 's' || s[i+4] == 'e') i = i+5;
				else break;
			}
			else{
				if(s[i-1] == 'm' && s[i+1] == 'r') i = i + 2;
				else break;
			}
		}
		else{
			if(s[i] == 'r' && s[i-1] == 'e') i = i + 1;
			else break;
		}
	}

	if(s[i]) printf("NO");
	else printf("YES");

return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 10;
int n;
int p[N];

int32_t main() {

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

    int ans = 0;
    int mxp = 0;
    for(int i = 0; i < n; ++i) {
        int pi = p[i];
        mxp = max(mxp, pi);
        ans += pi;
    }

    ans -= mxp/2;

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <math.h>
#include <cstdint>
#include <cstring>

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int main()
{
		int N;
		cin >> N;
		
		int count = 0;

		for (int i = 1; i <= N; i++){
			
			unsigned int keta = 0;
			
			int num = i;

			while (num != 0){
				num = num / 10;
				++keta;
			}

			//cout << i << ",";
			//cout << keta << endl;


			if (keta % 2 == 0){
				//printf("%d は偶数です\n", a);
			}
			else {
				++count;
				//printf("%d は奇数です\n", a);
			}
		}
		cout << count << endl;
		//system("pause");
		return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
using namespace std;

void solve()
{
    int n;
    cin>>n;
    int cnt=0;
    for(int i=2;i*i<=n;i++)
    {
        int dem=0;
        while(n%i==0)
        {
            dem++;
            n/=i;
        }
        int mx=0;
        for(int j=1;j<=60;j++)
        {
            if(j*(j+1)/2<=dem) mx=j;
            else break;
        }
        cnt+=mx;
    }
    if(n>1) cnt++;
    cout<<cnt;
}


main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //int t;
    //cin>>t;
    //while(t--)
        solve();
}


Measured memory_bytes: 3640
li = input().split()
N = int(li[0])
A = int(li[1])
B = int(li[2])
ans = 0
for i in range(N + 1):
  t = list(str(i))
  s = 0
  for j in t:
    s += int(j)
  if B>= s:
    if s >= A:
      ans += i
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,ans=1<<30;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n>>1;i++)
        {
            int tmp=0,a=i,b=n-i;
            for(int k=1;k<=5;k++)
                tmp=tmp+a%10+b%10,a/=10,b/=10;
            ans=min(ans,tmp);
        }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
use std::io::{self, BufRead, BufWriter, Write};

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let a_line = lines.next().unwrap().unwrap();
    let mut splited = a_line.trim().split_whitespace();
    let _n: i32 = splited.next().unwrap().parse().unwrap();
    let k: i32 = splited.next().unwrap().parse().unwrap();

    let a_line = lines.next().unwrap().unwrap();
    let mut splited = a_line.trim().split_whitespace();
    let ans: i32 = splited
        .map(|s| s.parse().unwrap())
        .map(|c: i32| if c >= k { 1 } else { 0 })
        .sum();

    writeln!(&mut writer, "{}", ans).unwrap();
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"4 150
150 140 100 200", br"2
",
        ),
        (
            br"1 500
499", br"0
",
        ),
        (
            br"5 1
100 200 300 400 500", br"5
",
        ),
    ];

    #[test]
    fn test_b() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s);i<(e);i++)
#define rep(i,n) REP(i,0,n)

int main(void) {
    int A, B;
    cin >> A >> B;
    if (A <= 5) cout << 0 << endl;
    else if (A <= 12) cout << B / 2 << endl;
    else cout << B << endl;
    return 0;
}


Measured memory_bytes: 256
n,k,s=map(int,input().split())
l=[]
if s<10**8:
    for i in range(n):
        if i<k:
            l.append(s)
        else:
            l.append(s+10)
else:
    for i in range(n):
        if i<k:
            l.append(s)
        else:
            l.append(s-10)

for i in l:
    print(i,end=" ")

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int k,a,b;
    cin>>k>>a>>b;
    string ans="NG";
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            ans="OK";
            break;
        }
    }
    cout<<ans;
    return 0;
}

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

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[] arr = new int[n];
        while(m-- > 0){
            arr[scan.nextInt() - 1]++;
            arr[scan.nextInt() - 1]++;
        }
        for(int i : arr) System.out.println(i);
        
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MX 1000000000
void fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}
ll dp[100001][3];
int main() {
	fastio();
	ll n;
	cin>>n;
	ll ar[n+5][5];
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=3;j++)
		{
			cin>>ar[i][j];
		}
	}
	for(int i=1;i<=3;i++)
	dp[1][i]=ar[1][i];
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=3;j++)
		{
			for(int k=1;k<=3;k++)
			{
				if(j==k)continue;
				dp[i][j]=max(dp[i][j],dp[i-1][k]+ar[i][j]);
			}
		}
	}
	ll ans=-1;
	for(int i=1;i<=3;i++)
	ans=max(ans,dp[n][i]);
	cout<<ans;
	
	return 0;
}

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

using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back

const int N = 1e5 + 5, inf = 1e18;
int n, m, x, val[N], l = -inf, r = inf;
bool vis[N], sta[N];
vector< pair<int, int> > gr[N];

void over() { cout << 0; exit(0); }

void dfs(int u, int p) {
    if(vis[u]) return ;
    vis[u] = 1; sta[u] = (sta[p] ^ 1);
    for (auto i : gr[u]) {
        int v = i.fi, w = i.se;
        if(vis[v]) {
            if(sta[u] != sta[v]) {
                if(val[u] + val[v] != w) over();
            }
            else {
                int tmp = w - val[u] - val[v], tmpx;
                if(sta[u]) {
                    if(tmp % 2) over();
                    else tmpx = tmp / 2;
                }
                else {
                    if(tmp % 2) over();
                    else tmpx = -tmp / 2;
                }
                if(!x) {
                    x = tmpx;
                    if(x <= 0) over();
                }
                else if(x != tmpx) over();
            }
        }
        else {
            val[v] = w - val[u];
            dfs(v, u);
        }
    }
}

signed main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int u, v, w; cin >> u >> v >> w;
        gr[u].pb( { v, w } ); gr[v].pb( { u, w } );
    }
    dfs(1, 0);

    if(x) {
        for (int u = 1; u <= n; ++u) {
            if(sta[u]) { if(x + val[u] <= 0) over(); }
            else { if(-x + val[u] <= 0) over(); }
        }
        cout << 1;
        return 0;
    }

    for (int i = 1; i <= n; ++i) {
        if(sta[i]) l = max(l, 1 - val[i]);
        else r = min(r, -1 + val[i]);
    }

    if(l > r) cout << 0;
    else cout << r - l + 1;

    return 0;
}


Measured memory_bytes: 11904
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;

struct FenwickTree {
    int length;
    vector<ll> node;
    FenwickTree (int N) : length(N), node(length + 1, 0) {}
    void add(int idx, ll val) {
        ++idx;
        while (idx <= length) {
            node[idx] += val;
            idx += (idx & (-idx));
        }
    }
    ll getsum(int idx) {
        ll ans = 0;
        while (idx) {
            ans += node[idx];
            idx -= (idx & (-idx));
        }
        return ans;
    }
};

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> S(N);
    rep(i, N) {
        cin >> S[i].first;
        S[i].second = i;
    }
    sort(ALL(S));
    vector<int> A(N);
    A[S[0].second] = 0;
    for (int i = 1; i < N; ++i) {
        if (S[i - 1].first == S[i].first) A[S[i].second] = A[S[i - 1].second];
        else A[S[i].second] = A[S[i - 1].second] + 1;
    }
    ll ans = 0;
    FenwickTree FT(N);
    rep(i, N) {
        ans += FT.getsum(N) - FT.getsum(A[i] + 1);
        FT.add(A[i], 1);
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 6724
import numpy as np
import sys
 
n,k=map(int,sys.stdin.readline().split())
a=np.array(list(map(int, input().split())))
 
a.sort()
neg=a[a<0]
zero=a[a==0]
pos=a[a>0]
 
def count(x):
    cnt=0
    if x>=0:
        cnt+=len(zero)*n
    cnt+=np.searchsorted(a,x//pos,side='right').sum()
    cnt+=(n-np.searchsorted(a,(-x-1)//(-neg),side='right')).sum()
    cnt-=np.count_nonzero(a*a<=x)
    return cnt//2
 
 
left=-10**18
right=10**18
 
while left+1<right:
    x=(left+right)//2
    out=count(x)
    if out>=k:
        right=x
    if out<k:
        left=x
print(right)

Measured memory_bytes: 32304
n, m, x = gets.split.map(&:to_i)
textbooks = []
n.times do
  input = gets.split.map(&:to_i)
  textbooks << { price: input[0], progress: input[1..-1] }
end

total_prices = []

(2 ** n).times do |i|
  skills = Array.new(m) { 0 }
  price = 0

  textbooks.each_with_index do |textbook, bit_i|
    next if i[bit_i].zero?

    textbook[:progress].each_with_index do |progress, progress_i|
      skills[progress_i] += progress
    end

    price += textbook[:price]
  end

  next if skills.any? { |skill| skill < x }

  total_prices << price
end

puts total_prices.min || -1


Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
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; }
const int INF = 1000100100;

int main() {
    ll N;
    cin >> N;

    vector<ll> a(N);
    REP(i, N) {
        cin >> a[i];
    }

    vector<ll> a_cnt(N);
    vector<vector<pair<ll, ll>>> id_cnts(N + 1);
    id_cnts.at(0).emplace_back(make_pair(-1, 0));
    REP(i, a.size()) {
        ll tmp = INF;
        REP(j, id_cnts.at(a[i] - 1).size()) {
            ll tmp_sum = id_cnts[a[i] - 1][j].second;
            tmp_sum += i - id_cnts[a[i] - 1][j].first - 1;
            chmin(tmp, tmp_sum);
        }
        a_cnt[i] = tmp;
        id_cnts.at(a[i]).emplace_back(make_pair(i, a_cnt[i]));
    }

    ll ans = INF;
    REP(i, a.size()) {
        chmin(ans, a_cnt[i] + (N - i - 1));
    }
    if(ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 17176
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans = (double)w * h / 2;
    if(x * 2 == w && y * 2 == h){
        printf("%.12lf 1\n", ans);
    }else{
        printf("%.12lf 0\n", ans);
    }
	return 0;
}

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

int main() {
	long long int a, b, k;
	cin >> a >> b >> k;
	if (k > a) {
		k = k - a;
		a = 0;
		b = b - k;
		if (b < 0) b = 0;
	}
	else {
		a = a - k;
	}
	cout << a << " " << b << endl;
}

Measured memory_bytes: 256
//ATCODER Qual A
#include <stdio.h>
#include <stdlib.h>

int main(){
    char string[13] = {'\0'};
    scanf("%s",string);
    int i = 0;
    while(i < 12){
        if(i==4){
            printf(" ");
        }
        printf("%c",string[i]);
        i++;
    }
    printf("\n");
    return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N, X, T;
    
    cin>>N>>X>>T;
    
    cout<<(N + X - 1) / X * T <<endl;
	
	
	return 0;
}

Measured memory_bytes: 3636
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    print(s.count('1'))

if __name__ == '__main__':
    main()

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

int main () {
  int N;
  cin >> N;
  int K;
  cin >> K;
  int i;
  int num=1;
  for (i=0;i<N;++i) {
    if (num <= K) {
      num *= 2;
    } else {
      num += K;
    }
  }
  cout << num << endl;
}

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

int main() {
  ll n; cin >> n;
  if (n-1) {
    ll a, b; cin >> a >> b;
    cout << a + b << endl;
  } else {
    cout << "Hello World" << endl;
  }
}

Measured memory_bytes: 3548
#include<stdio.h>

int main()
{

  int building1[3][10],building2[3][10],building3[3][10],building4[3][10],
      build_num,stair_num,room_num,people_num,i,j,k,n;

  for(i=0;i<3;i++){
    for(j=0;j<10;j++){
        building1[i][j]=0;
        building2[i][j]=0;
        building3[i][j]=0;
        building4[i][j]=0;
      }
  }

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d%d%d%d",&build_num,&stair_num,&room_num,&people_num);
    --stair_num;
    --room_num;
    switch(build_num){
      case 1:
        building1[stair_num][room_num]+=people_num;
        break;
      case 2:
        building2[stair_num][room_num]+=people_num;
        break;
      case 3:
        building3[stair_num][room_num]+=people_num;
        break;
      case 4:
        building4[stair_num][room_num]+=people_num;
        break;
      default:
        break;
    }
  }

  for(i=0;i<3;i++){
    for(j=0;j<10;j++)
        printf(" %d",building1[i][j]);
    printf("\n");
  }
  for(i=0;i<20;i++) printf("#");
  printf("\n");


  for(i=0;i<3;i++){
    for(j=0;j<10;j++)
        printf(" %d",building2[i][j]);
    printf("\n");
  }
  for(i=0;i<20;i++) printf("#");
  printf("\n");


  for(i=0;i<3;i++){
    for(j=0;j<10;j++)
        printf(" %d",building3[i][j]);
    printf("\n");
  }
  for(i=0;i<20;i++) printf("#");
  printf("\n");


  for(i=0;i<3;i++){
    for(j=0;j<10;j++)
        printf(" %d",building4[i][j]);
    printf("\n");
  }

  return 0;
}

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

int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
   
      long long n,i,j,k,sum=0,count=0,ans=0,x=0,y=0,l,r,m;
      cin>>n;
     long long a[n];
     for(i=0;i<n;i++)
     {
         cin>>a[i];
     }
     ans=a[0];
     for(i=1;i<n;i++)
     {
         if(a[i]<ans)
         count+=ans-a[i];
         ans=max(ans,a[i]);
     }
     cout<<count;

	return 0;
}

Measured memory_bytes: 5216
#include <stdio.h>

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

int main(void) {
	int i;
	int q;

	scanf("%d", &q);

	while (q--) {
		int n;
		int cnt;

		scanf("%d", &n);

		cnt = 0;
		while (n > 9) {
			int max = 0;
			for (i = 10; i <= 1000000; i *= 10)
				max = max(max, n / i * (n % i));
			n = max;

			cnt++;
		}

		printf("%d\n", cnt);
	}

	return 0;
}

Measured memory_bytes: 600
#N,W = map(int, input().split())
S=list(map(int,input().split()))
N=S[0]
W=S[1]

C=[[0]*(W+1) for i in range(N+1)]

for i in range(N):
    w,v=map(int, input().split())
    for j in range(W+1):
        if(j>=w):
            C[i+1][j]=max(C[i][j],C[i][j-w]+v)
        else:
            C[i+1][j]=C[i][j]
print(C[N][W])


Measured memory_bytes: 119916
n = int(input())
HXY = []
for i in range(n):
    x, y, h = map(int, input().split())
    HXY.append((h, x, y))

HXY.sort(reverse=True)

for i in range(101):
    for j in range(101):
        H = -1
        for k in range(n):
            h, x, y = HXY[k]
            if h > 0:
                temp = h + abs(x-i) + abs(y-j)
                if H > 0:
                    if H != temp:
                        break
                else:
                    H = temp
            else:
                if H - abs(x-i) - abs(y-j) > 0:
                    break
        else:
            if H > 0:
                print(i, j, H)


Measured memory_bytes: 42224
l,r=map(int,input().split())

r=min(r,l+2020)
min=100000000000000000000000
for i in range(l,r+1):
    for j in range(i+1,r+1):
        mod = (i*j)%2019
        if mod<min:
            min = mod
print(min)

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

int main(){
    
    int N;
    cin >> N;
    int A;
    int a,b,c,d,e,f,g,h,j;
    a = 0;
    b = 0;
    c = 0;
    d = 0;
    e = 0;
    f = 0;
    g = 0;
    h = 0;
    j = 0;
    for(int i = 0; i < N;i++){
        cin >> A;
        if(1<= A && A < 400)a++;
        else if(400<= A && A < 800)b++;
        else if(800<= A && A < 1200)c++;
        else if(1200<= A && A < 1600)d++;
        else if(1600<= A && A < 2000)e++;
        else if(2000<= A && A < 2400)f++;
        else if(2400<= A && A < 2800)g++;
        else if(2800<= A && A < 3200)h++;
        else j++;
    }
    
    
    if(a == 0 && b == 0 && c == 0 && d == 0
    && e == 0 && f == 0 && g == 0 && h == 0 && j != 0){
        cout << 1 <<" "<<j <<endl;
    }else{
        int mn = 0;
        int mx = 0;
        if(a>0) mn++;
        if(b>0) mn++;
        if(c>0) mn++;
        if(d>0) mn++;
        if(e>0) mn++;
        if(f>0) mn++;
        if(g>0) mn++;
        if(h>0) mn++;
        
        mx = mn + j;
    
        
        cout << mn <<" "<<mx <<endl;
    }
}
    
    



Measured memory_bytes: 256
/*input
2020 4039
*/
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define pb push_back

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

template<typename T> using V = vector<T>;

const int N = 2019;

int main() {
	ios::sync_with_stdio(false);cin.tie(nullptr);
	ll L, R; cin >> L >> R;
	if(R - L + 1 >= N)
		return cout << 0, 0;
	ll ans = 2e18 + 100;
	for(ll i = L; i <= R; ++i) {
		for(ll j = i + 1; j <= R; ++j)
			ans = min(ans, (i * j) % N);
	}
	cout << ans << '\n';
	return 0;
}

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

public class Main {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;

    void solve() throws IOException {
        long n = nextLong();
        long value = n;
        long all = 0;
        while (value != 0) {
            long digit = value % 10;
            all += digit;
            value = value / 10;
        }
        long res = all;
        String str = Long.toString(n);
        res = Math.max(res, (str.charAt(0) - '1') + 9 * (str.length() - 1));
        outln(res);
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public Main() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new Main();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


Measured memory_bytes: 23124
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int k,a=0;
	for(int i=1;i<=3;i++)
	{
		cin>>k;
		a=a*10+k;
	 } 
	 if(a%4==0) cout<<"YES"<<endl;
	 else cout<<"NO"<<endl;
	 return 0;
}

Measured memory_bytes: 256
N, C = map(int, input().split())
tv = [[0]*C for _ in range(100000)]
for _ in range(N):
    s, t, c = map(int, input().split())
    for i in range(s-1, t): tv[i][c-1] = 1
print(max([sum(tv[i]) for i in range(100000)]))


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

using namespace std;

typedef long long/*--------------------*/ll;
typedef long double/*------------------*/ld;
typedef unsigned long long/*-----------*/ull;
typedef pair<ll, ll >/*----------------*/pll;
typedef std::vector<pll >/*------------*/vpll;

#define rep(i,a)/*---------------------*/for(i = 0 ; i < a ; i++)
#define repr(i,a)/*--------------------*/for(i = a ; i >= 0 ; i--)
#define REP(i,a,b)/*-------------------*/for(i = a ; i <= b ; i++)
#define REPR(i,a,b)/*------------------*/for(i = a ; i >= b ; i--)

#define YES/*--------------------------*/cout << "YES" << endl
#define NO/*---------------------------*/cout << "NO" << endl

#define lb/*---------------------------*/lower_bound
#define ub/*---------------------------*/upper_bound
#define pb/*---------------------------*/push_back
#define popb/*-------------------------*/pop_back
#define mem(a,b)/*---------------------*/memset(a,b,sizeof(a))
#define sz/*---------------------------*/size()
#define mpp/*--------------------------*/make_pair
#define bs/*---------------------------*/binary_search
#define gcd(a, b)/*--------------------*/__gcd(a, b)
#define lcm(a, b)/*--------------------*/((a)*((b)/gcd(a,b)))
#define sqr(x)/*-----------------------*/(x)*(x)
#define all(a)/*-----------------------*/a.begin(),a.end()

#define ff/*---------------------------*/first
#define ss/*---------------------------*/second

#define endl/*-------------------------*/'\n'
#define inf/*--------------------------*/(ll)2e15
#define MOD/*--------------------------*/(ll)1000000007

void solve();
void boost()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
}
int main()
{
	boost();
	ll t,i;
	t = 1;
    //cin >> t;
	REP(i,1,t)
	{
       //cout << "Case "<< i << ": ";
       solve();
	}
	return 0;
}

void solve()
{
    ld r,g;
    cin >> r >> g;
    cout << 2*g - r << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define pi 3.1415926
#define MOD 998244353
#define sec setprecision
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n,ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return pow(x * x % m, n / 2, m);
	else
		return x * pow(x, n - 1, m) % m;
}
ll pow(ll x, ll n) {
	if (n == 0)
		return 1;
	else if (x == 1)return(1);
	else if (n % 2 == 0)
		return pow(x * x , (n / 2));
	else
		return x * pow(x, n - 1);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long com(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	int a, b;
	cin >> a >> b;
	int n;
	cin >> n;
	vector<int>c(n);
	rip(i, n)cin >> c[i];
	vector<int> d(a*b);
	int k = 0;
	rip(i, n) {
		for(int j=0;j<c[i];j++) {
			d[k] = i+1, k++;
		}
	}
	int l;
	rip(i, a) {
		rip(j, b) {
			if (i % 2 == 1)l = b * i + (b - 1 - j);
			else l = b* i + (j);
			cout << d[l] << " ";
		}
		cout << endl;
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int c,a,cnt=0,ans, N;cin>>N;
    set<int> s;
    for(int i=0; i<N;i++){
       cin>>a;
       for(int j=0;j<8;j++){
         if(j*400 <= a && a<= (j+1)*400-1){
           c = j;
         }
       }
       if(a>=3200){
         c=8; cnt++;
       }
       s.insert(c);
    }

    int k = s.size();
    if(cnt>=1) k--;

    ans = max(k+cnt, 1);
    cout<<max(k,1)<<" "<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
    
  string ans = "No";
  if(N[0]=='7') ans = "Yes";
  if(N[1]=='7') ans = "Yes";
  if(N[2]=='7') ans = "Yes";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
n = int(input())
h_arr = list(map(int, input().split()))
dp = [100000 for _ in range(n)]
dp[0] = 0
dp[1] = abs(h_arr[1] - h_arr[0])
for i in range(2,n):
  dp[i] = min(dp[i-1] + abs(h_arr[i-1] - h_arr[i]), dp[i-2] + abs(h_arr[i-2] - h_arr[i]))
print(dp[n-1])

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

using namespace std;

int main() {
  
  int Tc; cin >> Tc;
  
  while(Tc--) {
    int a, b; cin >> a >> b;
    int const S = a;
    int const T = b;
    
    if(S < T && S < 5) {
      for(int i=S; i<=T; i++) {
	if(i>S) cout << " ";
	cout << i;
      }
      cout << endl;
    }
    else if(S > T && S < 5) {
      for(int i=S; i>=T; i--) {
	if(i<S) cout << " ";
	cout << i;
      }
      cout << endl;
    }
    else if(S == 5) {
      if(0<=T && T<5) {
	for(int i=S; i>=T; i--) {
	  if(i<S) cout << " ";
	  cout << i;
	}
	cout << endl;
      }
      else {
	for(int i=S; i<=T; i++) {
	  if(i>S) cout << " ";
	  cout << i;
	}
	cout << endl; goto EXIT;
      }
    }
    else {
      assert(S > 5);
      if(5 < T && T < S) {
	for(int i=S; i<10; i++) {
	  if(i>S) cout << " ";
	  cout << i;
	}
	for(int i=5; i>=0; i--) {
	  cout << " "; cout << i;
	}
	for(int i=1; i<=T; i++) {
	  cout << " "; cout << i;
	}
	cout << endl;
	
      }
      else if(S < T) {
	for(int i=S; i<=T; i++) {
	  if(i>S) cout << " ";
	  cout << i;
	}
	cout << endl;
      }
      else {
	for(int i=S; i<10; i++) {
	  if(i>S) cout << " ";
	  cout << i;
	}
	for(int i=5; i>=T; i--) {
	  cout << " " << i;
	}
	cout << endl;
      }
    }
    
  EXIT:;
  }
  
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    int o = 0;
    int e = 0;
    for (int i = 1; i <= n; ++i) {
        if (i % 2) o++;
        else e++;
    }
    cout << fixed << setprecision(10) << (double)o / (double)(o+e) << endl;
}

Measured memory_bytes: 3756
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    string s[3];
    REP(i, 3){
        cin >> s[i];
    }

    cout << s[0][0] << s[1][0] << s[2][0] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll ans = 0;
int first_len;
vector<string>v;
void sum(string S){
	ll pro = 0;
	
	for(int i = 0; i < S.length(); i++){
		
		if(S[i] != '+'){
			pro *= 10;
			pro+=S[i] - '0';
		//	cout<<pro<<endl;
		//	cout<<S.length()<<S<<endl;
		}
		if(S[i] == '+' || i == S.length() - 1){
			ans += pro;
			//cout<<"a"<<endl;
			//cout<<pro<<endl;
			pro = 0;
		}
	}
	
	
}

void add_plus(string S){
	if(S.length() == first_len * 2 - 1)return;
	for(int i = 0; i < S.length(); i++){
		if(S[i] != '+' && S[i + 1] != '+'){
			if(i != S.length() - 1){
			S.insert(S.begin() + i + 1, '+');
			//cout<<i<<","<<S[i]<<","<<S<<endl;
			//cout<<S<<endl;
		
			if(find(v.begin(), v.end(), S) == v.end()){
				add_plus(S);
				//cout<<S<<endl;
				sum(S);
			//	cout<<S<<endl;
				v.push_back(S);
			}
			S.erase(S.begin() + i + 1);
		}
		}	
	}
}
int main(){
	string S;
	cin>>S;
	first_len = S.length();
	sum(S);
	add_plus(S);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * http://abc068.contest.atcoder.jp/tasks/arc079_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		final long K = sc.nextLong();
		sc.close();
		
		final int N = 50;
		long[] ans = new long[N];
		for(int i=0; i<N; i++) ans[i] = K/N+i;


		for(int i=0; i<K%N; i++){
			for(int j=0; j<N; j++){
				if(i==j){
					ans[j] = ans[j] + N;
				}else{
					ans[j] --;
				}
			}
		}
		
		System.out.println(N);
		for(int i=0; i<N; i++){
			if(i==N-1){
				System.out.println(ans[i]);
			}else{
				System.out.print(ans[i]+" ");
			}
		}
		
	}

}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n;i++)
        cin >> a[i];
    for (int i = 1; i < n;i++)
        a[i] += a[i - 1];
    int res = inf;
    for (int i = 0; i < n-1;i++){
        res = min(res, abs(a[n - 1] - 2 * a[i]));
    }
    cout << res << endl;
}

Measured memory_bytes: 1792
N, M = map(int, input().split())
G = [[] for _ in range(N)]

for i in range(M):
    x, y, z = map(int, input().split())
    G[x-1].append(y-1)
    G[y-1].append(x-1)

lst = []
visited = [0]*N
for i in range(N):
    if visited[i] == 1:continue
    temp = [i]
    lst1 = [i]
    visited[i] = 1
    while temp:
        p = temp.pop()
        for q in G[p]:
            if visited[q] == 0:
                visited[q] = 1
                lst1.append(q)
                temp.append(q)
    if lst1 != []:lst.append(lst1)
    
print(len(lst))

Measured memory_bytes: 37736
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int sum = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] < d) {
				for (int j = 0; j * a[i] + 1 <= d; j++) {
					sum++;
				}
			} else {
				sum++;
			}
		}
		sum += x;
		System.out.println(sum);
		sc.close();
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <map>
#include <queue>
#include <climits>

using namespace std;

const int e_dx[] = {0, 1, 1, 1, 0, -1};
const int e_dy[] = {-1, -1, 0, 1, 1, 0};
const int o_dx[] = {-1, 0, 1, 0, -1, -1};
const int o_dy[] = {-1, -1, 0, 1, 1, 0};;

int m, n;
int place[102][102];

class state {
public:
    int x, y;
    int cnt;
    state(int a, int b, int c) { x = a; y = b; cnt = c; }
};

void init()
{
    for (int y = 1; y <= n; y++)
        for (int x = 1; x <= m; x++)
            place[y][x] = INT_MAX;

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

        cin >> x >> y;
        place[y][x] = 0;
        state s(x, y, 0);
        queue<state> q;
        q.push(s);

        while (!q.empty()) {
            state now = q.front();
            q.pop();

            for (int i = 0; i < 6; i++) {
                int nx, ny;
                if (now.y % 2) {
                    nx = now.x + o_dx[i];
                    ny = now.y + o_dy[i];
                }
                else {
                    nx = now.x + e_dx[i];
                    ny = now.y + e_dy[i];
                }

                if (nx < 1 || nx > m || ny < 1 || ny > n)
                    continue;
                if (now.cnt + 1 < place[ny][nx]) {
                    place[ny][nx] = now.cnt + 1;
                    state tmp(nx, ny, now.cnt + 1);
                    q.push(tmp);
                }
            }
        }
    }
}


void bfs()
{
    int t;
    int ans = 0;

    cin >> t;
    while (t--) {
        int p, q;
        map<pair<int, int>, bool > ma;
        int num = 0;

        cin >> p >> q;
        state s(p, q, 0);
        queue<state> qu;
        ma[pair<int, int>(p, q)] = true;
        qu.push(s);

        while (!qu.empty()) {
            state now = qu.front();
            qu.pop();

            for (int i = 0; i < 6; i++) {
                int nx, ny;
                if (now.y % 2) {
                    nx = now.x + o_dx[i];
                    ny = now.y + o_dy[i];
                }
                else {
                    nx = now.x + e_dx[i];
                    ny = now.y + e_dy[i];
                }

                if (nx < 1 || nx > m || ny < 1 || ny > n)
                    continue;
                if (ma.count(pair<int, int>(nx, ny)) != 0)
                    continue;
                if (now.cnt + 1 < place[ny][nx]) {
                    num++;
                    state tmp(nx, ny, now.cnt + 1);
                    qu.push(tmp);
                    ma[pair<int, int>(nx, ny)] = true;
                }
            }
        }
        ans = max(ans, num + 1);
    }
    cout << ans << endl;
}

int main()
{
    while (cin >> m >> n, m) {
        init();        
        bfs();
    }

    return 0;
}

Measured memory_bytes: 1320
#include<bits/stdc++.h>
#define ll long long

int take()
{
    int n;
    scanf("%d",&n);
    return n;

}

ll takes()
{
    ll n;
    scanf("%lld",&n);
    return n;

}
#define M 200005
#define Int take()
#define LL takes()

#define fr(n) for(int i=1;i<=n;i++)
#define rfr(n) for(int i=n;i>=1;i--)
int cas;
#define print printf("Case %d:",++cas)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mk  make_pair
#define fill(x,v) memset(x,v,sizeof x)
using namespace std;


int main(){
        int r=Int,g=Int;
        cout<<2*g-r<<"\n";
 return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int w = sc.nextInt();
		String ans = "";
		
		for(int i = 0; i < s.length; i++){
			if(i%w==0) ans += String.valueOf(s[i]);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 39500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

struct wall{
  ll x,y;
};

bool o(wall w1,wall w2){
  return w1.x==w2.x?w1.y<w2.y:w1.x<w2.x;
}

const ll MOD=1e9+7;

ll ad(ll x,ll y=0){
  return (x+y)%MOD;
}

ll mlt(ll x,ll y=1){
  return (x*y)%MOD;
}

ll pwr(ll x,ll y){
  ll pw[32]={},w=1;
  pw[0]=x;
  fr(i,31) pw[i+1]=mlt(pw[i],pw[i]);
  fr(i,32){
    w=mlt(w,1+(y%2)*(pw[i]-1));
    y/=2;
  }
  return w;
}

ll inv(ll x){
  return pwr(x,MOD-2);
}

ll fc[200010]={1};
ll fct(ll x){
  if(fc[x]==0) fc[x]=mlt(x,fct(x-1));
  return fc[x];
}

ll ifc[200010]={1};
ll ifct(ll x){
  if(ifc[x]==0) ifc[x]=inv(fct(x));
  return ifc[x];
}

ll comb(ll n,ll r){
  if(n<0 || r<0 || n<r) return 0;
  return mlt(fct(n),mlt(ifct(r),ifct(n-r)));
}

ll rt(ll x,ll y){
  return comb(x+y,y);
}

int main(){
  ll h,w,n,x,y,dp[3010];
  wall k[3010];
  cin>>h>>w>>n;
  fr(i,n){cin>>x>>y;k[i]=(wall){--x,--y};}
  sort(k,k+n,o);
  fr(i,n){
    dp[i]=rt(k[i].x,k[i].y);
    fr(j,i) dp[i]=ad(dp[i],MOD-mlt(dp[j],rt(k[i].x-k[j].x,k[i].y-k[j].y)));
  }
  ll ans=comb(h+w-2,h-1);
  fr(i,n) ans=ad(ans,MOD-mlt(dp[i],rt(h-1-k[i].x,w-1-k[i].y)));
  cout<<ans<<endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define maxn 105
#define ll long long
using namespace std;
int n, d;
int pre[maxn][maxn];

int main()
{
    scanf("%d%d",&n,&d);
    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            scanf("%d",&pre[i][j]);
        }
    }
    for(int i=1;i<n;i++){
        for(int j=0;j<i;j++){
            int xx = 0;
            for(int k=0;k<d;k++){
                xx += (pre[i][k] - pre[j][k]) * (pre[i][k] - pre[j][k]);
            }
            double yy = sqrt(xx * 1.0);
            int x = yy;
            if(x == yy) ans ++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
    int a;
    string S;
    cin >> a >> S;
    if (a >= 3200)
    {
        cout << S << endl;
    } else
    {
        cout << "red" << endl;
    }
    
    

  return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 
#include <numeric>
#include <cctype>

using namespace std; 

const long long mod=1e9+7;


int main(){

    for(int i=0;i<5;i++){
        int x;
        cin>>x;

        if(x==0){
            cout<<i+1<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3584