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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i=0; i<N; i++){
    cin >> L.at(i);
  }
  
  int D=0, count=1;
  for (int i=0; i<N; i++){
    D += L.at(i);
    if (D<=X) {
      count++;
    }
    else {
      break;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "

int main()
{
    int n, m, x; cin >> n >> m >> x;
    VI c(n);
    VVI a(n, VI(m));
    rep(i, n) {
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }
    int ans = (1 << 30);
    

    for (int bit = 0; bit < (1<<n); ++bit) {
        VI sum(m);
        int ansi = 0;
        rep(i, n) {
            if (bit & (1<<i)) {
                rep(j, m) {
                    sum[j] += a[i][j];
                }
                ansi += c[i];
            }
        };
        bool f = true;
        rep(j, m) if (sum[j] < x) {
            f = false;
            break;
        };
        if (f) ans = min(ans, ansi);
    }
    if (ans == (1 << 30)) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    A = list(map(int, input().split()))
    adict = {}
    for a in A:
        if a in adict.keys():
            adict[a] += 1
        else:
            adict[a] = 1
    # print(adict)
    sum = 0
    for key, v in adict.items():
        sum += key*v
    # print(sum)
    Q = int(input())
    for i in range(Q):
        B, C = map(int, input().split())
        keys_ = adict.keys()
        if B in keys_ and C in keys_:
            sum = sum - B*adict[B] + C*adict[B]
            adict[C] += adict[B]
            adict[B] = 0
        elif B in keys_:
            sum = sum - B*adict[B] + C*adict[B]
            adict[C] = adict[B]
            adict[B] = 0
        print(sum)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 20608
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
h_list = input().split()
h_list = [int(h) for h in h_list]

count = 0
result_dict = {}

for i in range(n):
    key = (i+1) + h_list[i]
    value = result_dict.get(key, 0)
    result_dict[key] = value + 1

for j in range(n):
    key = (j+1) - h_list[j]
    count += result_dict.get(key, 0)

print(count)


Measured memory_bytes: 40308
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define ull unsigned long long
#define EPS 1e-8
using namespace std;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
const double pi = acos(-1.0);
int read()
{
	int ret=0;char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	for(;ch>='0'&&ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret;
}
int n;
int main()
{
 	#ifdef TEST
	 	freopen("input.txt","r",stdin);
	#endif
	cin>>n;
	if(n%10==9||n/10==9)
	{
		puts("Yes");
		return 0;
	}
	puts("No");
	return 0;
}



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

n = int(input())
S = [int(input()) for _ in range(n)]
S.sort()
if sum(S) % 10 != 0:
    print(sum(S))
    exit()
for s in S:
    if s % 10 != 0:
        print(sum(S) - s)
        exit()
print(0)


Measured memory_bytes: 2940
n = gets.to_i
s = {}
for i in 0...n do
  ss = gets.chomp
  if s.include?(ss)
    s[ss] += 1
  else
    s[ss] = 1
  end
end
m = gets.to_i
t = {}
for i in 0...m do
  tt = gets.chomp
  if t.include?(tt)
    t[tt] += 1
  else
    t[tt] = 1
  end
end
max_x = 0
s.each do |k, v|
  x = v - t[k].to_i
  max_x = x if max_x < x
end
puts max_x


Measured memory_bytes: 1788
($t[2],$t[1])=glob<>;
@l=map{[glob<>]}(0..2);
@p=sort{$$b[1]<=>$$a[1]}map{$c=$_;map{[$c,$_]}@{$l[$c]}}(2,1,0);
$a=$t[1]+$t[2];
for(;0<$a;$i++){
  ($e,$f)=@{$p[$i]};
  $e?($e==1)&&($t[1]?$t[1]--:next):($t[2]?$t[2]--:next);
  $d+=$f;$a--;
}
print$d

Measured memory_bytes: 112004
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N){
  ll ans = 0;
  cout << N*(N-1)/2 << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
W, H, N = gets.split.map(&:to_i)
xyas = N.times.map { gets.split.map(&:to_i) }
xmin = 0
xmax = W
ymin = 0
ymax = H
xyas.each do |(x, y, a)|
  case a
  when 1
    xmin = x if x > xmin
  when 2
    xmax = x if x < xmax
  when 3
    ymin = y if y > ymin
  when 4
    ymax = y if y < ymax
  end
end
ans = [xmax - xmin, 0].max * [ymax - ymin, 0].max
puts ans


Measured memory_bytes: 1916
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n;
    while(cin >> n){
        int a = 0;
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                for(int k=0;k<10;k++){
                    for(int l=0;l<10;l++){
                        int x = i + j + k + l;
                        if(n==x){
                            a++;
                        }
                    }
                }
            }
        }
        cout << a << endl;
    }
}

Measured memory_bytes: 0
md = 1000000007
n,m = list(map(int,input().split()))
broken = [0 for i in range(n+1)]
dp=[0 for i in range(n+1)]
dp[0] = 1
for i in range(m):
	broken[int(input())]=1
# print(brok	en)
for j in range(1,n+1):
	if(broken[n-j]==1):
		continue
	if(j==1):
		dp[j]=1
	else:
		dp[j]=(dp[j-1]+dp[j-2])%md
# print(dp)
print(dp[n]%md)

Measured memory_bytes: 7832
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int N; double D[303][303][303];

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

	for (int i=0;i<=N;i++) for (int j=0;i+j<=N;j++) for (int k=0;i+j+k<=N;k++){
		if (i == 0 && j == 0 && k == 0) continue;
		double &r = D[k][j][i];
		r = N;
		if (k) r += D[k-1][j][i] * k;
		if (j) r += D[k+1][j-1][i] * j;
		if (i) r += D[k][j+1][i-1] * i;
		r /= i + j + k;
	}
	printf ("%.12lf\n",D[c[1]][c[2]][c[3]]);

	return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	int n;

	cin >> n;

	long long ans = 0;
	for(int i = 1; i <= n; i++){
		if(i % 3 == 0 || i % 5 == 0) continue;

		ans += i;
	}

	cout << ans << "\n";

	return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll k;
    string s;
    cin >> k >> s;
    if(s.size() <= k){
        cout << s << endl;
    }else{
        for(i = 0;i < k;++i){
            cout << s.at(i);
        }
        for(i = 0;i < 3;++i){
            cout << '.';
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3640
import sys
input = sys.stdin.readline

def main():
    n = int(input())

    stick = list(map(int, input().split()))

    total = sum(stick)
    mid = total // 2

    cum = 0
    midi = 0
    for i, block in enumerate(stick):
        cum += block
        if cum >= mid:
            midi = i
            break

    l1 = cum
    r1 = total - l1
    diff1 = abs(l1 - r1)
    
    l2 = l1 - stick[midi]
    r2 = r1 + stick[midi]
    diff2 = abs(l2 - r2)
    
    print(min(diff1, diff2))

main()

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

int main() {
    int T;
    string input;

    while(getline(cin, input)) {
        stringstream temp(input);

        int number;
        vector<int> vec;
        while(temp>>number) vec.push_back(number);

        sort( vec.rbegin(), vec.rend() );

        int size=vec.size();
        for(int i=0; i<size-1; i++) cout<<vec[i] <<" ";

        cout << vec[size-1] <<"\n";
    }
}

Measured memory_bytes: 3152
def cmb(n, r, mod):
	if (r < 0) or (n < r):
		return 0
	r = min(r, n-r)
	return fact[n]*factinv[r]*factinv[n-r]%mod


mod = 10**9+7
N = 10**6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N+1):
	fact.append((fact[-1]*i)%mod)
	inv.append((-inv[mod%i]*(mod//i))%mod)
	factinv.append((factinv[-1]*inv[-1])%mod)

n, k = map(int,input().split())
ans = 0

for i in range(0, min(n, k+1)):
	#0がi個
	ans = (ans + cmb(n, i, mod) * cmb(n-1, i, mod)) % mod
print(ans)

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


#define mod 1000000007
#define ull unsigned long long int
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return true; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

ll ncr(int n, int k)  
{  
    if(k>n)return 0;
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
#define  deb(x)       cout << '>' << #x << ':' << x << endl;

void  solve()
{
    
    int n;
    cin>>n;
    std::vector<int> v;
    fora(i,1,n)v.pb(i);
    int a[n],b[n];
    int p1=0,p2=0;
    forn(i,n)cin>>a[i];
    forn(i,n)cin>>b[i];
    int x=1;
    forn(i,n)
    do{
        int f=0;
        forn(i,n)
        {
            if(a[i]!=v[i])f=1;
        }
        if(!f)
        {
            p1=x;
        }
        f=0;
        forn(i,n)
        {
            if(b[i]!=v[i])f=1;
        }
        if(!f)
        {
            p2=x;
        }
        x++;
    }while(next_permutation(all(v)));
    cout<<abs(p2-p1)<<endl;
    

}

int main()
{
 
    FastIO;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

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


 
int main(){
    string S;
    cin>>S;
    int N=S.size();
    int ans=999;
    for(int i=0;i<=N-3;i++){
        int num=(S[i]-'0')*100+(S[i+1]-'0')*10+S[i+2]-'0';
        ans=min(ans,abs(num-753));
    }
    cout<<ans<<endl;
}

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

int main() {
  ll n;
  int p;
  cin>>n>>p;
  string S; cin>>S;

  ll res=0;
  if (p==2||p==5) {
    rep(i, n) {
      if ((S[i]-'0')%p==0) res+=i+1;
    }
  }
  else {
    ll sum=0;
    ll digit=1;
    map<int, int> X;
    X[0]++;
    rep(i, n) {
      sum=(sum+(S[n-1-i]-'0')*digit)%p;
      res+=X[sum];
      digit=(digit*10)%p;
      X[sum]++;
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 900
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int long long i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int main(){

    ll x,y;
    ll ans=0;
    cin>>x>>y;
    ll i=0;
    ll xx=x;
    while(xx<=y){
        ans++;
        i++;
        xx=x*pow(2,i);
    }
    
    
    cout<<ans<<endl;
    
    
    return 0;
}

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

int main() {
  int n, l;
  cin>>n>>l;

  int a = 0;
  for (int i=1; i<=n; i++) {
    a += l + i - 1;
  }
  int first = l;
  int last = l + n - 1;
  if (first <= 0 && last >= 0) {
    cout<<a<<endl;
  } else if (last < 0) {
    cout<<a - last<<endl;
  } else {
    cout<<a - first<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;
int main(){
  string s="abcdefghijklmnopqrstuvwxyz";
  string t;
  char aa;
  cin>>t;
  for(int i=0;i<t.size();i++){
    for(int j=0;j<s.size();j++){
      if(t[i]==s[j])
        s[j]=' ';
    }
  }
  bool ans=false;
  for(int i=0;i<s.size();i++){
    if(s[i]!=' '){
      aa=s[i];
      ans=true;
      break;
    }
  }
  if(ans)
    cout<<aa<<endl;
  else
    cout<<"None"<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

int main()
{
    std::vector<std::string> list = {
        "S 1"
      , "S 2"
      , "S 3"
      , "S 4"
      , "S 5"
      , "S 6"
      , "S 7"
      , "S 8"
      , "S 9"
      , "S 10"
      , "S 11"
      , "S 12"
      , "S 13"
      , "H 1"
      , "H 2"
      , "H 3"
      , "H 4"
      , "H 5"
      , "H 6"
      , "H 7"
      , "H 8"
      , "H 9"
      , "H 10"
      , "H 11"
      , "H 12"
      , "H 13"
      , "C 1"
      , "C 2"
      , "C 3"
      , "C 4"
      , "C 5"
      , "C 6"
      , "C 7"
      , "C 8"
      , "C 9"
      , "C 10"
      , "C 11"
      , "C 12"
      , "C 13"
      , "D 1"
      , "D 2"
      , "D 3"
      , "D 4"
      , "D 5"
      , "D 6"
      , "D 7"
      , "D 8"
      , "D 9"
      , "D 10"
      , "D 11"
      , "D 12"
      , "D 13"
    };

    int n;
    std::cin >> n;

    char suit;
    int rank;
    std::vector<std::string> inputs;
    inputs.reserve(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> suit >> rank;
        if (rank < 10) {
            char buf[4];
            snprintf(buf, 4, "%c %d", suit, rank);
            inputs.push_back(std::string(buf));
        } else {
            char buf[5];
            snprintf(buf, 5, "%c %d", suit, rank);
            inputs.push_back(std::string(buf));
        }
    }

    for (const std::string& card : list) {
       if (std::find(inputs.begin(), inputs.end(), card) == inputs.end()) {
           std::cout << card << std::endl;
       }
    }

    return 0;
}


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



int main() {
  vector<int> vec(102);
  int x, n;
  cin >> x >> n;
  rep(i, n){
    int p;
    cin >> p;
    vec.at(p) = 1;
  }
  pair<int, int> ans(99999, -1);
  for(int i=0; i<102; ++i){
    if(vec[i]==1) continue;
    int dif = abs(x-i);
    ans = min(ans, pair<int, int>(dif, i));
  }
  cout << ans.second << endl; 
  return 0;
}

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

int main(){
  int K, S;
  cin >> K >> S;
  int ans=0;
  for(int i=0; i<=K; i++){
    for(int j=0; j<=K; j++){
      if(0<=S-i-j && S-i-j<=K){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));

    rep(i, n-1) {
        if (a[i+1]<=a[i]) {
            cout << "NO" << endl;
            return 0;
        }
    } 
    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 1024
using System;

namespace abc153_c
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' '); //モンスターの体力と必殺技の種類数
            int H = int.Parse(input[0]);
            int N = int.Parse(input[1]);

            string[] input2 = Console.ReadLine().Split(' '); //必殺技の威力
            int[] A = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = Convert.ToInt32(input2[i]);
            }

            Mons mons = new Mons();

            for (int j = 0; j < N; j++)
            {
                mons.hp = H;
                mons.damage = A[j];
                H = mons.Battle();

            }

            if(mons.hp > 0)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
            Console.ReadLine();
        }
    }

    class Mons
    {
        public int hp;
        public int damage;
        public int Battle()
        {
            hp -= damage;
            return hp;
        }

    }
}



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

int main(){
  int N; vector<int64_t> X(200010), sortX(200010);

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

  sort(sortX.begin(), sortX.begin()+N);

  map<int64_t, int64_t> median;

  for(int i=0; i<N; i++){
    if(i < N/2){
      median[sortX[i]] = sortX[N/2];
    } else {
      median[sortX[i]] = sortX[N/2-1];
    }
  }

  for(int i=0; i<N; i++){
    cout << median[X[i]] << endl;
  }
}


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

#define rep(i,n) for(signed i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define print(a) cout<<a<<endl;
#define end cout<<endl;
#define elif else if


int a,b,c,i,j,k,n,m,x,y,z;
str s,t;
vector<signed> v;

signed main(){
  
  int k,a,b;
  cin>>k>>a>>b;
  int bisk=1,my=0;
  if(a>=b-1){
      cout<<(k+bisk);
      return 0;
  }
  rep(i,k){
      int t=k-1-i;
      if(my!=0){
          my--;
          bisk+=b;
      }
      else if(i==k-1){
          bisk++;
      }
      else if(a-bisk>t){
          bisk++;
      }
      else if(bisk>=a){
          bisk-=a;
          my++;
      }
      else bisk++;
      
      //debg(bisk);
  }
  cout<<bisk;
  
  
  return 0;
}

Measured memory_bytes: 256
a = 0
b = 0

N = int(input())
X = list(map(int, input().split()))
avg = sum(X) // N
for tai in X:
  a += (tai - avg) ** 2
for tai in X:
  b += (tai - (avg + 1)) ** 2
if a > b :
  print(b)
else :
  print(a)

Measured memory_bytes: 9112
#include <stdio.h>
#define N 100000
int main(){
  int i,j,n,q,S[N],T[N],cunt = 0,left = 0,right,mid;
  
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&q);
  for(j = 0;j < q;j++){
    scanf("%d",&T[j]);
  }
  right = i;
  for(j = 0;j < q;j++){
    while (left < right){
      mid = (left + right) / 2;
      if(S[mid] == T[j]){
	cunt++;
	break;
      }else if(T[j] < S[mid]){
	right = mid;
      }else{
	left = (mid + 1);
      }
    }
    left = 0;
    right = i;
  }
  printf("%d\n",cunt);
  return 0;
}



Measured memory_bytes: 2324
n, k = map(int, input().split())

j = 0

while k > 2 ** j:
    j += 1

jl = [j]

for i in range(2, n+1):
    p = jl[i - 2]
    if k <= i:
        p = 0
    else:
        while True:
            p -= 1
            if k > i * (2**p):
                p += 1
                break
    jl.append(p)

ans = 0

for j in jl:
    ans += 2**(-j) / n

# print(jl)
print(ans)


Measured memory_bytes: 3860
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int[] d = new int[6];
		int n = scan.nextInt();
		Dice[] dices = new Dice[n];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < 6; j++){
				d[j] = scan.nextInt();
			}
			dices[i] = new Dice(d);
		}

		boolean flag = false;
		boolean ans = true;
		for(int i = 0; i < n - 1; i++){
			for(int j = i + 1; j < n; j++){
				flag = dices[i].equals(dices[j]);
				if(flag == true){
					ans = false;
					break;
				}
			}
		}
		System.out.println(ans? "Yes" : "No");
	}
}

class Dice{
	int[] d_ = new int[6];
	public static final int
		TOP = 0, SOUTH = 1, EAST = 2,
		WEST = 3, NORTH = 4, BOTTOM = 5;

	public Dice(int[] d){
		for(int i = 0; i < 6; i++){
			d_[i] = d[i];
		}
	}

	@Override
	public boolean equals(Object obj){
		boolean result = false;
		Dice diceB = null;
		if(obj instanceof Dice){
			diceB = (Dice) obj;
		}
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 4; j++){
				result = Arrays.equals(this.d_, diceB.d_);
				if(result == true)break;
				diceB.rollEast();
			}
			for(int j = 0; j < 4; j++){
				result = Arrays.equals(this.d_, diceB.d_);
				if(result == true)break;
				diceB.rollSouth();
			}
			result = Arrays.equals(this.d_, diceB.d_);
			if(result == true)break;
			diceB.rollRight();
		}
		return result;
	}

	public void setTop(int num){
		if(num == d_[EAST]){
			this.rollWest();
		} else if(num == d_[WEST]){
			this.rollEast();
		} else if(num == d_[SOUTH]){
			this.rollNorth();
		} else if(num == d_[NORTH]){
			this.rollSouth();
		} else if(num == d_[BOTTOM]){
			this.rollEast();
			this.rollEast();
		}
	}

	public void setSouth(int num){
		if(num == d_[EAST]){
			this.rollRight();
			this.rollRight();
			this.rollRight();
		} else if(num == d_[WEST]){
			this.rollRight();
		} else if(num == d_[NORTH]){
			this.rollRight();
			this.rollRight();
		}
	}

	public int show(int side){
		return d_[side];
	}

	public void rollEast(){
		int work = d_[TOP];
		d_[TOP] = d_[WEST];
		d_[WEST] = d_[BOTTOM];
		d_[BOTTOM] = d_[EAST];
		d_[EAST] = work;
	}

	public void rollWest(){
		int work = d_[TOP];
		d_[TOP] = d_[EAST];
		d_[EAST] = d_[BOTTOM];
		d_[BOTTOM] = d_[WEST];
		d_[WEST] = work;
	}

	public void rollSouth(){
		int work = d_[TOP];
		d_[TOP] = d_[NORTH];
		d_[NORTH] = d_[BOTTOM];
		d_[BOTTOM] = d_[SOUTH];
		d_[SOUTH] = work;
	}

	public void rollNorth(){
		int work = d_[TOP];
		d_[TOP] = d_[SOUTH];
		d_[SOUTH] = d_[BOTTOM];
		d_[BOTTOM] = d_[NORTH];
		d_[NORTH] = work;
	}

	public void rollRight(){
		int work = d_[SOUTH];
		d_[SOUTH] = d_[WEST];
		d_[WEST] = d_[NORTH];
		d_[NORTH] = d_[EAST];
		d_[EAST] = work;
	}
}

Measured memory_bytes: 29276
import java.util.*

fun main(args: Array<String>) {
    val mod = 1000000007
    val (n, k) = readLine()!!.split(' ').map(String::toInt)
    val edge = Array(n) {
        emptyList<Int>().toMutableList()
    }
    for (i in 1 until n) {
        val (a, b) = readLine()!!.split(' ').map(String::toInt)
        edge[a - 1].add(b - 1)
        edge[b - 1].add(a - 1)
    }
    val score = Array(n) { (-n - 1).toLong() }
    // (Point, (dist=1, dist=2))
    val que = LinkedList<Pair<Int, Pair<Long, Long>>>()
    que.add(Pair(0, Pair(0L, 0L)))
    while (que.isNotEmpty()) {
        val (point, pair) = que.remove()!!
        score[point] = k - (pair.first + pair.second)
        var index = 0
        edge[point].forEach {
            if (score[it] < -n) {
                que.add(Pair(it, Pair(1L, pair.first + index)))
                index++
            }
        }
    }
    println(score.reduce { acc, i -> acc * i % mod })
}


Measured memory_bytes: 103628
A, B, C = map(int, input().split())
K = int(input())
i_ans = 0
j_ans = 0
for i in range(0,8):
    B_after = B * (2 ** i)
    if B_after > A:
        i_ans = i
        break
B_after = B * (2 ** i_ans)
for j in range(0,8):
    C_after = C * (2 ** j)
    if C_after > B_after:
        j_ans = j
        break
if i_ans + j_ans <=K:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9136
#include <iostream>
using namespace std;
int main(){
  int H,W;cin>>H>>W;
  int mp[H][W];
  int mp2[H][W];
  for(int i = 0; H > i; i++){
    for(int j = 0; W > j; j++){
      cin>>mp[i][j];
      mp2[i][j] = mp[i][j];
    }
  }
  int ret = 0;
  for(int i = 0; H > i; i++){
    for(int j = 0; W > j; j++){
      if(i == H-1 && j == W-1)continue;
      if(mp[i][j] % 2 == 1){
        ret++;
        mp[i][j]--;
        if(j == W-1){
          mp[i+1][j]++;
        }else{
          mp[i][j+1]++;
        }
      }
    }
  }
  cout << ret << endl;
  for(int i = 0; H > i; i++){
    for(int j = 0; W > j; j++){
      if(i == H-1 && j == W-1)continue;
      if(mp2[i][j] % 2 == 0)continue;
      if(j == W - 1){
        cout << i+1 << " " << j+1 << " " << i+2 << " " << j+1 << endl;
        mp2[i][j]--;
        mp2[i+1][j]++;
      } else {
        cout << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << endl;
        mp2[i][j]--;
        mp2[i][j+1]++;
      }
    }
  }

}

Measured memory_bytes: 4096
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] s = new char[h][w];
		for(int i = 0; i < h; i++) {
			s[i] = sc.next().toCharArray();
		}
		int[][] count = new int[h][w];
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				if(s[i][j]=='#') {
					count[i][j]=-1;
					continue;
				}
				if(j-1>=0&&s[i][j-1]=='#') count[i][j]++;
				if(i-1>=0&&s[i-1][j]=='#') count[i][j]++;
				if(i+1<h&&s[i+1][j]=='#')  count[i][j]++;
				if(j+1<w&&s[i][j+1]=='#') count[i][j]++;
				if(i-1>=0&&j-1>=0&&s[i-1][j-1]=='#') count[i][j]++;
				if(i-1>=0&&j+1<w&&s[i-1][j+1]=='#') count[i][j]++;
				if(i+1<h&&j+1<w&&s[i+1][j+1]=='#') count[i][j]++;
				if(i+1<h&&j-1>=0&&s[i+1][j-1]=='#') count[i][j]++;
			}
		}
		for(int i = 0; i < h; i++) {
			String ans = "";
			for(int j = 0; j < w; j++) {
				if(count[i][j]==-1)ans+='#';
				else ans += count[i][j];
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 39812
program main
implicit None
	integer::n,i,t1,a1,k
	real::a,t
	real,allocatable::h(:)
	
	read *,n
	read *,t,a
	allocate(h(n))
	
	read *,h
	
	h = a - t + h*0.006
	
	k = 1
	do i = 1,n
		if(abs(h(i)) < abs(h(k))) k = i
	enddo
	
	print 101,k
	
101 format(i0)
end program main

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

 int main(){

  int W, H;
  cin>>W>>H;
  
  int x, y, r;
  cin>>x>>y>>r;
  

  if(x - r >=0 && x + r <=W && y-r >=0 && y + r<=H ) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
  }


Measured memory_bytes: 3104
// https://atcoder.jp/contests/abc168/tasks/abc168_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll K;
  string S;
  cin >> K >> S;

  string res = S.substr(0, K) + (S.size() > K ? "..." : "");
  cout << res << "\n";
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define myfill(a, val, type) fill((type *)a, (type *)a+sizeof(a)/sizeof(type), val)
const int INF = 1001001001;

int main() {
	int n, m, R;
	cin >> n >> m >> R;
	vector<int> r(R);
	for (int i = 0; i < R; i++) {
		cin >> r[i];
		r[i]--;
	}
	int d[200][200]; myfill(d, INF, int);
	for (int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		d[a][b] = d[b][a] = c;
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	int ans = INF;
	sort(r.begin(), r.end());
	do {
		int now = 0;
		for (int i = 0; i < r.size()-1; i++) {
			now += d[r[i]][r[i+1]];
		}
		ans = min(ans, now);
	} while (next_permutation(r.begin(), r.end()));
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	string S;
	cin >> S;
	string T;
	rep(i,3) T+=S[i];
	cout << T << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

	cout<<(1-x)<<endl;
	return 0;
}


Measured memory_bytes: 3584
import sys

def solve(n, p):
    count = 0
    for i in range(n - 2):
        if p[i] <= p[i+1] < p[i+2] or p[i] > p[i+1] >= p[i+2]:
             count += 1

    return count


if __name__ == '__main__':

    n = sys.stdin.readline().strip()
    p = map(int, sys.stdin.readline().strip().split(" "))
    print solve(int(n), p)

Measured memory_bytes: 2568
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

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

    int tmp = (N < 10) ? R + 100 * (10 - N) : R;
    cout << tmp << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define sz(x) (int)(x).size()

const int N = 500010;
char s[N];
int n, a[N], f[N];

int main() {
  scanf("%s", s);
  n = strlen(s) + 1;
  cerr << "n : " << n << '\n';  
  f[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--) f[i] = (s[i] == '<' ? 0 : 1 + f[i + 1]);
  for (int i = 0; i < n; i++) cerr << f[i] << '\n';
  cerr << " --- \n";

  a[0] = f[0];
  for (int i = 1; i < n; i++) {
    char sg = s[i - 1];
    if (sg == '>') assert(f[i] <= a[i - 1] - 1);
    a[i] = (sg == '<' ? max(f[i], a[i - 1] + 1) : max(0, min(f[i], a[i - 1] - 1)));
  }

  for (int i = 0; i < n; i++) cerr << a[i] << '\n';

  ll sm = 0;
  for (int i = 0; i < n; i++) sm += a[i];
  printf("%lld\n", sm);
}



Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(ALL(a));
    ll ans =0;
    queue<int> que;
    que.push(a[n-1]);
    rep(i,n-1){
        ans += que.front();
        que.pop();
        que.push(a[n-i-2]);
        que.push(a[n-i-2]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5632
#include <iostream>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

bool dfs(Graph& g, Array& used, ll v,ll pre) {
	used[v] = true;
	for (auto e : g[v]) {
		if (e.to != pre) {
			if (used[e.to]) {
				return false;
			}
			else {
				if (!dfs(g, used, e.to, v)) {
					return false;
				}
			}
		}
	}
	return true;
}

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

	ll n, m;
	cin >> n >> m;

	vector<P> ba;
	REP(i, m) {
		ll a, b;
		cin >> a >> b;
		ba.push_back(make_pair(b,a));
	}
	sort(all(ba));

	ll f=-1;//最後に切った位置
	ll ans = 0;
	for (auto i : ba) {
		ll b = i.first;
		ll a = i.second;
		if (a < f) {
			continue;
		}
		f = b;
		ans++;
	}
	cout << ans << endl;

	return 0;
}

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

int     main() {
        long N;
        cin >>N;
        long NN;
        if (0==N%2) {
                NN=N/2;
                NN *= N-1;
        } else {
                NN=(N-1)/2;
                NN *=N;
        }
        cout <<NN <<endl;
        return 0;
};

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

using namespace std;

int main(){
	string s;
    string t;
  cin >> s;
  if(s.length() == 3){
    t += s[2];
    t += s[1];
    t += s[0];
    cout << t << "\n" <<endl;
  }else{
    cout << s << endl;
  }

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
void primeFactors(ll n,set <ll> &s1)  
{  
    // Prll the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        s1.insert (2);
        n = n/2;  
    }  
  
    // n must be odd at this poll. So we can skip  
    // one element (Note i = i +2)  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, prll i and divide n  
        while (n % i == 0)  
        {  
            s1.insert (i);
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        s1.insert (n);
}
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll a,b;
    cin>>a>>b;
    ll x=__gcd(a,b);
    set <ll> s1;
    primeFactors(x,s1);
    cout<<s1.size()+1<<"\n";
}


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

bool my_sort(const pair<long long int, int> &a, const pair<long long int, int> &b)
{
    return a.first < b.first;
}

int main()
{
    long long int N, M;

    cin >> N >> M;

    vector< pair<long long int, long long int> > cp;

    long long int A, B;
    for (long long int i = 0; i < N; i++)
    {
        cin >> A >> B;
        cp.push_back(make_pair(A, B));
    }

    sort(cp.begin(), cp.end(), my_sort);


    long long int ans = 0;
    for (long long int i = 0;i < N; i++)
    {
        if (M-cp[i].second > 0)
        {
            M-=cp[i].second;
            ans += cp[i].first * cp[i].second;
        }
        else{
            ans += cp[i].first * M;
            break;
        }

    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

int main(){
	long n;
	cin >> n;
	vector<double> x(n);
	for (long i = 0; i < n; i++){
		cin >> x[i];
	}
	vector<double> y(n);
	for (long i = 0; i < n; i++){
		cin >> y[i];
	}
	double one = 0;
	for (long i = 0; i < n; i++){
		one += abs(x[i] - y[i]);
	}
	cout << fixed << one << endl;
	double two = 0;
	for (long i = 0; i < n; i++){
		two += pow(abs(x[i] - y[i]), 2);
	}
	two = sqrt(two);
	cout << fixed << two << endl;
	double three = 0;
	for (long i = 0; i < n; i++){
		three += pow(abs(x[i] - y[i]), 3);
	}
	three = pow(three, 1.0/3.0);
	cout << fixed << three << endl;
	double inf = 0;
	for (long i = 0; i < n; i++){
		if (abs(x[i] - y[i]) > inf) inf = abs(x[i] - y[i]);
	}
	cout << fixed << inf << endl;
	return 0;
}

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

bool check(int dig) {
    int tmp = dig % 10;
    dig /= 10;
    while(dig) {
        if(tmp == dig % 10)
            dig /= 10;
        else return false;
    }
    return true;
}

int main() {
    int dig;
    cin >> dig;
    while(!check(dig)) dig++;
    cout << dig << endl;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
Yen = Y/1000

for i in range(N+1):
    for j in range(N+1-i):
        if i*10 + j*5 + (N-i-j) == Yen:
            print(i, j, N-i-j)
            exit()
print('-1 -1 -1')

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

int main() {
  int k;
  cin>>k;
  long long a[k];
  for (int i=0; i<k; i++) cin>>a[i];

  if (a[k-1] != 2) {
    cout<<-1<<endl;
    return 0;
  }
  long long max_n = 3, min_n = 2;;
  for (int i=k-2; i>=0; i--) {
    min_n = max(a[i], min_n);
    min_n = a[i] * ((min_n - 1) / a[i] + 1);
    long long max_n_group = max_n / a[i];
    if (max_n_group == 0) {
      cout<<-1<<endl;
      return 0;
    }
    if (max_n_group * a[i] + a[i] - 1 < max_n) {
      cout<<-1<<endl;
      return 0;
    }
    max_n = max_n_group * a[i] + a[i] - 1;
  }
  long long x = max_n, y = min_n;
  for (int i=0; i<k; i++) {
    x = x / a[i] * a[i];
    y = y / a[i] * a[i];
  }
  if (x != 2 || y != 2) {
    cout<<-1<<endl;
  } else {
    cout<<min_n<<" "<<max_n<<endl;
  }
}

Measured memory_bytes: 1024
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
int n,k,x[10],len,ans;
bool ban[10];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

bool chk(int x)
{
	while (x)
	{
		int now=x%10;x/=10;
		if (ban[now]) return 0;
	}
	return 1;
}

int main()
{
	n=read();k=read();
	rep(i,1,k) ban[read()]=1;
	int ans=n;
	while (1)
	{
		if (chk(ans)) {printf("%d",ans);break;}
		else ans++;
	}
	return 0;
}


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

int ans=0;
int maxn=0;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<3;i++)
	{
		if(s[i]=='R') ans++;
		else ans=0;
		maxn=max(maxn,ans);
	}
	cout<<maxn;
	return 0;
 } 

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <sstream>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;

int N = 505;
int H, W, a;
int A[505][505];
int M = 0;
vector<vector<int> > ans;

int main() {
    cin >> H >> W;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            A[i][j] = 0;
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> a;
            A[i][j] = a;
        }
    }

    for (int i = 0; i < H - 1; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] % 2 == 1) {
                A[i][j]--;
                A[i+1][j]++;
                M++;
                vector<int> v;
                v.push_back(i+1);
                v.push_back(j+1);
                v.push_back(i+2);
                v.push_back(j+1);
                ans.push_back(v);
            }
        }
    }

    int x = H - 1;
    for (int j = 0; j < W - 1; j++) {
        if (A[x][j] % 2 == 1) {
            A[x][j]--;
            A[x][j+1]++;
            M++;
            vector<int> v;
            v.push_back(x+1);
            v.push_back(j+1);
            v.push_back(x+1);
            v.push_back(j+2);
            ans.push_back(v);
        }
    }

    cout << M << endl;
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << " " << ans[i][3] << endl;
    }

    return 0;
}

Measured memory_bytes: 11568
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int myXOR(int x, int y) 
{ 
   return (x | y) & (~x | ~y); 
}   

int main(){
  ios::sync_with_stdio(false);    
  int n;
  cin >> n;
  int A[n];
  int total=0;
  for (int i=0; i<n; i++){
    cin >> A[i];
    total = myXOR( total,A[i]);
  }
  for (int j=0;j<n;j++){
    cout << -1-myXOR(total,~(A[j])) << " ";
  }  
}


Measured memory_bytes: 3904
#include <algorithm>
#include <cstdint>
#include <cstdio>
#include <queue>
#include <vector>

using namespace std;

#define TREE_SIZE 100000

struct data_t {
  uint64_t index;
  int64_t point;

  data_t(uint64_t index, int64_t point)
  {
    this->index = index;
    this->point = point;
  }

  bool operator<(const data_t &right) const
  {
    return point < right.point;
  }
};

struct vertex_t {
  uint64_t to;
  int64_t weight;

  vertex_t(uint64_t to, int64_t weight)
  {
    this->to = to;
    this->weight = weight;
  }
};

enum status_t { WHITE, GRAY, BLACK };

static vector<data_t> xs;
static vector<data_t> ys;
static vector<vertex_t> tree[TREE_SIZE];

static status_t status[TREE_SIZE];
static int64_t dist[TREE_SIZE];

static uint64_t min_dist(uint32_t num)
{
  for (uint32_t i = 0; i < num; i++) {
    status[i] = WHITE;
    dist[i] = UINT32_MAX;
  }

  uint64_t weights = 0;
  priority_queue<pair<int64_t, uint32_t>> queue;

  queue.push(make_pair(0, 0));

  while (!queue.empty()) {
    uint32_t index = queue.top().second;
    int64_t weight = -queue.top().first;
    queue.pop();

    if (status[index] != BLACK) {
      weights += weight;
      status[index] = BLACK;
      for (uint32_t i = 0; i < tree[index].size(); i++) {
        uint32_t to = tree[index][i].to;
        int64_t weight = tree[index][i].weight;
        if (status[to] != BLACK) {
          queue.push(make_pair(-weight, to));
          status[to] = GRAY;
        }
      }
    }
  }

  return weights;
}

int32_t main()
{
  uint32_t num;
  scanf("%u", &num);

  for (uint32_t i = 0; i < num; i++) {
    uint64_t x, y;
    scanf("%lu %lu", &x, &y);
    xs.push_back(data_t(i, x));
    ys.push_back(data_t(i, y));
  }

  sort(xs.begin(), xs.end());
  sort(ys.begin(), ys.end());

  for (uint32_t i = 0; i < num - 1; i++) {
    tree[xs[i].index].push_back(vertex_t(xs[i + 1].index, abs(xs[i].point - xs[i + 1].point)));
    tree[xs[i + 1].index].push_back(vertex_t(xs[i].index, abs(xs[i].point - xs[i + 1].point)));

    tree[ys[i].index].push_back(vertex_t(ys[i + 1].index, abs(ys[i].point - ys[i + 1].point)));
    tree[ys[i + 1].index].push_back(vertex_t(ys[i].index, abs(ys[i].point - ys[i + 1].point)));
  }

  printf("%ld\n", min_dist(num));

  return 0;
}


Measured memory_bytes: 17764
#include <stdio.h>
#include <string.h>
#define HWMAX 50
int h, w;
char field[HWMAX][HWMAX];
int bfs(void);
int main(void)
{
  int i, j, res, ans = 0;
  scanf("%d %d%*c", &h, &w);
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      field[i][j] = getchar_unlocked();
      if (field[i][j] == '.') ans++;
    }
    getchar_unlocked();
  }
  res = bfs();
  if (res == -1) printf("-1\n");
  else printf("%d\n",ans - res - 1);
}

int bfs(void)
{
  int top = 0, tail = 0, que[h*w][2], dist[h][w];
  memset(dist, -1, sizeof(dist));
  que[tail][0] = 0;
  que[tail++][1] = 0;
  dist[0][0] = 0;
  while (top != tail) {
    int d, px = que[top][0], py = que[top++][1], dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};
    if (px == h - 1 && py == w - 1) break;
    for (d = 0; d < 4; d++) {
      int nx = px + dx[d], ny = py + dy[d];
      if (nx >= 0 && nx < h && ny >= 0 && ny < w && field[nx][ny] == '.' && dist[nx][ny] == -1) {
        que[tail][0] = nx;
        que[tail++][1] = ny;
        dist[nx][ny] = dist[px][py] + 1;
      }
    }
  }
  return dist[h-1][w-1];
}

Measured memory_bytes: 128