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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long mod = 1000000007;

// auto mod int
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    combination cb(n);
    vector<mint> mxsub(n-k+2, 0);
    for (int i=k; i<=n; ++i) {
        if (i==k) mxsub[i-k+1] = cb(i, k);
        else mxsub[i-k+1] = cb(i, k) - cb(i-1, k);
    }
    VSORT(a);
    mint ans = 0;
    for (int i=1; i<=n-k+1; ++i) {
        ans += mxsub[i] * a[i+k-2];
        ans -= mxsub[i] * a[n-k+1-i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5608
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
using namespace std;
int main (){
    int a,p;
    cin >> a >> p;

    p = p + a*3;
    cout << p /2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007;
#define pi 3.14159265358979323846264
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vl vector <long long>
#define vpii vector <pair <int, int> >
#define ll long long
#define fi first
#define se second
int n, x, ans;
char s[105];
int main() {
    scanf("%d %s", &n, s);
    for (int i=0;i<n;i++) {
        if (s[i]=='I') x++;
        else x--;
        ans=max(ans,x);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 764
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var t = 1;
        for (int i = 0; i < 5; i++)
        {
            t *= 10;
            if (n == t) { Console.WriteLine(10); goto end; }
        }
        Console.WriteLine(getAns(n));
        end:;
    }
    public static int getAns(int aa)
    {
        var a = aa.ToString();
        var ret = 0;
        for (int i = 0; i < a.Length; i++)
            ret += int.Parse(a[i].ToString());
        return ret;
    }
}

Measured memory_bytes: 13140
r, c = map(int, raw_input().split())
sum_c = [0 for x in range(r)]
sum_r = [0 for x in range(c)]
sum = 0

for i in range(r):
    column = map(int, raw_input().split())
    for j in range(c):
        sum_c[i] += column[j]
        sum_r[j] += column[j]
        sum += column[j]
    print(" ".join(map(str, column)) + " " + str(sum_c[i]))

print (" ".join(map(str, sum_r)) + " " + str(sum))

Measured memory_bytes: 4232
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int q = 0;

    int prime[100001] = {};
    int primenum[100001] = {};
    for(int i = 2; i <= 100000; i++)
        prime[i] = true;

    for(int i = 2; i * i <= 100000; i++){
        if( prime[i] ) {
            for(int j = i*2; j <= 100000; j+= i){
                prime[j] =false;
            }
        }
    }

    for(int i = 3; i <= 100000; i+= 2){
        primenum[i] = primenum[i-2];
        if( prime[i] && prime[(i+1)/2] ) primenum[i]++;
    }

    Scd(q);
    int l,r;
    Rep(i,q){
        Scd2(l,r);
        printf ("%d\n", primenum[r] - primenum[l-2]);
    }

    return 0;
}



Measured memory_bytes: 1408
N, T = map(int, input().split())
a_list = []
for _ in range(N):
    a, b = map(int, input().split())
    a_list.append((a, b))
a_list.sort(key=lambda x: x[0])

dp = [[0 for _ in range(T + 3001)] for _ in range(N + 1)]
for i in range(1, N + 1):
    a, b = a_list[i - 1]
    for j in range(T + 3001):
        dp[i][j] = dp[i - 1][j]
    for j in range(T):
        dp[i][j + a] = max(dp[i - 1][j + a], dp[i - 1][j] + b)
print(max(dp[-1]))

Measured memory_bytes: 218308
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

template <typename T>
vector<T> dijkstra(int s,vector<vector<pair<T,int>>> & G){
    const T inf=numeric_limits<T>::max();
    using edge=pair<T,int>;
    priority_queue<edge, vector<edge>, greater<edge> > que;
    int n=G.size();
    vector<T> d(n,inf);
    vector<int> b(n,-1);
    d[s]=0;
    que.emplace(d[s],s);
    while (!que.empty()){
        edge p = que.top(); que.pop();
        int v = p.second;
        if (d[v]<p.first) continue;
        for(auto& e:G[v]){
            int u=e.second;
            T c=e.first;
            if (d[u]>d[v]+c){
                d[u]=d[v]+c;
                b[u]=v;
                que.emplace(d[u],u);
            }
        }
    }
    return d;
}

int n,m,S,max_c=0;
int u[155],v[155],a[155],b[155],c[55],d[55];
vector<vector<pair<ll,int>>> G;

void solve(){
    cin >> n >> m >> S;
    rep(i,m){
        cin >> u[i] >> v[i] >> a[i] >> b[i];
        u[i]--;v[i]--;
        max_c+=a[i];
    }
    rep(i,n){
        cin >> c[i] >> d[i];
    }
    max_c+=1;
    G.resize(n*max_c);
    rep(i,m){
        rep(t,max_c){
            if(t>=a[i]){
                G[u[i]*max_c+t].emplace_back(b[i],v[i]*max_c+t-a[i]);
                G[v[i]*max_c+t].emplace_back(b[i],u[i]*max_c+t-a[i]);
            }
        }
    }
    //cout << G.size() << endl;
    rep(i,n){
        rep(t,max_c){
            G[i*max_c+t].emplace_back(d[i],i*max_c+min(max_c-1,t+c[i]));
        }
    }
    vector<ll> D=dijkstra(0+min(max_c-1,S),G);
    //cout << D.size() << endl;
    Rep(t,1,n){
        ll ans=INF;
        rep(j,max_c){
            ans=min(ans,D[t*max_c+j]);
        }
        cout << ans << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 25488
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int[] s = { sc.nextInt(), sc.nextInt(), sc.nextInt() };
            if(s[0]+s[1]+s[2]==0) {
                break;
            }
            for (int i = 0; i < s.length - 1; i++) {
                for (int j = i + 1; j < s.length; j++) {
                    if (s[i] > s[j]) {
                        int temp = s[i];
                        s[i] = s[j];
                        s[j] = temp;
                    }
                }
            }

            int n = sc.nextInt();
            for (int i = 0; i < n; i++) {
                System.out.println(isEntry(s[0], s[1], sc.nextInt() * 2));
            }
        }
    }

    static String isEntry(int a, int b, int n) {
        return a * a + b * b < n * n ? "OK" : "NA";
    }
}


Measured memory_bytes: 26188
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  const int64 inf = 1e9;
  int64 N, K;
  cin >> N >> K;
  vector<int64> h(N);
  cin >> h;
  debug(h);
  vector<int64> dp(N + 1, inf);
  dp[0] = 0;
  for (int64 i = 1; i <= N; i++) {
    int64 start = max(i - K, 0LL);
    debug(start);
    for (int64 j = start; j <= i - 1; j++) {
      dp[i] = min(dp[i], abs(h[i] - h[j]) + dp[j]);
    }
  }
  debug(dp);
  cout << dp[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 1792
# 2019/04/01
# AtCoder Beginner Contest 106 - C

s = input()
k = int(input())

onecnt = 0

for i in range(len(s)):
    if s[i] == "1":
        onecnt += 1
    else:
        second_str = s[i]
        break

if k > onecnt:
    print(second_str)
else:
    print("1")


Measured memory_bytes: 2940
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int a[55][55]={0},h,w;
vector<string> sb;
int main()
{
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;i++)
	{
		string s;
		cin>>s;
		sb.push_back(s);
		for(int j=0;j<w;j++)
		{
			if(s[j]=='#')
				for(int p=-1;p<2;p++)
					for(int q=-1;q<2;q++)
						a[i+p+1][j+q+1]++;
		}
	}
	for(int i=0;i<h;puts(""),i++)
		for(int j=0;j<w;j++)
		{
			if(sb[i][j]=='.')printf("%d",a[i+1][j+1]);
			else putchar('#');
		}
}


Measured memory_bytes: 256
import { readFileSync } from 'fs'

function main(input: string) {
  const [N, K] = input.split(' ').map(Number)

  if (K === 1) {
    console.log(0)
    return
  }

  console.log(N - K)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 11468
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;


Node root;

Node treeMim(Node x){

  while(x->left!=NULL){
    x=x->left;
  }
  return x;
}


Node treeSearch(Node u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<(u->key)){
      u=u->left;
    }else{
      u=u->right;
    }
  }
  return u;
}


Node TreeSuccessor(Node x){
  Node y,p;
  if(x->right!=NULL){
    return treeMim(x->right);
  }
  y=x->parent;
  while(y!=NULL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void TreeDelete(Node z){

  Node x,y;

  if(z->left==NULL||z->right==NULL){
    y=z;
  }else{
    y=TreeSuccessor(z);
  }
  if(y->left!=NULL){
    x=y->left;
  }else{
    x=y->right;
  }
  if(x!=NULL){
    x->parent=y->parent;
  }
  if(y->parent==NULL){
    root=x;
  }else if(y==y->parent->left){
    y->parent->left=x;
  }else{
    y->parent->right=x;
  }

  if(y!=z){
    z->key=y->key;
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;

  if(y==NULL){
    root=z;
  }else if(z->key < y->key){
    y->left=z;
  }else{
    y->right=z;
  }

}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" ");
    printf("%d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  printf(" ");
  printf("%d",u->key);
  if(u->left!=NIL){ 
    preorder(u->left);
  }
  if(u->right!=NIL){
    preorder(u->right);
  }
}


int main(){
  int n=0, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", &com[0]);
    x=0;
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(com[0]=='d'){
      scanf("%d",&x);
      TreeDelete(treeSearch(root,x));  
      
    }
  }
  return 0;
}

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/


  int P,Q,R;

  cin>>P>>Q>>R;

  cout<<P+Q+R-(max(max(P,Q),R))<<endl;
  
  return 0;

}


Measured memory_bytes: 256
package main

import "fmt"

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

	ps := primeFactorization(n)
	ans := 0
	for _, c := range ps {
		for i := 1; i <= c; i++ {
			ans++
			c -= i
		}
	}

	fmt.Println(ans)
}

func primeFactorization(n int) map[int]int {
	ps := make(map[int]int)
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			ps[i]++
			n /= i
		}
	}
	if n != 1 {
		ps[n]++
	}

	return ps
}


Measured memory_bytes: 1856
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int n; in(n);
  vl a(n); ina(a,n);
  double ans = 1;
  double alpr = 1, alsm = 0;
  rep(i,n) alpr *= a[i];
  rep(i,n) alsm += alpr / a[i];
  ans = alpr / alsm;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int x; cin >>x;
  int cnt=1,a=x;
  while(1){
    a+=x;
    cnt++;
    if(a%360==0)break;
  }
  print(cnt);
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
		return n;
}

ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

vector<vector<int>> g;
vector<int> d;

int dfs(int v){
  int res = 0;
  vector<int> s;
  for (auto x : g[v])
  {
    s.pb(dfs(x));
  }
  if(!s.empty()){
    sort(rall(s));
    rep(i, s.size()) s[i] += i + 1;
    res = *max_element(all(s));
  }
  return d[v] = res;
}

void solve()
{
	int n;
	cin >> n;
  vector<int> a(n-1);
  rep(i, n-1) cin >> a[i];
  g.resize(n);
  rep(i,n-1){
    a[i]--;
    g[a[i]].eb(i+1);
  }
  d.resize(n);
  dfs(0);
  cout << d[0]<< endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n;
  cin >> n;
  auto v=divisor(n);
  ll ans=LLONG_MAX;
  rep(i,v.size()){
    ll op=n/v[i];
    ans=min(ans, op+v[i]-2LL);
  }
  cout << ans << endl;

  
  return 0;
    

}


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

int main(void){
    string str;
    cin >> str;
    int x;
    int l=str.length();
    int min=abs(753-((str[0]-'0')*100+(str[1]-'0')*10+(str[2]-'0')));
    int n=((str[0]-'0')*100+(str[1]-'0')*10+(str[2]-'0'));
    for(int i=1;i<l-2;i++){
        x=((str[i]-'0')*100+(str[i+1]-'0')*10+(str[i+2]-'0'));
        if(min>abs(753-x)){
            min=abs(753-x);
            n=x;
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {

  public static void main(String[] args){

    try{
      String str;
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in, "UTF-8"));
      str = br.readLine();
String[] ss = str.split(" ");
      //int sample = Integer.parseInt(str);
      func(Integer.parseInt(ss[0]),Integer.parseInt(ss[1]));
    } catch(IOException e){
      e.printStackTrace();
    }
  }

  public static void func(int a, int b){
    if((a+b)%2 == 0){
System.out.println(Math.abs((a+b)/2));
} else System.out.println("IMPOSSIBLE");
  }
}


Measured memory_bytes: 21460
s=input()
r=0
i=0
if s[i]=='R':
  r=r+1

i=i+1
if s[i]=='R':
  r=r+1
  i=i+1
  if s[i]=='R':
    r=r+1
elif s[i+1]=='R' and r==0:
  r=1
  
print(r)

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

long long h;
vector<long long> v;

void makeh(int id);

string s;

int main() {
  v.push_back(-1);
  while(1) {
    cin >> s;
    if(s == "end") break;
    if(s == "insert") {
      int x, id = v.size();
      cin >> x;
      ++h;
      v.push_back(x);
      while(id > 1 && v[id >> 1] < v[id]) {
        swap(v[id >> 1], v[id]);
        id >>= 1;
      }
    }
    else {
      cout << v[1] << endl;
      swap(v[1], v[h--]);
      v.pop_back();
      makeh(1);
    }
  }
  return 0;
}

void makeh(int id) {
  long long l = id * 2, r = id * 2 + 1, lar = id;
  if(l <= h && v[l] > v[lar]) lar = l;
  if(r <= h && v[r] > v[lar]) lar = r;
  if(lar != id) {
    swap(v[id], v[lar]);
    makeh(lar);
  }
}



Measured memory_bytes: 11244
#include <bits/stdc++.h>
using namespace std ;
using ll = long long ;
int main ()
{
   int a,b,k;
    cin >> a >> b >> k;
    int sum = 0;
    for(int i = min(a,b); i > 0; i--) {
        if(a%i == 0 && b%i == 0) {
            sum++;
            if(sum== k) {
                cout << i << endl;
                break;
            }
        }
    }




    return 0 ;
}



Measured memory_bytes: 256
//https://atcoder.jp/contests/abc153/tasks/abc153_c
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long n , specialpower, sum = 0 ;
    cin >> n >> specialpower ;
    long long health[n];
    for(auto &x :health) cin >> x ;
    sort(health, health+n);
    if(specialpower != 0)
    {
        for(int i = 0 , j = 0; i < specialpower , j <= specialpower; i++, j++)
        {
            health[n - j] = 0 ;
        }
    }
    //for(auto x : health) cout << x << endl ;
    for(auto x : health) sum += x ;
    cout << sum << endl ;
}

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

using ll = unsigned long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	ll n, k;
	cin >> n >> k;
	ll ans = min(n % k, k - (n % k));
	cout << ans << endl;
}


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

int main() {
	int n;
	cin >> n;
	map<int,int> a,b;
	for(int i=0; i<n; i++){
		int c;
		cin >> c;
		(i%2?a:b)[c]++;
	}
	int a1{},a2{},b1{},b2{},c,d;
	for(int i=0; i<=1e5; i++){
		if(a1<=a[i]){
			a2 = a1;
			a1 = a[i];
			c = i;
		}
		else if(a2<=a[i]) a2 = a[i];
		if(b1<=b[i]){
			b2 = b1;
			b1 = b[i];
			d = i;
		}
		else if(b2<=b[i]) b2 = b[i];
	}
	if(c!=d) cout << n-(a1+b1) << endl;
	else cout << min(n-(a1+b2), n-(a2+b1)) << endl;
	
}

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



int main(){
  int x,n; cin>>x>>n;
  if(n==0) {cout<<x<<endl; return 0;}
  vector<int> p(n+1,-100);
  for(int i=0;i<n;i++){
      int AA; cin>>AA;
      p[i]=AA;
  }
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());

  int j=0,memo=1000,ans=0;
  for(int i=300;i>=0;i--){
      if(i==p[j]){ j++; continue;}
      if(memo>=abs(x-i)){ ans=i; memo=abs(x-i);}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(void){
    int n, money=100000; 
    cin >> n;
    for(int i=1; i<=n; i++){
        money *= 1.05;
        if(money%1000 != 0){
            money = money/1000*1000 +1000;
        }
    }
    cout << money << endl;
    return 0;
}



Measured memory_bytes: 3072
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, q;
    cin >> n >> q;
    vector<list<int>> l(n);
    while (q--) {
        int com;
        cin >> com;
        if (com == 0) {
            int t, x;
            cin >> t >> x;
            l[t].insert(l[t].end(), x);
        } else if (com == 1) {
            int t;
            cin >> t;
            auto itr = l[t].begin();
            if (itr != l[t].end()) {
                cout << *itr;
            }
            while (++itr != l[t].end()) {
                cout << " " << *itr;
            }
            cout << endl;
        } else {
            int s, t;
            cin >> s >> t;
            l[t].splice(l[t].end(), move(l[s]));
        }
    }
}



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


int p[20], n;

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    int ans = 0;
    for(int i = 1; i < n - 1; i++){
        if(p[i - 1] < p[i] && p[i] < p[i + 1]){
            ans++;
        }
        if(p[i + 1] < p[i] && p[i] < p[i - 1]){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[51],t=0,k;
void kp(int l,int r){
	int i=l,j=r,mid=a[(l+r)/2];
	while(i<=j){
		while(a[i]<mid)i++;
		while(a[j]>mid)j--;
		if(i<=j){
			swap(a[i],a[j]);
			i++;j--;
		}
	}if(i<r) kp(i,r);
	 if(j>l) kp(l,j);
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i]; 
	kp(1,n);
	for(int i=n;i>n-k;i--)t+=a[i];
	cout<<t;
	return 0;
}

Measured memory_bytes: 256
package main

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

var (
	S, T, U string
	A, B    int
)

func readVariables() {
	S, T = nextStr(), nextStr()
	A, B = nextInt(), nextInt()
	U = nextStr()
}

func main() {
	readVariables()
	if U == S {
		A--
	} else {
		B--
	}
	fmt.Println(A, B)
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}


Measured memory_bytes: 640
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };

int t[100001] = {};
int x[100001] = {};
int y[100001] = {};

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

	for (int i = 1; i <= n; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}

	for (int i = 0; i < n; i++) {

		int time = t[i + 1] - t[i];

		int dis = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);

		if (time >= dis && (time - dis) % 2 == 0) {

		}
		else {
			cout << "No" << endl;
			return 0;
		}

	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1408
#2_A
def bubble_sort(a,n):
    flag = 1
    count = 0
    while flag:
        flag = 0
        for i in range(n-1):
            j = n - 1 - i
            if a[j] < a[j-1]:
                v = a[j]
                a[j] = a[j-1]
                a[j-1] = v
                flag = 1
                count += 1
    return a, count

n = int(input())
a = list( map(int, input().split()) )

arr, count = bubble_sort(a, n)
res = str(arr[0])
for i in range(n-1):
    res += " " + str(arr[i+1])

print(res)
print(count)


Measured memory_bytes: 5600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 6005
#define F first
#define S second
using namespace std;

int n, t, mx, d[N];
pair<int,int> a[N];

int main() {
	int i, j;
	cin >> n >> t;
	for(i=0; i<n; i++) cin >> a[i].F >> a[i].S;
	sort(a, a+n);
	memset(d, -1, sizeof(d));
	d[0] = 0;
	for(j=0; j<n; j++) {
		for(i=t-1; i>=0; i--) {
			if(d[i] != -1) {
				d[i+a[j].F] = max(d[i+a[j].F], d[i] + a[j].S);
			}
		}
	}
	for(i=0; i<N; i++) mx = max(mx, d[i]);
	cout << mx;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, k; cin >> n >> k;
  int cnt = (n - 1) * (n - 2) / 2;
  if (k > cnt) {
    cout << -1 << '\n';
    return 0;
  }
  vector<int> u, v;
  FOR(i, 2, n + 1) {
    u.emplace_back(1);
    v.emplace_back(i);
  }
  FOR(i, 2, n + 1) FOR(j, i + 1, n + 1) {
    if (cnt > k) {
      u.emplace_back(i);
      v.emplace_back(j);
      --cnt;
    }
  }
  cout << u.size() << '\n';
  REP(i, u.size()) cout << u[i] << ' ' << v[i] << '\n';
  return 0;
}


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

int main()
{
  int p,q,r;
  cin>>p>>q>>r;
  int ans;
  ans=p+q;
  if(ans>q+r){
    ans=q+r;
  }
  if(ans>r+p){
    ans=r+p;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
	long long n;
	cin >> n;
	long long answer = 1e18;
	for(long long i = 1; i * i <= n; ++i) {
		if(n % i == 0)
			answer = min(answer, n / i + i);
	}
	cout << answer - 2;
}


Measured memory_bytes: 3476
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N ;
    cin >> N;
    
    ll ans =0 ;
    rep(i,N){
        ll inp; cin >> inp;
        ans += (inp-1);
    }
    
    cout << ans << endl;
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math

n = int(input())
max = int(math.sqrt(n) + 1)
L = [0] * (n + 1)
for x in range(1, max):
    for y in range(1, max):
        for z in range(1, max):
            tmp = x * x + y * y + z * z + x * y + y * z + z * x
            if tmp > n:
                continue
            L[tmp] += 1

for i in range(1, n + 1):
    print(L[i])


Measured memory_bytes: 9304
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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;
}

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}


void solve() {
    ll n;
    cin >> n;
    ll a[n+1],b[n+1],ans[n+1];
    for(int i = 1;i < n+1;i++){
        cin >> a[i];
        b[i] = 0;
        ans[i] = 0;
    }

    ll sum = 0;
    for(int i = n;i >= 1;i--){

        if(i*2 > n){
            if(a[i] == 1){
                ans[i] = 1;
                sum++;
            }
        }else{
            ll tmp = 0;
            for(ll j = 2*i;j <= n;j+=i){
                if(ans[j] == 1) tmp++;
            }
            if(a[i] != tmp%2){
                ans[i] = 1;
                sum++;
            }
        }

    }
    cout << sum << endl;

    if(sum != 0){
        for(int i = 1;i < n+1;i++){
            if(ans[i] == 1) cout << i << endl;
        }
    }
    
}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


Measured memory_bytes: 5632
import java.util.Scanner;

/*
 * @author Tanzim Ibn Patowary
 * Created  Apr 25, 2020 3:55:23 AM
 */
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner mScanner = new Scanner(System.in);
		int N = mScanner.nextInt();
		int M= mScanner.nextInt();
		int sum = 0;
		for (int i = 0; i < M; i++) {
			int a = mScanner.nextInt();
			sum+=a;
			
		}
		if (sum>N) {
			System.out.println(-1);
		}else {
			System.out.println(N-sum);
		}
	}

}


Measured memory_bytes: 39580
N, D = map(int, input().split())

X = [list(map(int, input().split())) for _ in range(N)]
S = {i**2 for i in range(1000)}
ans = sum(
    a != b and sum((x - y)**2 for x, y in zip(a, b)) in S
    for a in X
    for b in X
) // 2

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#define M 1046257
#define NIL (-1)
#define L 14
char H[M][L];
int getChar(char ch) {
  if ( ch == 'A' ) return 1;
  else if ( ch == 'C' ) return 2;
  else if ( ch == 'G' ) return 3;
  else if ( ch == 'T' ) return 4;
  return 0;
}
long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for(i=0;i<strlen(str);i++) {
    sum += p*(getChar(str[i]));
    p*= 5;
  }
  return sum;
}
int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }
int find(char str[]) {
  long long key, i, h;
  key = getKey(str); /* 文字列を数値に変換 */
  for(i=0; ;i++) {
    h = (h1(key) + i*h2(key)) % M;
    if( strcmp(H[h],str) == 0) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}
int insert(char str[]) {
  long long key, i, h;
  key = getKey(str); /* 文字列を数値に変換 */
  for(i=0; ; i++) {
    h = (h1(key) + i * h2(key)) %M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) {
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}
int main(void) {
  int i, n;
  char str[L], com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s %s",com,str);
    if(com[0] == 'i') {
      insert(str);
    } else {
      if(find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 16080
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

fn main() {
    input! {
        d: u32,
        n: u64,
    }

    if n == 100 {
        println!("{}", 100u64.pow(d) * 101);
    } else {
        println!("{}", 100u64.pow(d) * n);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

 int gcd(int a,int b){

   if(a%b == 0)
    return b;
   else
    return gcd(b,a%b);
 }

 long long numbers[500005];

 /*

 int main(){

   long long n;   cin>>n;
vector<int>v(n);

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

 int ans=0;

  while(true)
 {
   if(*max_element(v.begin(),v.end()) == 0)
    break;

    int i=0;

    while(i<n)
   {
      if(v[i] == 0) i++;
      else {
        ans++;
         while(i<n && h[i] > 0)
        {
            h[i]--;
            i++; }
      }
    }

  }

   cout<<ans<<endl;

return 0;
 }
   */
 int main(){

 long long n;
 cin>>n;

   vector<int>v(n);

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

    long long ans=0;

 while(true){

    if(*max_element(v.begin(),v.end()) == 0) break;

  //if(max(v,v+n) == 0)

    int i=0;

    while(i<n){

     if(v[i] == 0) i++;
     else {
        ans++;
        while(i<n && v[i] > 0){
            v[i]--;
            i++;
        }
      }
    }

 }

 cout<<ans<<endl;

 return 0;
 }

Measured memory_bytes: 3592
#include <cstdio>
#include <string>
#include <algorithm>
#include <list>

int main() {
  std::list<std::string> lines;
  while (true) {
    char buf[32];
    fgets(buf, sizeof buf, stdin);
    std::string line=buf;
    if (line == "END_OF_TEXT\n")
      break;

    lines.emplace_back(line);
  }

  auto it=lines.begin();
  size_t cc=0;
  std::string kbuf="";
  while (true) {
    char op;
    scanf(" %c", &op);

    switch (op) {
    case '-': {
      for (const auto &line: lines)
        printf("%s", line.c_str());
      return 0;
    }

    case 'a':
      cc = 0;
      break;

    case 'e':
      cc = it->size()-1;
      break;

    case 'p':
      cc = 0;
      if (it != lines.begin())
        --it;
      break;

    case 'n':
      cc = 0;
      if (std::next(it) != lines.end())
        ++it;
      break;

    case 'f':
      if ((*it)[cc] != '\n') {
        ++cc;
      } else if (std::next(it) != lines.end()) {
        ++it;
        cc = 0;
      }
      break;

    case 'b':
      if (cc > 0) {
        --cc;
      } else if (it != lines.begin()) {
        --it;
        cc = it->size()-1;
      }
      break;

    case 'd':
      if ((*it)[cc] != '\n') {
        *it = it->substr(0, cc) + it->substr(cc+1);
      } else if (std::next(it) != lines.end()) {
        it->pop_back();
        auto tmp=std::next(it);
        *it += *tmp;
        lines.erase(tmp);
      }
      break;

    case 'k':
      if ((*it)[cc] != '\n') {
        kbuf = it->substr(cc);
        kbuf.pop_back();
        *it = it->substr(0, cc) + "\n";
      } else if (std::next(it) != lines.end()) {
        kbuf = "\n";
        it->pop_back();
        auto tmp=std::next(it);
        *it += *tmp;
        lines.erase(tmp);
      }
      break;

    case 'y':
      if (kbuf.empty()) {
        // no-op;
      } else if (kbuf == "\n") {
        std::string s=it->substr(cc);
        *it = it->substr(0, cc) + "\n";
        auto tmp=std::next(it);
        lines.emplace(tmp, s);
        ++it;
        cc = 0;
      } else {
        *it = it->substr(0, cc) + kbuf + it->substr(cc);
        cc += kbuf.length();
      }
      break;
    }

    // fprintf(stderr,
    //         "[%c] / L%td C%zu\n", op, std::distance(lines.begin(), it), cc);
    // for (const auto &line: lines)
    //   fprintf(stderr, "%s", line.c_str());
  }
}



Measured memory_bytes: 2864
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

struct edge {
	int to;
	long long cost;
	edge(int to_, long long cost_) :
		to(to_), cost(cost_) {}
};
const long long INF = 123456789012345;
using P = pair<long long, int>;
void dijkstra(vector<edge>graph_[], long long dist[], int n_, int s_) {
	priority_queue<P, vector<P>, greater<P>>que;
	que.push({ 0,s_ });
	fill(dist, dist + n_, INF);
	dist[s_] = 0ll;
	while (!que.empty()) {
		auto q = que.top();
		que.pop();
		long long thd = q.first;
		int thv = q.second;
		if (thd > dist[thv])
			continue;
		for (auto ed : graph_[thv]) {
			if (dist[ed.to] > ed.cost + thd) {
				dist[ed.to] = ed.cost + thd;
				que.push({ dist[ed.to],ed.to });
			}
		}
	}
}

vector<edge>G[1234567];
LL dist[1234567];

vector<string>raw;
int chart[1234][1234];
bool bomb[1234][1234];

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

LL H, W, A, B;

inline bool zone(int x, int y) {
	return (0 <= x && x < H && 0 <= y && y < W);
}

inline int num(int x, int y) {
	return x * W + y;
}

int main(void)
{
	cin >> H >> W >> A >> B;
	for (int i = 0; i < H; ++i) {
		string tmp;
		cin >> tmp;
		raw.push_back(tmp);
	}
	int sx, sy, gx, gy;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			switch (raw[i][j]) {
			case 's':
				sx = i; sy = j;
				break;
			case 'g':
				gx = i; gy = j;
				break;
			case '#':
				chart[i][j] = 1;
				break;
			case '*':
				bomb[i][j] = true;
				for (int d = 0; d < 8; ++d) {
					int ii = i + dx[d];
					int jj = j + dy[d];
					if (zone(ii, jj)) {
						bomb[ii][jj] = true;
					}
				}
				break;
			}
		}
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int me = num(i, j);
			for (int d = 0; d < 8; ++d) {
				int ii = i + dx[d];
				int jj = j + dy[d];
				if (!zone(ii, jj))continue;
				bool four = (dx[d] == 0 || dy[d] == 0);
				int to = num(ii, jj);
				if (chart[ii][jj] == 0 && four) {
					G[me].push_back({ to,A });
				}
				else if (chart[ii][jj] == 1 && !bomb[i][j]) {
					G[me].push_back({ to,A+B + (four ? 0 : A) });
				}
			}
		}
	}
	int snum = num(sx, sy);
	int gnum = num(gx, gy);
	dijkstra(G, dist, H*W, snum);
	LL ans = dist[gnum];
	if (ans < INF) {
		cout << ans << endl;
	}
	else {
		cout << "INF" << endl;
	}
	return 0;
}



Measured memory_bytes: 186256