akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N,K;
    cin >> N >> K;
    ll ans = 0;
    if(K==0){
        cout << N * N << endl;
        return 0;
    }
    repe(i,K+1, N+1){
        ll p = (N - 1) / i;
        ans += p * (i-K);
        if(N%i)
            ans += max(0ll, N - p * i - K + 1);
        else
            ans += max(0ll, N - p * i - K);
        cerr << ans << endl;
    }

    cout << ans << endl;
}

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

int main() {
  IN (ll, H);
  IN (ll, W);
  IN (ll, M);
  map<pair<int, int>, int> hw;
  vector<ll> h(H, 0);
  vector<ll> w(W, 0);
  REP(i, M) {
    IN(ll, tmp_h);
    tmp_h--;
    IN(ll, tmp_w);
    tmp_w--;
    hw[make_pair(tmp_h, tmp_w)] = 1;
    h.at(tmp_h)++;
    w.at(tmp_w)++;
  }

  vector<ll> max_h = {};
  ll max_val_h = 0;
  REP(i, H) {
    if (h.at(i) > max_val_h) {
      max_val_h = h.at(i);
      max_h.clear();
      max_h.push_back(i);
    }
    else if (h.at(i) == max_val_h) max_h.push_back(i);
  }
  vector<ll> max_w = {};
  ll max_val_w = 0;
  REP(i, W) {
    if (w.at(i) > max_val_w) {
      max_val_w = w.at(i);
      max_w.clear();
      max_w.push_back(i);
    }
    else if (w.at(i) == max_val_w) max_w.push_back(i);
  }

  ll max = 0;
  REP(i, max_h.size()) {
    REP(j, max_w.size()) {
      ll tmp = h.at(max_h.at(i)) + w.at(max_w.at(j));
      bool flag = true;
      if (hw.count(make_pair(max_h.at(i), max_w.at(j)))) {
        flag = false;
      }
      if (flag) {
        cout << tmp << endl;
        return 0;
      } else {
        max = tmp - 1;
      }
    }
  }
  cout << max << endl;

  return 0;
}


Measured memory_bytes: 35092
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using  namespace std;

int main(void){
    vector<int>a(3);
    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int ans;
    ans=a[2]*10+a[1]+a[0];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

def char_count(a, b):
    if len(a) < len(b):
        s1 = a
        s2 = b
    else:
        s1 = b
        s2 = a
    result = 0
    d = {}
    for s in s1:
        if s in d:
            continue
        d[s] = True
        if s in s2:
            result += 1
    return result

ans = 0
for i in range(1, N-1):
    ans = max(ans, char_count(S[:i], S[i:]))

print(ans)

Measured memory_bytes: 3064
package main

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

func main() {
	A, B, C, K := getStdinInt()

	if A >= K {
		fmt.Printf("%d\n", K)
		return
	}
	K = K - A

	if B >= K {
		fmt.Printf("%d\n", A)
		return
	}
	K = K - B

	if C >= K {
		fmt.Printf("%d\n", A-K)
		return
	}
	fmt.Printf("%d\n", A-C)
}

var sc = bufio.NewScanner(os.Stdin)

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinInt() (int, int, int, int) {
	str := getStdin()
	list := strings.Split(str, " ")
	A, _ := strconv.Atoi(list[0])
	B, _ := strconv.Atoi(list[1])
	C, _ := strconv.Atoi(list[2])
	D, _ := strconv.Atoi(list[3])
	return A, B, C, D
}


Measured memory_bytes: 1740
#include<iostream>
#include<string>

using namespace std;

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

  length = str.size();
  
  for(int i=0;i<length;i++) {
    if(str[i] == '?') {
      if(str[i-1] == 'P') {
        str.replace(i, 1, "D");
      }else if(str[i+1] == 'D') {
        str.replace(i, 1, "P");
      } else {
        str.replace(i, 1, "D");
      }
    }
  }
  cout << str << endl;
  return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define debugVec(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define mod (int)(1e9+7)
using namespace std;
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}
signed main(){
	fastIO

    int n;
    cin >> n;
    int a[n+1];
    memset(a, 0, sizeof(a));
    for (int i = 0; i < n-1; i++){
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }
    for (int i = 1; i <= n; i++){
        cout << a[i] << endl;
    }

    return 0;

}


Measured memory_bytes: 5216
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const long long mod = 1e9+7;

int main() {
  int N, M; cin >> N >> M;
  vector<int> a(N+1, true);
  for (int i = 0; i < M; ++i) {
    int c; cin >> c;
    a[c] = false;
  }
  
    vector<long long int> dp(N+1);
  
  dp[0] = 1;
  
  for (int i = 0; i < N; ++i) {
    for (int j = i+1; j <= min(N, i+2); ++j) {
	  if (a[j]) {
        dp[j] += dp[i];
        dp[j] %= mod;
      }
    }
  }
  
  cout << dp[N] << endl;
  
  return 0;
}

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

string s;
long long int res = 0;
vector<int> a(10);

int main() {
  cin >> s;
  int n = s.size();
  rep(i, n){
    a.at(i) = s.at(i) - '0';
  }
  rep(S, 1 << n - 1){
    long long int now = a.at(0);
    long long int sum = 0;
    rep(i, n-1){
      if(S >> i & 1){
        now *= 10LL;
        now += a.at(i+1);
      }else{
        sum += now;
        now = a.at(i+1);
      }
    }
    sum += now;
    //cout << sum << " ";
    res += sum;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
//Dragan Andrei Gabriel
//    (-_-)

//#include <bits/stdc++.h>

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

using namespace std;

int n, x[10], y[10];

int main()
{
    scanf("%d\n", &n);

    long long fact = 1;
    long double ans = 0.0;
    for (int i = 1; i <= n; i++)
        fact *= i;

    for (int i = 1; i <= n; i++)
    {
        scanf("%d %d", &x[i], &y[i]);
    }

    int f = 2;
    for (int i = 2; i < n; i++)
        f *= i;

    for (int i = 1; i <= n; i++)
        for (int j = 1; j < i; j++)
        {
            long double dist = (long double)sqrt((x[i] - x[j]) * (long double)(x[i] - x[j]) + (y[i] - y[j]) * (long double)(y[i] - y[j]));
            ans += (dist * (long double)f);
        }

    ans /= (long double)fact;

    printf("%.10Lf", ans);
    return 0;
}


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

int main() {
  long long a,b,c;
  cin >> a >> b >> c;
  if(a+b>c){
  cout << "No" << endl;
  return 0;
  }  
  if(4*a*b<(c-a-b)*(c-a-b)){
  cout << "Yes" << endl; 
  }  
  else{  
  cout << "No" << endl;  
  }  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,x;
    int d = 0;
    int tmp,i;
    int count = 1;
    vector<int> l;
    cin >> n >> x;
    for(i=0;i<n;i++){
        cin >> tmp;
        l.push_back(tmp);
    }
    for(i=0;i<n;i++){
        d += l[i];
        if(d > x) break;
        count++;
    }
    cout << count << endl;
}

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

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

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int a,b;cin>>a>>b;
    vector<int> h(1000,0);
    for(int i=1;i<=999;i++){
        h[i]=h[i-1]+i;
        if(b-a==i){
            cout<<h[i]-b<<endl;
            return 0;
        }
    }

}


Measured memory_bytes: 256
#pragma GCC optimize("O2") 

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define test(t) int t; cin>>t; while(t--)

void solve()
{
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  int flag=1;
  while(a>0 && c>0)
  {
    if(flag)
    {
      c=c-b;
      flag=0;
    }
    else
    {
      a=a-d;
      flag=1;
    }
  }
  if(a<=0)
    cout<<"No"<<endl;
  else if(c<=0)
    cout<<"Yes"<<endl;
}

int main()
{
     fast;
     //test(t)
          solve();
     return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a[i];
    sort(a.begin(), a.end());

    int cnt=0;
    for(int i=0; i<N; i++){
        if(x>=a[i]){
            x-=a[i];
            cnt++;
        }else{
            cout << cnt;
            return 0;
        }
    }
    if(x>0){
        cout << cnt-1;
    }else{
        cout << cnt;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main(){
  int a, b;
  std::cin >> a >> b;
  std::string s;
  std::cin >> s;
  for(int i=0;i<s.size();i++){
    if(i == a){
      if(s[i] != '-'){
        std::cout << "No" << std::endl;
        return 0;
      }
    }
    else{
      if(s[i] < '0' || s[i] > '9'){
        std::cout << "No" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
const double pie  =3.141592653589793238463;
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define POP(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(),A.end());
#define REV(A) reverse(A.begin(), A.end());
#define lenth length()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n" 
const ll dx[4] = { -1, 1, 0, 0};
const ll dy[4] = {0, 0, -1, 1};
ll XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
ll YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
#define precise(x) cout<<fixed<<setprecision(x)
#define t1(x)                cerr<<#x<<": "<<x<<endl
#define t2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define t4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define t5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define t6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
void SieveOfEratosthenes(ll n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // for (ll p=2; p<=n; p++) 
       // if (prime[p]) 
          // cout << p << " "; 
} 

ll power(ll x, ll y) 
{ 
    ll res = 1; 
    while (y > 0) 
    { 
        if (y & 1) 
            res = res * x; 
        y = y >> 1; 
        x = x * x; 
    } 
    return res; 
}
int main()
{
    fastio
    ll t,i,j,k,l,m,n,a,x,b,y,z,c,h,d,e,p,o,nl,np,q,r;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;


}

Measured memory_bytes: 3632
#!/usr/bin/env ruby

attrs = Array.new
while line = $stdin.gets
  attrs << line.chomp.split
end
H = attrs[0][0].to_i
W = attrs[0][1].to_i
a = ((H * W) / 2.0).ceil
a = 1 if (H == 1 || W == 1)
puts a

Measured memory_bytes: 1788
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

void solve() {
  int n, k;
  cin >> n >> k;
  if((n+1)/2 >= k) cout << "YES\n";
  else cout << "NO\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


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

vector < int > pot[6];

int main(){
	vector < int > arr;
	for(int i = 2 ; i <= 30000 ; ++i)
		if(i % 2 == 0 || i % 3 == 0) pot[i % 6].push_back(i);
	int N; cin >> N;
	if(N == 3){printf("2 5 63"); return 0;}
	if(N == 4){printf("2 5 20 63"); return 0;}
	cout << pot[3][0] << ' ' << pot[3][1] << ' '; N -= 2;
	for(int i = 0 ; N && i < 5000 ; ++i){
		--N; cout << pot[0][i] << ' ';
		if(N % 2 == 0 && N <= 14998) break;
	}
	for(int i = 0 ; i < 5000 && N ; ++i){
		cout << pot[2][i] << ' ' << pot[4][i] << ' ';
		N -= 2;
	}
	for(int i = 2 ; i <= 5000 && N ; i += 2){
		N -= 2; cout << pot[3][i] << ' ' << pot[3][i + 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 512
H, W = list(map(lambda x: int(x), input().split(' ')))
table = [[c for c in input()] for _ in range(H)]

for i in range(H):
    for j in range(W):
        if table[i][j] == '#':
            if i > 0 and table[i-1][j] == '#':
                continue

            elif i < H-1 and table[i+1][j] == '#':
                continue

            elif j > 0 and table[i][j-1] == '#':
                continue

            elif j < W-1 and table[i][j+1] == '#':
                continue

            else:
                print('No')
                exit()

print('Yes')

Measured memory_bytes: 39280
#include<bits/stdc++.h>
#define MOD 1000000007
#define line "\n"
#define loop(i,a,n) for(ll i=a;i<n;i++)
#define ll long long int
#define lb long double
#define ull unsigned long long int
#define pb push_back
#define vi vector < int >
# define vs vector < string >
# define vb vector < bool >
#define vll vector<ll>
# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >
#define vpii vector<pair<int,int>>
#define vpsi vector<pair<string,int>>
#define mii map<int ,int>
#define mis map<int,string>
#define all(v) v.begin(),v.end()


# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
using namespace std;

void solve()
{ 
int n;
cin>>n;
int count=0;
vi v(n+1);
loop(i,1,n+1)
{
  cin>>v[i];
  if(i&1)
if(v[i]&1)count++;
}
cout<<count;

}



int main()
{fast
// #ifndef ONLINE_JUDGE
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
//  #endif
// ll t;
// cin>>t;
// while(t--)
{
solve();
}

}



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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll power(ll x, ll y, ll p = MOD){  
  ll res = 1LL; 
  x = x % p;
  if (x == 0) return 0;
  while (y > 0){
    if (y & 1LL)  
      res = (res*x) % p;
    y = y>>1LL; 
    x = (x*x) % p;  
  }  
  return res;  
} 

int main(){
	IO
	int n, W;
	cin >> n >> W;

	ll weight[n], value[n];
	for(int i = 0; i<n; ++i) {
		cin >> weight[i] >> value[i];
	}

	ll prev[W + 1] = {0}, curr[W + 1] = {0};
	for(int i = 0; i<n; ++i) {
		for(int w = W; w >= weight[i]; --w) {
			curr[w] = max(curr[w], prev[w - weight[i]] + value[i]);
		}
		for(int j = 0; j <= W; ++j) {
			prev[j] = curr[j];
		}
	}

	cout << prev[W] << endl;
	return 0;
}

Measured memory_bytes: 5192
/*...Bismillahir Rahmanir Rahim...*/
#include <bits/stdc++.h>
using namespace std;


int main()
{
    map<string,int> m;
    int n,c=0; cin>>n;
    string a[n];
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
        m[a[i]]++;
    }
    for (auto &it : m) 
        if (it.second>c) c = it.second;
    
    for (auto it : m) 
        if (c == it.second) cout<<it.first<<endl;
    return 0;
}



Measured memory_bytes: 26752
import java.util.*;

class Main{
	static public void main(String args[]){
		Scanner sc=new Scanner(System.in);
		
		int x=sc.nextInt(),n=sc.nextInt();
		
		List<Integer>p=new ArrayList<>();
		
		for(int i=0;i<n;i++)
			p.add(sc.nextInt());
			
		
		int ans=0,min=150;
		//minはカンスト値の半分
		
		
		for(int i=-100;i<=200;i++){
			if(!p.contains(i)&&Math.abs(i-x)<min){
				ans=i;
				min=Math.abs(i-x);
			}
		}
		System.out.print(ans);
	}
}

Measured memory_bytes: 35880
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
#define INF (1<<29)



int main(){
	int m;
	cin>>m;
	while(m--){
		int s,y,n;
		cin>>s>>y>>n;
		int ans=-1;
		while(n--){
			int ss=s;
			int a,tesu;
			double nenri;
			cin>>a>>nenri>>tesu;
			if(a==0){
				int risi=0;
				for(int i=0;i<y;i++){
					risi += (int)(ss*nenri);
					ss -= tesu;
				}
				ans = max(ans,ss+risi);
			}else{
				for(int i=0;i<y;i++){
					ss += (int)(ss*nenri)-tesu;
				}
				ans = max(ans,ss);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1232
# This program computes GCD and LCM
# -*- coding: utf-8
import sys


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    for i in range(max([a, b]), a*b + 1):
        if(i % a == 0 and i % b == 0):
            return i
    return a*b


for i in sys.stdin:
    try:
        line = [int(k) for k in i.split(" ")]
        g = gcd(min(line), max(line))
        print(str(g) + " " + str(line[0]*line[1]//g))  # + str(lcm(line[0], line[1]))
    except:
        exit()

Measured memory_bytes: 7660
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,M;
  cin>>N>>M;
  vector<ll>S(N),T(M);
  vector<vector<ll> > dp(N+1,vector<ll>(M+1,0));
  vector<vector<ll> > dp2(N+1,vector<ll>(M+1,0));
  for(int i=0;i<N;i++){
    cin>>S[i];
    dp2[i][0]=1ll;
  }
  for(int i=0;i<M;i++){
    cin>>T[i];
    dp2[0][i]=1ll;
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(S[i]==T[j]){
        dp[i+1][j+1]=dp2[i][j]%MOD;
      }
      dp2[i+1][j+1]=(dp2[i][j+1]+dp2[i+1][j]-dp2[i][j]+dp[i+1][j+1]+MOD)%MOD;
    }
  }
  cout<<(dp2[N][M]+2)%MOD<<endl;
}


Measured memory_bytes: 62976
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  vector<ll> a(5);
  REP(i, 5) cin >> a[i];
  sort(a.begin(), a.end());
  ll mn = a[0];

  ll ans = 4;
  if (n > mn) {
    ans += (n + mn - 1) / mn;
  } else {
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func bs(a []int, t int) int {
	l, r := -1, len(a)
	for r-l > 1 {
		if m := l + (r-l)/2; a[m] < t {
			l = m
		} else {
			r = m
		}
	}
	return l
}

func main() {
	var n int
	fmt.Scan(&n)
	ls := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&ls[i])
	}
	sort.Ints(ls)
	ans := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			a, b := ls[i], ls[j]
			idx := bs(ls[j+1:], a+b)
			countC := idx + 1
			ans += countC
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

S = str(input())

if S[2]==S[3] and S[4]==S[5]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38256
#include <cstring>
#include <string>
#include <memory>
#include <iostream>

/**
@note prime number and less than 1,000,000
*/
constexpr int max_size()
{
    return 1046527;
}

constexpr int null_val()
{
    return -1;
}

class dictionary {
public:
    dictionary()
        : _data(std::make_unique<int[]>(max_size()))
    {
        for (int i = 0; i < max_size(); ++i) {
            _data[i] = null_val();
        }
    }

    void insert(const std::string& str) {
        return insert(str2key(str), 0);
        return;
    }

    bool find(const std::string& str) {
        return find(str2key(str), 0);
    }

private:
    int str2int(const char ch) {
        if (ch == 'A') {
            return 1;
        }
        if (ch == 'C') {
            return 2;
        }
        if (ch == 'G') {
            return 3;
        }
        if (ch == 'T') {
            return 4;
        }
        return 0;
    }

    int str2key(const std::string& str)
    {
        int sum = 0;

        for (std::size_t i = 0; i < str.size(); ++i) {
            sum += str2int(str[i]);
            sum *= 5;   //move up;
        }
        
        return sum;
    }

    int base_hash(const int key) const
    {
        return key % max_size();
    }

    int collision_hash(const int key) const
    {
        constexpr int modulo = max_size() + 1;
        return 1 + key % modulo;
    }

    int create_hash(const int key, const int r) const 
    {
        const int base = base_hash(key);
        const int collision = collision_hash(key);
        const int h = (base + r * collision) % max_size();
        return h;
    }

    void insert(const int key, const int r)
    {
        const int h = create_hash(key, r);
        if (is_empty(h)) {
            _data[h] = key;
            return;
        }
        if (_data[h] == key) {
            return;
        }

        return insert(key, r + 1);
    }

    bool find(const int key, const int r) const
    {
        const int h = create_hash(key, r);
        if (is_empty(h)) {
            return false;
        }
        if (_data[h] == key) {
            return true;
        }

        return find(key, r + 1);
    }

    bool is_empty(const int idx) const {
        return _data[idx] == null_val();
    }

private:
    std::unique_ptr<int[]> _data;
};

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

    int n;
    std::cin >> n;
    std::cin.ignore();

    dictionary dict;
    std::string buf;
    for (int i = 0; i < n; ++i) {
        getline(std::cin, buf);
        if (buf.front() == 'i') {
            static const std::size_t size = strlen("insert ");
            const std::string val
                = buf.substr(size, buf.size() - size);
            dict.insert(val);
        }
        else {
            static const std::size_t size = strlen("find ");
            const std::string val
                = buf.substr(size, buf.size() - size);
            if (dict.find(val)) {
                std::cout << "yes" << std::endl;
            }
            else {
                std::cout << "no" << std::endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 7068
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y; cin >> x >> y;
    ll ans = LLONG_MAX;
    if(x<=y) chmin(ans,abs(y-x));
    if(x<=-y) chmin(ans,-y-x+1);
    if(-x<=y) chmin(ans,y+x+1);
    if(-x<=-y) chmin(ans, -y+x+2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007 
using namespace std;
long long n,m,i,j,k,ans,f[3005][3005][2];
int main(){
    cin >> n >> m;
    f[0][0][1]=1;
   	for(i=1;i<=n;i++)
   		f[0][i][0]=1;
   	for(i=1;i<=m;i++)
   		for(j=0;j<=n;j++)
   			for(k=0;k<=1;k++){
				if(j!=0){
					f[i][j][k|(j==1)]=(f[i][j][k|(j==1)]+f[i-1][j][k])%mo;
					f[i][j-1][k|(j==1)]=(f[i][j-1][k|(j==1)]+f[i-1][j][k])%mo;	
				}
				if(n-j!=0){
					f[i][j+1][k]=(f[i][j+1][k]+f[i-1][j][k])%mo;
					f[i][j][k]=(f[i][j][k]+f[i-1][j][k])%mo;
				}
			}
	for(i=0;i<=n;i++)
		ans=(ans+f[m][i][1])%mo;
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 141184
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
ll powMod(ll x, ll k, ll m) {//x^k (mod n)
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k/2, m);
	else            return x*powMod(x, k-1, m) % m;
}
int N;
int dp1[10]={0},dp2[10]={0},dp3[10]={0};
int ruiseki[31451];
int main(){
	cin>>N;
	string str;
	cin>>str;
	set<int> hoge,fuga;
	ruiseki[0]=0;
	rep(i,str.size()){
		int x=str[i]-'0';
		hoge.insert(x);
		ruiseki[i+1]=hoge.size();
	}
	int ans=0;
	for(int i=N-1;i>=0;i--){
		int sz=fuga.size();
		int x=str[i]-'0';
		fuga.insert(x);
		if(fuga.size()!=sz){
			int used[10]={0};
			for(int j=i-1;j>=0;j--){
				int xx=str[j]-'0';
				if(used[xx]==0){
					used[xx]=1;
					ans+=ruiseki[j];
				}
			}
		}
	}
	cout<<ans<<endl;
}





Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <queue>
#include <functional>
const int INF =1e5;
const int MOD = 1e9 + 7;
using namespace std;
typedef pair<int,int> P;
typedef long long lint;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fill(x,y) memset(x,y,sizeof(x))
#define all(x) (x).begin(),(x).end()
#define pb push_back

int main(){
    string str;
    cin>>str;
    cout<<str[0]<<str.size()-2<<str[str.size()-1]<<endl;
    
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <vector>

#define ll long long

int main()
{
    std::string S, T;
    std::cin >> S >> T;

    int s_size = S.size();
    int t_size = T.size();
    int ans = t_size;
    for(int i=0; i < (s_size-t_size+1); i++) {
        int tmp = 0;
        for(int j=0; j < t_size; j++) {
            if(S[i+j] != T[j]) {
                tmp++;
            }
        }
        ans = ans > tmp ? tmp : ans;
        if (ans == 0) {
            break;
        }
    }
    std::cout << ans << std::endl;
}

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

using namespace std;

int main()
{
	int k,n;
	int ans = 0;
	int l[50];
	cin >> n >> k;

	for(int i = 0; i < n; i++)
	{
		cin >> l[i];
	}
	sort(l, l+n, greater<int>());
	
	for(int i = 0; i < k; i++)
	{
		ans += l[i];
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<cmath>
using namespace std;
#define pi 3.141592653589793283462   
int main(){
  int n;
  cin>>n;
  int max;
  int min;
  long sum;
  int a[10000];
  cin>>a[0];
  sum=a[0],max=a[0],min=a[0];
  for(int i=1;i<=n-1;i++){
	  cin>>a[i];
	  sum+=a[i];
	  if(a[i]>max)
		  max=a[i];
	  if(a[i]<min)
		  min=a[i];
  }
  cout<<min<<" "<<max<<" "<<sum<<endl;
  return 0;
}

Measured memory_bytes: 1204
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc =new Scanner(System.in);
		int n=sc.nextInt();
		long a[]=new long[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextLong();
		}
		Arrays.sort(a);
		System.out.print(a[n-1]+" ");
		double x=(double)(a[n-1])/2;
		double d=Double.MAX_VALUE;
		long second=a[0];
		for(int i=0;i<n;i++) {
			if(Math.abs(x-a[i])<d) {
				d=Math.abs(x-a[i]);
				second=a[i];
			}
			else {
				System.out.println(second);
				break;
			}
		}
		
		
	}

}


Measured memory_bytes: 49860
#include <iostream>
#include <vector>
#include <algorithm>
#include <tr1/unordered_map>

using namespace std;

void init(int N, int S, int W, vector<int> &as) {
    int g = S;
    for(int i = 0; i < N; ++i) {
        as[i] = (g/7) % 10;
        if(g%2 == 0) g = g/2;
        else g = (g/2) ^ W;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    while(true) {
        int N, S, W, Q;
        cin >> N >> S >> W >> Q;
        if(!N && !S && !W && !Q) break;
        vector<int> as(N);
        init(N, S, W, as);
        long long ans = 0;
        if(Q == 2) {
            int nonzero = 0;
            for(int i = 0; i < N; ++i) {
                if(as[i] != 0) ++nonzero;
                if(as[i] % 2 == 0) ans += nonzero;
            }
        } else if(Q == 5) {
            int nonzero = 0;
            for(int i = 0; i < N; ++i) {
                if(as[i] != 0) ++nonzero;
                if(as[i] % 5 == 0) ans += nonzero;
            }
        } else {
            vector<long long> sum(N, 0);
            tr1::unordered_map<long long,int> sumcnt;
            sumcnt[0] = 1;
            long long ord = 1;
            for(int i = N-1; i >= 0; --i) {
                if(i == N-1) sum[i] = as[i] % Q;
                else sum[i] = (sum[i+1] + static_cast<long long>(as[i])*ord) % Q;
                if(as[i] != 0) {
                    //cout << as[i] << ' ' << sumcnt[sum[i]] << endl;
                    ans += sumcnt[sum[i]];
                }
                sumcnt[sum[i]]++;
                ord *= 10;
                ord %= Q;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 6148
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <ctime>
#include <string>
#include <cstring>
#include <random>
#define mp make_pair
#define pb push_back
#define NAME ""
#define y1 y1_423
#define list lista

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename T>
ostream& operator << (ostream& cout, const vector<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "()");
	}
	cout << "(" << a[0];
	for (int i = 1; i < (int)a.size(); i++) {
		cout << "; " << a[i];
	}
	return (cout << ")");
}

template<typename T>
ostream& operator << (ostream& cout, const set<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T>
ostream& operator << (ostream& cout, const multiset<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T1, typename T2>
ostream& operator << (ostream& cout, const pair<T1, T2> &a) {
	return cout << "(" << a.first << "; " << a.second << ")";
}

random_device gen;
mt19937 rnd(gen());

const int nmax = 2010;
const int inf = 2000 * 1000 * 1000;
const ll infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const ld pi = acos(-1.0);

int n, m, q;
string s[nmax];
int v[nmax][nmax], l[nmax][nmax], u[nmax][nmax];

int main() {
	cin >> n >> m >> q;
	getline(cin, s[0]);
	for (int i = 0; i < n; i++) {
		getline(cin, s[i]);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			v[i + 1][j + 1] = v[i][j + 1] + v[i + 1][j] - v[i][j] + (s[i][j] == '1');
			l[i + 1][j + 1] = l[i][j + 1] + l[i + 1][j] - l[i][j];
			u[i + 1][j + 1] = u[i][j + 1] + u[i + 1][j] - u[i][j];
			if (j && s[i][j] == '1' && s[i][j - 1] == '1') {
				l[i + 1][j + 1]++;
			}
			if (i && s[i][j] == '1' && s[i - 1][j] == '1') {
				u[i + 1][j + 1]++;
			}
		}
	}
	for (int qu = 0; qu < q; qu++) {
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		x1--, y1--, x2--, y2--;
		int vv = v[x2 + 1][y2 + 1] - v[x2 + 1][y1] - v[x1][y2 + 1] + v[x1][y1];
		int edges = max(0, l[x2 + 1][y2 + 1] - l[x2 + 1][y1 + 1] - l[x1][y2 + 1] + l[x1][y1 + 1]);
		edges += max(0, u[x2 + 1][y2 + 1] - u[x2 + 1][y1] - u[x1 + 1][y2 + 1] + u[x1 + 1][y1]);
		printf("%d\n", vv - edges);
	}
	return 0;
}


Measured memory_bytes: 53248
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	string s[10001];
	int ans=0;
	int A=0,B=0,BA=0;
	scan(N);
	rep(i,N){
		scan(s[i]);
		rep(j,s[i].size()-1){
			if(s[i][j]=='A'&&s[i][j+1]=='B') ans++;
		}
	}
	rep(i,N){
		if(s[i][0]=='B'&&s[i].back()=='A'){
			if(A>0||B>0) ans++;
			else A++,B++;
		}
	}
	rep(i,N){
		if(s[i][0]=='B'&&s[i].back()!='A'){
			if(A>0) ans++,A--;
			else B++;
		}
	}
	rep(i,N){
		if(s[i][0]!='B'&&s[i].back()=='A'){
			if(B>0) ans++,B--;
			else A++;
		}
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int main()
{
    char s[11];
    cin>>s;
    int len = strlen(s);
    double k;
    int num,diff,d=0;
    for(int i = 0; i<=len-3; i++){
        num = 0,diff = 0;
        //k = 2;
        for(int j = i,k=2; j<(j+3),k>=0; j++,k--){
                double p = pow(10,k);
                num+=( (s[j]-48) * p);
                //k--;
        }
        //cout<<num<<endl;
        diff = abs(num-753);
        if(i==0)d = diff;
        else d=min(d,diff);
    }
    cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 256
// 2020 3/25 ABC158 B Count Balls
#include <iostream>
using namespace std;
using ll = long long;
// int型(20億ぐらい)じゃ全然足りない
// long long (2^63ぐらい <- 9e18)

int main() {
    ll n, a, b;
    ll ans = 0;
    cin >> n >> a >> b;

    ans = n / (a + b) * a;
    ll rem = n % (a  + b);
    ans += min(rem, a);
    cout << ans << endl;
    return 0;

//
//    if ((a == 0) || (a == 0 && b == 0)) {
//        cout << "0" << endl;
//        return 0;
//    }
//
//    if (n <= a) {
//        cout << n << endl;
//        return 0;
//    }
//
//    int seg = n / (a + b);
//    ans = seg * a;
//    n -= seg * (a + b);
//
//    if (n >= a) ans += a;
//    else ans += n;
//
//    cout << ans << endl;
//
//    return 0;


}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 505
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int x[MAXN],id[MAXN];
int val[MAXN * MAXN];
bool vis[MAXN];
vector<int> r;
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {
        read(x[i]);
        val[x[i]] = i;
        id[i] = i;
    }
    sort(id + 1,id + N + 1,[](int a,int b){return x[a] < x[b];});
    int p = 1,rem = id[1] - 1;
    vis[1] = 1;
    for(int i = 1 ; i <= N * N ; ++i) {
        if(val[i]) {
            if(!vis[val[i]]) {puts("No");return;}
            for(int j = 1 ; j <= N - val[i] ; ++j) r.pb(val[i]);
        }
        else {
            while(!rem && p < N) {++p;rem = id[p] - 1;}
            if(rem) {
                val[i] = id[p];
                --rem;
                if(!rem) vis[id[p]] = 1;
            }
            else {
                if(r.size() == 0) {puts("No");return;}
                val[i] = r.back();r.pop_back();
            }
        }
    }
    puts("Yes");
    for(int i = 1 ; i <= N * N ; ++i) {out(val[i]);space;}
    enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

int main(){
  int n,k; cin >> n >> k;
  set<int> s;
  for(int i=0; i<k; ++i){
    int d; cin >> d;
    for(int j=0; j<d; ++j){
      int a; cin >> a;
      s.insert(a);
    }
  }
  cout << n-(int)s.size() << endl;
  return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main  {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int a = Integer.parseInt(tokenizer.nextToken());
        int b = Integer.parseInt(tokenizer.nextToken());
        int c = Integer.parseInt(tokenizer.nextToken());
        int i = 1;
        int count = 0;
        while (a*i <= c){
            count+= b;
            i++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23252
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x.sort()
y.sort()
ans = "War"

for Z in range(X + 1, Y + 1):
  if x[-1] < Z and y[0] >= Z:
    ans = "No War"

print(ans)


Measured memory_bytes: 3060
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [h, w] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const [, ...a] = stdin.trim().split('\n')

const aij = a.map(e => e.split(''))

let delRowIdx = []
let delColIdx = []

for (let i = 0; i < h; i++) {
  let rowStreak = true

  for (let j = 0; j < w; j++) {
    const el = aij[i][j]

    if (i === 0) {
      delColIdx.push(el === '#' ? false : true)
    } else if (el === '#') {
      delColIdx[j] = false
    }

    if (el === '#') {
      rowStreak = false
    }

    if (j === w - 1 && rowStreak) {
      delRowIdx.push(i)
    }
  }
}

for (let i = 0; i < h; i++) {
  if (delRowIdx.indexOf(i) === -1) {
    const row = aij[i].filter((r, j) => !delColIdx[j])
    console.log(row.join(''))
  }
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  int a = 1;
  int ans = 0;
  
  for (int i = 0; i < N; i++) {
    a = vec.at(a - 1);
    ans++;
    
    if (a == 2) {
      break;
    }
  }
  
  if (ans <= N -1) {
    cout << ans << endl;
  }
  
  if (ans > N - 1) {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <numeric>
using namespace std;

#define PI 3.14159265359

double dis(int i, int j, const vector<pair<int,int>> & pos ){
    return sqrt(pow(pos[i].first-pos[j].first,2)+pow(pos[i].second-pos[j].second,2));
}

int main(){
    double n;
    cin>>n;
    cout << 2*PI*n<<endl;
    return 0;

}

Measured memory_bytes: 3768
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0 for _ in range(n)]
for i in range(1, n):
    hi = h[i]
    x = 2 * 10 ** 9
    for j in range(1, min(k, i) + 1):
        x = min(x, dp[i - j] + abs(hi - h[i - j]))
    dp[i] = x
print(dp[-1])


Measured memory_bytes: 56672
# include <bits/stdc++.h>
# define ll long long
# define fi first
# define se second

using namespace std ;

ll n, x ;
ll ans[100001], vc[100001];

int main() {
    cin >> n ;
    for( int i = 0 ; i < n ; i ++ ) {
        cin >> vc[i] ;
    }
    for( int i = 1 ; i < n ; i ++ ) {
        ans[i] = abs(vc[i] - vc[i-1]) + ans[i-1];
        if( i > 1 ) ans[i] = min(ans[i], abs(vc[i]-vc[i-2]) + ans[i-2] ) ;
    }
    cout << ans[n-1] << endl;
}


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

using namespace std;

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

    string t;
    cin>>t;

    for(int i=0;i<t.length();i++){
        if(t[i]=='?'){
            if(i>0){
                if(t[i-1]=='P'){
                    t[i]='D';
                }
                else{
                    if(t[i+1]=='D'){
                        t[i]='P';
                    }
                    else{
                        t[i]='D';
                    }
                }
            }
            else{
                t[i]='D';
            }
        }
    }

    cout<<t<<"\n";


    return 0;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> c(m, 0);
	REP(i, n){
		int k; cin >> k;
		REP(j, k){
			int l; cin >> l;
			++c[l-1];
		}
	}
	int res = 0;
	REP(i, m){
		if (c[i] == n) {
			++res;
		}
	}
	cout << res << endl;

	return 0;
}

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

using namespace std;

using ll = long long;

const long long MOD_NUMBER = 1000000007;
const double PI = 3.14159265358979323846;

int main() {
  ll a;
  for (int i = 0; i < 5; i++) {
    cin >> a;
    if (a == 0) {
      cout << i + 1;
      return 0;
    }
  }
}

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

vector<ll> divisor(ll n){
	vector<ll> res;
	for(ll i = 1; i*i <= n; i++){
		if(n%i == 0){
			res.push_back(i);
			if(i != n/i) res.push_back(n/i);
		}
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	int ans = 0;
	for(ll x : divisor(n)){
		if(x == 1) continue;
		ll tmp = n;
		while(tmp%x == 0) tmp /= x;
		tmp %= x;
		if(tmp == 1) ans++;
	}
	ans += divisor(n-1).size() - 1;
	cout << ans << endl;
	return 0;
}

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

int main() {
  int a,b;
  double c;
  cin >> a >> b;
  c = (a+b)/2.0;
  a = (a+b)/2;
  b = c*10;
  b = (b%10)/5;
  cout << a+b << endl;
}

Measured memory_bytes: 256