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


int main()
{
	int n, k;
	cin>> n >> k;
	vector<int> a(n-1);
	
	int a0;
	cin>> a0;
	for(int i=0;i<n-1;i++){
		cin>>a[i];
	}
	
	long long ans = 1E13;
	for(int bit=0;bit<(1<<(n-1));bit++){
		int col = 1;
		vector<bool> look(n-1);
		long long cost = 0;
		for(int i=0;i<n-1;i++){
			if(bit&(1<<i)){
				look[i] = 1;
				col++;
			}
		}
		if(col<k) continue;
		
		int hight = a0;
		for(int i=0;i<n-1;i++){
			if(look[i]){
				if(a[i]<hight+1){
					cost += (hight+1-a[i]);
					hight++;
				}else{
					hight = a[i];
				}
			}else{
				if(hight<a[i]){
					hight = a[i];
				}
			}
		}
		if(cost<ans) ans = cost;
	}
	cout<<ans<<endl;
}


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

int main(void){
    long long H,W;
    const int MAX = 100000;
    // input
    cin >> H >> W;
    // 制約
    if (H < 2 && H > MAX && W < 2 && W > MAX){
        return 0;
    }
    // 横 横
    if (H % 3 == 0 || W % 3 == 0){
        cout << 0 << endl;
        return 0;
    }
    long long Sa,Sb,Sc,Smax,Smin;
    long long ans = 100000000000000;
    if (H % 3 == 0){
        ans = 0;
    }else{
        ans = min(ans, W);
    }
    if (W % 3 == 0){
        ans = 0;
    }else{
        ans = min(ans, H);
    }
    // 横 縦
    for (int i = 1;i < H;i++){
        Sa = i * W;
        long long w = W / 2;
        Sb = (H - i)*w;
        Sc = (H - i)*(W -w);
        Smax = max(Sa,max(Sc,Sb));
        Smin = min(Sa,min(Sc,Sb));
        ans = min(ans,Smax - Smin);
    }
    // 縦 横
    swap(H,W);
    for (int i = 1;i < H;i++){
        Sa = i * W;
        long long w = W / 2;
        Sb = (H - i)*w;
        Sc = (H - i)*(W -w);
        Smax = max(Sa,max(Sc,Sb));
        Smin = min(Sa,min(Sc,Sb));
        ans = min(ans,Smax - Smin);
    }
    cout << ans << endl;

    return 0;
}


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


int a,b,c;

int main(){
	cin >> a>> b >> c;
	
	cout << (a -= b) - c*(a/c) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
void p(vector<int>a){
	for(int i=0;i<a.size();i++) cout<<a[i]<<" ";
	return;
}
/*
int gcd (vector<int>&a){
	p(a);
	int min=1e9+1,max=0,flg=0;
	for(int i=0;i<a.size();i++){
		if(min>a[i]&&a[i]!=0) min=a[i];
		if (max<a[i])max=a[i];
	}
	if (min==max) return max;
	else{
		for(int i=0;i<a.size();i++){
			if(flg==0&&a[i]==min){
				flg=1;
			}
				a[i]=a[i]%min;
		}
		return gcd(a);
	}
}
*/
int gcd(int a,int b){
//	cout<<"a="<<a<<",b="<<b<<endl;
	int min,max;
	if (a<b){
		min=a;
		max=b;
	}else{
		min=b;
		max=a;
	}
	if (min==0) return max;
	else{
		return gcd(min,max%min);
	}
}
int main(){
	int n;
	cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	int rslt=a[0];
	for(int i=1;i<n;i++){
		rslt=gcd(rslt,a[i]);
	}
	cout<<rslt<<endl;
	return 0;
}

Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;

fn main() {
    let k: i64 = read();
    let a: i64 = read();
    let b: i64 = read();
    if a + 1 >= b || a > k {
        println!("{}", k+1);
        return;
    }

    let po: i64 = k - (a+1);
    let mut ans: i64 = b;
    if po % 2 == 0 {
        ans += (b-a) * (po/2);
    } else {
        ans += (b-a) * ((po-1)/2) + 1;
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


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

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
#define deb1(x) cout << #x <<"="<< x <<endl;
#define deb2(x,y) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<endl;
#define deb3(x,y,z) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<<endl;
#define deb4(x,y,z,a) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<< ", "<<#a <<"="<<a << endl;
#define debarr(x) cout << #x<<endl;for(int i : x){cout << i <<" ";} cout <<endl;

const int N = 2e3;
char grid[N][N];
int h,w;

int dp[N][N];

void mymain(){
  cin >> h >> w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        cin >> grid[i][j];
    }
  }
  int i=1;
  while(grid[0][i] == '.'){
    dp[0][i] = 1;
    i++;
  }
  while(i<w){
    dp[0][i] = 0;
    i++;
  }
  i=1;
  while(grid[i][0]=='.'){
    dp[i][0] = 1;
    i++;
  }
  while(i<h){
    dp[i][0] = 0;
    i++;
  }
  for(int i=1;i<h;i++){
    for(int j=1;j<w;j++){
        if(grid[i][j] == '#')
            dp[i][j] = 0;
        else{
            dp[i][j] = ( dp[i-1][j] + dp[i][j-1] ) % mod;
        }
    }
  }

  cout << dp[h-1][w-1] <<endl;
  /*for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        cout << dp[i][j] <<" ";
    }
    cout << endl;
  }*/



}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
//cin>>t;

for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}
/*

*/


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


void print(int a[][10]){
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 10; j++){
            cout<< " " << a[i][j];
        }
        cout << endl;
    }
}

int main()
{
    int n,b,f,r,v = 0;
    cin >> n;
    
    int A[3][10], B[3][10], C[3][10], D[3][10];
    
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 10; j++){
            A[i][j] = 0;
            B[i][j] = 0;
            C[i][j] = 0;
            D[i][j] = 0;
        }
    }
    
    for (int i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        
        if (b == 1) A[f-1][r-1] += v;
        else if (b == 2) B[f-1][r-1] += v;
        else if (b == 3) C[f-1][r-1] += v;
        else D[f-1][r-1] += v;
    }

    print(A);
    cout << "####################" << endl;
    print(B);
    cout << "####################" << endl;
    print(C);
    cout << "####################" << endl;
    print(D);

    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int n;
  cin >> n;
  vector<int> v1(n/2+1);
  vector<int> v2(n/2+1);
  rep(i, n) {
    if (i % 2 == 0) cin >> v1[i/2];
    else cin >> v2[i/2];
  }
  v1[n/2] = 100005;
  v2[n/2] = 100005;
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  vector<pair<int, int>> maxv1(3);
  vector<pair<int, int>> maxv2(3);
  rep(i, n/2+1) {
    if (v1[i] == maxv1[0].first) maxv1[0].second++;
    else {
      if (maxv1[0].second > maxv1[2].second) {
        swap(maxv1[0], maxv1[2]);
        if (maxv1[1].second < maxv1[2].second) {
          swap(maxv1[1], maxv1[2]);
        }
      }
      maxv1[0].first = v1[i];
      maxv1[0].second = 1;
    }
  }
  rep(i, n/2+1) {
    if (v2[i] == maxv2[0].first) maxv2[0].second++;
    else {
      if (maxv2[0].second > maxv2[2].second) {
        swap(maxv2[0], maxv2[2]);
        if (maxv2[1].second < maxv2[2].second) {
          swap(maxv2[1], maxv2[2]);
        }
      }
      maxv2[0].first = v2[i];
      maxv2[0].second = 1;
    }
  }
  if (maxv1[1].first != maxv2[1].first) cout << n-maxv1[1].second-maxv2[1].second << endl;
  else cout << n-(max(maxv1[1].second+maxv2[2].second, maxv1[2].second+maxv2[1].second)) << endl;
}

Measured memory_bytes: 640
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int A,B;
    cin>>A>>B;
    int ans=0;

    for(int i=A;i<=B;i++){
        int s=i%10;
        int t=i/10000%10;
        int u=i/10%10;
        int v=i/1000%10;

        if(s==t&&u==v){
            ans++;
        }
    }

    cout<<ans<<endl;

}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>
#include <cmath>
#include <unordered_map>

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


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    int ans=N%1000;
    if(ans!=0){
        ans=1000-ans;
    }
    
    cout<<ans<<endl;;


    return 0;
}


Measured memory_bytes: 3752
package main

import (
	"fmt"
)

func main() {
	var a, b, c, x int
	fmt.Scan(&a, &b, &c, &x)
	total, count := 0, 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				total = 500*i + 100*j + 50*k
				if total == x {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
import math

N = int(input())
list = []
for i in range(5):
    list.append(int(input()))
#print(list)
twn = [0] * 6
twn[0] = N
#print(twn)

ans = []
for i in range(5):
    ans.append(math.ceil(N / list[i]))
#print(ans)
#print(sum(ans))

answer = ans[0] + ans[1] - 1 + ans[2] - 1 + ans[3] - 1 + ans[4]
#print(answer)
#print(max(sum(ans),answer))
print(max(ans) + 4)

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

int main() {
    int64_t N,M,H_self;
    int64_t cnt = 0;
    int64_t A,B;
    cin >> N >> M;
    vector<int64_t> H(N);
    vector<int64_t> judge(N,1);
    vector<priority_queue<int>> kumi(M);
    for(int i = 0; i < N; i++){
        cin >> H.at(i);
    }

    for(int i = 0; i < M; i++){
        cin >> A >> B;
        if(H.at(A-1) == H.at(B-1)){
            judge.at(A-1) = 0;
            judge.at(B-1) = 0;
        }else if(H.at(A-1) < H.at(B-1)){
            judge.at(A-1) = 0;
        }else{
            judge.at(B-1) = 0;
        }
    }

    for(int i = 0; i < N; i++){
        if(judge.at(i) == 1){
            cnt++;
        }
    }


    cout << cnt << endl;
}


Measured memory_bytes: 8008
#include <bits/stdc++.h>
#define orta ((bas+son)/2)
#define N 1000005
using namespace std;
typedef long long ll;
ll n, a[N], bas = -1000000000, son = 1000000000;
// ll bas = -2000000000, son = 2000000000;

ll bak(ll b){
	ll ans = 0;
	for(ll i = 1; i <= n; i++){
		ans += abs(a[i] - (b + i));
	}
	return ans;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld",&n);
	for(ll i = 1; i <= n; i++)
		scanf("%lld",a+i);
	while(bas + 1 < son){
		ll bir = bak(orta);
		ll iki = bak(orta + 1);
		if(bir < iki)
			son = orta;
		else if(iki < bir)
			bas = orta + 1;
		else{
			printf("%lld\n", bak(orta));
			return 0;
		}
	}
	printf("%lld\n",min(bak(bas), bak(son)));
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,l;
    scanf("%d%d",&n,&l);
    int sum=0;
    for(int i=1;i<=n;i++)
        sum=(sum+l+i-1);
    int ans=1e9,ma;
    for(int i=1;i<=n;i++)
    {
        int res=0;
        for(int j=1;j<=n;j++)
        {
            if(j==i) continue;
            res=(res+l+j-1);
        }
        if(abs(res-sum)<ans)
        ans=min(ans,abs(res-sum)),ma=res;
    }
    printf("%d\n",ma);
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int N,K;
	scanf("%d %d",&N,&K);
	int a=1,i;
	for(i=0; i<N; i++) {
		if(i==0) {
			a=K;
		} else {
			a=a*(K-1);
		}
	}
	printf("%d\n",a);
	return 0;
}

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

int frac(int n){
  if (n == 1) return 1;
  return n * frac(n - 1);
}

int main(){
  int n; cin >> n;
  int x[10], y[10];
  for (int i = 0; i < n; i++){
    cin >> x[i] >> y[i];
  }
  double sum = 0;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    a.at(i) = i;
  }
  auto dist = [&](int p, int q){
    int s = (x[p] - x[q]) * (x[p] - x[q])
    + (y[p] - y[q]) * (y[p] - y[q]);
    double ret = sqrt(s);
    return ret;
  };
  do{
    for (int i = 0; i < n - 1; i++){
      sum += dist(a.at(i), a.at(i + 1));
    }
  }while (next_permutation(a.begin(), a.end()));

  double ans = sum / frac(n);
  printf("%.10f\n", ans);
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

using P=std::pair<ll, int>;

int n;
std::vector<std::pair<int, ll>> e[100005];
ll d[100005];
int main() {
	std::cin >> n;

	int f = 0;
	for (int i = 0, end = n - 1; i < end; ++i) {
		int u, v;
		ll w;
		std::cin >> u >> v >> w;

		--u, --v;
		if (i == 0)
			f = u;

		e[u].emplace_back(v, w);
		e[v].emplace_back(u, w);

	}

	std::priority_queue<P, std::vector<P>, std::greater<P>> que;

	std::fill(d, d + n, inf);
	d[f] = 0;
	que.emplace(0, f);

	while (!que.empty())
	{
		auto p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first)
			continue;
		for (int i = 0, end = e[v].size(); i < end; ++i)
		{
			auto ee = e[v][i];
			if (d[ee.first] > d[v] + ee.second)
			{
				d[ee.first] = d[v] + ee.second;
				que.emplace(d[ee.first], ee.first);
			}
		}
	}

	std::cout << 1 << std::endl;
	for (int i = 1; i < n; ++i)
	{
		if (d[0] % 2 == d[i] % 2)
			std::cout << 1 << std::endl;
		else
			std::cout << 0 << std::endl;
	}

	return 0;
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
        sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
        {
sim > struct rge
{
        c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
        ~debug()
        {
                cerr << endl;
        }
        eni(!=) cerr << boolalpha << i;
        ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
        ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
                *this << ", " + 2 * (it == d.b) << *it;
        ris << "]";
}
#else
        sim dor(const c &)
        {
                ris;
        }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{
        ll n; cin >> n;
        map<int, int> m;
        for (int i = 0; i < n; ++i)
        {
                ll x; cin >> x;
                m[x]++;
        }
        ll res = 0;
        for (auto x: m)
        {
                if (x.second >= x.first)
                {
                        res += (x.second - x.first);
                }
                else
                {
                        res += x.second;
                }
        }
        cout << res << endl;
}

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



Measured memory_bytes: 7940
#include <bits/stdc++.h>
using namespace std;
#define N 100005 
int n,m,ans[2],vs[N][2];
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1,x;i<=m;++i)
	{
		char a[5];scanf("%d %s",&x,a);
		if(a[0]=='A') vs[x][0]=1;
		else if(!vs[x][0]) ++vs[x][1];
	}
	for(int i=1;i<=n;++i) if(vs[i][0])
		ans[0]+=vs[i][0],ans[1]+=vs[i][1];
	printf("%d %d\n",ans[0],ans[1]);return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  string s;
  cin >> n >> s;
  ll r = 0;
  for(int i = 0;i < (int)s.size();i++){
    if(s[i] == 'R')r++;
  }
  ll res = r;
  for(int i = 0;i < r;i++){
    if(s[i] == 'R')res--;
  }
  cout << res << endl;
}

Measured memory_bytes: 3748
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void){

    int N,K; cin>>N>>K;
    vector<ll> X(N);
    for (int i = 0; i < N; ++i) {
        cin>>X[i];
    }
    ll ans = 1000000000;
    for (int i = 0; i < N-K+1; ++i) {
        if(abs(X[i])>=abs(X[i+K-1])){
            ans = min(ans, abs(X[i+K-1]) + abs(X[i+K-1]-X[i]));
        }else{
            ans = min(ans, abs(X[i]) + abs(X[i+K-1]-X[i]));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
//
// Created by yuu on 2019-08-10.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;


int main(void){
    int A,B;
    cin>>A>>B;

    int temp = A - B;

    if(temp < A*B){temp = A*B;}

    if(temp < A+B)temp = A+B;



    cout<<temp<<endl;



    return 0;
}


Measured memory_bytes: 256
n, x, m =  map(int, input().split())
ans = 0
loop_list = [0] * m
loop_list[x] = 1
order_list = [x]

for i in range(1, m + 1):
    x = pow(x, 2, m)
    if loop_list[x] != 1:
        loop_list[x] = 1
        order_list.append(x)
    else:
        break

index = order_list.index(x)
time = (n - index) // (len(order_list) - index)
mod = (n - index) % (len(order_list) - index)

ans += sum(order_list[:index])
ans += sum(order_list[index:]) * time
ans += sum(order_list[index:index + mod])

print(ans)


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

int main() {
	int N;
	bool flag = false;

	cin >> N;

	int tmp = N;
	for (int i = 0; i < N; i++) {
		if (tmp % 10 == 7) {
			flag = true;
		}
		tmp /= 10;
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3612
import itertools

N,K = map(int,input().split())
a = list(map(int,input().split()))
lis = [x for x in range(1,N)]
m = 10**15

for con in itertools.combinations(lis, K-1):
  mm = 0
  f = a[0]
  for i in range(K-1):
    if f+1 <= a[con[i]]:
      f = a[con[i]]
    else:
      mm += (f+1) - a[con[i]]
      f += 1
    for j in range(con[i]-1):
      if a[j] >= f:
        mm = 10**15
        break
    else:
      continue
    break
  m = min(m,mm)
  
print(m)

Measured memory_bytes: 41456
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	int n = readln.chomp.to!int;
	int[] as = readln.chomp.split.map!(to!int).map!(x => x - 1).array;
	
	int count = 0;
	
	foreach(i, a; as){
		if(i < a && as[a] == i) count ++;
		}
	
	count.writeln;
	
	}

Measured memory_bytes: 3004
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main()
{
    int n;
    int c[200005]={};
    long long int color_dp[200005]={};
    long long int dp=1;
    long long int backdp;
    scanf("%d",&n);
    int col;
    scanf("%d",&c[0]);
    int count=1;
    REP(i,n){
        scanf("%d",&col);
        if(c[count-1]!=col){
            c[count]=col;
            count++;
        }
    }
    REP(i,count){
        backdp=dp;
        dp+=color_dp[c[i]];
        dp%=1000000007;
        color_dp[c[i]]+=backdp;
        color_dp[c[i]]%=1000000007;
    }
    printf("%lld\n",dp);
    return 0;
}

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

int main(){
  int a,b,c;cin >> a >> b >> c;
  if(a+b == c)cout << "Yes" << endl;
  else if(b+c == a)cout << "Yes" << endl;
  else if(a+c == b)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main(){
	int A,B,x;
  cin>> A >> B;
  for(int i=A;i<B+1;i++){
  	 if(i/10000==i%10&&i/1000%10==i%100/10) x++;
     }
  	  cout << x;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int main(void) {

	ll N;
	cin >> N;
	vector<ll> a(N);
	REP(i, N) cin >> a[i];

	sort(a.begin(), a.end());

	cout << (a[N-1] - a[0]) << endl;

	return 0;
}

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

struct edge{int from,to,cost;};
const int INF = 1000000000;

int main(){
	int v,e,r;
	vector<edge> E;
	scanf("%d %d %d",&v,&e,&r);
	for(int i=0;i<e;i++){
		int s,t,d;
		scanf("%d %d %d",&s,&t,&d);
		edge e;
		e.from = s;
		e.to = t;
		e.cost = d;
		E.push_back(e);
	}
	int d[1000];
	fill(d,d+v,INF);
	d[r] = 0;
	for(int i=0;i<v;i++){
		bool flag = true;
		for(int j=0;j<e;j++){
			if(d[E[j].from]!=INF&&d[E[j].to]>d[E[j].from]+E[j].cost){
				d[E[j].to] = d[E[j].from] + E[j].cost;
				flag = false;
			}
		}
		if(flag) break;
		if(i==v-1){
			printf("NEGATIVE CYCLE\n");
			return 0;
		}
	}
	for(int i=0;i<v;i++){
		if(d[i]==INF) printf("INF\n");
		else printf("%d\n",d[i]);
	}
	return 0;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n' //toggle off for interactive problems
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 2e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int n, x[N], y[N];
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i=0; i<n; i++) cin >> x[i] >> y[i];
	int max_sum = x[0] + y[0];
	int min_sum = x[0] + y[0];
	int max_dif = x[0] - y[0];
	int min_dif = x[0] - y[0];
	for(int i=1; i<n; i++){
		max_sum = max(max_sum, x[i]+y[i]);
		min_sum = min(min_sum, x[i]+y[i]);
		max_dif = max(max_dif, x[i]-y[i]);
		min_dif = min(min_dif, x[i]-y[i]);
	}
	int ans = max(max_sum-min_sum, max_dif-min_dif);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5224
//--------------------------------------------------
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,avx,avx2,popcnt,fma")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
//--------------------------------------------------
#include <bits/stdc++.h>
#include <chrono>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <time.h>
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#include <stack>
#include <cstring>
//--------------------------------------------------
#define forn(i, n) for(int i = 0; i < n; i++)
#define forw(i, n) for(int i = n-1; i >= 0; --i)
#define forns(i, n, s) for(int i = s; i < n; i++)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
//----------------------------------------------------
using namespace std;
//----------------------------------------------------
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef vector<ll> lnum;
typedef complex<ld> comp;
//----------------------------------------------------
const ll mod = 1e9 + 7, mod2 = 998244353;
const ld eps = 1e-6;
const ll inf = 1e18;
const int base = 1e9;
const ld PI = 3.1415926;
//----------------------------------------------------
//#define endl '\n';
#ifdef MY_DEBUG
void deb(ld x) { cerr << x << endl; };
#else
void deb(ld x){};
#endif
//----------------------------------------------------
int n, p;
string s;
ll ans = 0, curr = 0;
ll pw[2*100*1000], nx[2*100*1000+1], last[10*1000+1], dp[2*100*1000+1];
//----------------------------------------------------
unsigned int bitcount(ull val) { return __builtin_popcount(val) + __builtin_popcount(val >> 32); }

void local() {
    freopen("test.in", "r", stdin);
}

void remote() {
}

void read() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> p >> s;
}

int main() {
#ifdef MY_DEBUG
    local();
#else
    remote();
#endif
    read();

    if(p == 2 || p == 5){
        forn(i, n) if((s[i]-'0') % p == 0) ans += i+1;
        cout << ans << endl;
        return 0;
    }

    fill(nx, nx+n+1, -1);
    fill(last, last+p+1, -1);
    pw[0] = 1;
    forns(i, n, 1) pw[i] = (pw[i-1] * 10) % p;

    last[0] = n;
    forw(i, n){
        curr += pw[n-1-i] * (s[i]-'0'), curr %= p;
        if(last[curr] != -1)
            nx[last[curr]] = i;
        last[curr] = i;
    }

    forn(i, n+1){
        int j = nx[i];
        dp[i] = j >= 0 ? (dp[j]) + 1: 0;
        ans += dp[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 5396
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int xG = -x;
		int yG = -y;
		int ans = Integer.MAX_VALUE;
		if(x <= y) {
			ans = Math.min(ans, y-x);
		}
		if(xG <= y) {
			ans = Math.min(ans, y-xG+1);
		}
		if(x <= yG) {
			ans = Math.min(ans, yG-x+1);
		}
		if(xG <= yG) {
			ans = Math.min(ans, yG-xG+2);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22100
#define _USE_MATH_DEFINES
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <cctype>
#include <cstdlib>
#include <map>
using namespace std;

#define INF (1 << 20)
#define EPS (1e-10)
#define EQ(a,b) (fabs((a)-(b)) < EPS)

int main(){
	int cnt[100] = {};
	int n;
	while (cin >> n) ++cnt[n];
	int M = 0;
	for (int i = 0; i < 100; ++i) M = max(M, cnt[i]);
	for (int i = 0; i < 100; ++i) if (cnt[i] == M) cout << i << endl;
	return 0;
}

Measured memory_bytes: 1160
A,B,C = map(int,input().split())
K = int(input())

for i in range(K+1):
  if( i == K+1 ):
    break
  for j in range(K+1):
    if( i + j == K+1 ):
      break
    for k in range(K+1):
      if( i + j + k == K+1 ):
        break
      if A*(2**i) < B*(2**j) < C*(2**k):
        print("Yes")
        exit()
     
print("No")

Measured memory_bytes: 9192
"""
AtCoder :: M-Solutions Programming Contest 2020 :: Magic 2
https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_b
"""
import sys


def solve(red, green, blue, K):
    """Solve puzzle."""
    # The integer on the green card is strictly greater than the integer on the red card.
    # The integer on the blue card is strictly greater than the integer on the green card.
    for _ in range(K):
        if green > red and blue > green:
            return True

        if red >= green:
            green *= 2
        else:
            blue *= 2

    return green > red and blue > green


def main():
    """Main program."""
    red, green, blue = (int(i) for i in sys.stdin.readline().split())
    K = int(sys.stdin.readline())
    if solve(red, green, blue, K):
        print('Yes')
    else:
        print('No')
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
aten_num, sta_poi, corect_num = tuple(int(i) for i in input().split(" "))
aten_list = []
for i in range(aten_num):
    aten_list.append(0)
for i in range(corect_num):
    corect_aten = int(input())
    aten_list[corect_aten - 1] += 1
for i in range(aten_num):
    if sta_poi - corect_num + aten_list[i] > 0:
        print("Yes")
    else:
        print("No")


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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int x = b - a;
    if (x % 2 == 0)
        cout << "Alice" << endl;
    else
        cout << "Borys" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string n;
    cin >> n;
    for (int i = 0; i < n.size(); i++)
    {
        if (n[i] == '1')
        {
            n[i] = '9';
        }
        else if (n[i] = '9')
        {
            n[i] = '1';
        }
    }
    cout << n << endl;
}


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

using namespace std;

#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())

typedef long long ll;typedef vector<int> vi;
typedef pair<int,int> ii;typedef vector<ii> vii;
typedef vector<vi> vvi;

signed main(){
	IOS
	int x,y;cin>>x>>y;
	int a = 4*x-y;
	if(a<0||a%2){
		cout<<"No";
	}
	else{
		a/=2;
		if(a<=x)
			cout<<"Yes";
		else
			cout<<"No";
	}
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


const long long INF = 1LL<<60;

vector<vector<int>> calcsame(string S, string T) {
    int N = S.size();
    vector<vector<int>> res(N+1, vector<int>(N+1, 0));
    for (int i = 0; i <= N; ++i) {
        res[i][0] = 0;
        for (int j = 0; i + j < N; ++j) {
            if (S[i+j] == T[j]) res[i+j+1][j+1] = res[i+j][j]+1;
            else res[i+j+1][j+1] = res[i+j][j];
        }
        res[0][i] = 0;
        for (int j = 0; i + j < N; ++j) {
            if (S[j] == T[i+j]) res[j+1][i+j+1] = res[j][i+j]+1;
            else res[j+1][i+j+1] = res[j][i+j];
        }
    }
    return res;
}

long long calccost(string S, string T) {
    int N = S.size();
    const auto& cost = calcsame(S, T);

    //COUT(S); COUT(T); COUT(cost);
    
    vector<vector<long long>> dp(N+1, vector<long long>(N+1, INF));
    dp[0][0] = 0;
    for (int l = 0; l <= N; ++l) {
        for (int r = 0; r <= N; ++r) {
            if (l) {
                chmin(dp[l][r], dp[l-1][r] + cost[l][r]);
            }
            if (r) {
                chmin(dp[l][r], dp[l][r-1] + cost[l][r]);
            }
        }
    }
    return dp[N][N];
}

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> fi(W, string(H, 'U'));
    for (int i = 0; i < H; ++i) for (int j = 0; j < W; ++j) cin >> fi[j][i];
    long long res = 0;
    for (int i = 0; i + 1 < fi.size(); ++i) {
        res += calccost(fi[i], fi[i+1]);
    }
    cout << res << endl;
}


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

inline void ak(string s,int* a){
    if(s=="a"){
        *a=1;
    }else if(s=="b"){
        *a=2;
    }else if(s=="c"){
        *a=3;
    }else{
        *a=4;
    }
}

int main(){
    string b,a;
    int aa,bb;
    cin>>a>>b;
    ak(a,&aa);
    ak(b,&bb);
    if(a>b){
        cout<<">"<<endl;
    }else if(a<b){
        cout<<"<"<<endl;
    }else{
        cout<<"="<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}


int main(void){
    int n, k;
    scanf("%d %d", &n, &k);
    int l[50];
    int i;
    int ans = 0;
    for (i = 0; i < n; i++){
        scanf("%d", &l[i]);
    }

    qsort(l, n, sizeof(int), descending_compare);
    for (i = 0; i < k; i++){
        ans += l[i];
    }

    printf("%d\n", ans);
    return 0;
    
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9 + 7;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
const int mod = 1e9 + 7;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

struct Node {
    int parent = -1;
    int weight = -1;
    int id = -1;
    bool operator<(const Node &another) const {
        return weight < another.weight;
    };
};
int main() {
    int table[26] = {0};
    string s; cin >> s;
    int c = 0;
    rep(i, s.size()) {c++; table[s[i] - 'a']++;}
    if (c == 0) {cout << s.size() << endl; return 0;}
    vector<Node> node;
    rep(i, 26) {
        if (table[i]) {
            Node tmp;
            tmp.weight = table[i];
            tmp.id = i;
            node.push_back(tmp);
        }
    }
    //rep(j, node.size()) cout << node[j].id << " "; cout << endl;
    int n = (int)node.size() - 1;
    vector<Node> node2;
    c = node[node.size() - 1].id + 1;
    rep(i, n) {
        sort(node.begin(), node.end());
        Node next;
        next.weight = node[0].weight + node[1].weight;
        next.id = c++;
        node.push_back(next);
        node[0].parent = node[1].parent = next.id;
        node2.push_back(node[0]);
        node2.push_back(node[1]);
        node.erase(node.begin());
        node.erase(node.begin());
        //cout << endl; rep(j, node2.size()) cout << node2[j].id << " "; cout << endl;
        //rep(j, node.size()) cout << node[j].id << " "; cout << endl;
    }
    int cc = c;
    node2.push_back(node[0]);
    rep(i, 26) table[i] = 0;
    //rep(i, node2.size()) cout << node2[i].id << " "; cout << endl;
    //rep(i, node2.size()) if (node2[i].id == 25) cout << node2[i].parent << endl;
    rep(i, 26) {
        rep(j, node2.size()) {
            if (node2[j].id == i) {
                c = 0;
                Node now = node2[j];
                while (1) {
                    //cout << now.id << endl;
                    rep(k, node2.size()) {
                        if (node2[k].id == now.parent) {
                            now = node2[k];
                            break;
                        }
                    }
                    c++;
                    if (now.parent == -1) break;
                }
                table[i] = c;
                break;
            }
        }
    }
    c = 0;
    rep(i, s.size()) c += table[s[i] - 'a'];
    cout << c << endl;
}




Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
ll a[20000];
ll d[20000];
ll c[20000];
int main()
{
    memset(c,inf,sizeof(c));
    int n;
    cin>>n;
    ll  sum=1000;
    ll  k=0;
    int x=0,y=0;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    for(int i=1; i<=n; i++)
    {
        if(a[i]>=a[i+1]&&a[i]>a[i-1])
        {
            d[x++]=i;
        }
    }
    a[0]=inf;
    a[n+1]=inf;
    for(int i=1; i<=n; i++)
    {
        if(a[i]<a[i+1]&&a[i]<=a[i-1])
        {
            c[y++]=i;
        }
    }
    for(int i=0,j=0;i<y;i++)
    {
        for(;j<x;j++)
        {
            if(d[j]>c[i]&&a[c[i]]<a[d[j]])
            {
                k=k+sum/a[c[i]];
                sum=sum%a[c[i]];
                sum+=k*a[d[j]];
                k=0;
                break;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3700
import std.stdio, std.conv, std.string, std.array, std.algorithm;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];

    auto AS = readln.split.to!(long[]);
    sort!"a < b"(AS);

    int cnt;
    foreach (k, a; AS) {
        if (a >= K) continue;
        bool needed;
        auto s = a;
        size_t i, j;
        for (;;) {
            if (s >= K && s - a < K) {
                needed = true;
                break;
            } else if(i == AS.length) {
                break;
            } else if (i == k) {
                ++i;
            } else if (j == k) {
                ++j;
            } else if (s < K) {
                s += AS[i++];
            } else {
                s -= AS[j++];
            }
        }
        if (!needed) ++cnt;
    }
    writeln(cnt);
}

Measured memory_bytes: 2428
#include<iostream>
#include<string>
#include<cstdlib>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int s[100];
	int *sp=s;
	string str;
	while(cin>>str) {
		if(str=="+") {
			--sp;
			*(sp-1)+=*sp;
		} else if(str=="-") {
			--sp;
			*(sp-1)-=*sp;
		} else if(str=="*") {
			--sp;
			*(sp-1)*=*sp;
		} else {
			*sp++=atoi(str.c_str());
		}
	}
	cout<<*--sp<<'\n';
	return 0;
}



Measured memory_bytes: 3200
//Powerful Discount Tickets

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n,m;cin>>n>>m;
    if(n==m)cout<<"Yes"<<nnn;
    else cout<<"No"<<nnn;
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main(){
  int N,Y;
  cin>>N>>Y;
  for(int a=0;a<=N;a++){
    for(int b=0;b<=N;b++){
      if(N-a-b>=0 && 10000*a+5000*b+1000*(N-a-b)==Y){
        cout<<a<<" "<<b<<" "<<N-a-b<<endl;
        return 0;
      }
    }
  }
  cout<<-1<<" "<<-1<<" "<<-1<<endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
out = "No"
if S[0] == S[1]:
    if S[2] == S[3] and S[1] != S[2]:
        out = "Yes"
elif S[0] == S[2]:
    if S[1] == S[3] and S[1] != S[2]:
        out = "Yes"
elif S[0] == S[3]:
    if S[1] == S[2] and S[1] != S[0]:
        out = "Yes"
print(out)

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

int main() {
	while (true) {
		double n;
		cin >> n;
		if (n == 0) break;
		vector<int> a(n);
		for (int i = 0; i < n; i++) cin >> a[i];

		double sum = 0;
		for (int i = 0; i < n; i++) {
			sum += a[i];
		}

		double ave = sum / n;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			if (ave >= a[i]) {
				cnt++;
			}
		}
		cout << cnt << endl;
	}
}



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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

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

    vector<int> vec;
    for(int i = k - 1; 0 < i; i--){
        int num = x - i;
        if(num < -1000000) break;
        vec.push_back(num);
    }
    vec.push_back(x);
    for(int i = 1; i < k; i++){
        int num = x + i;
        if(1000000 < num) break;
        vec.push_back(num);
    }
    int s = vec.size();
    rep(i, s){
        cout << vec[i] << " ";
        if(i == s - 1) {
            cout << endl;
        }
    }
}


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

int main(){
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  
  if( e-a>k ){
    cout << ":(" << endl;
  }else{
    cout << "Yay!"<< endl;
  }
}
          

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a= sc.nextLong();
		long b = sc.nextLong();
		if (a>0) {
			System.out.println("Positive");
		} else if (b<0) {
			if (((b-a+1)*(-1))%2==0) {
				System.out.println("Positive");
			} else {
				System.out.println("Negative");
			}
		} else {
			System.out.println("Zero");
		}
	}
}

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

long long cut(long long w,long long h){
	long long ans = 1e18+7;
	int x = w/3;
	for(int i = x;i<=w-2*x;i++){
		long long wt = w,ht = h;
		long long area = wt*ht,sum1 = 0,sum = i*ht;
		area-=sum;
		wt-=i;
		if(h%2==0) sum1 = area/2;
		else{
			ht/=2;
			sum1 = wt*ht;
		}
		area-=sum1;
		long long t = max(sum,max(sum1,area))-min(sum,min(sum1,area));
		ans = min(ans,t);
	} 
	return ans;
}

int main(){
	long long w,h;
	
	cin >> w >> h;
	if(w%3==0||h%3==0){
		cout << 0;
		return 0;
	}
	long long x = min(w,h);
	cout << min(x,min(cut(w,h),cut(h,w)));
}

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

int main() {
  double a, b, c;
  int d, e;
  cin >> a >> b;
  c = (a + b) / 2.0;
  d = (a + b) / 2;
  e = 10*c -10*d;
  cout << d + 2*e/10 << endl;
}

Measured memory_bytes: 256
open Printf open Scanf
open Array

let () = scanf " %d" @@ fun n ->
  let edges = make n [] in
  let p = init (n-1) (fun _ -> scanf " %d %d %d" @@ fun u v w ->
    edges.(u-1) <- (v-1,w) :: edges.(u-1);
    edges.(v-1) <- (u-1,w) :: edges.(v-1);
    w,u
  )
  |> fold_left (fun u (w,p) ->
    if w mod 2 = 1 then p else u
  ) 0
  in
  let color = make n 2 in
  let rec dfs i c =
    if color.(i) <> 2 then ()
    else (
      color.(i) <- c;
      List.iter (fun (j,w) ->
        if w mod 2 = 0 then dfs j c
        else dfs j (1-c)
      ) edges.(i);
    )
  in dfs p 0;
  iter (printf "%d\n") color


Measured memory_bytes: 23808
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

using ll = long long;

int main()
{
	int a, b, k;
	cin >> a >> b >> k;

	int cnt = 0;
	for (int i = min(a, b); i >= 1; i--)
	{
		if (a % i == 0 && b % i == 0)
			cnt++;

		if (cnt == k)
		{
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
	static List<String> list;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		String P = sc.nextLine().replaceAll(" ", "");
		String Q = sc.nextLine().replaceAll(" ", "");
		String first ="";
		if(P.equals(Q)) {
			System.out.println(0);
			return;
		}
		for(int i=1; i<=N;i++) {
			first += i;
		}
		list = new ArrayList();
		permutation(first, "");
		int p = list.indexOf(P);
		int q = list.indexOf(Q);
		System.out.println(Math.abs(p-q));
	}

	public static void permutation(String  s, String ans) {
		if(s.length() <= 1) {
			list.add(ans+s);
		} else {
			for(int i=0; i< s.length(); i++) {
				permutation(s.substring(0, i)+ s.substring(i + 1), ans + s.charAt(i));
			}
		}
	}
}

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

int main() {
    //入力
    int n;
    string s; //左が縦の行数、右が横の列数（念のため、余裕をもって+1）
    int num_e = 0; //西向きの合計人数
    int num_w = 0; //東向きの合計人数
    cin >> n >> s;
    for (int i=0; i<n; i++) {
        if (s[i]=='E') num_e++;
        if (s[i]=='W') num_w++;
    }
    int ans = 300000;
    int change_w = 0; //リーダーの西で向きを変える必要のある人数。西の端から一個ずつ東へズレてカウントしていく。
    int change_e = num_e; //リーダーの東で向きを変える必要のある人数（リーダーの西側に区切り線を置いてる感じ）
    for (int i=0; i<n; i++) {
        if (s[i]=='E') change_e--; //リーダーが'E'の場合、東側から'E'が一人減る
        if (change_e + change_w <= ans) ans = change_e + change_w;
        if (s[i]=='W') change_w++; //リーダーが'W'の場合、西側に'W'が一人増える
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3920
n , m = map(int,input().split())
if m == 0:
    print(0,0)
    exit()
ps = [0] * m
ss = [0] * m
for i in range(m):
    p,s = map(str,input().split())
    ps[i],ss[i] = int(p),s

ac = [0] * (n + 1)
wa = [0] * (n + 1)

for i in range(m):
    if ac[ps[i]] == 1:
        continue
    if ss[i] == 'AC':
        ac[ps[i]] = 1
    else:
        wa[ps[i]] += 1

for i in range(n+1):
    if ac[i] == 0:
        wa[i] = 0

print(sum(ac),sum(wa))


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

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

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

int main() {
	ll ans = 0;
	int tmp;
	int n;
	cin >> n;
	vector<string> s(2*n);
	REP(i, n){
		cin >> s[i];
		s[i]+=s[i];
		s[i+n] = s[i];
	}
	REP(i, n){
		bool ch = true;
		REP(j, n){
			REP(k, n){
				if(s[i+j][k] != s[i+k][j]) ch = false;
			}
		}
		if(ch) ans+=n;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4112