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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acosl(-1)
#define ld long double
#define prime (1000000000 + 7)
#define INF 1000000000

using namespace std;
 
ld pot(ld b, ll e){
	ld res = 1;
	while (e){
		if(e&1){
			res *= b;
		}
		b *= b;
		e >>= 1;
	}
	return res;
}

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

	ll n, k;
	cin >> n >> k;
	ld res = 0, lk = k;
	for(int i = 1; i <= n; ++i){
		ll aux = 0;
		if(k >= i){
			aux = ceill(log2l(lk/i));
		}
		// W(aux, " ")
		// W(res, "\n")
		if(aux < k){
			res += pot(0.5, aux);
			// W(aux, " ")
			// W(res, "\n")
		} else{
			break;
		}
		
	}
	cout << fixed << setprecision(10) << res/n << "\n";

	return 0;
}

// 2^x >= k/i

// s 		= 		p^1 + p^2 + p^3 + p^4 + ... + p^(n-1) + p^n
// s/p 		= p^0 + p^1 + p^2 + p^3 + p^4 + ... + p^(n-1)
// _____________________________________________________________
// s - s/p	= p^n - p^0
// s 		= (p^n - p^0)*p/(p - 1)


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

struct Card { char suit ,value; };

void bubble(struct Card A[], int N) {
    for ( int i = 0; i < N; i++ ) {
        for ( int j = N - 1; j >= i + 1; j-- ) {
            if( A[j].value < A[j - 1].value ) {
                Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N) {
    for ( int i = 0; i < N; i++ ) {
        int minj = i;
        for ( int j = i; j < N; j++ ) {
            if ( A[j].value < A[minj].value ) minj = j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(struct Card A[], int N) {
    for ( int i = 0; i < N; i++) {
        if ( i > 0 ) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

// バブルソートと選択ソートの結果を比較
bool isStable(struct Card C1[], struct Card C2[], int N) {
    for ( int i = 0; i < N; i++ ) {
        if ( C1[i].suit != C2[i].suit ) return false;
    }
    return true;
}

int main() {
    Card C1[100], C2[100];
    int N;
    char ch;

    cin >> N;
    for ( int i = 0; i < N; i++ ) {
        cin >> C1[i].suit >> C1[i].value;
    }

    for ( int i = 0; i < N; i++ ) C2[i] = C1[i];

    bubble(C1, N);
    selection(C2, N);

    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if ( isStable(C1, C2, N) ) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for(int i = 0; i<N; i++){
    int A;
    cin >> A;
    vec[i] = A;
  }
  
  bool ans = false;// vec[i] がすべて偶数かどうかを判定するフラグ
  int c = 0;
  
  while(true){
   
    for(int i = 0;i < N; i++){
      if(vec[i]%2 > 0){// 奇数があったらフラグを立てる
        ans = true;
        break;
      }
      vec[i] = vec[i] / 2; // 操作を行えるなら操作を実際に行う
      
    }
    if(ans){// 奇数があったら break
      break;
    }
    c++;
  }
  cout << c << endl;// 操作回数をインクリメント
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp>
  using namespace __gnu_pbds;
  using namespace std;
  #define int         long long
  #define mod         1000000007
  #define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  #define f(i,n)      for(int i=0;i<n;i++)
  #define fp(i,k,n)   for(int i=k;i<=n;i++)
  #define fr(i,k,n)   for(int i=k;i>=n;i--)
  #define pb          push_back
  #define pii         pair<int,int>
  #define vi          vector<int>
  #define vii         vector<pii>
  #define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
  #define F           first
  #define S           second
  #define sz(x)       (int)(x).size()
  #define lb          lower_bound
  #define ub          upper_bound
  #define mems(x)     memset(x,0,sizeof(x))
  #define all(a)      a.begin(),a.end()
  typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

  /*---------------------------------------------------------------------------------------------------*/

  void solve()
  {
    int n;
    cin >> n;
    if(n>=30)
     cout << "Yes\n";
     else
    cout << "No\n";
    return;
  } 

  signed main()
  {
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    FAST
    int T=1;
    // cin >> T;
    while(T--)
    {
      solve();
    }
    return 0;
  }


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
struct node {
	int h,p;
	bool YN=false;
}f[105];
int main() {
	int k11,k12,k13,k21,k22,k23,k31,k32,k33;
	cin>>k11>>k12>>k13>>k21>>k22>>k23>>k31>>k32>>k33;
	int n;
	cin>>n;
	set<int> s;
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		s.insert(a);
	}
	if(s.find(k11)!=s.end()&&s.find(k12)!=s.end()&&s.find(k13)!=s.end()){
		cout<<"Yes";
		return 0;
	}
	if(s.find(k21)!=s.end()&&s.find(k22)!=s.end()&&s.find(k23)!=s.end()){
		cout<<"Yes";
		return 0;
	}
	if(s.find(k31)!=s.end()&&s.find(k32)!=s.end()&&s.find(k33)!=s.end()){
		cout<<"Yes";
		return 0;
	}
	if(s.find(k11)!=s.end()&&s.find(k21)!=s.end()&&s.find(k31)!=s.end()){
		cout<<"Yes";
		return 0;
	}
	if(s.find(k12)!=s.end()&&s.find(k22)!=s.end()&&s.find(k32)!=s.end()){
		cout<<"Yes";
		return 0;
	}
	if(s.find(k13)!=s.end()&&s.find(k23)!=s.end()&&s.find(k33)!=s.end()){
		cout<<"Yes";
		return 0;
	}
	if(s.find(k11)!=s.end()&&s.find(k22)!=s.end()&&s.find(k33)!=s.end()){
		cout<<"Yes";
		return 0;
	}
	if(s.find(k13)!=s.end()&&s.find(k22)!=s.end()&&s.find(k31)!=s.end()){
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}


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

int main(void){
    int n;
    cin >> n;
    
    int number;
    char pattern;
    vector<int> s(13),h(13),c(13),d(13);
    
    for(int i = 0; i < n; i++){
        cin >> pattern >> number;
        number--;
        if(pattern == 'S'){
            s[number]++;
        } else if(pattern == 'H'){
            h[number]++;
        } else if(pattern == 'C'){
            c[number]++;
        } else if(pattern == 'D'){
            d[number]++;
        }
    }
    
    for(int i = 0; i < 13; i++){
        if(s[i] == 0){
            cout << "S " << i+1 << endl;
        }
    }
   
    
    for(int i = 0; i < 13; i++){
        if(h[i] == 0){
            cout << "H " << i+1 << endl;
        }
    }

    for(int i = 0; i < 13; i++){
        if(c[i] == 0){
            cout << "C " << i+1 << endl;
        }
    }

    for(int i = 0; i < 13; i++){
        if(d[i] == 0){
            cout << "D " << i+1 << endl;
        }
    }

}



Measured memory_bytes: 3108
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif

static void D_task();

int main()
{
	D_task();
	
	fflush(stdout);
	return 0;
}


static void D_task()
{
	int N, K;
	scanf(" %d %d", &N, &K);

	LLONG value;
	std::vector<LLONG> inDeq;
	for (int i = 0; i < N; i++) {
		scanf(" %lld", &value);
		inDeq.push_back(value);
	}
	LLONG maxVal = 0;
	for (int ope = 1; ope <= K; ope++) {

		LLONG nowVal = 0;
		auto lit = inDeq.begin();
		std::multiset<LLONG> inHand;
		for (int l = 0; l <= std::min(N,ope); l++) {
			if (l > 0) {
				nowVal += *lit;
				inHand.insert(*lit);
				lit++;
				if (maxVal < nowVal) {
					maxVal = nowVal;
				}
			}
			LLONG nowVal2 = nowVal;
			auto rit = inDeq.rbegin();
			std::multiset<LLONG> inHand2(inHand);
			for (int r = 0; r <= std::min((N - l),(ope - l)); r++) {
				if (r > 0) {
					nowVal2 += *rit;
					inHand2.insert(*rit);
					rit++;
					if (maxVal < nowVal2) {
						maxVal = nowVal2;
					}
				}
				LLONG nowVal3 = nowVal2;
				auto tit = inHand2.begin();
				for (int t = 0; t <= std::min((int)(inHand2.size()), (ope - l - r)); t++) {
					if (t > 0) {
						nowVal3 -= *(tit);
						tit++;
						if (maxVal < nowVal3) {
							maxVal = nowVal3;
						}
					}
				}
			}
		}
	}
	printf("%lld\n", maxVal);
}


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

n, m = map(int, input().split())
S = input()
T = input()

gcd = gcd(n, m)
L = int(n * m / gcd)

a = int(L/n)
b = int(L/m)

flag=True

if n > m:
    for j in range(n):
        i = j * a
        if (int(i%a) == 0 and int(i%b) == 0):
            if not S[int(i/a)] == T[int(i/b)]:
                flag = False
else:
    for j in range(m):
        i = j * b
        if (int(i%a) == 0 and int(i%b) == 0):
            if not S[int(i/a)] == T[int(i/b)]:
                flag = False
                
if flag:
    print(L)
else:
    print("-1")


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const long long INF = (1LL << 60);
using namespace std;

const int MAX_V = 101;

void init(long long m[MAX_V][MAX_V]){
    rep(i,MAX_V) rep(j,MAX_V) m[i][j] = INF;
    rep(i,MAX_V) m[i][i] = 0;
}

void warshallFloyd(long long m[MAX_V][MAX_V], int n){
    rep(k,n){
        rep(i,n){
            rep(j,n){
                m[i][j] = min(m[i][j], m[i][k] + m[k][j]);
            }
        }
    }
}

bool isNegative(long long m[MAX_V][MAX_V]){
    rep(i,MAX_V){
        if(m[i][i] < 0) return true;
    }
    return false;
}

int main(){
    int v, e;
    long long m[MAX_V][MAX_V];

    init(m);
    cin >> v >> e;
    rep(i,e){
        int a, b, c;
        cin >> a >> b >> c;
        m[a][b] = c;
    }
    warshallFloyd(m, v);
    if(isNegative(m)) cout << "NEGATIVE CYCLE" << endl;
    else{
        rep(i,v){
            rep(j,v){
                if(j) cout << ' ';
                if(m[i][j] >= (1LL << 50)) cout << "INF";
                else cout << m[i][j];
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
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; }

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];

    sort ALL(A);
    cout << A[N-1] << ' ';
    int ans = A[0];
    REPP(i,1,N){
        if(abs(A[N-1]/2 + 1 - A[i]) < abs(A[N-1]/2 +1 - A[i-1]) && A[N-1]%2 == 1){
            ans = A[i];
        }
        else if(abs(A[N-1]/2 - A[i]) < abs(A[N-1]/2 - A[i-1]) && A[N-1]%2 == 0){
            ans = A[i];
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int
main()
{
    string s,t;
    cin >> s >> t;

    int len = t.length();
    if(len != s.length()+1){
        cout << "No" << endl;
        return -1;
    }

    string u = t.substr(0,len-1);
    if(s != u) {
        cout << "No" << endl;
        return 0;
    }

    for(char c = 'a'; c <= 'z'; c++){
        if(t[len-1] == c){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3048
from bisect import bisect_left, bisect_right
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
A.sort()
C.sort()
for b in B:
	a_cand = bisect_left(A, b)
	c_cand = N - bisect_right(C, b)
	ans += a_cand * c_cand
print(ans)

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

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

  int cnt;
  for (int i = 0; i < w.size(); i++)
  {
    cnt = 0;
    for (int j = 0; j < w.size(); j++)
    {
      if (w.at(i) == w.at(j)){
        cnt += 1;
      }
    }
    if (cnt % 2 == 1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using pii = pair<int,int>;
using pll = pair<long,long>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back

vector<pll> btn(100010);

int main() {
  int n; cin>>n;
  ll cnt=0;
  rep(i,n) cin>>btn[i].first>>btn[i].second;
  for(int i=n-1;i>=0;i--) {
    btn[i].first+=cnt;
    ll q=btn[i].first%btn[i].second;
    if(q!=0) cnt+=btn[i].second-q;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 4688
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var delimiter = " "
	var studinParams = strings.Split(nextLine(), delimiter)
	validation(studinParams)
	var answerWord = fmt.Sprintf("%s%s", studinParams[1], studinParams[0])
	fmt.Fprintln(os.Stdout, answerWord)
}

func validation(studinParams []string) []string {

	if len(studinParams) != 2 {
		panic("argment error")
	}
	var firstWord, secondWord = studinParams[0], studinParams[1]
	var firstWordLength = len(firstWord)
	var secondWordLength = len(secondWord)
	// length 1 - 100 and small a - z
	if firstWordLength < 1 || 100 < firstWordLength {
		panic("allow length 1 to 100")
	}
	if secondWordLength < 1 || 100 < secondWordLength {
		panic("allow length 1 to 100")
	}

	var regexpSmallAlphabet = regexp.MustCompile(`^[a-z]*$`)
	if !regexpSmallAlphabet.Match([]byte(firstWord)) || !regexpSmallAlphabet.Match([]byte(secondWord)) {
		panic("allow char a to z")
	}
	return studinParams
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}


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

int main() {
	long long n;
	string res = "";
	cin >> n;
	while (n--) {
		res += 'a' + (char)(n % 26);
		n /= 26;
	}

	for (int i = res.size() - 1; i >= 0; i--) {
		cout << res[i];
	}
	return 0;
}


Measured memory_bytes: 3624
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll k,a,b;cin>>k>>a>>b;
  ans(a%k==0||b%k==0||a/k!=b/k,"OK","NG");
  return 0;
}

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

#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define pb push_back
#define fi first
#define se second

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}
ll LCM(ll x, ll y){
	return x/GCD(x, y)*y;
}

int main() {
	int n, m; cin >> n >> m;
	cout << (n-1)*(m-1) << endl;
	return 0;
}

Measured memory_bytes: 3628
import itertools

N,K = map(int,input().split())
sunuke = []

for _ in range(K):
    d = int(input())
    sunuke.append(list(map(int,input().split())))

ans_li = list(itertools.chain.from_iterable(sunuke))

count = 0
for i in range(N):
    if i+1 not in ans_li:
        count += 1

print(count)

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    int cnt=0;
    int ans=0;
    vector<int>counter(n,0);
    rep(i,n){
        counter[a[i]-1]+=1;
    }
    int c=0;
    rep(i,counter.size()){
        if(counter[i]!=0)c+=1;
    }
    sort(counter.begin(),counter.end());
   
    if(k>=c)cout<<0<<endl;
    else{
        rep(i,counter.size()){
            if(cnt==c-k)break;
            else if(counter[i]!=0){
                ans+=counter[i];
                cnt+=1;
            }
        }
        cout<<ans<<endl;
    }
         
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=50000005;
int s,len[N],p[N];
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    p[0]=1;
    scanf("%d",&s);
    ll ans=0;
    int sum=0;
//input
    for(int l=1,r=0;l<10000000;l++)
    {
        while(sum<s)
        {
            r++;
            p[r]=p[r-1];
            len[r]=len[r-1];
            if(r/p[r]!=0) p[r]*=10,len[r]++;
            sum+=len[r];
        }
        if(sum==s) ans++;
        sum-=len[l];
    }
    for(int t=1;t<=s/8;t++)
    {
        if(s%t) ans=(ans+1)%mod;
        else ans=(ans+(qpow(10,s/t)-qpow(10,s/t-1)-t+1))%mod;
    }
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}

Measured memory_bytes: 178432
/*********************
*  Author: xuziyuan  * 
*********************/

#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 pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int main()
{
	int a,b;
	cin>>a>>b;
	if(abs(a-b)%2==1) puts("IMPOSSIBLE");
	else cout<<min(a,b)+abs(a-b)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    s = input()

    K = int(input())

    subsrings = [s[i : i + K + 1] for i in range(len(s))]
    subsrings.sort()

    first = set()

    for s in subsrings:

        for i in range(1, len(s) + 1):
            if s[:i] not in first:
                first.add(s[:i])
                if len(first) == K:
                    print(s[:i])
                    break


Measured memory_bytes: 75152
iN ,iX  = [int(x) for x in input().split()]
#かえって遅い？
aCum = [0]
for x in input().split():
    aCum += [aCum[-1] + int(x)]

def fCeil(iT,iR):
    return -1 * iT // iR * -1

def fCalcCost(iN,iX,aCum,iK):
    iCost = (iN + iK ) * iX + 5 * aCum[-1]
    for i in range(2,fCeil(iN,iK) ):
        iCost += 2 * aCum[iN - i * iK ]
    return iCost

#枝刈り
iTotalCost = fCalcCost(iN,iX,aCum,1)
for iK in range(2,fCeil(iN,2) + 1):
    iThisCost = fCalcCost(iN,iX,aCum,iK)
    if iThisCost > iTotalCost:
        break
    else:
        iTotalCost = iThisCost
print(iTotalCost)


Measured memory_bytes: 27244
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
  vi vec(3);
  for (int i=0; i<3; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());

  int a = vec.at(2);
  int b = vec.at(1);
  int c = vec.at(0);

  int x = a - b;
  int y = a - (c + x);

  int z;

  if (y % 2 == 0){
    z = x + (y/2);
  }
  else {
    z = x + (y/2) + 2;
  }

  cout << z << endl;
}


Measured memory_bytes: 3604
N, K = map(int, input().split())
step = list(map(int, input().split()))
dp = [float('inf')] * N
dp[0] = 0
for i, s in enumerate(step):
  for k in range(1, K + 1):
    if i < k:
      break
    dp[i] = min(dp[i], dp[i - k] + abs(step[i - k] - step[i]))
print(dp[N - 1])

Measured memory_bytes: 55008
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}
const int mod = 1e9 + 7;
void mul(ll &a, ll b) {
	b = ((b % mod) + mod) % mod;
	a = (a * b) % mod;
}
int main() {
	run();
	int num, k;
	cin >> num >> k;
	vector<ll> pos, neg;
	ll total = 1;
	int cnt0 = 0;
	for (int i = 0; i < num; i++) {
		int a;
		cin >> a;
		mul(total, a);
		if (a == 0)
			cnt0++;
		else if (a > 0)
			pos.push_back(a);
		else
			neg.push_back(-a);
	}
	if (num == k)
		return cout << total, 0;
	sort(all(pos));
	sort(all(neg));
	ll res = 1;
	if (k & 1) {
		if (sz(pos)) {
			res = pos.back();
			pos.pop_back();
			k--;
		} else {
			if (cnt0)
				return cout << 0, 0;
			for (int i = 0; i < k; i++)
				mul(res, -neg[i]);
			cout << res << endl;
			return 0;
		}
	}
	while (k >= 2) {
		if (sz(pos) >= 2 && sz(neg) >= 2) {
			ll p = pos[sz(pos) - 1] * pos[sz(pos) - 2];
			ll n = neg[sz(neg) - 1] * neg[sz(neg) - 2];
			if (p > n) {
				mul(res, p);
				pos.pop_back();
				pos.pop_back();
			} else {
				mul(res, n);
				neg.pop_back();
				neg.pop_back();
			}
		} else if (sz(pos) >= 2) {
			mul(res, pos[sz(pos) - 1] * pos[sz(pos) - 2]);
			pos.pop_back();
			pos.pop_back();
		} else if (sz(neg) >= 2) {
			mul(res, neg[sz(neg) - 1] * neg[sz(neg) - 2]);
			neg.pop_back();
			neg.pop_back();
		} else
			break;
		k -= 2;
	}
	if (k) {
		return cout << 0, 0;
	}
	cout << res << endl;
}


Measured memory_bytes: 5536
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    string s,t;
    cin >> s >> t;
    intl len = s.length();
    bool f = false;
    rep(i,len){
        if(s == t)f = true;
        char a = t[0];
        t.erase(0,1);
        t += a;
    }
    fp(f);
    return 0;
}

Measured memory_bytes: 256
N,M,R = list(map(int,input().split()))

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

e_list = [[] for i in range(N)]

for i in range(M):
    a,b,c = list(map(int,input().split()))
    e_list[a-1].append((b-1,c))
    e_list[b-1].append((a-1,c))

#dijkstra
#you need to prepare e_list = [[orient,dist]]

import heapq

def dijkstra(vi):

    min_d_list = [10**27 for i in range(N)]
    min_d_list[vi] = 0
    q = []
    for i in range(N):
        heapq.heappush(q,[min_d_list[i],i])

    while len(q)>0:
        d,v = heapq.heappop(q)
        for e in e_list[v]:
            v1,d1=e
            if min_d_list[v1]>d+d1:
                min_d_list[v1]=d+d1
                heapq.heappush(q,[d+d1,v1])

    return min_d_list

D = [[0]*R for i in range(R)]
for i in range(R):
    min_d_list = dijkstra(r[i]-1)
    for j in range(R):
        D[i][j] = min_d_list[r[j]-1]

import itertools
min_ans=10**27
for v in itertools.permutations(range(R)):
    ans = 0
    for i in range(1,R):
        ans+=D[v[i]][v[i-1]]

    min_ans=min(min_ans,ans)

print(min_ans)

Measured memory_bytes: 62808
#n=int(input())
#li=input().split()
#li=list(map(int,input().split()))
n=input()
ans=""
for i in range(len(n)):
    if n[i]=="0":
        ans+="0"
    elif n[i]=="1":
        ans+="1"
    elif n[i]=="B":
        if ans=="":
            pass
        else:
            ans=ans[:-1]

print(ans)


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

int main() {
  long long x, m = 100;
    cin >> x;
    int i;
    for (i = 1; ; ++i) {
        m += m / 100;
        if (m >= x)
            break;
    }
    cout << i << endl;

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll MAX = ll(1e9) + 7;

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

int main()
{
    int N, K;
    cin >> N >> K;
    ll ans = 0;
    vector<ll> cnt(K+1);
    for(int i = K; i > 0; i--) {
        cnt[i] = modpow(ll(K/i), ll(N), MAX);
        repSE(j,2,K/i+1) {
            cnt[i] = (cnt[i] - cnt[j*i]) % MAX;
        }
        ans = (ans + ll(cnt[i] * i)) % MAX;
    }
    if (ans < 0) ans += MAX;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int a, b;
	cin >> a >> b;

	if (a + b == 15) {
		cout << "+" << endl;
	} else if (a * b == 15) {
		cout << "*" << endl;
	} else {
		cout << "x" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
def write(h, w)
  h.times do |n|
    if n == 0
      puts '#' * w
      next
    end
    if n == (h - 1)
      puts '#' * w
      next
    end
    puts "##{'.' * (w - 2)}#"
  end
  puts ''
end


def func
  loop do
    h, w = gets.split.map(&:to_i)
    break if [h, w].all? {|n| n == 0}

    write(h, w)
  end
end


func


Measured memory_bytes: 6960
void main() {
    int[] tmp = readln.split.to!(int[]);
    int a = tmp[0], b = tmp[1];
    writeln(a >= 13 ? b : a >= 6 ? b / 2 : 0);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.typecons;

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

fn solve(x: i64) -> (i64, i64) {
  for a in 0i64.. {
    let pa = a.pow(5);
    if pa > x {
      break;
    }
    for b in 0i64.. {
      let pb = b.pow(5);
      if pb > x {
        break;
      }
      if pa + pb == x {
        return (a, -b);
      }
    }
  }
  for b in 0i64.. {
    let pb = b.pow(5);
    for k in 0i64.. {
      let pk = k.pow(5);
      if pk > x {
        break;
      }
      if (b + k).pow(5) - pb == x {
        return (b + k, b);
      }
    }
  }
  todo!()
}

#[fastout]
fn main() {
  input! {
    x: i64,
  }
  let (a, b) = solve(x);

  println!("{} {}", a, b);
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
#include<vector>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){

	ios::sync_with_stdio(false);
	long long N;		cin >> N;
	printf("%lld\n" ,((N - 1) * N) / 2 );

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





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

  vector<int> p(n);
  rep(i,n){
    cin>>p[i];

  }

  sort(all(p));
  reverse(all(p));

  int a=0,b=0;
  rep(i,n){
    if(i%2==0) a+=p[i];
    else b+=p[i];
  }


  cout << a-b << endl;
}

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

int main(){
    ll a, b, c;
    cin >> a >> b >> c;

    if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
        cout << 0 << endl;
    }else{
        ll ans = 0;
        ll odd = a / 2;
        ll even = a - odd;
        ans = (even - odd) * b * c;
        ll ans1 = 0;
        odd = b / 2;
        even = b - odd;
        ans1 = (even - odd) * a * c;
        if(ans > ans1){
            ans = ans1;
        }
        ans1 = 0;
        odd = c / 2;
        even = c - odd;
        ans1 = (even - odd) * a * b;
        if(ans > ans1){
            ans = ans1;
        }
        cout << ans << endl;
    }
}

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 vector<int> vi;
typedef pair<int, int> pii;

typedef vector<ll> vl;
typedef pair<ll, ll> pll;

#define St first
#define Nd second
#define Pb push_back
#define print_pair(p) cout<<p.St<<" "<<p.Nd
#define endl "\n"

#define REP(i,a,b) for(int i = a; i <= b; i++)
#define REV(i,a,b) for(int i = a; i >= b; i--)

#define AritSum(a,d,n) ((n)*(2*(a)+((n)-1)*(d)))/2
#define Log(base, num) log2(num)/log2(base)

#define MOD 1000000007
ll binpow(ll x, ll y) {
	ll z = 1;
	while(y > 0) {
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
// a^-1 (mod m) = a^(m-2) (mod m) - m is prime
ll inv(ll x) {return binpow(x, MOD - 2);}
ll divide(ll x, ll y) {return x* inv(y);}

// ************* MAIN *******************

int X, N;

unordered_set<int> p;

void solve() {
    cin >> X >> N;
    REP(i,0,N-1) {
        int t; cin >> t;
        p.insert(t);
    }

    int a = 0;
    while(true) {
        for (int i = -1; i <= 1; i+=2) {
            if (p.count(X + a*i)==0) {
                cout << X + a*i << endl;
                return;
            }
        }
        a++;
    }
}

/*
g++ -std=c++14 -Wall -Wextra -O2 Test.cpp -o Test

./Test < in
*/
int main() {
    int _=1;
    // cin>>_;
    REP(t,1,_) {
        // cout << "Case #" << t << ": ";
        solve();
        // cout << ((solve())? "YES" : "NO") << endl;
        // cout << solve() << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  ll N; cin>>N;
  map<ll,int> mp;
  ll X=N;
  for(ll i=2;i*i<=X;i++){
    if(X%i==0){
      while(X%i==0){
        mp[i]++;
        X/=i;
      }
    }
  }
  if(X!=1) mp[X]++;
  int ans=0;
  for(auto m:mp){
    int x=m.second;
    int cnt=1;
    while(x>=cnt){
      x-=cnt;
      cnt++;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3632
import java.io.*;

class Main
{
    public static void main (String[ ] args) throws Exception
    {
        boolean[][] b = new boolean[4][13];
        String[] s = {"S", "H", "C", "D"};
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
        
        int n = Integer.parseInt(br.readLine());
        for(int i = 0; i < n; i++)
        {
            String[] strArr = (br.readLine()).split(" ");
            int rank = Integer.parseInt(strArr[1]);
            if("S".equals(strArr[0]))
            {
                b[0][rank - 1] = true;
            }
            else if("H".equals(strArr[0]))
            {
                b[1][rank - 1] = true;
            }
            else if("C".equals(strArr[0]))
            {
                b[2][rank - 1] = true;
            }
            else if("D".equals(strArr[0]))
            {
                b[3][rank - 1] = true;
            }
        }
        
        for(int i = 0; i < 4; i++)
        {
            for(int j = 0; j < 13; j++)
            {
                if(true != b[i][j])
                {
                    System.out.println(s[i] + " " + (j + 1));
                }
            }
        }
    }
}

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

int main(){
    int n;
    int i;
    int a;
    long x = 0;
    int y = 1000001;
    int z = -1000001;
    
    cin >> n;
    
    for (i=1;i <= n;i++){
        cin >> a;
        x += a;
        
        if(y >= a){
            y = a;
        }
        if(z <= a){
            z = a;
        }
        
    }
    cout << y <<" "<< z <<" "<< x <<endl;
    
    return 0;
}



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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	ll x = 1, y = 1;
	FOR(i,0,n) {
		ll a, b; cin >> a >> b;
		ll c = (x+a-1)/a, d = (y+b-1)/b;
		c = max(c,d);
		x = c*a, y = c*b;
	}
	cout << x+y << endl;
}



Measured memory_bytes: 256
#132 b
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(n-2):
    a=p[i]
    b=p[i+1]
    c=p[i+2]
    if b!=min(a,b,c) and b!=max(a,b,c):
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void){
  int n,i,j;
  string sb;
  vector <string> s;
  bool ans=true;
  cin >> n;
  for (i=0;i<n;i++){
    cin >> sb;
    if (i>0&&sb[0]!=s[i-1].back()) ans=false;
    for (j=0;j<i;j++) if (s[j]==sb){
      ans=false;
      break;
    }
    if (!ans) break;
    s.push_back(sb);
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
int main()
{
    ios;
    ll n ;
    cin >> n ;
    vector<ll> v;
    for(ll i=1;i<=n;++i){
        ll x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin() , v.end());
    v[n-1] = v[n-1]/2;
    ll oo = accumulate(v.begin() , v.end() , 0);
    cout << oo <<endl;

}


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

using namespace std;
typedef long long ll;

int main(void) {
	ll n, s, buf, sum;
	cin >> n >> s;
	if (n == s) {
		cout << n + 1 << "\n";
		return 0;	
	}
	for (ll i = 2; i <= sqrt(n); i++) {
		sum = 0;
		buf = n;
		while (buf > 0) {
			sum += buf % i;
			buf /= i;
		}
		if (sum == s) {
			cout << i << "\n";
			return 0;
		}
	}
	sum = n << 1;
	for (ll i = 1; i < sqrt(n); i++) {
		buf = (n - s) / i + 1;
		if (buf > 0 && n % buf + i == s)
			sum = min(sum, buf);
	}
	if (sum == n << 1)
		printf("-1\n");
	else
		cout << sum << "\n";
	return 0;
}

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

int main() {
    int n,sum = 0;
    cin >> n;
    vector<int> data(n);
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            if(i == j)break;
            sum += data.at(i) * data.at(j);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
//@Author- sitanshu
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair 
#define mii map<int, int>
#define umii unordered_map<int, int>
#define vi vector<int>
#define vl vector<ll>
#define clr(val) memset(val,0,sizeof(val))
const ll MAX = 1000009, MOD = 1e9 + 7;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);


void solve()
{
    int n, k;
    cin >> n >> k;
    int arr[n], dp[n];
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
        if (i == 0)
        dp[i] = 0;
        else
        {
            dp[i] = INT_MAX;
            for(int x = 1; i-x>= 0 && x <= k; x++)
            {
                dp[i] = min(dp[i], dp[i-x]+abs(arr[i]-arr[i-x]));

            }

        }
        
        
    }   

    cout << dp[n-1] << endl;

   
}



int main()
{
    //OJ;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    t = 1;
    while(t--)
    {
        solve();
    }  
    return 0;
}

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

//LIFE IS NOT A PROBLEM TO BE SOLVED

#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
#define debug(a) cout << #a << " = " << a << endl;
#define debug2(a,b) cout << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugP(a) cout << a.F << " " << a.S << endl;
#define debugM(mat,n,m) rep( i, 0, n ){ rep( j, 0, m ) cout << mat[i][j] << " "; cout << endl; }
#define all(s) s.begin(), s.end()

using namespace std;

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

int main(){
	
	int a, b, k; cin >> a >> b >> k;
	vector <int> v;
	rep(i, 1, 101){
		if(a%i==0 && b%i==0){
			v.pb(i);
		}
	}
	
	reverse(v.begin(), v.end());
	cout << v[k-1] << '\n';
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define U [1<<17]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;
map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)
	d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}
L M(L i){return i?B[i]+M(i^i&-i):0;}
L S(L a,L i){for(a=M(i++G i);i<1e5;i+=i&-i)B[i]+=a;}
L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}
main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
	for(D(a=b=0);n<*Z;a=H[P[++n]]-n?n:0)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;
	for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}

Measured memory_bytes: 33400
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    
    if m==-1 or f==-1:
        print('F')
    elif m+f>=80:
        print('A')
    elif m+f>=65 and  m+f<80:
        print('B')
    elif (m+f>=50 and  m+f<65) or (m+f>=30 and  m+f<50 and r>=50):
        print('C')
    elif m+f>=30 and  m+f<50 and r<50:
        print('D') 
    else:
        print('F')



Measured memory_bytes: 5588
N = list(str(input()))
one = int(N[-1])


def honpon(one):
    if one==2 or one==4 or one==5 or one==7 or one==9:
        return 'hon'
    elif one==0 or one==1 or one==6 or one==8:
        return 'pon'
    elif one==3:
        return 'bon'

print(honpon(one))

Measured memory_bytes: 9192
#include <iostream>
using namespace std;
int main(){

  int n;
  cin>>n;

  if(n%7==1) cout<<"fri"<<endl;
  if(n%7==2) cout<<"sat"<<endl;
  if(n%7==3) cout<<"sun"<<endl;
  if(n%7==4) cout<<"mon"<<endl;
  if(n%7==5) cout<<"tue"<<endl;
  if(n%7==6) cout<<"wed"<<endl;
  if(n%7==0) cout<<"thu"<<endl;

  return 0;

}



Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    long x, y;
    vector<long> a;
    vector<long> b;
    vector<long> c;
    vector<long> d;
    vector<int> ans;

    for(int i = 0; i < N; i++){
        cin >> x >> y;
        a.push_back(x);
        b.push_back(y);
    }
    for(int i = 0; i < M; i++){
        cin >> x >> y;
        c.push_back(x);
        d.push_back(y);
    }


    for(int i = 0; i < a.size(); i++){
        int min_num = 0;
        long temp = 0;
        long min = labs(a[i] - c[0]) + labs(b[i] - d[0]);
        for(int j = 1; j < c.size(); j++){
            temp = labs(a[i] - c[j]) + labs(b[i] - d[j]);
            if(temp < min){
                min = temp;
                min_num = j;
            }
        }
        ans.push_back(min_num + 1);
    }

    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }

    return 0;
}


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

const int maxn=5e5+10;

int n,L,H,T;

struct Point{
	LL x;
	double y;
	Point() {}
	Point(LL x,double y):x(x),y(y) {}
	Point operator + (const Point &p) const {return Point(x+p.x,y+p.y);}
	Point operator - (const Point &p) const {return Point(x-p.x,y-p.y);}
};

double Cross(Point A,Point B) {return A.x*B.y-A.y*B.x;}

Point P[maxn];

Point GetPoint(Point A,Point B,LL x)
{
	double t=((double)x-A.x)/(B.x-A.x);
	return Point(x,A.y+t*(B.y-A.y));
}

int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	scanf("%d%d",&n,&L);
	H=T=1;
	P[1]=Point(0,0);
	while (n--)
	{
		Point p;
		scanf("%lf%lld",&p.y,&p.x);
		p.y*=p.x;
		T++;
		P[T]=P[T-1]-p;
		while (H!=T&&P[H+1].x-P[T].x>=L) H++;
		if (P[H].x-P[T].x>L)
			P[H]=GetPoint(P[H],P[H+1],P[T].x+L);
		while (H+1<T&&Cross(P[T-1]-P[T],P[T-2]-P[T])>=0) P[T-1]=P[T],T--;
		if (n%5000==0) for (int i=H;i<=T;i++) P[i]=P[i]-P[T];
		printf("%.10lf\n",((double)P[H].y-P[T].y)/L);
	}
}


Measured memory_bytes: 18304
from collections import deque
N=int(input())
visited=[-1]*N
l=[[] for i in range(N)]
for i in range(N-1):
   a,b,c=map(int,input().split())
   a-=1;b-=1
   l[a].append((b,c%2))
   l[b].append((a,c%2))
def ans(node,dis):
   visited[node]=0
   que=deque(l[node])
   while que:
      node,dis=que.popleft()
      visited[node]=dis
      for i,j in l[node]:
         if visited[i]==-1:
            visited[i]=(dis+j)%2
            que.append((i,(dis+j)%2))
ans(0,0)
for i in visited:
   print(i)

Measured memory_bytes: 39852
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  string s, t; cin >> s >> t;
  int n = s.size();
  int retval = 0;
  rep(i,n) {
    if (s[i]!=t[i]) retval++;
  }
  cout << retval <<endl;
  

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3920
a,b=input().split()
r=''
x=0
for i in b:
  if i=='.':
    r=r
  elif i!='0':
    x=1
    r=r+i
  elif x==1 and i=='0':
    r=r+i
if len(r)==0:
  r='0'
A=int(a)
B=int(r)
print(A*B//100)

Measured memory_bytes: 9228
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Array as A
import qualified Data.Vector.Unboxed as VU

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    as <- VU.fromList <$> getIntList
    let ss = VU.scanl (+) 0 as
    let arr = A.array ((1,1),(n,n)) [((l,r), f l r) | l <- [1..n], r <- [1..n]]
                where f l r | l >= r = 0
                            | otherwise = minimum $ map g [l..r-1]
                            where g m = (arr A.! (l,m)) + (arr A.! (m+1,r)) + (ss VU.! r) - (ss VU.! (l-1))
    print $ arr A.! (1,n)

Measured memory_bytes: 23932
N=int(input())
H=list(map(int,input().split()))
a=True
for i in range(N-1, 0, -1):
    if H[i-1]>H[i]:
        if H[i-1]-H[i]>1:
            a=False
            break
        else:
            H[i-1]-=1
print("Yes" if a else "No")

Measured memory_bytes: 14396