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

ll N;
string S;
void solve() {
  int n = S.size();
  ll res = n + 1;
  vector<ll> sb(n + 1, 0), sw(n + 1, 0);
  for (int i = 0; i < n; i++) {
    ll b = 0, w = 0;
    if (S[i] == '#') {
      b++;
    } else {
      w++;
    }
    sb[i + 1] = sb[i] + b;
    sw[i + 1] = sw[i] + w;
  }

  for (int i = 0; i <= n; i++) {
    ll b = i, w = n - i, tmp = 0;
    tmp += (b - sw[i]);
    tmp += (w - sb[n] + sb[i]);

    res = min(res, tmp);
  }
  cout << res << "\n";
  return;
}

int main() {
  cin >> N >> S;
  solve();
  return 0;
}


Measured memory_bytes: 3716
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define ll long long

int main(){
    int T;
    cin>>T;
    REP(i,T){
        ll N,M,A,B;
        cin>>N>>M>>A>>B;
        cout<<floor_sum(N,M,A,B)<<endl;
    }
}

Measured memory_bytes: 3724
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int A=sc.nextInt();
		String op=sc.next();
		int B=sc.nextInt();
		if(op.equals("+")) {
			System.out.println(A+B);
		}else {
			System.out.println(A-B);
		}
		sc.close();
	}
}

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

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

int main(void){
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto& x : a){
		cin >> x;
	}
	vector<int> l(n+2, 0), r(n+2, 0);
	for(int i = 0; i < n; ++i){
		l[i+1] = gcd(l[i], a[i]);
	}
	for(int i = n-1; i > 0; --i){
		r[i+1] = gcd(r[i+2], a[i]);
	}
	int ans = 0;
	for(int i = 1; i <= n; ++i){
		ans = max(gcd(l[i-1], r[i+1]), ans);
	}
	cout << ans << endl;
}

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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

int main(){
  int a,b;
  cin >> a >> b;
  cout << (((a-2*b) <= 0)?0:(a-2*b)) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;


ll N, M, P[1000], k[1000], s[100][100],ans;
string S[1000];


int main() {
	
	cin >> N>>M;
	FOR(i, 0, M) {
		cin >> k[i];
		FOR(j, 0, k[i])cin >> s[i][j];
	}
	FOR(i, 0, M)cin >> P[i];

	FOR(i, 0, 1<<N) {
		ll cur = i;
		vint V;
		FOR(k, 0, 10) {
			V.push_back(cur %2);
			cur /= 2;
		}
		FOR(f, 0, M) {
			ll cnt = 0;
			FOR(j, 0, k[f]) {
				if (V[s[f][j] - 1] == 1)cnt++;
			}
			if (cnt % 2 != P[f])break;
			if (f == M - 1)ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
	
	int n, m;
	cin >> n >> m;
	int max = m;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		
		m += x - y;
		
		if (m < 0) {
			cout << "0\n";
			return 0;
		}
		if (max < m) max = m;
	}
	cout << max << "\n";
	return 0;
	
}


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

int main()
{
    int a,b;

    int i;
    long c=0;
    long d=0;

    scanf("%d %d",&a,&b);

    for(i=0;i<b;i++)
    {
        c=(10*c)+a;
    }

    for(i=0;i<a;i++)
    {
        d=(10*d)+b;
    }
   
   if(a==b)
        printf("%ld",c);
else if(a<b)
    printf("%d",c);
else if(a>b)
    printf("%d",d);


    return 0;
}


Measured memory_bytes: 128
s=input()
odd='RUD'
even='LUD'
count=0
for i in range(len(s)):
  if i%2==0:
    if s[i] in odd:
      count+=1
  else:
    if s[i] in even:
      count+=1
if count==len(s):
  print('Yes')
else:
  print('No')

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

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

void solve(long long X, long long A, long long B){
    if (X + A - B >= 0) {
        if (A - B >= 0) print("delicious");
        else print("safe");
    } else
        print("dangerous");
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long X;
    scanf("%lld",&X);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(X, A, B);
    return 0;
}


Measured memory_bytes: 256
using namespace std;

#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
using namespace std;


int main(void){
	long long int A,B;

	cin >> A>>B;
  cout << (A >= 13 ? B : (A >= 6 ? B / 2 : 0)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

static long long const LIMIT = 1000000000000000000;

int
main()
{
  int N;
  cin >> N;
  long long val = 1;
  for (int n = 0; n < N; n++)
  {
    long long a;
    cin >> a;
    if (a == 0)
    {
      val = 0;
    }
    else if (val != -1)
    {
      long long newval = val * a;
      if (newval < val || LIMIT < newval)
      {
        val = -1;
      }
      else
      {
        val = newval;
      }
    }
  }
  cout << val << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;

int main() {
  ll N, M;
  cin >> N >> M;
  if(N >= M/2)
    cout << M/2 << endl;
  else
    cout << (N*2+M)/4 << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
int MOD = 1000000007;

using namespace std;

vector<int> r[100001];
int n;
int B[100001] = {0};
int W[100001] = {0};
int Bu[100001] = {0};
int Wu[100001] = {0};
int dfs_w(int x,int i){
    if(Wu[x] == 1 || x == 1)return 0;
    else{
        W[x] = i;
        Wu[x] = 1;
        for(auto y:r[x]) dfs_w(y,i+1);
    }
    return 0;
}

int dfs_b(int x,int i){
    if(Bu[x] == 1 || x == n)return 0;
    else{
        B[x] = i ;
        Bu[x] = 1 ;
        for(auto y:r[x]) dfs_b(y,i+1);
    }
    return 0;
}

signed main(){
       
    cin >>  n;
    
    REP(i,n-1){
        int a,b;
        cin >> a >> b;
        r[a].pb(b);
        r[b].pb(a); 
    }
    dfs_b(1,1);
    dfs_w(n,1);

    // int x1 = x2 = x3 = x4 = -1;
    // REP(i,n){
    //     if(abs(B[i+1]-W[i+1]) == 0 && W[i+1] != 0 && B[i+1] != 0) x1 = i+1;
    //     if(B[i+1]-W[i+1] == 2 && W[i+1] != 0 && B[i+1] != 0) x2 = i+1;
    //     if(B[i+1] - W[i+1] == 1 && W[i+1] != 0 && B[i+1] != 0) x3 = i+1;
    //     if(B[i+1] - W[i+1] == -1 && W[i+1] != 0 && B[i+1] != 0) x4 = i+1;
    // }
    int cntBW = 0;
    int cntB = 0;
    int cntW = 0;
    REP(i,n){
        if(B[i+1] != 0 && W[i+1] != 0 && B[i+1] <= W[i+1])cntB++;
        else if(B[i+1] != 0 && W[i+1] != 0 && B[i+1] > W[i+1])cntW++;
        else if(B[i+1] == 0 && W[i+1] != 0) cntW++;
        else if(B[i+1] != 0 && W[i+1] == 0) cntB++;
  
    }
    if(cntW >= cntB)cout << "Snuke" << endl;
    else cout << "Fennec" << endl;
    // REP(i,n){
    //     cerr << " " << cntBW/2 + cntW << " "<< (cntBW - cntBW/2) + cntB << endl;;
    // }


    

    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 13568
// {{{ include and macros
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(a, b) for(int unsafe_cnt=a; unsafe_cnt < b;unsafe_cnt++)
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using namespace std;
// }}}

// {{{ io
void newline() {cout << endl;}
template <typename T>
void display(T input){cout << input;}
template <typename T>
void put(T input){display(input); newline();}
template <typename T>
void vec_put(vector<T> v){
  for(auto &a: v){display(a);display(" ");}
  newline();}
  int input_int(){
  int a; cin >> a; return a;}
string input_string(){
  string a; cin >> a; return a;}
// }}}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a+b < a+c && a+b < b+c){put(a+b);}
  else if(b+c < a+b && b+c < a+c){put(b+c);}
  else {put(c+a);}
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORq(i, m, n) for(int i = (m); i < (n); i++)
#define FORr(i, n) for (int i = (n); i >= 0; i++)

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

	vector<int> A(N);
	FOR(i, N) {
		cin >> A[i];
	}

	bool end = false;
	while (!end) {
		sort(A.begin(), A.end());
		int count = 0;
		for (int i = 1; i < N; i++) {
			A[i] %= A[0];
			if (A[i] == 0) {
				count++;
				A[i] = A[0];
			}
		}
		if (count == N - 1) {
			end = true;
		}
	}
	cout << A[0] << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

template <typename T>
T powint(T a, ll n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= a; 
        a *= a;
        n >>= 1;
    }
    return ret;
}

template <ll mod>
class ModInt {
private:
    ll num;
public:
    ModInt() {};
    ModInt(ll n) { num = n % mod; }
    ModInt inv() const { return powint(*this, mod-2); }
    explicit operator ll() const { return num; }

    ModInt& operator+=(const ModInt& a) {
        num += a.num; 
        if (num >= mod) num -= mod; 
        return *this;
    }
    ModInt& operator-=(const ModInt& a) {
        if (num < a.num) num += mod;
        num -= a.num;
        return *this;
    }
    ModInt& operator*=(const ModInt& a) {
        num = num * a.num % mod;
        return *this;
    }
    ModInt& operator/=(const ModInt& a) { return *this *= a.inv(); }
    friend ModInt operator+(const ModInt& a, const ModInt& b) { return ModInt(a) += b; }
    friend ModInt operator-(const ModInt& a, const ModInt& b) { return ModInt(a) -= b; }
    friend ModInt operator*(const ModInt& a, const ModInt& b) { return ModInt(a) *= b; }
    friend ModInt operator/(const ModInt& a, const ModInt& b) { return ModInt(a) /= b; }

    friend ostream& operator<<(ostream& os, const ModInt& a) { return os << a.num; }
    friend istream& operator>>(istream& is, ModInt& a) {
        ll tmp;
        is >> tmp;
        a.num = tmp % mod;
        return is;
    }
};
using mint = ModInt<1000000007>;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &e: a) cin >> e;

    vector<int> cnt(n, 0);
    vector<mint> c(n, 1);
    for (int i = 0; i < n; ++i) {
        cnt[a[i]]++;
        if (a[i] != 0) {
            c[a[i]] *= cnt[a[i]-1];
            cnt[a[i]-1]--;
        }
    }

    mint ans = 1;
    for (auto &e: c) ans *= e;

    int zc = count(a.begin(), a.end(), 0);
    for (int i = 0; i < zc; ++i) {
        ans *= (3-i);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int d;cin>>d;
  	if(d==25){
    	cout<<"Christmas"<<endl;
    }else if(d==24){
    	cout<<"Christmas Eve"<<endl;
    }else if(d==23){
    	cout<<"Christmas Eve Eve"<<endl;
    }else if(d==22){
    	cout<<"Christmas Eve Eve Eve"<<endl;
    }
}


Measured memory_bytes: 256
//Be Name Khorgraph, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/stweight++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include <iostream>
#include <fstream>


using namespace std;

long long a, b, c;

int main()
{
	cin >> a >> b;
	for (int i = 0; i < b; i++)
	{
		cin >> c;
		a -= c;
	}
	if (a < 0)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << a << endl;
	}
	


}




Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
    int x,a,b;
    cin>>x>>a>>b;
    if (abs(x-a)>abs(x-b))
        cout << "B" << endl;
    else
        cout << "A" << 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 < n; ++i)
#define rep2(i, i0, n) for (int i = i0; i < n; ++i)

int main() {
  int k;
  string s;
  cin >> k >> s;
  if (s.size() <= k)
    cout << s << endl;
  else
    cout << s.substr(0, k) << "..." << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

typedef long long ll;
typedef long double ld;
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPR(i,a,b) for(int i = b; i >= a; i--)
#define all(a)              a.begin(), a.end()
#define alln(a, n)          (a, a+n)
#define sz(x) (int)(x).size()
#define MAX                 10000007
#define MIN                 -10000007
#define pi pair<int,int>
#define pl pair<ll,ll>
#define mii             map<int,int>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf 1e18
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<vi> vvi; 
typedef vector<string> vs;
typedef set<int> si;
const int MOD=998244353;
ll lcm(ll a,ll b){return (a * b) / __gcd(a,b);}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll power(ll a,ll b,ll MOD){if(b == 0)return 1;if(b == 1)return a;ll ans = power(a,b/2,MOD) % MOD;ans *= ans;ans %= MOD;if(b % 2 == 1)ans *= a;return ans%MOD;}
ll inverse(ll x){x%=MOD;return power(x,MOD-2,MOD);}
ll fact[1],inv[1];
void factorial(ll n){
  fact[0]=1;
  for(ll i=1;i<=n;i++){
    fact[i]=fact[i-1]*i;
    if(fact[i]>=MOD)
      fact[i]%=MOD;
  }
}
ll ncr(ll n,ll r){
  if(n<r||n<0||r<0)
    return 0;
  ll b=inv[n-r];
  ll c=inv[r];
  ll a=fact[n]*b;
  if(a>=MOD)
    a%=MOD;
  a*=c;
  if(a>=MOD)
    a%=MOD;
  return a;
}
vector<char> is_prime(100001, true);
void sieve(ll n){
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= n; i++) {
        if (is_prime[i] && (long long)i * i <= n) {
            for (int j = i * i; j <= n; j += i)
                  is_prime[j] = false;
        }
  }    
}     
 
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
      
    int t;
    t=1;
    cout<<fixed<<setprecision(0);
     //  cin>>t;
    while(t--){
            int n,k;
            cin>>n>>k;
            vpi v(k);
            vl dp(n+2);
            REP(i,0,k-1) cin>>v[i].first>>v[i].second;
            sort(all(v));
            dp[n]=1;
            for(int i=n-1;i>=1;i--){
              for(auto x:v){
                if(i+x.first>n) break;
                int low=i+x.first;
                int high=min(n,i+x.second);
                dp[i]=(dp[i]+(dp[low]-dp[high+1]))%MOD;
                while(dp[i]<0)
                  dp[i]+=MOD;
              }
              if(i==1) break;
              dp[i]=(dp[i]+dp[i+1])%MOD;
            }
            cout<<dp[1]<<"\n";
       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 4792
from math import ceil
a = list(map(int, input().split()))
a.sort()
kisu_cnt = 0
ans = 0
for _a in a:
    if _a % 2 == 1:
        kisu_cnt += 1
if kisu_cnt == 3 or kisu_cnt == 0:
    ans += (a[-1] - a[1]) // 2
    ans += (a[-1] - a[0]) // 2
    print(ans)
    exit()
else:
    if kisu_cnt == 1:
        for i in range(3):
            if a[i] % 2 == 0:
                a[i] += 1
    else:
        for i in range(3):
            if a[i] % 2 == 1:
                a[i] += 1
a.sort()
ans += 1
ans += (a[-1] - a[1]) // 2
ans += (a[-1] - a[0]) // 2
print(ans)






Measured memory_bytes: 62272
# -*- coding: utf-8 -*-
import sys
import bisect
N=input()
seq=map(int, sys.stdin.readline().split())

LIS = [seq[0]]
for i in range(len(seq)):
    if seq[i]>LIS[-1]:
        LIS.append(seq[i])
    else:
        LIS[bisect.bisect_left(LIS, seq[i])] = seq[i]

l=-1 #長さ
for i,x in enumerate(LIS):
    if i+1==x:
        l=x

if l==-1:
    print -1
else:
    print N-l

Measured memory_bytes: 57640
#include <iostream>
#include <vector>

using namespace std;

int N, A;


int main(){
  cin >> N >> A;
  
  vector<unsigned long long int> V(N,0);
  
  for(int i = 0; i < N; i++){
    cin >> V[i];
  }
  unsigned long long int ans = 0;
  unsigned long long int dp[100][100][2501] = {0};
  
  for(int j = 0; j <= N; j++){
    for(int k = 0; k <= N; k++){
      for(int s = 0; s <= N*A; s++){
        if(j == 0 && k == 0 && s == 0) dp[j][k][s] = 1LL;
        else if(j >= 1 && V[j-1] > s) dp[j][k][s] = dp[j-1][k][s];
        else if(j >= 1 && k >= 1 && V[j-1] <= s)dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-V[j-1]];
        else dp[j][k][s] = 0LL;
      }
    }
  }
  for(int k = 1; k <= N; k++) ans += dp[N][k][k*A];
  cout << ans;
}


Measured memory_bytes: 195584
n = int(input())
k = int(input())
x = list(map(int, input().split()))
ans = 0

for i in range(n):
    type_a = abs(x[i]-0) * 2
    type_b = abs(x[i]-k) * 2
    ans += min(type_a, type_b)
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>

using namespace std;

int64_t dist[1'000];
vector<tuple<int, int, int64_t>> edges;

int main()
{
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int a, b;
        int64_t c;
        cin >> a >> b >> c;
        a--;
        b--;

        edges.push_back(make_tuple(a, b, -c));
    }

    for (int i = 0; i < N; i++)
    {
        if (i == 0)
        {
            dist[i] = 0;
            continue;
        }
        dist[i] = 1'000'000'000'000;
    }
    for (int i = 0; i < N - 1; i++)
    {
        for (const auto &e : edges)
        {
            int from = get<0>(e);
            int to = get<1>(e);
            int64_t cost = get<2>(e);

            dist[to] = min(dist[to], dist[from] + cost);
        }
    }

    int64_t score = dist[N - 1];

    for (int i = 0; i < N; i++)
    {
        for (const auto &e : edges)
        {
            int from = get<0>(e);
            int to = get<1>(e);
            int64_t cost = get<2>(e);

            dist[to] = min(dist[to], dist[from] + cost);
        }
    }

    if (dist[N - 1] < score)
    {
        cout << "inf" << endl;
    }
    else
    {
        cout << -score << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,a[100]={0};   //１００個
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=n-1;i>=0;i--){
        if(i==n-1){
            cout<<a[i];
        }
        else{
            cout<<" "<<a[i];
        }
    }
    cout<<endl;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){

    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

bool IsPrime(ll num){
    if(num < 2) return false;
    else if(num == 2) return true;
    else if(num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for(ll i = 3; i <= sqrtNum; i += 2){
        if(num%i==0){
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

signed main(){
  int n; cin>>n;
  VI a(n); rep(i,n) cin>>a[i];
  int ans = 0;
  int cnt = 1;
  rep(i,n){
    if(cnt==a[i]) cnt++;
    else ans++;
  }
  if(ans==n) ans = -1;
  cout << ans << endl;


  return 0;
}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution() {
  int n, d;
  cin >> n >> d;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d) ans++;
  }
  cout << ans << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


Measured memory_bytes: 3648
import std;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, M, K;
    scan(N, M, K);
    long MOD = 998244353;
    auto C = Combination_mod(N, MOD);
    long ans;
    foreach (i; 0 .. K + 1)
    {
        long tmp = C(N - 1, i) * powmod(M - 1, N - i - 1, MOD);
        // writeln(tmp);
        ans = (ans + tmp) % MOD;
    }
    writeln(ans * M % MOD);
}

/// x^^n % m
T powmod(T = long)(T x, T n, T m = 10 ^^ 9 + 7)
{
    if (n < 1)
        return 1;
    if (n & 1)
    {
        return x * powmod(x, n - 1, m) % m;
    }
    T tmp = powmod(x, n / 2, m);
    return tmp * tmp % m;
}

/// Number of k-combinations % m (precalculated)
alias Combination_mod = Combination_modImpl!long;
struct Combination_modImpl(T)
{
    T _n, _m;
    T[] _fact, _factinv;
    this(T maxnum, T mod = 10 ^^ 9 + 7)
    {
        _n = maxnum, _m = mod, _fact = new T[](_n + 1), _factinv = new T[](_n + 1), _fact[0] = 1;
        foreach (i; 1 .. _n + 1)
            _fact[i] = _fact[i - 1] * i % _m;
        T powmod(T x, T n, T m)
        {
            if (n < 1)
                return 1;
            if (n & 1)
            {
                return x * powmod(x, n - 1, m) % m;
            }
            T tmp = powmod(x, n / 2, m);
            return tmp * tmp % m;
        }

        foreach (i; 0 .. _n + 1)
            _factinv[i] = powmod(_fact[i], _m - 2, _m);
    }

    T opCall(T n, T k, T dummy = 10 ^^ 9 + 7)
    {
        return n < k ? 0 : ((_fact[n] * _factinv[n - k] % _m) * _factinv[k] % _m);
    }
}


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

int main(){
    string s1,s2,s3;
    int a,b;
    map<string,int>mp;
    cin>>s1>>s2>>a>>b>>s3;
    mp[s1]=a;
    mp[s2]=b;
    mp[s3]--;
    cout<<mp[s1]<<' '<<mp[s2]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

int main()
{
	long long int n, s;
    scanf("%lld", &n);
    scanf("%lld", &s);
    if(n<s){
      printf("%d\n", -1);
    }else if(n==s){
      printf("%lld\n", n+1);
    }else{
      long long int d;
      for(d=1; d*d<=n-s; d++){
        if((n-s)%d!=0) continue;
        long long int b=d+1, q=n,r;
        long long int sum=0;
        while(q!=0){
			r=q%b;
            sum=sum+r;
            q=q/b;
        }
        if(sum==s){
          printf("%lld\n", b);
          break;
        }
      }
      if(d*d>n-s){
        d--;
        long long int d1;
        for(d1=d; d1>0; d1--){
          if((n-s)%d1!=0) continue;
          long long int b=(n-s)/d1+1, q=n, r;
          long long int sum=0;
          while(q!=0){
			r=q%b;
            sum=sum+r;
            q=q/b;
          }
          if(sum==s){
            printf("%lld\n", b);
            break;
          }
        }
        if(d1==0){
          printf("%d\n", -1);
        }
      }
    }
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0){
				break ;
		}
		for (int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(i == 0 || i == H - 1 || j == 0 || j == W - 1){
					System.out.printf("#");
				} else {
					System.out.printf(".");
				}
			}
			System.out.printf("\n");
		}
		System.out.printf("\n");
 		}
	}
}


Measured memory_bytes: 61220
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    
    int N;    cin >> N;
    int T, A; cin >> T >> A;
    vector<pair<double,int>> vT(N);
    for(int i=0; i<N; ++i){
        double h; cin >> h;
        vT[i].first  = abs( (T - h * 0.006) - A );
        vT[i].second = i;
    }
    sort(vT.begin(), vT.end());
    
    cout << vT[0].second + 1 << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        sc.close();
        
        System.out.println(z + " " + x + " " + y);
    }
}

Measured memory_bytes: 39056
#include<iostream>
using namespace std;
int main()
{
    int n,i,j=0,s=0,m=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    {   cin>>a[i];
        if(a[i]%4==0) j++;
        else if(a[i]%2==0) s++;
        else m++;
    }
    if(j>=m||(j-m==-1)&&s==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 640
command_num = STDIN.gets.to_i
commands = STDIN.read.split("\n")

list_head = nil
list_tail = nil

commands.each do |command|
  func, arg =command.split(' ')
  case func
  when 'insert'
    if list_head.nil?
      # list is empty
      list_head = {value: arg, prev: nil, next: nil}
      list_tail = list_head
    else
      list_second = list_head
      list_head = {value: arg, prev: nil, next: list_second}
      list_second.update({prev: list_head})
    end
  when 'delete'
    current = list_head
    until current.nil? do
      if current[:value] == arg
        if current[:prev].nil? and current[:next].nil?
          # list becomes empty
          list_tail = nil 
          list_head = nil
        elsif current[:prev].nil?
          # delete first element
          list_head = current[:next]
          list_head.update({prev: nil})
        elsif current[:next].nil?
          # delete last element
          list_tail = current[:prev]
          list_tail.update({next: nil})
        else
          current[:prev].update({next: current[:next]})
          current[:next].update({prev: current[:prev]})
        end
        break
      else
        current = current[:next]
      end
    end
  when 'deleteFirst'
    unless list_head.nil?
      if list_head[:next].nil?
        #list becomes empty
        list_head = nil
        list_tail = nil
      else
        list_head = list_head[:next]
        list_head.update({prev: nil})
      end
    end
  when 'deleteLast'
    unless list_tail.nil?
      if list_tail[:prev].nil?
        #list becomes empty
        list_head = nil
        list_tail = nil
      else
        list_tail = list_tail[:prev]
        list_tail.update({next: nil})
      end
    end
  end
end
current = list_head
until current.nil? do
  print("#{current[:value]}")
  current = current[:next]
  print(" ") unless current.nil?
end
print("\n")

Measured memory_bytes: 515588
#include<bits/stdc++.h>
using namespace std;
bool check(string S,long L)
{
    if(L%2)
        return 0;
    L/=2;
    for(long i=0;i<L;i++)
        if(S[i]!=S[L+i])
            return 0;
    return 1;
}
int main()
{
   // ifstream cin("input.in");
   // ofstream cout("output2.out");
    ios::sync_with_stdio(0);cin.tie(0);
    string S;
    cin>>S;
    long P=0;
    long L=S.size();
    for(long i=1;i<L;i++){
        //cout<<S.substr(0,i)<<"\n";
        if(check(S.substr(0,i),i)){
            //cout<<S.substr(0,i)<<"\n";
            P=max(i,P);
        }}
    cout<<P;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    int vsum = 0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        vsum ^= A[i];
    }
    for(auto v : A){
        cout << (v ^ vsum) << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 4052
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner (System.in);
        while(true){
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a==0&&b==0) break;
        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++){
                System.out.print("#");
            }
            System.out.println("");
        }
        System.out.println();
    }

    }
}


Measured memory_bytes: 33456
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        String s = sc.next();
        String t = sc.next();
        char[] ss = s.toCharArray();
        Arrays.sort(ss);
        char[] ts = t.toCharArray();
        Arrays.sort(ts);

        String S = new String(ss);
        String T = new StringBuilder(new String(ts)).reverse().toString();
        out.println(S.compareTo(T) < 0 ? "Yes" : "No");

        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define MAX_LEN 1000

int dp[MAX_LEN + 1][MAX_LEN + 1];

int main() {
	int q;
	cin >> q;
	while (q-->0) {
		string X, Y;
		cin >> X >> Y;
		for (int i = 0; i <= X.size(); ++i)
			for (int j = 0; j <= Y.size(); ++j)
				dp[i][j] = 0;
		for (int i = 0; i < X.size(); ++i)
			for (int j = 0; j < Y.size(); ++j)
				if (X[i] == Y[j])
					dp[i+1][j+1] = dp[i][j] + 1;
				else
					dp[i+1][j+1] = max(dp[i][j + 1], dp[i + 1][j]);
		cout << dp[X.size()][Y.size()] << endl;
	}
	return 0;
}

Measured memory_bytes: 5116
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
    
def solve():
    n = inp()
    print((pow(10,n,1000000007) - pow(9,n,1000000007) - pow(9,n,1000000007) + pow(8,n,1000000007)) % 1000000007)
    
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)
 
def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))
 
def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    n,m = len(a),len(a[0])
    b = [[0] * n for i in range(m)]
    for i in range(m): 
        for j in range(n): 
            b[i][j] = a[j][i]
    return(b)

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

Measured memory_bytes: 62908
#include <bits/stdc++.h>
using namespace std;
bool isprime(int x) {
  if (x == 1 || x == 2) {
    return true;
  }

  if (x < 2 || x % 2 == 0) {
    return false;
  }

  int i = 3;
  while (i <= sqrt(x)) {
    if (x / i > 0 && x % i ==0) {
      return false;
    }
    i = i + 2;
  }

 return true;

}
int main() {
  int n;
  cin >> n;
  vector<int> data(n);
  int count = 0;
  for (int i = 0; i < n; i++) {
    cin >> data[i];
  }
  for (int i = 0; i < n; i++) {
    int d = data[i];
    if (isprime(d)) {
      count ++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3120
/*
_________________________
|   LIVE FREE OR DIE     |
|       327 2153         |
|          New           |
|_______HAMPSHIRE________|
 
*/
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define MAX 200005
#define int long long
#define MOD 1000000007

int32_t main()
{
	IOS;
	int a,b,c,k;cin>>a>>b>>c>>k;
	int ans=0;
	ans+=min(a,k);
	k-=a;
	k=max(0LL,k);
	k-=b;
	k=max(0LL,k);
	if(k==0)
		cout<<ans;
	else
	{
		ans-=min(k,c);
		cout<<ans;
	}

	return 0;
}

Measured memory_bytes: 3640
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int a, b;
	cin >> a >> b;
	vector<string> s(74);
	s[0] = "";
	REP(i, 98) s[0]+="#";
	s[73] = "";
	REP(i, 98) s[73]+=".";
	REP1(i, 72){
		s[i] = "#";
		if(i%3==1) 		REP(j, 24) s[i] += ".###";
		else if(i%3==2) REP(j, 24) s[i] += ".#.#";
		else 			REP(j, 24) s[i] += "...#";
		s[i] += ".";
	}
	int wh = 1, bl = 1;
	REP(i, 24){
		REP(j, 24){
			if(wh < a){
				wh++;
				s[3*i+3][4*j+3] = '#';
			}
			if(bl < b){
				bl++;
				s[3*i+1][4*j+2] = '.';
			}
		}
	}
	cout << "74 98" << endl;
	REP(i,74) cout << s[i] << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>

using namespace std;

int main(){
    
    int n;
    cin >> n;
    char s[n];
    cin >> s;
    bool x=true;
    int num = strlen(s);
    char ans[n];
    if(num%2!=0){
        x=false;
    }
    else {
        for(int i=0;i<num/2;i++){
            ans[i]=s[i];
            ans[i+num/2]=s[i];
        }
    for(int j=0;j<num;j++){
        if(ans[j]==s[j]){
            continue;
            }
        else x=false;;
        }
        }
    if(x==true){
        cout << "Yes" << endl;
        }
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
from math import  sqrt
def isPrime(n):
    if (n == 0 or n == 1): return True
    else:
        
        for i in range(2,n):
            i = int(i)
            if (i*i > n): break
            if n % i == 0:
                return False
        return True

n = int(input())
while(True):
    if (not isPrime(n)): n += 1
    else:
        print(n)
        break

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>

using namespace std;

int main() {

  int n;
  double bubble, pliefsto, gappy;
  cin >> n;
  for(int i = 1;i <= n;i++){
    cin >> pliefsto;
    gappy = gappy + 1 / pliefsto;

  }
  bubble = 1 / gappy;
  cout << fixed << setprecision(10) << bubble;
  return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
ll n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

//桁数を返す
int find_digits(ll n){
    int digit = 0;

    while(n){
        n /= 10;
        digit++;
    }
    return digit;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    ll a, b;
    int a_digit, b_digit;
    int f = INFTY, tmp;
    
    for(ll i = 1; i * i <= n; i++){
        a = i;
        if(n % a == 0){
            b = n / a;
            a_digit = find_digits(a);
            b_digit = find_digits(b);
            tmp = max(a_digit, b_digit);
            f = min(f, tmp);
        }
    }
    
    cout << f << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int N, A, B;
	int pa = 0, pab = 0, pb = 0;
	cin >> N;
	cin >> A >> B;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		if (x <= A)
			pa++;
		else if (x > A&&x <= B)
			pab++;
		else
			pb++;
	}
	
	cout << min({ pa,pab,pb }) << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
h = [None]+LI()
dp = [float('INF')]*(N+1) #1_indexed
dp[1] = 0
for i in range(1,N+1):
    for j in [1,2]:
        if i+j>=N+1:
            continue
        dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
print(dp[-1])


Measured memory_bytes: 56312
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>

using namespace std;

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

int p[100005];

int main() {
    int N;
    scanf ("%d", &N);
    for (int i = 0; i < N; ++i) {
        scanf ("%d", &p[i]);
    }

    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        if (p[i] == i + 1) {
            if (i + 1 < N) swap (p[i], p[i + 1]);
            ++cnt;
        }
    }
    printf ("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 640
/* ***********************************************
Author        :yang12138
Created Time  :2018年06月23日 星期六 20时56分59秒
File Name     :C.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=705;

vector<int>G[N];
int is[N][N];

void add_edge(int u,int v){
	G[u].push_back(v);
	G[v].push_back(u);
}

int tag[N];
bool flag=1;

void dfs(int u,int& b,int& w){
	for(int i=0;i<(int)G[u].size();i++){
		int v=G[u][i];
		if(tag[v]==0){
			tag[v]=3-tag[u];
			if(tag[v]==1) b++;
			else w++;
			dfs(v,b,w);
		}
		else{
			if(tag[u]==tag[v]){
				flag=0;
			}
		}
	}
}

int c[N],d[N];
#include <bitset>
bitset<N>dp;

int C(int n){
	return n*(n-1)/2;
}

void solve(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		is[u][v]=is[v][u]=1;
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(!is[i][j]){
				add_edge(i,j);
			}
		}
	}
	mem(tag,0);

	int cnt=0;
	for(int i=1;i<=n;i++){
		if(tag[i]==0){
			int b=0,w=0;
			b++;
			tag[i]=1;
			dfs(i,b,w);
			++cnt;
			c[cnt]=b,d[cnt]=w;
		}
	}

	if(!flag){
		printf("-1\n");
		return ;
	}

	dp.reset();
	dp[0]=1;
	for(int i=1;i<=cnt;i++){
		dp=(dp<<c[i])|(dp<<d[i]);
	}

	for(int i=n/2;i>=0;i--){
		if(dp[i]){
			printf("%d\n",C(i)+C(n-i));
			return ;
		}
	}
}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	solve();
    return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>

int main(void){
  char abc1,abc2,res;

  res = 'A';
  while(scanf("%c,%c" ,&abc1,&abc2) != EOF){
    if( abc1 == res && abc2 != abc1 ) res = abc2;
    else if( abc2 == res && abc2 != abc1 ) res = abc1; 
  }
  printf("%c\n" ,res);

    return 0;
}

Measured memory_bytes: 544
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    string S;
    cin >> S;
    int cnt=0;
    for(int i=0;i<S.length();i++){
        if (S[i]=='o'){
            cnt++;
        }
    }

    if(15-S.length()+cnt>=8){
        cout << "YES"<<endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#define min(a,b) ((a)<=(b)?(a):(b))
int main() {
	int N,K,a,b;
	scanf("%d %d",&N,&K);
	for(int i=0;i<K;i++) {
		scanf("%d %d",&a,&b);
		a=min(a,N-a+1)-1,b=min(b,N-b+1)-1;
		printf("%d\n",(b<=a)?b%3+1:a%3+1);
	}
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var ABC = ReadLine().Split().Select(int.Parse).ToList();
        ABC.Sort();
        var A = ABC[0];
        var B = ABC[1];
        var C = ABC[2];
        if (A == C) WriteLine(0);
        else if (B == C)
        {
            WriteLine((C - A) / 2 + ((C - A) % 2 == 1 ? 2 : 0));
        }
        else
        {
            var a = (C - A) / 2;
            var b = (C - B) / 2;
            WriteLine((C - A) % 2 == 0 && (C - B) % 2 == 0 ? a + b : (C - A) % 2 == 1 && (C - B) % 2 == 1 ? a + b + 1 : a + b + 2);
        }
    }
}



Measured memory_bytes: 13268