akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N;
int b[110];
int ans;

int main() {
	cin >> N;
	if (N == 2) {
		cin >> b[0];
		cout << b[0] * 2 << endl;
		return 0;
	}
	for (int i = 0; i < N - 1; i++) {
		cin >> b[i];
	}
	ans = b[0];
	for (int i = 0; i < N - 2; i++) {
		if (b[i] < b[i + 1]) {
			ans += b[i];
		}
		else {
			ans += b[i + 1];
		}
	}
	ans += b[N - 2];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int n, cnt=0, num=0;
    cin >> n;
    for(int i=1; i<=n; i++){
        int n=i;
        num = 0;
        while(n){
            n /= 10;
            num++;
        }
        if(num % 2 == 1) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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 rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

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

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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
#define leftunique(a) {sort((a).begin(),(a).end());(a).erase(unique((a).begin(),(a).end()),(a).end());}
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; }
static const ll INF = 1LL << 60;
//Write From this Line

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

	// 1-0-1-0-1を作りたい, 1スタートにしたいからnow = 1 ; にする
	vector<int> Nums;
	int now = 1; // 今見ている数
	int cnt = 0; // now がいくつ並んでいるか
	rep(i, n) {
		if(s[i] == char('0' + now)) cnt ++;
		else {
			Nums.push_back(cnt);
			now = 1 - now;
			cnt = 1; // 新しいのをカウントし始めるk
		}
	}
	if(cnt != 0) Nums.push_back(cnt);
	//1-0-1-0-1 つまり要素数は奇数
	//1-0-1-0　みたいに0で終わってたら適当に1つ足す
	if(Nums.size() % 2  == 0) Nums.push_back(0);
	// どこまで見るか
	int Add = 2 * k + 1; 

	// 累積わを作る
	vector<int> sum(Nums.size() + 1);
	for (int i = 0; i < Nums.size(); i ++){
		sum[i + 1] = sum[i] + Nums[i];
	}
	int ans = 0;
	// 1-0-1..の１から始めるので偶数番目だけ見る。
	for (int i = 0; i < Nums.size(); i += 2) {
		int left = i;
		int right = min(i + Add, (int)Nums.size());
		int tmp = sum[right] - sum[left];
		ans = max(tmp,ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(int i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define vinn(n,v) int n;cin>>n;vector<int>v(n);loop(i,0,n)cin>>v[i];
#define vinm(n,m,v) int n,m;cin>>n>>m;vector<int>v(n);loop(i,0,n)cin>>v[i];
#define debug(x) cerr<<#x<<" : "<<x<<endl;
signed main() 
{
    fastio();

    int n,k;
    cin>>n>>k;
    int cnt = 0;
    while(n>0)n/=k,cnt++;
    cout<<cnt;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,dp[1000010][2];
bool is[1000010];
string s;

int ans(int curr , int tag){
    if(curr == n){
        return 0;
    }
    if(dp[curr][tag] != -1){
        return dp[curr][tag];
    }
    int ret = 1000000000,v;
    if(tag == 0){
        v = (s[curr]-'0');
    }else{
        v = (10-(s[curr]-'0')-is[curr]);
        if(is[curr] == 0){
            ret = min(v,11-v);
        }
    }
    ret = min({ret,ans(curr+1,tag) + min(v,11-v) , ans(curr+1,1-tag) + v+1});
    return dp[curr][tag] = ret;
}

int main(){
    memset(dp,-1,sizeof dp);
    cin >> s;
    n = s.size();
    is[n-1] = false;
    for(int i = n-2 ; i >= 0 ; i -= 1){
        is[i] = (is[i+1] | s[i+1] != '0');
    }
    cout << min(ans(0,0),1+ans(0,1)) << endl;
}

Measured memory_bytes: 72580
class card:
    def __init__(self,suit,num,input_index):
        self.suit = suit
        self.num = num
        self.input_index = input_index

def partition(p,r):
    c_pivot=cards[r]
    i=p-1
    for j in range(p,r):
        if(cards[j].num<=c_pivot.num):
            i+=1
            cards[i],cards[j]=cards[j],cards[i]
    cards[i+1],cards[r]=cards[r],cards[i+1]
    return i+1

def quicksort(p,r):
    if(p<r):
        q=partition(p,r)
        quicksort(p,q-1)
        quicksort(q+1,r)

n=int(input())
cards=[]
for i in range(n):
    suit,num=input().split()
    cards.append(card(suit,int(num),i))

quicksort(0,n-1)

stableflag=True
for i in range(1,n):
    if(cards[i-1].num == cards[i].num and cards[i-1].input_index > cards[i].input_index):
        stableflag=False
        break
if(stableflag):
    print("Stable")
else:
    print("Not stable")

for ci in cards:
    print(ci.suit,ci.num)



Measured memory_bytes: 29916
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    char s[100], t[100], tmp[100], ans[100];
    scanf("%s", s);
    scanf("%s", t);
    int ls = strlen(s), lt = strlen(t), cnt = 0;
    int flag = 1;
    for(int i = 0; i < ls; ++i) {
        for(int j = 0; j < lt; ++j) {
            if(t[j] != s[i + j] && s[i + j] != '?') {
                flag = 2;
                break;
            }
        }
        if(flag == 2) flag = 1;
        else {
            for(int k = 0; k < ls; ++k) tmp[k] = s[k];
            for(int k = i; k <= lt + i - 1; ++k) tmp[k] = t[k - i];
            for(int k = 0; k < ls; ++k) {
                if(tmp[k] == '?') ans[k] = 'a';
                else ans[k] = tmp[k];
            }
            cnt++;
        }
    }
    if(cnt) {
        for(int i = 0; i < ls; ++i) putchar(ans[i]);
        puts("");
    } else puts("UNRESTORABLE");
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String word = input.readLine();
        boolean [] freq = new boolean[26];
        for (char c: word.toCharArray()) {
            freq[c - 'a'] = true;
        }

        for (int i = 0; i < 26; i++) {
            if (!freq[i]){
                System.out.println((char)(i + 'a'));
                return;
            }
        }
        System.out.println("None");
    }
}


Measured memory_bytes: 25300
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    string s;
    cin >> s;
    for (int i = s.size() - 1; i > 0; i--) {
        string temp = s.substr(0, i);
        if (i % 2 == 1) {
            continue;
        }
        string temp0 = temp.substr(0, i / 2), temp1 = temp.substr(i / 2, i);
        if (temp0 == temp1) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
import fractions
a, b, c, d = map(int,input().split())

l = int(fractions.gcd(c,d) * c / fractions.gcd(c,d) * d / fractions.gcd(c,d))
#print(l)
x = b // c - a // c
y = b // d - a // d
z = b // l - a // l
if a % c == 0 or a % d == 0:
    print(int(b-a-(x+y-z)))
else:
    print(int(b-a-(x+y-z))+1)
#print(x,y,z)

Measured memory_bytes: 5048
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
    I LOVE CLARICE STARLING

     ♥LOVE♥        ♥LOVE♥
  ♥LOVE♥♥LOVE♥  ♥LOVE♥♥LOVE♥
♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
   ♥LOVE♥♥LOVE♥♥LOVE♥♥LOVE♥
      ♥LOVE♥♥LOVE♥♥LOVE♥
         ♥LOVE♥♥LOVE♥
            ♥LOVE♥
               ♥


    EXPLAINATION BELOW->
   

*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
ll binpow(ll x,ll n)
{
    ll res=1;
    while(n>0)
    {
        if(n&1)res=res*x;
         x=x*x;
         n>>=1;
    }
    return res;
}
void solve()
{
   ll X;cin>>X;
   vector<ll>V;
   ll i;
   V.pb(0);
   fo(i,1,1001)
   {
       ll p=binpow(i,5LL);
       V.pb(p);V.pb(-1LL*p);
   }
   sort(all(V));
   
   vector<ll>::iterator it;
   it=lower_bound(all(V),0);
   ll pivot,A,B;
   pivot=it-V.begin();
   fo(i,0,sz(V))
   {
       it=lower_bound(all(V),V[i]-X);
       if(V[i]-X==(*it))
       {
            A=i-pivot;B=it-V.begin()-pivot;
           cout<<A<<" "<<B<<"\n";
           return;
       }
   }
   
}
int main()
{
   fastio
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


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

int n,m,x, ret = 1e9;
int c[12] = {}, under[12] = {};
vector<int> a[12];

bool check_under(){
    for(int i = 0; i < m ; ++i){
        if(under[i] < x){
            return false;
        }
    }
    return true;
}

int sol(int index, int money){
    if(index == n){
        if(check_under())
            return money;
        return 1e9;
    }
    if(check_under() && money >= ret)
        return ret;
    //not buy
    ret = min(ret,sol(index+1, money));
    //buy 
    for(int i = 0; i < m ; ++i){
        under[i] += a[index][i];
    }
    ret = min(ret,sol(index+1, money+c[index]));
    for(int i = 0; i < m ; ++i){
        under[i] -= a[index][i];
    }
    return ret;
}

int main(){
    cin >> n >> m >> x;
    for(int i = 0; i < n ; ++i){
        cin >> c[i];
        for(int j = 0,num ; j < m ; ++j){
            cin >> num;
            a[i].emplace_back(num);
        }
    }
    cout << (sol(0,0) == 1e9 ? -1 : ret);

    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,m,t,num[20],val[20],ans=1e9;
string s[20];

int main()
{
	cin>>n>>m>>t;
	rep(i,n) cin>>s[i];
	rep(i,1<<(n-1))
	{
		int res=__builtin_popcount(i);
		memset(num,0,sizeof(num));
		memset(val,0,sizeof(val));
		rep(j,n) rep(k,j) num[j]+=(int)((i&(1<<k))>0);
		rep(j,m)
		{
			rep(k,n) val[num[k]]+=(s[k][j]=='1');
			bool ok=true;
			rep(k,15)
			{
				if(val[k]>t)
				{
					ok=false;
					break;
				}
			}
			if(!ok)
			{
				res++;
				memset(val,0,sizeof(val));
				rep(k,n) val[num[k]]+=(s[k][j]=='1');
				ok=true;
				rep(k,15)
				{
					if(val[k]>t)
					{
						ok=false;
						break;
					}
				}
				if(!ok)
				{
					res=1e9;
					break;
				}
			}
		}
		ans=min(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

N,K,L=map(int,input().split())

class UnionFind(object):
  def __init__(self,n):
    self.table=[-1]*n
 
  def find(self,x):
    parent=self.table[x]
    if parent<0:
      return x
    else:
      root=self.find(parent)
      self.table[x]=root
      return root
 
  def union(self,a,b):
    root1=self.find(a)
    root2=self.find(b)
    if root1 != root2:
      if self.table[root1] != self.table[root2]:
        if self.table[root1] < self.table[root2]:
          self.table[root2]=root1
        else:
          self.table[root1]=root2
      else:
        self.table[root1]+=(-1)
        self.table[root2]=root1
      
ufK=UnionFind(N)
for i in range(K):
  p,q=map(int,input().split())
  ufK.union(p-1,q-1)

ufL=UnionFind(N)
for i in range(L):
  p,q=map(int,input().split())
  ufL.union(p-1,q-1)

KL=defaultdict(int)
ans=[]
for i in range(N):
  a=ufK.find(i)
  b=ufL.find(i)
  KL[(a,b)]+=1
for i in range(N):
  a=ufK.find(i)
  b=ufL.find(i)
  ans.append(KL[(a,b)])
  
print(*ans)


Measured memory_bytes: 41692
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

int main(){
    int n;
    ll ans = 0;
    cin >> n;
    vl a(n),b(n);
    
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    ll tmp = 0;
    for(int i = n-1;i >= 0;i--){
        
        if((a[i]+ans) % b[i] != 0){
            tmp = b[i] - ((a[i]+ans) % b[i]);
            //cout << i << " " << tmp << endl;
            ans += tmp;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4820
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;


// 68 11 55 - rank 3
// 69 12 19 - rank 3
// 70 12 34 - rank 100
// 71 12 58 -

ull gcd(ull a, ull b) {
    while (b != 0) {
        auto na = a % b;
        a = b;
        b = na;
    }
    return a;
}


void oneCase() {
    string line;
    cin >> line;
    sort(line.begin(), line.end());
    int i = 97;
    for (auto el : line) {
        if (i < int(el)) {
            cout << char(i) << "\n";
            return;
        } else if (i == int(el)) {
            ++i;
        }
    }
    if (i == 123) {
        cout << "None" << "\n";
    } else {
        cout << char(i) << "\n";
    }


}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}

ll fact(ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        res = (res * n) % mod;
        --n;
    }
    return res;
}


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

using ll=long long;

class UnionFind{
    int N;
    vector<int> par;
    vector<int> rank;
    public:
    UnionFind(int N):N(N),par(N),rank(N,0){iota(par.begin(),par.end(),0);}
    int find(int x);
    void unite(int x,int y);
    bool same(int x,int y){return find(x)==find(y);}
};

int UnionFind::find(int x){
    if(par[x]==x) return x;
    return par[x]=find(par[x]);
}
void UnionFind::unite(int x,int y){
    x=find(x),y=find(y);
    if(x==y) return;
    if(rank[x]>=rank[y]){
        if(rank[x]==rank[y]) rank[x]++;
        par[y]=x;
    }else{
        par[x]=y;
    }
}

int main(){
    int n;
    cin>>n;
    vector<ll> x(n),y(n);
    for(int i=0;i<n;i++) cin>>x[i]>>y[i];
    vector<pair<ll,int>> xid(n);
    vector<pair<ll,int>> yid(n);
    for(int i=0;i<n;i++){
        xid[i]={x[i],i};
        yid[i]={y[i],i};
    }
    sort(xid.begin(),xid.end());
    sort(yid.begin(),yid.end());
    using Edge=pair<ll,pair<int,int>>;
    vector<Edge> edges;
    for(int i=0;i<n-1;i++){
        edges.push_back(Edge{xid[i+1].first-xid[i].first,{xid[i].second,xid[i+1].second}});
        edges.push_back(Edge{yid[i+1].first-yid[i].first,{yid[i].second,yid[i+1].second}});
    }
    sort(edges.begin(),edges.end());
    UnionFind u(n);
    ll res=0;
    for(auto &e:edges){
        ll d=e.first;
        int a=e.second.first,b=e.second.second;
        if(!u.same(a,b)){
            u.unite(a,b);
            res+=d;
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 11120
// Problem Code: abc162_a

#include <iostream>
#include <string>

using namespace std;

string lucky_7(int N) {
	while (N) {
		if (N % 10 == 7)
			return "Yes";
		N /= 10;
	}
	return "No";
}

int main() {
	int N;
	cin >> N;
	cout << lucky_7(N);
	return 0;
}

Measured memory_bytes: 3592
#
# coding: utf-8

n=int(input())
p=[] #pは値段のリスト
sum=0 #sumは合計金額

for i in range(n):
    p.append(int(input()))
p.sort() #pをソート
p[n-1]=int(p[n-1]/2) #p中で一番高いのを半額
for q in p:
    sum+=q

print(sum)

Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
string s;
int i;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>s;
    for(i=0;i<s.size()-1;i++)if(s[i]=='A' && s[i+1]=='C')rc("Yes");
    rc("No");
	return 0;
}

Measured memory_bytes: 256
import sys

def is_center(x, y, P):
  H = [abs(x-p[0]) + abs(y-p[1]) + p[2] for p in P if p[2] != 0]
  return H


def center(C, P):
  for c in C:
    check = [p[2] == max(c[2] - abs(p[0] - c[0]) - abs(p[1] - c[1]), 0) for p in P]
    if all(check):
      return '{} {} {}'.format(c[0], c[1], c[2])

def main():
  input = sys.stdin.readline
  N = int(input())
  P = [[0, 0, 0] for _ in range(N)]

  for i in range(N):
    x, y, h = map(int, input().split())
    P[i][0], P[i][1], P[i][2] = x, y, h

  C = []
  for i in range(101):
    for j in range(101):
      H = is_center(i, j, P)
      if len(set(H)) == 1:
        C.append([i, j, H[0]])
  
  ans = center(C, P)
  print(ans)


if __name__ == '__main__':
  main()

Measured memory_bytes: 4084
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

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

  if(n % 2 == 0){
    cout << 0.5 << endl;
  }else{
    double x = ((double)(n+1)/2) / (double)n;
    cout << x << endl;
  }
}

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


int main(){
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	
	for (int i = 0; i < y2 - y1; ++i)
		cout << "U";
	for (int i = 0; i < x2 - x1; ++i)
		cout << "R";
	for (int i = 0; i < y2 - y1; ++i)
		cout << "D";
	for (int i = 0; i < x2 - x1; ++i)
		cout << "L";

	cout << "L";
	for (int i = 0; i < y2 - y1+1; ++i)
		cout << "U";
	for (int i = 0; i < x2 - x1+1; ++i)
		cout << "R";
	cout << "DR";
	for (int i = 0; i < y2 - y1+1; ++i)
		cout << "D";
	for (int i = 0; i < x2 - x1+1; ++i)
		cout << "L";
	cout << "U" << endl;
}

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

def main():
    n, m = map(int, input().split())
    graph_a = [list(input()) for _ in range(n)]
    graph_b = [list(input()) for _ in range(m)]

    check = True
    flag = False

    for s in range(n-m+1):
        for t in range(n-m+1):
            check = True
            for p in range(m):
                for q in range(m):
                    if graph_a[s+p][t+q] != graph_b[p][q]:
                        check = False
            if check:
                flag = True
    
    if flag:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <stdio.h>

using namespace std;

int main(){
    int C[10001] = {0};
    int n;
    scanf("%d",&n);
    int* A = new int[n];
    int* B = new int[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&A[i]);
        C[A[i]]++;
    }
    for(int i = 1; i < 10001; i++) C[i] += C[i-1];

    for(int i = n-1; i >= 0; i--) B[(C[A[i]]--)-1] = A[i];

    for(int i = 0; i < n-1; i++) printf("%d ",B[i]);
    printf("%d\n",B[n-1]);
}

Measured memory_bytes: 16708
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
	string lattices[10];


int dfs(int n,vi &used,vi &bottom,vi &lr){
	if(n==5){
		vs matrix(5);
		REP(i,5){
			string s=lattices[bottom[i]];
			if(lr[i]){
				s=string(s.rbegin(),s.rend());
			}
			REP(j,5){
				s[j]=s[j]=='1'?'0':'1';
			}
			matrix[i]=s;
		}
		REP(j,10){
			if(!used[j]){
				REP(k,5){
					REP(d,2){
						REP(l,5){
							if(d==0&&lattices[j][l]!=matrix[l][k]){
								goto a;
							}else if(d==1&&lattices[j][4-l]!=matrix[l][k]){
								goto a;
							}
						}
						goto b;
a:;
					}
				}
				return 0;
			}
b:;
		}
		return 1;
	}

	int res=0;
	REP(i,10){
		if(used[i])continue;
		vi nused(used); 
		nused[i]=1;
		vi nbottom(bottom);
		nbottom[n]=i;
		int ss=2;
		if(lattices[i][0]==lattices[i][4]&&lattices[i][1]==lattices[i][3]){
			ss=1;
		}
		REP(j,ss){
			vi nlr(lr);
			nlr[n]=j;
			res+=dfs(n+1,nused,nbottom,nlr);
		}
	}
	return res;
}

int main(){
	while(cin>>lattices[0],lattices[0]!="END"){
		REP(i,9){
			cin>>lattices[i+1];
		}

		vi used(10),bottom(5),lr(5);
		int ans=dfs(0,used,bottom,lr);
		cout<<ans/8<<endl;
	}
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int X;
    cin >> X;
    if(X >= 30){
        Yes();
    }
    else{
        No();
    }
}

Measured memory_bytes: 3604
package main

import (
	"fmt"
)

func main() {
	var n, a int
	fmt.Scanln(&n)
	ans := 32
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		div_num := 0
		for a%2 == 0 {
			a /= 2
			div_num++
		}
		if div_num < ans {
			ans = div_num
		}
	}
	fmt.Println(ans)
}


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

int main() {
 int N;
 cin>>N;
 if(N/10%10==N/100%10){
   if(N%10==N/10%10){
   cout<<"Yes"<<endl;}
   else if(N/1000==N/100%10){
   cout<<"Yes"<<endl;}
   else{
   cout<<"No"<<endl;}
 }
 else{
 cout<<"No"<<endl;}
}

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

#define fs first
#define sc second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	int H = in(), W = in(), h = in(), w = in();
	bool f = false;

	if (H % h + W % w) {
		puts("Yes");
	} else {
		puts("No");
		return 0;
	}

	if (W % w == 0) {
		swap(H, W);
		swap(h, w);
		f = true;
	}

	vi s(W + 1);
	for (int i = w; i <= W; i++) {
		s[i] = s[i - w] - 1;
	}

	s[W] = 1;
	for (int i = W - w; i > 0; i -= w) {
		s[i] = s[i + w] + 1;
	}

	for (int i = W; i; --i) {
		s[i] = s[i] - s[i - 1];
	}


	if (f) {
		swap(H, W);
		swap(h, w);
	}

	rep(i, H) {
		rep(j, W) {
			cout << (f ? s[i + 1] : s[j + 1]) << " ";
		}
		puts("");
	}

}


Measured memory_bytes: 1408
N = int(input())
A = list(map(int,input().split()))

def selectionSort(A, N):
    cnt = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j

        temp = A[i]
        A[i] = A[minj]
        A[minj] = temp
        if i != minj:
            cnt += 1

    return(A, cnt)

out_A, cnt_sort = selectionSort(A,N)

out_A_str = list(map(str, out_A))
print(" ".join(out_A_str))
print(str(cnt_sort))


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

#define fi first
#define se second

const int N = 100100;

using namespace std;

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        int n, t;
        cin >> n >> t;
        vector < int > a(n);
        long long res = 0;
        for(int i = 0; i < n; i++){
                cin >> a[i];
                if(i > 0){
                        res += min(a[i] - a[i - 1], t);
                }
        }
        cout << res + t << "\n";
}


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

int main(){
  string S;
  cin >> S;
  int count = 0;
  for(int i=0;i<3;i=i+1){
    if(S.at(i)=='o')count++;
  }
  cout << 700 + 100*count << endl;
}

    

Measured memory_bytes: 256
<?php
  list($n, $x) = explode(" ", trim(fgets(STDIN)));

  $l = explode(" ", trim(fgets(STDIN)));

  $a = 0;
  $ans = 1;
  for($i=0; $i<$n; $i++){
    $a+=$l[$i];
    if($a > $x){
      break;
    }
    $ans++;
  }

  echo $ans;

  

Measured memory_bytes: 4728
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;
const i64 mod = 1e9 + 7;

using namespace std;

int main() {

	const int N = read_item();
	const int K = read_item();

	i64 ans = 0;
	for(auto p : range(K, N + 2)) {
		i64 lo = (i64)(p - 1) * p / 2;
		i64 hi = (i64)(N + (N - p + 1)) * p / 2;
		ans += (hi + 1 - lo);
		ans = ans % mod;
	}
	printf("%lld\n", ans);

	return 0;
}

/* wafdayo~~~ */


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


int main() {

    int h, w;
    cin >> h >> w;
 
    vector<string> v(h);
    for(int i = 0; i < h; i++) cin >> v[i];
    for(auto x: v){
        cout << x << endl;
        cout << x << endl;
    }
}
  

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

#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.bigin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vi>
#define vvi64 vector<vi64>

using namespace std;

int main(){
    int n;
    cin >> n;
    vi h(n),dp(n);
    Srep(n) cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    Lrep(i,2,n){
        if(dp[i-1] + abs(h[i] - h[i-1]) < dp[i-2] + abs(h[i] - h[i-2])){
            dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
        }else{
            dp[i] = dp[i-2] + abs(h[i] - h[i-2]);
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 4032
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[] S = new String[H];
		for (int i = 0; i < H; i++) {
			S[i] = sc.next();
		}
		int[] x = { 0, 1, 1, 1, 0, -1, -1, -1 };
		int[] y = { 1, 1, 0, -1, -1, -1, 0, 1 };
		for (int i = 0; i < H; i++) {
			String str = "";
			for (int j = 0; j < W; j++) {
				if (j + 1 == W) {
					if ("#".equals(S[i].substring(j))) {
						str = str + "#";
						continue;
					}
				} else {
					if ("#".equals(S[i].substring(j, j + 1))) {
						str = str + "#";
						continue;
					}
				}
				int count = 0;
				for (int k = 0; k < 8; k++) {
					int dx = j + x[k];
					int dy = i + y[k];
					if (dx < 0 || W <= dx || dy < 0 || H <= dy) {
						continue;
					} else if (dx + 1 == W) {
						if ("#".equals(S[dy].substring(dx))) {
							count++;
						}
					} else {
						if ("#".equals(S[dy].substring(dx, dx + 1))) {
							count++;
						}
					}
				}
				str = str + String.valueOf(count);
			}
			System.out.println(str);
		}
	}
}


Measured memory_bytes: 28976
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

ll n;
ll cnt[21000000];
int main() {
	scanf("%lld", &n);
	ll sum = 1;
	for (ll i = 2; i <= n; i++)
		cnt[i] = 1;
	for (ll i = 2; i <= n; i++) {
		if (cnt[i] == 1) {
			for (int j = i; j <= n; j += i) {
				int val = j, tc = 0;
				while ((val % i) == 0)
					tc++, val /= i;
				cnt[j] *= (tc + 1);
			}
		}
		sum += i * cnt[i];
	}
	printf("%lld\n", sum);
}

Measured memory_bytes: 79856
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = 1e-9;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline ll gcd(ll a, ll b) {
	while (b) {
		ll c = a;
		a = b; b = c % b;
	}
	return a;
}
inline ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
bool isprime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
ll mypow(ll a, ll b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	ll memo = mypow(a, b >> 1);
	return memo * memo;
}
ll modpow(ll a, ll b, ll m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	ll memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
int k, cnt;
string s;
void func(int n) {
	if (n == 0) {
		cnt++;
		if (cnt == k) {
			cout << s << endl;
			exit(0);
		}
		return;
	}
	if (s.empty()) {
		REP(i, 9) {
			s += '0' + i;
			func(n - 1);
			s.pop_back();
		}
		return;
	}
	if (s.back() != '0') {
		s += s.back() - 1;
		func(n - 1);
		s.pop_back();
	}
	s += s.back();
	func(n - 1);
	s.pop_back();
	if (s.back() != '9') {
		s += s.back() + 1;
		func(n - 1);
		s.pop_back();
	}
}
signed main() {
	cin >> k;
	int digits = 1;
	while (true) {
		func(digits);
		digits++;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	char s[1];
	scanf("%s",s);
	
	if(*s=='A')
	puts("T");
	
	else if(*s=='T')
	puts("A");
	
	else if(*s=='C')
	puts("G");
	
	else if(*s=='G')
	puts("C");
	

	return 0;
}
	

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

int main(){

int k;
cin >> k;
int cnt=1;
int a=7;
while(cnt<=10000010){
    if(a%k==0) {
        cout << cnt << endl;
        return 0;
    }
    a = 10*(a%k) + 7;
    cnt++;
}
cout << -1 << endl;

}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#define N 2010
#define M 2000001
#define ls i << 1
#define rs i << 1 | 1
#define inf 0x3f3f3f3f
#define inc(i) (++ (i))
#define dec(i) (-- (i))
// #define mid ((l + r) >> 1)
#define int long long
#define XRZ 998244353
#define debug() puts("XRZ TXDY");
#define n_ ((n >> 1) + 1)
#define mem(i, x) memset(i, x, sizeof(i));
#define Next(i, u) for(register int i = head[u]; i ; i = e[i].nxt)
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout);
#define Rep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i <= i##Limit ; inc(i))
#define Dep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i >= i##Limit ; dec(i))
// const int dx[10] = {1, -1, 0, 0};
// const int dy[10] = {0, 0, 1, -1};
using namespace std;
inline int read() {
    register int x = 0, f = 1; register char c = getchar();
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
void work() {}
signed main(){
	int H, W;
	H = read(), W = read();
	int ans = H * W / 2;
	if(H * W % 2) ++ ans;
	if(H == 1 || W == 1){ printf("1"); return 0;}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if (a == b && a != c){
    cout << "Yes\n";
  }
  if (a == c && a != b){
    cout << "Yes\n";
  }
  if (b == c && a != c){
    cout << "Yes\n";
  }
  if (a == b && b == c){
    cout << "No\n";
  }
  if (a != b && b !=c && c!= a){
    cout << "No\n";
  }
  return 0;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int n, a;

int main(){
	cin >> n;
	int b = INF,c = 0;
	for(int i = 0; i < n; i++){
		cin >> a;
		b = min(b, a);
		c = max(c, a);
	}
	
	cout << c - b << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string s;
    cin>>s;
    ll sum=0;
    for(int i=0;i<s.size();i++)
    {
        sum+=s[i]-'0';
    }
    if(sum%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 510
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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

ll c[MAXN], s[MAXN], f[MAXN];
int main() {
    int n;
    cin >> n;

    rep(i, n-1) {
        cin >> c[i] >> s[i] >> f[i];
    }

    rep(i, n-1) {
        ll cur = 0;
        for(int k=i; k<n-1; ++k) {
            if (cur <= s[k]) {
                cur = (s[k] + c[k]);
            } else {
                if (cur % f[k] == 0) {
                    cur += c[k];
                } else { 
                    cur += f[k] - (cur % f[k]);
                    cur += c[k];
                }
            }
        }

        cout << cur << endl;
    }

    cout << 0 << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=998244353;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main() {
    ll n,k;cin>>n>>k;
    n--;
    vi l(k),r(k);
    rep(i,k)cin>>l[i]>>r[i];
    vi dp(n+1);
    dp[0]=1;
    REP(i,1,n+1){
        ll res=0;
        rep(j,k){
            if(l[j]>i)continue;
            res+=dp[i-l[j]];
            if(i-r[j]-1>=0)res-=dp[i-r[j]-1];
            res=(res+mod)%mod;
        }
        if(i==n)out(res);
        dp[i]=(dp[i-1]+res)%mod;
    }
}

Measured memory_bytes: 4840
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const ll INF = 1ll << 60;

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int N;
  while (cin >> N) {
    vector<ll> A(N);
    for (ll& x : A) cin >> x;
    ll sum = 0, mn = INF;
    int neg = 0;
    for (ll x : A) {
      if (x < 0) ++neg;
      sum += abs(x);
      mn = min(mn, abs(x));
    }
    ll res;
    if (neg % 2 == 0) {
      res = sum;
    } else {
      res = sum - 2 * mn;
    }
    cout << res << endl;
  }
  return 0;
}


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

using namespace std;

int main()
{
    string str;
    while(getline(cin, str))
    {
        if(str == "-"){ break; }

        string buf;
        getline(cin, buf);
        int n = stoi(buf);
        for(int i = 0; i < n; i++)
        {
            getline(cin, buf);
            int x = stoi(buf);
            str = str.substr(x) + str.substr(0,x);
        }
        cout << str << endl;

    }

    return 0;
}

Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>
#include <tuple>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> primes;
	for (int i = 2; i <= 100; ++i) {
		bool isprime = true;
		for (int j = 2; j < i; j++) {
			if (i%j == 0) {
				isprime = false;
			}
		}
		if (isprime) {
			primes.push_back(i);
		}
	}
	vector<int> stock = vector<int>(primes.size(),0);
	for (int i = 2; i <= n; ++i) {
		for (int pi = 0;pi<primes.size();++pi) {
			int v = i;
			int prime = primes[pi];
			while (v%prime == 0) {
				stock[pi]++;
				v /= prime;
			}
		}
	}
	int sum = 0;
	int above3 = 0;
	int above5 = 0;
	int abovebe3 = 0;
	int above15 = 0;
	int above25 = 0;
	int above75 = 0;
	for (int s : stock) {
		if (s >= 2) above3++;
		if (s >= 2 && s < 4) abovebe3++;
		if (s >= 4) above5++;
		if (s >= 14) above15++;
		if (s >= 24) above25++;
		if (s >= 74) above75++;
	}
	sum += above75;
	sum += above25 * (above3 - 1);
	sum += above15 * (above5 - 1);
	sum += above5 * (above5 - 1) / 2 * (above3 - 2);
	//sum += above5 * (above5 - 1) / 2 * abovebe3;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#from numpy import*
#from scipy import*
from collections import* #defaultdict Counter deque
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2)
from operator import mul
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial
from copy import deepcopy
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)

#enumerate input

def main():
    n,k,*a=map(int,open(0).read().split())
    print(((n-k)-1)//(k-1)+2)

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 15976