akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
//cout << fixed << setprecision();
//priority_queue<ll, vector<ll>, greater<ll>> q;
vector<set<ll>> vset(26);
string s;
void change(ll ind,char c){
	vset[s[ind]-'a'].erase(ind);
	s[ind]=c;
	vset[s[ind]-'a'].insert(ind);
}

ll get(ll l,ll r){
	ll ret=0;
	rep(i,0,26){
		auto it = vset[i].lower_bound(l);
		if(it != vset[i].end() && *it<r)ret++;
	}
	return ret;
}

signed main(){
	ll n; cin>>n;
	cin>>s;
	rep(i,0,n)vset[s[i]-'a'].insert(i);
	ll q; cin>>q;
	vl ans(0);
	while(q--){
		ll ty; cin>>ty;
		if(ty==1){
			ll ind;
			char c;
			cin>>ind>>c;
			change(--ind,c);
		}
		else{
			ll l,r; cin>>l>>r;
			--l;
			ans.push_back(get(l,r));
		}
	}
	rep(i,0,ans.size())cout<<ans[i]<<'\n';
	
	
	return 0;
}

Measured memory_bytes: 27452
#include <stdio.h>
 
int main()
{
 
  /* 文字 */
  char moji[1];
  char str[27] = "abcdefghijklmnopqrstuvwxyz";
 
  scanf("%c", moji);
  
  int i=0;
  
  for(i=0;i<27;i++){
		if(moji[0] == str[i] ){
  printf("%c", str[i+1]);
        }
  }
  
 
  return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>) {
    val sb = StringBuilder( readLine()!! )
    val w = listOf("dream","dreamer","erase","eraser")

    while (sb.isNotEmpty()){
        val erase = w.find { sb.endsWith(it) }
        if(erase==null){
            println("NO")
            return
        }else{
            sb.delete(sb.length-erase.length , sb.length)
        }
    }
    println("YES")
}

Measured memory_bytes: 38424
# -*- coding: utf-8 -*-

def main():
    a,b,c = map(int, input().split())

    # A = B の時
    if a == b:
        if a != c:
            print('Yes')
        else:
            print('No')
    # A != B の時
    else:
        if a == c or b == c:
            print('Yes')
        else:
            print('No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int m = 1000000007;
int main() {
    ll n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    ll inv1=0,inv2=0;
    rep(i, 0, n){
      rep(j, 0, n){
        if(i==j) continue;
        if(a[i]>a[j]){
          if(i<j) inv1++;
          inv2++;
        }
      }
    }
    ll ans=0;
    ans+=(k*inv1)%m;
    ans+=((k*(k-1))/2)%m*inv2;
    ans%=m;
    cout<< ans;
    return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
int main(){
  int a,b,c,d,e;
  scanf("%d",&a);
  if(a<40){
    a=40;
  }
  scanf("%d",&b);
  if(b<40){
    b=40;
  }
  scanf("%d",&c);
  if(c<40){
    c=40;
  }
  scanf("%d",&d);
  if(d<40){
    d=40;
  }
  scanf("%d",&e);
  if(e<40){
    e=40;
  }
  printf("%d\n",(a+b+c+d+e)/5);
  return 0;
}
  

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

int main(){
  long long int H, W;
  cin >> H >> W;
  
  if (H == 1 || W == 1){
    cout << "1" << endl;
    exit(0);
  }
  
  long long int ans = H * W / 2;
  if (H % 2 == 1 && W % 2 == 1){
    ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, X;
  cin>>N>>X;
  vector<ll> A(N);
  for(int i=0;i<N;++i) cin>>A[i];
  sort(A.begin(), A.end());
  ll sum = X;
  int ans;
  for(int i=0;i<N;++i) {
    if(i==N-1) {
      if(sum==A[i]) ans = N;
      else ans = N-1;
    }
    else {
      if(sum<A[i]) {
        ans = i;
        break;
      }
    }
    sum -= A[i];
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin>>H>>W;
  for(int i=0;i<(W+2);i++){
  cout <<"#";
  }
  cout <<endl;
   string pixl;
  for(int i=0;i<H;i++){
  string pixel;
  cin >> pixel;
  cout <<"#";
  cout <<pixel;
  cout <<"#"<<endl;
  } 
 
  for(int i=0;i<(W+2);i++){
  cout <<"#";
  }
  cout <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    vector<vector<int>> dp(n+1,vector<int>(m+1,1e9+7));
    rep(i,m)dp[0][i] = i;
    rep(i,n)dp[i][0] = i;
    rep(i,n)rep(j,m){
        if(s[i]==t[j])chmin(dp[i+1][j+1],dp[i][j]);
        chmin(dp[i+1][j+1],dp[i+1][j]+1);
        chmin(dp[i+1][j+1],dp[i][j+1]+1);
        chmin(dp[i+1][j+1],dp[i][j]+1);
    }
    /*
    rep(i,n+1){
        rep(j,m+1){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */
    cout << dp[n][m] << endl;
}


Measured memory_bytes: 6848
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
string s;
long long l,ans;
int main()
{
    cin>>s;
    l=s.size();
    ans=l-2;
    cout<<s[0]<<ans<<s[l-1];
    return 0;    
} 


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;
ll gcd(ll a, ll b)
{ return b ? gcd(b, a % b) : a;}

int main()
{
	int n;
	cin >> n;
	vector<int> A(n);
	rep(i, n)cin >> A[i];
	vector<int> l_gcd(n);
	vector<int> r_gcd(n);
	l_gcd[0] = A[0];
	r_gcd[n - 1] = A[n - 1];
	rep(i, n - 1)
	{
		l_gcd[i + 1] = gcd(l_gcd[i], A[i + 1]);
		r_gcd[n - 1 - (i + 1)] = gcd(r_gcd[n - 1 - i], A[n - 1 - (i + 1)]);
	}

	int ans = 1;
	rep(i, n)
	{
		int gcd_tot;
		if(i==0)
		{
			gcd_tot = r_gcd[1];
		}
		else if (i==n-1)
		{
			gcd_tot = l_gcd[n - 2];
		}
		else
		{
			gcd_tot = gcd(l_gcd[i - 1], r_gcd[i + 1]);
		}
		ans = max(ans, gcd_tot);
	}
	co(ans);
	return 0;
}


Measured memory_bytes: 1408
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]

for i in range(3):
	for j in range(3):
		for k in range(N):
			if A[i][j] == B[k]:
				A[i][j] = 0

cnt = 0
for i in range(3):
	S = 0
	for j in range(3):
		S += A[i][j]
	if S == 0:
		cnt = 1
		
for j in range(3):
	S = 0
	for i in range(3):
		S += A[i][j]
	if S == 0:
		cnt = 1
		
S = A[0][0] + A[1][1] + A[2][2]
if S == 0:
	cnt = 1
	
S = A[0][2] + A[1][1] + A[2][0]
if S == 0:
	cnt = 1
	
if cnt == 1:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t int64;
typedef int64_t ll;

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

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

using namespace std;


class C {
	int n;
	vector<int> a;
public:
	C()
	{
		cin >> n;
		a.resize(n);
		REP(i, n)
			cin >> a[i];
	}

	int gcd(int a, int b)
	{
		return b ? gcd(b, a % b) : a;
	}

	ll lcm(int a, int b)
	{
		return (ll)a * b / gcd(a, b);
	}

	void solve()
	{
		//ll m{ a[0] };
		//REP(i, n - 1)
		//	m = lcm(m, a[i + 1]);

		//ll ans{ 0 };
		//REP(i, n)
		//	ans += (m - 1) % a[i];

		//cout << ans << endl;

		cout << accumulate(ALL(a), 0) - SZ(a) << endl;
	}
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    int N;
    cin >> N;
    vector<ll> X(N), Y(N);

    for(int i = 0; i < N; i++){
      cin >> X[i] >> Y[i];
    }

    bool same_odd = true;
    int  odd = abs(X[0] + Y[0]) % 2;
    for(int i = 1; i < N; i++){
      if(abs(X[i]+Y[i])%2 != odd){
        same_odd = false;
        break;
      }
    }

    vector<ll> U(N), V(N);
    for(int i = 0; i < N; i++){
      U[i] = X[i] + Y[i];
      V[i] = X[i] - Y[i];
      if(odd == 0){//最後にRする
        U[i]--;
        V[i]--;
      }
    }

    int m = 31;

    vector<ll> d(m);
    d[0] = 1;
    for(int i = 0; i < m-1; i++){
      d[i+1] = d[i]*2;
    }

    vector<vector<ll>> d_u(N), d_v(N);
    
    for(int i = 0; i < N; i++){
      
      ll tmp_u = 0;
      for(int j = m-1; j >= 0; j--){
        if(tmp_u < U[i]){
          tmp_u += d[j];
          d_u[i].push_back(1);
        }else{
          tmp_u -= d[j];
          d_u[i].push_back(-1);
        }
      }

      ll tmp_v = 0;
      for(int j = m-1; j >= 0; j--){
        if(tmp_v < V[i]){
          tmp_v += d[j];
          d_v[i].push_back(1);
        }else{
          tmp_v -= d[j];
          d_v[i].push_back(-1);
        }
      }
    }

    vector<string> ans(N);

    for(int i = 0; i < N; i++){
    
      for(int j = m-1; j >= 0; j--){
        if      (d_u[i][j] == 1  && d_v[i][j]==  1){
          ans[i] += "R";
        }else if(d_u[i][j] == 1  && d_v[i][j]== -1){
          ans[i] += "U";
        }else if(d_u[i][j] == -1 && d_v[i][j]==  1){
          ans[i] += "D";
        }else{
          ans[i] += "L";
        }
      
      }
      if(odd == 0){
        ans[i] += "R";
      }
    }

    if(odd == 0){
      m++;
      d.push_back(1);
    }
    if( same_odd){
      cout << m << endl;
      for(int i = 0; i < m; i++){
        cout << d[i] << " ";
      }
      cout << endl;
      
      for(int i = 0; i < N; i++){
        cout << ans[i] << endl;
      }
    }else{
      cout << -1 << endl;
    }

    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << x << endl;
#else 
    #define dbg(x)
#endif

#define int long long
#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int add(int a, int b) {
    a += b;
    if (a >= MOD)
        return a - MOD;
    return a;
} 

int mult(int a, int b) {
    return a * b % MOD;
}

int dp[41][1 << 18][2];

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
       
    int n, x, y, z;
    cin >> n >> x >> y >> z;
    int full = (1 << 18) - 1;
    dp[0][1][0] = 1;
    fi(1, n + 1) {
        rep(d, 1, 11) {
            rep(from, 1, 1 << 18) {
                int to = ((from << d) & full)| 1;
                bool done = (to & (1 << z)) && (to & (1 << (z + y))) && (to & (1 << (z + y + x)));
                if (done) {
                    dp[i][to][1] = add(dp[i][to][1], add(dp[i - 1][from][0], dp[i - 1][from][1]));
                } else {
                    dp[i][to][0] = add(dp[i][to][0], dp[i - 1][from][0]);
                    dp[i][to][1] = add(dp[i][to][1], dp[i - 1][from][1]);
                }
            }
        }
    } 
    int ans = 0;
    rep(mask, 0, 1 << 18) {
        ans = add(ans, dp[n][mask][1]);
    }
    cout << ans << '\n';

}

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

int main(){
  int n;
  cin >> n;
  vector<double> v(n);
  double ave=0;
  rep(i, n){
    cin >> v.at(i);
    ave+= v.at(i);
  }
  ave /= n;
  ave = round(ave);
  double sum=0;
  rep(i, n){
    sum += (v.at(i)-ave) * (v.at(i)-ave);
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
using namespace std;

int main(){
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    int A[] = {a, b, c, d, e};
    int min = A[0];
    int max = A[0];
    for(int i=2; i<5; i++){
        if(min>A[i]){
            min = A[i];
        }else if(max<A[i]){
            max = A[i];
        }
    }
    int ans = max-min;
    if(ans<=k){
        cout << "Yay!";
    }else{
        cout << ":(";
    }
}

Measured memory_bytes: 256
h = 0
w = 0
dataset = []

while True:
    h, w = map(int, input().split())
    if (h > 0 and h <= 300) and (w > 0 and w <= 300):
        listed = []
        listed.append(h)
        listed.append(w)
        dataset.append(listed)
    else:
        break

for listed in dataset:
    h = listed[0]
    w = listed[1]

    for i in range(h):
        for j in range(w):
            print("#", end="")
        print()
    print()

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

using namespace std;

const long long MOD = 1000000007;
const long long MAX = 2000000;

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}


int main() {
    int N;
    cin>>N;
    string s[N];
    int t[N];
    for(int i=0;i<N;i++){
        cin>>s[i]>>t[i];
    }
    string X;
    cin>>X;
    //reverse(s,s+N);
    //reverse(t,t+N);
    int sum=0;
    bool flag=false;
    for(int i=0;i<N;i++){
        if(flag){
            sum+=t[i];
        }
        if(X==s[i]){
            flag=true;
        }
    }
    cout<<sum<<endl;



}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        var s = Console.ReadLine();
        long[] ans = new long[s.Length + 1];
        long[] l = new long[s.Length + 1];
        //if (s[0] == '<') l[0] = 1;
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == '<') l[i+1] = l[i] + 1;
        }

        long[] r = new long[s.Length + 1];
        //if (s[s.Length - 1] == '>') r[s.Length] = 1;
        for (int i = s.Length - 1; i >= 0; i--)
        {
            if (s[i] == '>') r[i] = r[i + 1] + 1;
        }

        for (int i = 0; i < ans.Length; i++)
        {
            ans[i] = Math.Max(l[i], r[i]);
        }

        // 出力
        Console.WriteLine(ans.Sum());
    }
}



Measured memory_bytes: 40180
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten53 300005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;

//stack<char> stk;
//set<ll> sll;
//set<pair<ll,ll>> spll;
//map<string,ll> mp;
//map<ll,ll> mp;
//deque<ll> deq;
vector<ll> vll,v1,v2,v3;
ll num[ten52],num2[ten52];
//priority_queue<pair<ll,ll>> pq;          //decreasing


int main(void)
{
    ll m=0,n,i=0,j,k=0;
    string s="";
    cin>>n;
    k=1;
    while(n>=m+k)
    {
        m+=k;
        k*=26;
        i++;
    }
    n-=m;
    while(n>0||i>0)
    {
        s+='a'+(n%26);
        n/=26;
        i--;
    }
    reverse(all(s));
    cout<<s;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<cstdio>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}

void solve(){
	int a,b;
	cin>>a>>b;
	b=min(a,2*b);
	cout<<a-b<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
bool possible(int s,int a[],int k,int n)
{
    int i;
    for(i=0;i<n;i++)
    {
        if(a[i]<=s)
        continue;
        k-=(a[i]/s);
        if(a[i]%s==0)
        k++;
    }
    return (k>=0);
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin>>n>>k;
    int a[n],i;
    for(i=0;i<n;i++)
    cin>>a[i];
    int l=1,r=1000000000,ans=1000000000;
    while(l<=r)
    {
        int mid=(l+r)/2;
        if(possible(mid,a,k,n))
        {
            ans=min(ans,mid);
            r=mid-1;
        }
        else
        l=mid+1;
    }
    cout<<ans<<endl;
    return 0;
}


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

#define mod 1000000007LL
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res + m) * ( a + m) % m;
        a = a * a % m;
        b >>= 1;
    }
    return (res + m) % m;
}

long long mul(long long a, long long b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return ((a + mod) * (b + mod))%mod;
}
long long add(long long a, long long b){
    a += mod;
    b += mod;
    return (a + b)%mod;
}
ll inv(ll x){
    return binpow(x, mod - 2, mod);
}
bool val(ll a, ll b, ll c) {
    if(a == b || a == c || b == c)
        return 0;
    if(a + b > c && b + c > a && c + a > b)
        return 1;
    return 0;
}
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(auto &it: a)
        cin >> it;
    ll ans = 0;
    for (ll i = 0; i < n;i++)
    {
        for (ll j = i + 1; j < n;j++)
        {
            for (ll k = j + 1; k < n;k++)
            {
                if(val(a[i], a[j], a[k]))
                    ans++;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3628
// AtCoder Beginner Contest 064
// B - Traveling AtCoDeer Problem

#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long int ll;


int N;
int min_a, max_a;

int main() {

    int a;

    scanf("%d", &N);
    min_a = 1000;
    max_a = 0;
    for (int i = 0; i < N; i++) {
        scanf("%d", &a);
        min_a = min(min_a, a);
        max_a = max(max_a, a);
    }

    printf("%d\n", max_a - min_a);

    return 0;

}





Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main() {

    string s;
    cin >> s;
    int count = 0;
    int nagasa = s.length();
    int wawa = 0;

    for(int i = 0; i < nagasa; i += 2){
        if(s[i] == 'L' || s[i + 1] == 'R') {
            cout << "No" << endl;
            wawa = 1;
            return 0;
        }
    }
    if(wawa == 0) cout << "Yes" << endl;

}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int N = sc.nextInt();
    long[] A = new long[N];
    long[] B = new long[N];
    for (int i = 0; i < N; i++) {
      A[i] = Long.parseLong(sc.next());
      B[i] = Long.parseLong(sc.next());
    }
    long ans = 0;
    for (int i = N - 1; i >= 0; i--) {
      long cur = A[i] + ans;
      ans += (cur + B[i] - 1) / B[i] * B[i] - cur;
    }
    System.out.println(ans);
  }

}


Measured memory_bytes: 36284
from collections import Counter
n = int(input())
V = list(input().split())
X = []
Y = []
ans = 0

for i in range(0, n-1, 2):
    X.append(V[i])
    Y.append(V[i + 1])

X = Counter(X).most_common()
Y = Counter(Y).most_common()

if X[0][0] != Y[0][0]:
    ans = n - X[0][1] - Y[0][1]
else:
    if n - X[0][1] - Y[0][1] == 0:
        ans = n // 2
    elif n // 2 - X[0][1] == 0 and n // 2 - Y[0][1] !=0:
        ans = n // 2 - Y[0][1]
    elif n // 2 - X[0][1] != 0 and n // 2 - Y[0][1] ==0:
        ans = n // 2 - X[0][1]
    else:
        ans = min(n - X[0][1] - Y[1][1], n - X[1][1] - Y[0][1])
        
print(ans)

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

string A, B;
int N, L[2000], R[2000];

int solve(){
    int pos;
    for(int i=N-1; i>=0; i--){
        if(B[i] == '1'){
            pos = i-N;
            break;
        }
    }
    for(int i=0; i<N; i++){
        if(B[i] == '1') pos = i;
        L[i] = pos;
    }
    for(int i=0; i<N; i++){
        if(B[i] == '1'){
            pos = i+N;
            break;
        }
    }
    for(int i=N-1; i>=0; i--){
        if(B[i] == '1') pos = i;
        R[i] = pos;
    }

    int ans = 1e9;
    for(int k=0; k<N; k++){
        int result = k;
        vector<pair<int, int>> shift;
        for(int i=0; i<N; i++){
            int j = (i+k) % N;
            if(A[i] != B[j]) result++;
            if(A[i] == '1' && i+k < R[i]){
                shift.push_back({i - L[i], R[j] - j});
            }
        }
        if(shift.size()){
            sort(shift.rbegin(), shift.rend());
            int opt = shift[0].first, sec = 0;
            for(int i=0; i<shift.size(); i++){
                if(i>0 && shift[i-1].first != shift[i].first) opt = min(opt, shift[i].first + sec);
                sec = max(sec, shift[i].second);
            }
            opt = min(opt, sec);
            result += 2*opt;
        }
        ans = min(ans, result);
    }
    return ans;
}

int main(){
    cin >> A >> B;
    N = A.size();

    if(count(A.begin(), A.end(), '1') > 0 && count(B.begin(), B.end(), '1') == 0){
        cout << -1 << endl;
        return 0;
    }

    int ans = solve();
    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());
    ans = min(ans, solve());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define maxn 112
#define maxw 112345
#define int long long
using namespace std;

int n,w;
int o[maxn][2];
int dp[maxn][maxw];

signed main(){
	cin >> n >> w;
	for (int i = 0; i < n; ++i)
		cin >> o[i][0] >> o[i][1];

	for (int i = 0; i < n+1; ++i)
		dp[i][0] = 0;
	for (int i = 0; i < w+1; ++i)
		dp[0][i] = 0;

	for (int i = 1; i <= n; ++i){
		for (int j = 1; j <= w; ++j){
			int v = 0;
			if(j >= o[i-1][0]) //se cabe
				v = o[i-1][1] + dp[i-1][j-o[i-1][0]];
			dp[i][j] = max(v,dp[i-1][j]);
		}	
	}

	cout << dp[n][w] << endl;
	return 0;
}

Measured memory_bytes: 90112
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)

def divisions_(n):
    sq = int(math.sqrt(n)+1)
    ss = 30030
    a = [None] * (ss)
    a[0] = 1
    t = 1
    for i in range(2,ss):
        if not a[i] is None:
            continue
        if t * i > ss:
            break
        t *= i
        for j in range(i*2,ss,i):
            a[j] = 1
    a = [i for i in range(t) if a[i] is None]
    d = collections.defaultdict(int)
    for i in a[1:]:
        while n % i == 0:
            n //= i
            d[i] += 1

    for j in range(1,sq//t+2):
        if j > n:
            break
        for ii in a:
            i = t*j+ii
            while n % i == 0:
                n //= i
                d[i] += 1
    r = [1]
    for k, v in d.items():
        for c in r[:]:
            for i in range(1,v+1):
                r.append(c*(k**i))

    return sorted(r)
def divisions(n):
    sq = int(math.sqrt(n)+1)
    d = collections.defaultdict(int)
    while n % 2 == 0:
        n //= 2
        d[2] += 1
    i = 3
    while n > 1 and sq >= i:
        if n % i == 0:
            n //= i
            d[i] += 1
        else:
            i += 2

    if n > 1:
        d[n] += 1

    r = [1]
    for k, v in d.items():
        for c in r[:]:
            for i in range(1,v+1):
                r.append(c*(k**i))

    return sorted(r)

def main():
    n = I()
    ds = divisions(n)
    # print(ds)
    r = 0
    u = set([0])
    mk = ds[0]
    if len(ds) > 1:
        mk = ds[1]
    for k in ds:
        if k < 2:
            continue
        for a in range(1,mk):
            t = k - a
            if t in u:
                continue
            u.add(t)
            if n // t == n % t:
                r += t

    return r


print(main())




Measured memory_bytes: 14492
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<cctype>
using namespace std;


int main() {
	int n;
	cin >> n;
	cout << 180 * (n - 2) << endl;
}

Measured memory_bytes: 256
i = input().split(" ")
a = int(i[0])
b = int(i[1])
c = int(i[2])
d = int(i[3])

negneg = a * c
negpos = a * d
posneg = b * c
pospos = b * d

print(max([negneg,negpos,posneg,pospos]))

Measured memory_bytes: 9184
####### 二項係数 C(n,k) mod pの計算 #######

MOD=10**9+7
FACT=[]
INV=[]

def pow(a,b)
  return 1 if b==0
  return a*pow(a,b-1)%MOD if b%2==1
  return pow(a**2%MOD,b/2)
end

def calc_fact(n)
  FACT[0]=1
  INV[0]=pow(FACT[0],MOD-2)
  for i in 1..n
    FACT[i]=FACT[i-1]*i%MOD
    INV[i]=pow(FACT[i],MOD-2)
  end
end

def com(n,k)
  (FACT[n]*INV[n-k]%MOD)*INV[k]%MOD
end

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


H,W,A,B=gets.split.map(&:to_i)
calc_fact(H+W-2)
ans=0

for i in 1..H-A do
  ans+=com(i+B-2,B-1)*com(H+W-i-B-1,W-B-1)%MOD
end

puts ans%MOD

Measured memory_bytes: 5100
import collections
N = int(input())
A = [int(i) for i in input().split()]

S = [0]
for a in A:
    S.append(S[-1]+a)

C = collections.Counter(S)

ans = 0
for v in C.values():
    if v >= 2:
        ans += v*(v-1)//2
print(ans)


Measured memory_bytes: 41472
#include <bits/stdc++.h>
int N,M,a;
int main(){
    std::cin >> N >> M;
    int k[++N]={},s[N]={1};
    while(M--)std::cin>>a,k[a]=1;
    s[1]=!k[1];
    for(a=2; a<N; a++)s[a] = !k[a]*(s[a-1]+s[a-2])%1000000007;
    std::cout << s[N-1] << '\n';
}

Measured memory_bytes: 1024
def kaibun(sl):
	f = 'Yes'
	for i in range(len(sl)):
		if sl[i] != sl[-1-i]:
			f = 'No'
			break
	return f


s = input()



sl = []
slz = []
slk = []

for i in range(len(s)):
    sl.append(s[i])

for i in range((len(s)-1) // 2):
    slz.append(s[i])


for i in range(((len(s)+3)//2), len(s)+1):
    slk.append(s[i-1])


f = 'Yes'
    
    
if kaibun(sl) == 'No':
	f = 'No'

if kaibun(slz) == 'No':
	f = 'No'

if kaibun(slk) == 'No':
	f = 'No'

print(f)






Measured memory_bytes: 3064
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>

int main(){
  int N, M;
  scanf("%d", &N);
  scanf("%d", &M);
  int neven = M; // Mを超えない最大偶数
  int nodd = M-1; // Mを超えない最大奇数
  if (M%2==1){
    std::swap(nodd, neven);
  }
  for (int i=0; i<(neven+1)/2; i++){
    int start = i+1;
    int width = neven-2*i;
    int end = start+width;
    printf("%d %d\n", start, end);
  }
  for (int i=0; i<(nodd+1)/2; i++){
    int start = i+2+neven;
    int width = nodd-2*i;
    int end = start+width;
    printf("%d %d\n", start, end);
  }
  return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(void){
	int n;
	int i;
	long long X=0, x = 0, ans = 1000000000000000000LL;
	cin >> n;
	vector<long long> a(n);
	for(i=0; i<n; i++){
		cin >> a[i];
		X += a[i];
	}
	for(i =0; i<n; i++){
		x += a[i];
		if(i + 1 < n){
			ans = min(ans, abs(X - 2*x));
		}
	}

	cout << ans;

	cout << '\n';
	return 0;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

void solve(){
	int k;
	string s;
	cin >> k;
	cin >> s;
	if((int)s.size() > k) {
		s = s.substr(0, k);
		s += "...";
	}
	cout << s;
}

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

	solve();
    
    return 0;
}


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

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

	cout << (((n % 2 == 0) && s.substr(0, n / 2) == s.substr(n / 2, n / 2)) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

count = 0
S = []

def action(q):
    global count
    if q % 2 == 0:
        count += 1
        action(q/2)
    else:
        S.append(count)
        count = 0

for i in range(n):
    action(a[i])

print(min(S))

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

int main(void)
{
	LL D;
	cin >> D;
	vector<LL>ten;
	ten.push_back(1);
	for (int i = 0; i <= 18; ++i)ten.push_back(ten.back() * 10);

	std::function<LL(LL, int, int)>f = [&](LL rem, int lev, int tot)
	{
		//基数を得る
		LL base = ten[tot - 1 - lev] - ten[lev];
		if (base <= 0)
		{
			if (rem == 0)return (tot % 2) * 9 + 1LL;
			return 0LL;
		}
		//div 10^lev mod 10 を得る
		LL mod = (rem / ten[lev]) % 10;
		if (rem < 0)
		{
			mod += 10;
			mod %= 10;
		}
		int ma = -mod;
		int mb = ma + 10;
		int za = 10 - abs(ma) - (lev == 0);
		int zb = 10 - abs(mb) - (lev == 0);
		LL ans = f(rem - ma * base, lev + 1, tot);
		ans *= za;
		if (mb < 10)
		{
			LL plus = f(rem - mb * base, lev + 1, tot);
			plus *= zb;
			ans += plus;
		}
		return ans;
	};

	LL ans = 0;
	for (int L = 2; L <= 18; ++L)
	{
		ans += f(D, 0, L);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<ll> S(N);
    ll sum = 0;
    for(int i=0; i<N; i++) {
        cin >> S[i];
        sum += S[i];
    }
    sort(S.begin(), S.end());

    for(int i=0; i<N; i++) {
        if(sum % 10 == 0 && S[i] % 10 != 0) {
            sum -= S[i];
        }
        if(sum % 10 != 0) {
            break;
        }
    }
    if(sum % 10 == 0) sum = 0;
    cout << sum << endl;

}

Measured memory_bytes: 3580
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
        }
        int max = l[0];
        int sum = l[0];
        for (int i = 1; i < n; i++) {
            if (max < l[i])
                max = l[i];
            sum += l[i];
        }
        if (sum - max - max > 0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
constexpr const int INF=1<<30,MOD=1000000007;constexpr const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;template<class...T>void _print(osd&a,T&&...t){}
#define cerr cer_
#endif
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}template<class T>istream&operator>(istream&i,T&t){return i>>t;}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<t<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}template<class...T>void dprint(T&&...t){_print(cerr,t...);}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<p.F<' '<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>p.F>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>queue<T>&operator<<(queue<T>&q,const T&t){q.push(t);return q;}template<class T>queue<T>&operator<<(T&t,queue<T>&q){t=q.front();q.pop();return q;}
template<class T>deque<T>&operator>>(const T&t,deque<T>&q){q.push_front(t);return q;}template<class T>deque<T>&operator<<(T&t,deque<T>&q){t=q.front();q.pop_front();return q;}
template<class T>deque<T>&operator<<(deque<T>&q,const T&t){q.push_back(t);return q;}template<class T>deque<T>&operator>>(deque<T>&q,T&t){t=q.back(t);q.pop_back();return q;}
template<class T>stack<T>&operator<<(stack<T>&s,const T&t){s.push(t);return s;}template<class T>stack<T>&operator>>(stack<T>&s,T&t){t=s.top();s.pop();return s;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    string s;
    cin>s;
    int cnt=0;
    for(auto c:s)if(c=='o')cnt++;
    YES(15 - s.size() + cnt > 7);
    return 0;
}


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

using namespace std;

int main(void){
    int n,k;

    cin >> n;
    char s[n], ans[n];
    cin >> s;
    cin >> k;

    for(int i = 0; i < n; i++){
        if(s[i] != s[k-1]){
            strcpy(ans+i, "*");
        }
        else{
            strcpy(ans+i, s+i);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(2e5)+5;




int main()
{
    idfc;

    vector<int> vv;
    int n,k;
    cin>>n>>k;
    int e;
    int i;

    for(i=0;i<n;i++)
    {
        cin>>e;
        vv.pb(e);
    }
    sort(vv.begin(),vv.end());
    ll ans=0;

    for(i=0;i<k;i++)ans+=vv[i];
    cout<<ans;


    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    long int n;
    cin >> n;
    int a = floor(sqrt(n));
    if(n == a*a) {
        cout<<n;
        return 0;
    }
    else{
        for(long int i=0;i<n;i++){
            n -= 1;
            a = floor(sqrt(n));
            if(n == a*a){
                cout<<n;
                break;
            }
        }
    }
    return  0;
}


Measured memory_bytes: 256
n=int(input())
d=[]
for i in range(0,n):
   a=[int(x) for x in input().split()] 
   d.append(a)
dis=0


for i in range(n):
    for j in range(n):
        dis+=((d[i][0]-d[j][0])**2+(d[i][1]-d[j][1])**2)**0.5
print(dis/n)


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

int main(){
  string s,t;
  cin >> s >> t;
  int ans = 0;
  rep(i,3){
    if(s[i] == t[i]) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
using namespace std;
#define Fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr)
#define f(i, n) for (long long int i = 0; i < n; i++)
#define ll long long int
#define fo(i, a, b) for (long long int i = a; i <= b; i++)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)
#define vi vector<int>
#define vl vector<long long int>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long int>>
#define mii map<int, int>
#define umii unordered_map<int, int>
#define newl cout<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e9 + 7;
const ll modc = 998244353;
#define MAX 100002

ll maxi(ll a,ll b){
	if(a>=b)return a;
	return b;
}

ll mini(ll a,ll b){
	if(a>=b)return b;
	return a;
}


int main(){
	Fio;
	ll n;
	cin>>n;
	ll A[n+1],B[n+1],C[n+1];
	fo(i,1,n)cin>>A[i]>>B[i]>>C[i];
	ll dp[n+1][3];
	fo(i,0,n)fo(j,0,2)dp[i][j] = 0;
	dp[1][0] = A[1],dp[1][1] = B[1],dp[1][2] = C[1];
	fo(i,2,n){
		dp[i][0] = A[i]+maxi(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = B[i]+maxi(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = C[i]+maxi(dp[i-1][0],dp[i-1][1]);
	}
	cout<<maxi(dp[n][0],maxi(dp[n][1],dp[n][2]));
	return 0;
}

Measured memory_bytes: 8336
#include<cstdio>
const int N=1e5+10;
int n,a[N];
long long f[N],sum;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	for(int i=1;i<n;i+=2)sum-=a[i]*2;
	f[n]=sum;
	for(int i=n-1;i>=1;i--)f[i]=a[i]*2-f[i+1];
	for(int i=1;i<=n;i++)
		printf("%d ",f[i]);
	return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

template < class T >
class SegmentTree {
    // 0-indexed Segment Tree
    long long n; // 葉の数
    vector<T> data;  // データを格納する配列
    T def;  // 初期値（単位元）
    function<T(T, T)> operation;  // 区間クエリで使う処理
    function<T(T, T)> update;  // 点更新で使う処理

    // 区間 [a, b) に対する query !!!!!
    T _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return def;
        if (a <= l && r <= b) return data[k];  // a,l,r,bの順で含まれる
        else {
            T c1 = _query(a, b, 2*k+1, l, (l+r)>>1);
            T c2 = _query(a, b, 2*k+2, (l+r)>>1, r);
            return operation(c1, c2);
        }
    }

public:
    // _n: 葉の要素の数, _def: 初期値（単位元）, _operation: クエリの関数, _update: 更新用の関数
    SegmentTree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update)
        : n(_n), def(_def), operation(_operation), update(_update) {
            n = 1;
            while (n < _n) n<<=1;
            data = vector<T>(2*n-1, def);
        }
    
    void change(int i, T x) {
        i += n - 1;
        data[i] = update(data[i], x);
        while (i>0) {
            i = (i-1)>>1;
            data[i] = operation(data[i*2+1], data[i*2+2]);
        }
    }

    // 区間 [a, b) に対する query !!!!!
    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    V<int> h(n), a(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    for (int i = 0; i < n; i++) cin >> a[i];
    SegmentTree<ll> seg(n, 0,
        [&](ll i, ll j) {return max(i, j);},
        [&](ll i, ll j) {return j;});
    V<int> ord(n); iota(ALL(ord), 0);
    sort(ALL(ord), [&](int i, int j){return h[i] < h[j];});
    for (int i: ord) {
        seg.change(i, seg.query(0, i) + a[i]);
    }
    cout << seg.query(0, n) << '\n';
    return 0;
}


Measured memory_bytes: 9784
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  ll N,Y ;
  cin >> N >> Y ;
  rep(i,N+1){
    rep(j,N+1){
      if(Y == 10000*i+5000*j+1000*(N-i-j) && N-i-j >=0){
        cout << i <<" "<< j <<" " << N-i-j << endl;
        return 0 ;
      }
    }
  }
  cout << -1 <<" "<< -1 <<" "<< -1 << endl;
}
      


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

N = int(input())
tree = [[] for _ in range(N)]
for i in range(N-1):
    a, b, c = map(int, input().split())
    tree[a-1].append([b-1, c])
    tree[b-1].append([a-1, c])
Q, K = map(int, input().split())

dist = [-1] * N
def dfs(v, total_cost):
    # v：頂点, total_cost：今までかかったコストの合計
    dist[v] = total_cost
    for v_next, cost in tree[v]:
        if dist[v_next] >= 0:
            continue
            # v_nextが訪問済みならスキップ
        dfs(v_next, total_cost+cost)

dfs(K-1, 0)

for i in range(Q):
    x, y = map(int, input().split())
    print(dist[x-1] + dist[y-1])


Measured memory_bytes: 139228
/*
 *  author: chw0501
 *  created: 15.04.2020 11:42:18(UTC)
*/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const ll MOD=1000000007ll;
ll n,k;
ll arr[101];
//dp[i][j]: j번째 사람까지 사용한 사탕 개수 i, 그럴 가짓수 %MOD
ll dp[100010][110];
//sum[i][j]: dp[0][j] ~ dp[i-1][j]까지의 합
ll sum[100010][110];
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		scanf("%lld",arr+i);
	}
	dp[0][0]=1;
	for(int i=0;i<=k;i++){
		sum[i+1][0]=sum[i][0]+dp[i][0];
	}
	for(int j=0;j<n;j++){
		for(int i=0;i<=k;i++){
			ll x=max(i-arr[j],0ll);
			dp[i][j+1]=(sum[i+1][j]-sum[x][j]+MOD)%MOD;
			sum[i+1][j+1]=(sum[i][j+1]+dp[i][j+1])%MOD;
		}
	}
	cout<<dp[k][n];
	return 0;
}

Measured memory_bytes: 172160
//Postal Code
#include <iostream>
using namespace std;

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

}

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

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

    if (str == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (str == "Cloudy") {
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256