akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,k,a[20];
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	ll ans=1e18;
	for(int i=0;i<(1ll<<n);i++){
		bool f[20]={};
		ll yojo=0;
		for(int j=0;j<n;j++){
			ll num=1ll<<j;
			if(i&num){
				f[j]=1;
				yojo++;
			}
		}
		if(yojo<k)continue;
		ll ma=a[0],cnt=0;
		for(int j=1;j<n;j++){
			if(f[j]&&a[j]<=ma){
				cnt+=ma-a[j]+1;
				ma++;
			}
			if(a[j]>ma)ma=a[j];
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
typedef pair<ll,ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )


void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}


const int N = 1e5 + 5, M = 1e6 + 6, OO = 0x3f3f3f3f;


int main(){
    init();

    int n;  cin >> n;
    cout << fixed << setprecision(7);
    if(n & 1)
        cout << 1.0 * ((n + 1) / 2) / n;
    else
        cout << 1.0 * (n / 2) / n;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	const int Min = 1000000001;
	const int Max = -1;
	int n;
	int a[1000];
    cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int res = Min;
	int ress = Max;
	for (int i = 0; i < n; i++) {
		if (res > a[i]) {
			res = a[i];
		}
		if (ress < a[i]) {
			ress = a[i];
		}
	}
	cout << ress - res << endl;
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
const Int INF = 1e18;

Int N, K;
vector<Int> M, P, Z;
Int m, p, z, neg, pos, zero;

// かけてx以下のペアがK個以上か
//   -> 各P[i]について，かけてx以下になるMの元の数を求めて，合計する
bool solve_m(Int x){
    Int sum = 0;
    rep(i, P.size()){
        Int d = (x-P[i]+1) / P[i];
        sum += upper_bound(M.begin(), M.end(), d) - M.begin();
    }
    return (sum >= K);
}

// かけてx以下のペアがK個以上か
//   -> 各P[i]について，かけてx以下になるPの元の数を求める
//   -> 各M[i]について，かけてx以下になるMの元の数を求める
//      -> 以上を合計する
bool solve_p(Int x){
    Int sum = 0;
    rep(i, P.size()){
        Int d = x / P[i];
        Int now = upper_bound(P.begin(), P.end(), d) - P.begin();
        if(i < now) now--;
        sum += now;
    }

    rep(i, M.size()){
        Int d = x / M[i];
        Int now = upper_bound(M.begin(), M.end(), d) - M.begin();
        if(i < now) now--;
        sum += now;
    }

    sum /= 2;
    return (sum >= K);
}

int main(){
    cin >> N >> K;
    
    rep(i,N) {
        Int A; cin >> A;
        if(A > 0) P.push_back(A);
        else if(A < 0) M.push_back(A);
        else Z.push_back(A);
    }

    sort(P.begin(), P.end());
    sort(M.begin(), M.end());

    m = M.size(); p = P.size(); z = Z.size();

    neg = m * p;
    pos = m*(m-1)/2 + p*(p-1)/2;
    zero = N*(N-1)/2 - neg - pos;

    if(K <= neg){
        Int l = -INF, r =-1;
        while(r-l > 1){
            Int mid = (l+r)/2;
            if(solve_m(mid)) r = mid;
            else l = mid;
        }
        cout << r << endl;
    } else if (K <= neg+zero){
        cout << 0 << endl;
    } else {
        K -= (neg+zero);

        rep(i,m) M[i] = -M[i];
        sort(M.begin(), M.end());

        Int l = 1, r = INF;
        while(r-l > 1){
            Int mid = (l+r)/2;
            if(solve_p(mid)) r = mid;
            else l = mid;
        }
        cout << r << endl;
    }

}

Measured memory_bytes: 2548
mod=998244353

class Combination:
    def __init__(self, N):
        self.fac = [1] * (N + 1)
        for i in range(1, N + 1):
            self.fac[i] = (self.fac[i - 1] * i) % mod
        self.invmod = [1] * (N + 1)
        self.invmod[N] = pow(self.fac[N], mod - 2, mod)
        for i in range(N, 0, -1):
            self.invmod[i - 1] = (self.invmod[i] * i) % mod
 
    def calc(self, n, k):  # nCk
        return self.fac[n] * self.invmod[k] % mod * self.invmod[n - k] % mod

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

C=Combination(N)
ans=0
c=[1]*(N)
for i in range(1,N):
    c[i]=c[i-1]*(M-1)%mod
for i in range(K+1):
    tmp=M*c[N-i-1]*C.calc(N-1,N-i-1)%mod
    ans=(ans+tmp)%mod
print(ans)

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

int main(){
  int N,K;  cin >> N >> K;
  vector<int>p(N);
  for(int i=0;i<N;i++){
    cin >> p.at(i);
  }
  sort(p.begin(),p.end());
  long long sum = 0;
  for(int i=0;i<K;i++){
    sum += p.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(){
	int a,b,ans;
	cin>>a>>b;
	b=b*10;
	bool f=false;
	for(int i=0;i<=9;i++){
		int bb=b+i;
		int t=bb*0.8;
		if(t>=10*a&&t<10*a+10){
			ans=bb;
			f=true;
			break;
		}
	}
	if(f) cout<<ans;
	else cout<<-1;
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include <string>
using namespace std;
typedef long long llint;

llint n;
map<string,llint> mp;

void input(){
  cin >> n;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    mp[s]++;
  }
}

void solve(){
  input();
  llint mx=0;
  for(auto p : mp) mx= max(mx,p.second);
  for(auto p : mp){
    if(p.second == mx){
      cout << p.first << endl;
    }
  }
}
int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int mod = 1e9 + 7;
int bfs2(vector<vector<int>> arr, pair<int, int> start_coordinates, int r, int c)
{
    queue<pair<int, int>> q; 
    q.push(start_coordinates);
    while (!q.empty()) 
    { 
        pair<int, int> t = q.front();
        q.pop(); 
        int start_r = t.fi;
        int start_c = t.se;
 
        if (start_r-1>=0)
        {
        	if (arr[start_r-1][start_c]==0 && (start_r-1!=start_coordinates.fi || start_c!=start_coordinates.se))
        	{
        		arr[start_r-1][start_c] = arr[start_r][start_c] + 1;
        		q.push(mp(start_r-1,start_c));
        	}
        }
        if (start_r+1<r)
        {
        	if (arr[start_r+1][start_c]==0 && ((start_r+1)!=start_coordinates.fi || start_c!=start_coordinates.se))
        	{
        		arr[start_r+1][start_c] = arr[start_r][start_c] + 1;
        		q.push(mp(start_r+1,start_c));
        	}
        }
        if (start_c-1>=0)
        {
        	if (arr[start_r][start_c-1]==0 && (start_r!=start_coordinates.fi || (start_c-1)!=start_coordinates.se))
        	{
        		arr[start_r][start_c-1] = arr[start_r][start_c] + 1;
        		q.push(mp(start_r,start_c-1));
        	}
        }
        if (start_c+1<c)
        {
        	if (arr[start_r][start_c+1]==0 && (start_r!=start_coordinates.fi || (start_c+1)!=start_coordinates.se))
        	{
        		arr[start_r][start_c+1] = arr[start_r][start_c] + 1;
        		q.push(mp(start_r,start_c+1));
        	}
        }
    } 
    int maxDis = 0;  
    for (int i = 0; i < r; ++i)
    {
     	for (int j = 0; j < c; ++j)
     	{
     		if (arr[i][j]==-1)
     		{
     			continue;
     		}
     		if (arr[i][j]>maxDis)
     		{
     			maxDis = arr[i][j];
     		}
     	}
    } 
    return maxDis;
}
int main()
{
	SPEED
	int c, r;
	cin >> r >> c;
	char ch;
	vector<vector<int>> labyrinth(r,vector<int>(c,0));
	int start_r, start_c;
	for (int i = 0; i < r; ++i)
	{
		for (int j = 0; j < c; ++j)
		{
			cin >> ch;
			if (ch=='#')
			{
				labyrinth[i][j] = -1;
				
			}
		}
	}
	int ans = 0;


	for (int i = 0; i < r; ++i)
	{
		for (int j = 0; j < c; ++j)
		{
			if (labyrinth[i][j]==0)
			{
				//cout << "enter process\n";
				pair<int, int> t1 = mp(i,j);
				int t2 = bfs2(labyrinth,t1,r,c);
				//cout << t2 << '\n';
				ans = max(ans, t2);

			}
		}
	}

	cout << ans;
	return 0;
}

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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
  #define DFUNC(fname, ...) fname(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFUNC(fname, ...)
#endif

string S;

bool maybeMonth(char c1, char c2) {
  ll x = (c1 - '0') * 10 + (c2 - '0');
  return ((1 <= x) && (x <= 12));
}

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> S;
  bool t1 = maybeMonth(S.at(0), S.at(1));
  bool t2 = maybeMonth(S.at(2), S.at(3));
  string answer;
  if (t1 && t2) {
    answer = string("AMBIGUOUS");
  }else if (t1 && !t2) {
    answer = string("MMYY");
  }else if (!t1 && t2) {
    answer = string("YYMM");
  }else {
    answer = string("NA");
  }
  cout << answer << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,m;
  cin>>n>>m;
  P path[m];
  vector<int> edge[n];
  rep(i,0,m){
    int a,b;
    cin>>a>>b;
    path[i]=P(a-1,b-1);
    edge[a-1].push_back(b-1);
    edge[b-1].push_back(a-1);
  }
  int ans=0;
  rep(i,0,m){
    bool p[n];
    rep(i,0,n) p[i]=false;
    p[0]=true;
    queue<int> q;
    q.push(0);
    while(q.size()){
      int r=q.front();
      q.pop();
      for(int s:edge[r]){
        if(P(r,s)!=path[i] && P(s,r)!=path[i] && !p[s]){
          p[s]=true;
          q.push(s);
        }
      }
    }
    int j=1;
    rep(i,0,n){
      if(!p[i]) j=0;
    }
    ans+=j;
  }
  cout<<m-ans<<endl;
}

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

int main()
{
    int N;
    cin >> N;
    vector<string> s(N);
    for (int i = 0; i < N; i++)
    {
        cin >> s.at(i);
    }
    int M;
    cin >> M;
    vector<string> t(M);
    for (int i = 0; i < M; i++)
    {
        cin >> t.at(i);
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int cnt = count(s.begin(), s.end(), s.at(i)) - count(t.begin(), t.end(), s.at(i));
        if (ans < cnt)
        {
            ans = cnt;
        }
    }
    cout << ans << "\n";
}

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

using namespace std;

#define rep(i,x) for(int i=0;i<x;++i)
#define all(a) begin(a),end(a)
#define fst first
#define scd second

bool a[5050][5050];
int n;

bool inside(int x, int y)
{
    //cout << "y = " << x << ", x = " << y << endl;
    return 0 <= x && x <= 5000 && 0 <= y && y <= 5000;
}

signed main()
{
    while (cin >> n, n) {
        memset(a, 0, sizeof(a));
        static pair<int, int> arr[3010];

        rep(i, n) {
            int x, y; cin >> x >> y;
            a[y][x] = true;
            arr[i] = pair<int, int>(y, x);
        }

        int ma = 0;

        rep(i, n) rep(j, n) {
            pair<int, int> p1 = arr[i], p2 = arr[j];

            bool f = true;

            int v1 = p2.fst - p1.fst, v2 = p2.scd - p1.scd;

            pair<int, int> p3{p1.fst - v2, p1.scd + v1};
            pair<int, int> p4{p3.fst + v1, p3.scd + v2};

            f &= inside(p3.scd, p3.fst) && a[p3.fst][p3.scd];
            f &= inside(p4.scd, p4.fst) && a[p4.fst][p4.scd];

            if (f) {
                int a = p1.fst - p2.fst, b = p1.scd - p2.scd;
                ma = max(ma, a * a + b * b);
            }
        }

        cout << ma << endl;
    }
}

Measured memory_bytes: 27872
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s1,s2;
  while(1){
    cin>>s1>>s2;
    if(s1.size()<4 && s2.size()<4)break;
    int h=0,b=0;
    vi a(10,0);
    rep(i,4){
      if(s1[i]==s2[i])h++;
      a[s1[i]-'0']++;
      a[s2[i]-'0']++;
    }
    rep(i,10)
      if(a[i]==2)b++;
    cout<<h<<" "<<b-h<<endl;
  }
}

Measured memory_bytes: 3144
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static ArrayList<String> strList = new ArrayList<String>();
	static ArrayList<String> strList2 = new ArrayList<String>();
	static ArrayList<Integer> intList = new ArrayList<Integer>();
	static HashMap<String,Integer> Hmap = new HashMap<String,Integer>();
	public static void main(String[] args) {

		String str1 = sc.nextLine();
		String[] strArray = str1.split(" ");

		int a = Integer.parseInt(strArray[0]);
		int b = Integer.parseInt(strArray[1]);
		int c = Integer.parseInt(strArray[2]);

		int ans=0;

		for(int i=a; i<=b;i++) {
			if(i % c ==0) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26968
#include <stdio.h>
#include <algorithm>
using namespace std;
const int maxn = 100010;
bool cmp(int a, int b)
{
    return a < b;
}
int binarysearch(int left, int right, int a[], int k)
{
    int mid = (left + right) / 2;
    while(left < right){
        if(left >= k)
            return left;
        if(right < k)
            return -1;
        if(a[mid] <= k && a[mid + 1] > k){
            return mid;
        }
        if(a[mid] < k && a[mid + 1] >= k)
            return mid + 1;
        if(a[mid] < k && a[mid + 1] < k){
            left = mid ;
        }
        if(a[mid] > k && a[mid - 1] > k){
            right = mid - 1;
        }
        printf("mid = %d, left = %d, right = %d\n", mid, left, right);
    }
    return -1;
}
int main()
{
    int n;
    int p[maxn];
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &p[i]);
    }
    sort(p, p + n, cmp);
    int sum = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            for(int k = j + 1; k < n; k++){
                if(p[i] + p[j] > p[k] && p[i] + p[k] > p[j] && p[j] + p[k] > p[i])
                    sum++;
            }
        }
    }
    printf("%d", sum);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 105000;

int st[MAXN];

int getSet(int x) {
  if (st[x] == x)
    return x;
  st[x] = getSet(st[x]);
  return st[x];
}

void unite(int a, int b) {
  a = getSet(a); b = getSet(b);
  if (rand() & 1)
    swap(a, b);
  st[a] = b;
}

int n, m;
int p[MAXN];
int ans;

int main() { 

  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
    st[i] = i;
  }

  for (int i = 0; i < m; i++) {
    int from, to;
    scanf("%d %d", &from, &to);
    from--; to--;
    unite(from, to);
  }

  for (int i = 0; i < n; i++) {
    if (getSet(i) == getSet(p[i] - 1)) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  string S;
  cin >> S;
  set<string> s;
  int n = S.length();
  if (n == 1) {
    cout << "1\n";
    return 0;
  }
  if (n == 2) {
    if (S[0] == S[1]) {
      cout << "1\n";
    } else {
      cout << "2\n";
    }
    return 0;
  }

  int dp[n + 1][2]{};
  dp[0][0] = 1;
  dp[0][1] = 0;
  if (S[0] == S[1]) {
    dp[1][0] = 1;
    dp[1][1] = 1;
  } else {
    dp[1][0] = 2;
    dp[1][1] = 1;
  }

  for (int i = 2; i < n; i++) {
    if(S[i] != S[i - 1]) {
      dp[i][0] = dp[i - 1][0] + 1; 
      dp[i][1] = dp[i - 2][0] + 1;
    } else {
      dp[i][0] = dp[i - 1][1] + 1;
      dp[i][1] = dp[i - 2][0] + 1;
    }
  }
  cout << max(dp[n -1][0], dp[n - 1][1]) << "\n";
  return 0;
}

Measured memory_bytes: 2180
package main

import (
	"fmt"
)

func main() {
	var n, min, max int
	fmt.Scan(&n)

	x := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x[i])
		if max < x[i] {
			max = x[i]
		}
		if min > x[i] {
			min = x[i]
		}
	}

	answer := 100000000
	for i := min; i < max+1; i++ {
		total := 0
		for j := 0; j < n; j++ {
			total += (x[j] - i) * (x[j] - i)
			// if answer < total {
			// 	total = 10000001
			// 	break
			// }
		}
		if answer > total {
			answer = total
		}
		// fmt.Println("i: ", i, "total: ", total)
	}

	fmt.Println(answer)
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
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 REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int pow3(int x){
    if(x == 0) return 1;
    if(x%2 == 1) return 3*pow3(x-1);
    int p = pow3(x/2);
    return p*p;
}
int main(){
    int N;
    cin >> N;
    int even = 0;
    REP(i,N){
        int A;
        cin >> A;
        if(A%2 == 0) even++;
    }
    int ans = pow3(N);
    ans -= 1<<even;
    cout << ans << endl;
    return 0;
}


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

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007
#define MINP 0x00FF

int main(int argc, char const *argv[])
{
	int n,h[107];
	int l = 0,r;
	int cnt = 0,min = MINP,flag = 1;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)	scanf("%d",&h[i]);
	while(l < n){
		min = MINP;
		flag = 1;
		if(h[l] == 0){
			++l;
			continue;
		}
		for (int i = l; (i < n && flag); ++i)
		{
			for (r = l; r < n; ++r)
			{
				if(h[r] == 0){
					flag = 0;
					break;
				}
			}
		}
		for (int i = l; i < r; ++i)
		{
			if(min > h[i])	min = h[i];
		}
		for (int i = l; i < r; ++i)	h[i] -= min;
		cnt += min;
	}
	printf("%d\n", cnt);
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;


int main(){
  string s;
  cin >> s;
  
  for (int i=0; i<s.size()/2; i++) {
    if (s[i]!=s[s.size()-1-i] || s[i]!=s[s.size()/2-1-i]) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

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

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

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

signed main() {
    queue<int> que;
    rep(i, 9) {
        que.push(i + 1);
    }
    int K;
    cin >> K;
    int count = 0;
    while (1) {
        for (int i = -1; i < 2; i++) {
            int d = que.front();
            d = d % 10 + i;
            if (d < 0 || d > 9) {
                continue;
            }
            int nx = que.front() * 10 + d;
            que.push(nx);
        }
        count++;
        if (count == K) {
            cout << que.front() << endl;
            break;
        }
        que.pop();
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <climits>
#include <bitset>
#include <time.h>
#include <numeric>
using namespace std;
 
#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define test(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;
void fast_io()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("error.txt", "w", stderr);
	freopen("output.txt", "w", stdout);
#endif
}

void sol()
{
	int n; cin>>n;
	int c=0,f=0,ans=0;
	for(int i=0;i<n;i++)
	{
		int x,y; cin>>x>>y;
		if(x==y)
		{
			if(f==1)
				c++;
			
				else
				{f=1; c++;
				}
		}
		else
		{
			f=0;
			c=0;
		}
		if(c>=3 && ans==0)
		{
			ans=1;
		}
	}
	if(ans)
		cout<<"Yes";
	else
		cout<<"No";

	
}
int32_t main()
{
	fast_io();
	//test(t)
	sol();
	//cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


Measured memory_bytes: 3648
#30 C - 4-adjacent
N = int(input())
A = list(map(int,input().split()))

multiple4 = 0
multiple2 = 0
for a in A:
    if a%4 == 0:
        multiple4 += 1
    elif a%2 == 0:
        multiple2 += 1

odd = N - (multiple4 + multiple2)
result = 'No'
if odd <= multiple4:
    result = 'Yes'
elif ((odd - 1) <= multiple4) and (multiple2%2 == 0):
    result = 'Yes'
print(result)

Measured memory_bytes: 19996
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a==b)
        printf("%d",a*2);
    else if(a==b-1 || b==a-1)
        printf("%d",a+b);
    else
    {


        if(a>b)
        printf("%d",(a*2)-1);
        else
         printf("%d",(b*2)-1);

        }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

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

  vector<ll> ans={};

  while(n!=0 || m!=0){
    ll c[m],x[n];
    for(int i=0;i<m;i++)cin >> c[i];
    for(int j=0;j<n;j++)cin >> x[j];
  
    //y_{i+1}をjにしたときの最小
    ll dp[n][256];
    for(int i=0;i<n;i++){
      for(int j=0;j<256;j++)dp[i][j]=inf;
    }

    ll y=128;
    for(int i=0;i<m;i++){
      if(y+c[i]>=255)dp[0][255]=(255-x[0])*(255-x[0]);
      else if(y+c[i]<=0)dp[0][0]=x[0]*x[0];
      else dp[0][y+c[i]]=(x[0]-y-c[i])*(x[0]-y-c[i]);
    }


    for(int i=1;i<n;i++){
      for(int k=0;k<256;k++){
        for(int j=0;j<m;j++){
          if(k+c[j]>=255)dp[i][255]=min(dp[i-1][k]+(255-x[i])*(255-x[i]),dp[i][255]);
          else if(k+c[j]<=0)dp[i][0]=min(dp[i-1][k]+x[i]*x[i],dp[i][0]);
          else dp[i][k+c[j]]=min(dp[i-1][k]+(k+c[j]-x[i])*(k+c[j]-x[i]),dp[i][k+c[j]]);
        }
      }
    }

    ll mi=10000000000;
    for(int i=0;i<256;i++)mi=min(mi,dp[n-1][i]);

    //cout << mi << endl;
    ans.push_back(mi);

    cin >> n >> m;
  }

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

}


Measured memory_bytes: 43140
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        StringBuilder output = new StringBuilder();
        int n = scan.nextInt();
        int m = scan.nextInt();
        int l = scan.nextInt();
        int[][] A = new int[n][m];
        int[][] B = new int[m][l];
        long[][] AB = new long[n][l];
         
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                A[i][j] = scan.nextInt();
            }
        }
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < l; j++) {
                B[i][j] = scan.nextInt();
            }
        }
         
        long sum_ij = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                for (int k = 0; k < m; k++) {
                    sum_ij += A[i][k] * B[k][j];
                }
                AB[i][j] = sum_ij;
                sum_ij = 0;
            }
        }
        for (int i = 0; i < n; i++) {
            output.append(AB[i][0]);
            for (int j = 1; j < l; j++) {
output.append(" ").append(AB[i][j]);
            }
            output.append('\n');
        }
        System.out.print(output);
        scan.close();
    }
 
}

Measured memory_bytes: 50356
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()

int main() {
  ll n;
  cin>>n;
 vector<ll> a(n);
 vector<ll> b(100001);
 rep(i,n){
cin>>a[i];
   b[a[i]]++;
 }
  ll max=0;
  rep(i,100001){
    if(max<b[i]+b[i+1]+b[i+2]) max=b[i]+b[i+1]+b[i+2];
  }
  cout<<max<<endl;
return 0;
}


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

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

ll N;

int dfs(ll v)
{
  int ret=0;
  if (v > N) return 0;
  int c3=0,c5=0,c7=0;
  ll tmp=v;
  while(tmp>0) {
    int x = tmp%10;
    if (x==3) c3=1;
    if (x==5) c5=1;
    if (x==7) c7=1;
    tmp/=10;
  }
  if (c3&&c5&&c7) ret++;
  ret += dfs(v*10+3);
  ret += dfs(v*10+5);
  ret += dfs(v*10+7);
  return ret;
}

void solve()
{
  cin>>N;
  int ans = dfs(0);
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
  	cin>>n;
  	long long ans = 0;
  	for(int i = 1; i <= n; ++i){
    	if(i%3 && i%5){
        	ans+=i;
        }
    }
  	cout<<ans;
	return 0;
}

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

struct UnionFind {
	vector<int> p;
	
	UnionFind(int n) : p(n) {
		for (int i = 0; i < n; i++) p[i] = i;
	}
	
	int root(int x) {
		return p[x] == x ? x : p[x] = root(p[x]);
	}
	
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x != y) p[x] = y;
	}
	
	bool same(int x, int y) {
		return root(x) == root(y);
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(m), b(m);
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
	}
	int ans = 0;
	rep(i, m) {
		UnionFind uf(n);
		rep(j, m) {
			if (i == j) continue;
			uf.unite(a[j], b[j]);
		}
		if (!uf.same(a[i], b[i])) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N;
    cin >> N;
    string S;
    cin >> S;
    ll cnt = 1;

    map<char, int> mp;
    for(int i = 0; i < N; i++) {
        mp[S[i]] ++;
    }

    for (auto t : mp) {
        cnt *= t.second + 1;
        cnt %= MOD;
    }

    cout << cnt - 1 << endl;
    
    //cout << ans << endl;
    return 0;
}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(exp, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (1e5)+5;
ll N, M;
pll AB[MAXN];

int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> M;
    for(int i=0; i<N; i++)
    {
        cin >> AB[i].f >> AB[i].s;
    }
    sort(AB, AB+N);
    int j=0, sum = 0;
    priority_queue<int> q;
    for(int i=1; i<=M; i++)
    {
        for(; AB[j].f == i && j < N; j++)
        {
            q.push(AB[j].s);
        }
        if(!q.empty())
        {
        //cout << q.top() << "\n";
            sum += q.top();
            q.pop();
        }
    }

    cout << sum;

    return 0;
}


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

int main(){
	int n; cin >> n;
	int t[n];
	int sum = 0;
	for(int i = 0; i < n; ++i){
		cin >> t[i];
		sum += t[i];
	}
	int m; cin >> m;
	int p[m], x[m];
	for(int i = 0; i < m; ++i){
		cin >> p[i] >> x[i];
		--p[i];
		cout << sum - t[p[i]] + x[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, s, a) for (int i = s; i < a; i++)
#define llint long long int
using namespace std;

const int N_MAX = 505;
const llint INF = 999999999999999;

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

    int c_pay = 0;
    bool ans = false;
    while (c_pay <= n) {
        if ((n - c_pay) % 7 == 0) ans = true;  
        c_pay += 4;
    }

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

Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
enum MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N = lread();
    auto f = factorize(N);
    long ans;
    foreach (key, val; f)
    {
        long cnt = 1;
        while ((cnt + 2) * (cnt + 1) / 2 <= val)
            cnt++;
        ans += cnt;
    }
    writeln(ans);
}

/// 素因数分解
long[long] factorize(long x)
{
    assert(0 < x, "x is negative");
    long[long] ps;
    while ((x & 1) == 0)
    {
        x /= 2;
        ps[2] = (2 in ps) ? ps[2] + 1 : 1;
    }
    for (long i = 3; i * i <= x; i += 2)
        while (x % i == 0)
        {
            x /= i;
            ps[i] = (i in ps) ? ps[i] + 1 : 1;
        }
    if (x != 1)
        ps[x] = (x in ps) ? ps[x] + 1 : 1;
    return ps;
}


Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;

int main(){
    int N, K; cin >> N >> K; int h[N];
    for (int i = 0; i < N; i++) cin >> h[i];
    sort(h, h+N);

    int MIN = INT_MAX;
    for (int i = 0; i < N-K+1; i++) MIN = min(MIN, h[i+K-1]-h[i]);
    cout << MIN << endl;

    return 0;
}


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

int main() {
  int N, H, W, cnt=0;
  cin >> N >> H >> W;
  int a[N], b[N];
  for(int i=0; i<N; i++) {
    cin >> a[i] >> b[i];
    if(a[i]>=H&&b[i]>=W) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
n, m, l = map(int, input().split())
a = [[int(num) for num in input().split()] for i in range(n)]
b = [[int(num) for num in input().split()] for i in range(m)]
c = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
for i in range(n):
    for j in range(l):
        if j == l - 1:
            print(c[i][j])
        else:
            print(c[i][j], end=" ")
            

Measured memory_bytes: 9048
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int a, b, c;

	cin>> a >> b >> c;

	a=max(a, max(b, c))*10-max(a, max(b, c))+a+b+c;

	cout<< a << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L = A + B;
  int R = C + D;
  if (L > R) {
    cout << "Left" << endl;
  }
  else if (L == R) {
    cout << "Balanced" << endl;
  }
  else if (L < R) {
    cout << "Right" <<endl;
  }
}


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

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define INF (int)1e9
typedef long long int int64;

void print() {
    cout << endl;
}

void print(const char* s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(char s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(string s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(int64 s, bool endline = true) {
    cout << s;
    if (endline) print();
}

void print(int s, bool endline = true) {
    cout << s;
    if (endline) print();
}

template <typename T, typename T2>
void print(pair<T, T2>& p, bool endline = true) {
    cout << "(";
    print(p.first, false);
    cout << ", ";
    print(p.second, false);
    cout << ")";

    if (endline) print();
}

template <typename T>
void print(T& t, bool endline = true) {
    cout << "[";
    for (auto it = t.begin(); it != t.end(); ++it) {
        if (it != t.begin()) cout << ", ";
        print(*it, false);
    }
    cout << "]";

    if(endline) print();
}

template <typename T>
vector<T> operator+(const vector<T> &a, const vector<T> &b)
{
    vector<T> ret;
    ret.reserve( a.size() + b.size() );                // preallocate memory
    ret.insert( ret.end(), a.begin(), a.end() );        // add A;
    ret.insert( ret.end(), b.begin(), b.end() );        // add B;

    return ret;
}

template <typename T>
vector<T> &operator+=(vector<T> &a, const vector<T> &b)
{
    a.reserve( a.size() + b.size() );                // preallocate memory without erase original data
    a.insert( a.end(), b.begin(), b.end() );         // add B;
    return a;
}

bool c(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.first + a.second > b.first + b.second); 
}

int main() {
    // g++ -Wall -Wextra -O2 -std=c++17 helloworld.cpp  
    
    string s;
    cin >> s;

    map<char, int64> m;

    for(auto& c : s) {
        m[c]++;
    }

    int64 count = 1LL;

    for(char c = 'a'; c <= 'z'; c++) {
        for(char c2 = c + 1; c2 <= 'z'; c2++) {
            count += m[c] * m[c2];
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void foo(long a, long b, vector<long> c, vector<long> d) {
  long ans = 0;
  long current = abs(a - c[0]) + abs(b-d[0]);

  rep (i, c.size()) {
    long tmp = abs(a - c[i]) + abs(b-d[i]);
    if (tmp < current) {
      ans = i;
      current = tmp;
    }
  }

  cout << ans + 1 << endl;
}

void solve() {
  long N, M;
  cin >> N >> M;

  vector<long> a(N), b(N);
  rep (i, N) cin >> a[i] >> b[i];

  vector<long> c(M), d(M);
  rep (i, M) cin >> c[i] >> d[i];

  rep (i, N) foo(a[i], b[i], c, d);
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

ans = sum(Ws)
for i in range(1, N):
    sum1 = sum(Ws[:i])
    sum2 = sum(Ws[i:])
    diff = abs(sum1-sum2)
    ans = min(ans, diff)

print(ans)


Measured memory_bytes: 2940
#include<stdio.h>
int main()
{
	int n;
	int a[100000];
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int x=1,t=0,flg=0;
	for(int j=1;j<=n;j++){
		x=a[x] ;
		++t;
		if(x==2){
			flg=1;      
			break;
		}
	}
	if(flg)
		printf("%d\n",t); 
	else
		printf("-1");
	return 0;
}

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

int main()
{
    int n;
    
    cin >> n;
    vector<ll> a(n-1,0);
    rep(i,n-1) {
        cin >> a[i];
    }

    vector<ll> count(n,0);
    //int count[1000000];
    rep(i,n-1) {
        count[a[i]-1]++;
    }

    rep(i,n) {
        cout << count[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 6344
a=input()
b=a.split()
c=list()

for d in b:
    c.append(int(d))
    
a=c[0]
b=c[1]

if a>b:
    print("a > b")
    
elif a<b:
    print("a < b")
    
else:
    print("a == b")
    



Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

int main() {
    int N; cin >> N;
    vl A(N); rep(i, N) cin >> A[i];

    ll total = 0;
    rep(i, N) total ^= A[i];

    rep(i, N) {
        cout << (total ^ A[i]);
        if (i != (N - 1)) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 4788
#include<bits/stdc++.h>
using namespace std;
#define REPP(i,A,B) for(int i=A;i<B;i++)

int main(){
    int a,b; cin>>a>>b;
    bool table[100][100]={};
    REPP(i,0,50){
        REPP(j,0,100){
            table[i][j]=1;  
        }
    }
    a--; b--;
    int count =0;
    for(int i=0;i<50;i+=2){
        for(int j=0;j<100;j+=2){
            if(count==a) break;
            table[i][j] = 0;
            count++;
        }
    }
    
    count=0;
    for(int i=51;i<100;i+=2){
        for(int j=0;j<100;j+=2){
            if(count==b) break;
            table[i][j] = 1;
            count++;
        }
    }
    cout<<"100"<<' '<<"100"<<endl;
    REPP(i,0,100){
        REPP(j,0,100){
            if(table[i][j]) cout<<"#";
            else cout<<".";
        }
        cout<<endl;
    }

    return 0;
}

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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    ll n;
    cin>>n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++){
        cin>>v[i];
        v[i]-=(i+1);
    }
    sort(v.begin(),v.end());
    ll ans=0;
    for(ll i=0;i<n;i++){
        ans+=abs(v[i]-v[n/2]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
  int n,k,q;
  cin>>n>>k>>q;
  VI a(q),b(n);
  rep(i,n){
    b[i]=-1*q;
  }
  rep(i,q){
    cin>>a[i];
    b[a[i]-1]++;
    //rep(i,n) cout<<b[i]<<" ";
    cout<<"\n";
  } 

  rep(i,n){
    b[i]+=k;
    //cout<<b[i]<<" ";
    if(b[i]>0){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
}



Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
#include<string.h>
#include<cmath>
#include<algorithm>
#include<assert.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const ll INF=4223372036854775807,max_n=300005,mod=1e9+7;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int main()
{
	ll n;cin>>n;
	cout<<n+n*n+n*n*n;
}

Measured memory_bytes: 3584
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;
using Graph = vector<vector<int>>;

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

vector<bool> seen;

void dfs(const Graph& G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int abs_B(long long num, long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

bool permutation(vector<int>& vec, vector<int>& P) {
    bool ok = true;
    for (int i = 0; i < vec.size(); i++) {
        if (vec.at(i) != P.at(i)) {
            ok = false;
        }
    }
    return ok;
}

const long long MOD = 1000000007;
const int INF = 1001001001;

int main() {
    int A, B;
    cin >> A >> B;
    for (int i = 1; i < 10000; i++) {
        int a, b;
        a = i * 0.08;
        b = i * 0.1;
        if (a == A && b == B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
#define INF 1000000000000000
ll n,m;
ll R;
ll r[100];
ll G[300][300];

bool used[100];

ll ans(ll depth,ll pre) {
	if(depth >= R) {
		return 0;
	}

	ll ret = INF;
	REP(i,R) {
		if(!used[i]) {
			used[i] = true;
			ret = min(ret,ans(depth + 1,r[i]) + G[pre][r[i]]);
			used[i] = false;
		}
	}
	return ret;
}

int main(){
	cin >> n >> m >> R;
	REP(i,R){
		cin >> r[i];
		r[i]--;
	}

	REP(i,n) {
		REP(j,n) {
			G[i][j] = INF;
		}
	}
	REP(i,n) {
		G[i][i] = 0;
	}

	REP(i,m) {
		ll a,b,c;
		cin >> a >> b >> c;

		a--;b--;
		G[a][b] = G[b][a] = c;
	} 
	REP(i,n) {
		G[i][n] = 0;
		G[n][i] = 0;
	}

	REP(k,n) {
		REP(i,n) {
			REP(j,n) {
				G[i][j] = min(G[i][j],G[i][k] + G[k][j]);
			}
		}
	}

	cout << ans(0,n) << endl;
	return 0;
}


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

using namespace std;


int main()
{
   long long x;
   cin >> x;
   int i,j;
   for(i=1000;i>=0;i--)
   {
       for(j=-200;j<=1000;j++)
       {
           long long a,b;
           a = pow(i,5);
           b = pow(j,5);
           if(a -b == x)
           {
               cout << i << " " << j;
               return 0;
           }
           else
           {
               continue;
           }
       }
   }
}

Measured memory_bytes: 4096
import sys
sys.setrecursionlimit(10**9)
H = 0
W = 0
field = []
def dfs(x, y, px, py):
    for dx, dy in ((1,0),(-1,0),(0,1),(0,-1),(1,1),(-1,1),(1,-1),(-1,-1)):
        dx += x
        dy += y
        if dx == px and dy == py: continue
        if not (0 <= dx < W and 0 <= dy < H): continue
        if field[dy][dx] == 1:
            field[dy][dx] = 2
            dfs(dx, dy, x, y)

while True:
    W, H = map(int, input().split())
    if H+W == 0: break
    ans = 0
    field = [list(map(int, input().split())) for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if field[h][w] == 1:
                ans += 1
                dfs(w,h,-1,-1)
    print(ans)



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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 1e5 + 9, M = 1e5, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

ll n, k;

ll power(ll b, ll p){
    if(p == 0)return 1;
    ll res = power(b,p/2);
    res *= res;
    res %= modulo;
    if(p & 1)res *= b;
    return res % modulo;
}

inline void fixMod(ll &x){
    x = ((x % modulo) + modulo) % modulo;
}

ll cnt[N] = {};

int main(){
    init();

    cin >> n >> k;

    ll ans = 0;
    for(int i = k;i >= 1;i--){
        ll mults = (k / i);
        ll localAns = power(mults, n);
        ll exclude = 0;
        for(int j = 2;j * i <= k;j++){
            exclude += cnt[i * j];  exclude %= modulo;
        }

        localAns -= exclude;    fixMod(localAns);
        cnt[i] = localAns;
        ans += localAns * i;    fixMod(ans);
    }

    cout << ans;
}

Measured memory_bytes: 4388