akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {

	ll N;
	cin >> N;
	vector<ll> C(N + 1);
	repn(i, N) cin >> C[i];

	vector<ll> pre(300000, -1), dp(N + 1, 0);

	dp[0] = 1;

	repn(i, N) {
		dp[i] = dp[i - 1];

		if (pre[C[i]] != -1 && pre[C[i]]!=i-1) { dp[i] += dp[pre[C[i]]]; }

		pre[C[i]] = i;

		dp[i] %= MOD;

		//cout << dp[i] << endl;
	}

	cout << dp[N];

	system("PAUSE");

}





Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define in(j,n) for(j=0;j<n;j++)
#define inp(j,n) for(j=1;j<=n;j++)
#define lo(i,st,n) for(i=st;i<n;i++)
#define pb push_back
#define csbits(n) __builtin_popcount(n)
#define fastio ios_base::sync_with_stdio(false)
int main()
{
	fastio;
	ll i,j,t,n;
	cin>>n;
	ll h[n+1];
	inp(i,n)
		cin>>h[i];
	ll dp[n+1]={0};
	dp[2]=abs(h[2]-h[1]);
	lo(i,3,n+1)
		dp[i]=fmin(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n]<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1001;
static const ll MOD = 1000000007;

//--global--//

int inp[MAX][MAX];
int out[MAX][MAX];

//----------//

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

struct node{
    int x, y, cnt;
};

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//
    
    int h, w, n;
    cin >> h >> w >> n;
    pair<int, int> start;
    pair<int, int> next;
    
    rep(i, h){
        string str;
        cin >> str;
        rep(j, w){
            if(str[j] == '.'){
                inp[i][j] = 0;
            }
            else if(str[j] == 'X'){
                inp[i][j] = -1;
            }
            else if(str[j] == 'S'){
                inp[i][j] = 10;
                start = make_pair(i, j);
            }
            else{
                inp[i][j] = str[j]-'0';
                if(inp[i][j] == 1)
                    next = make_pair(i, j);
            }
        }
    }

    // rep(i, h){
    //     rep(j, w){
    //         if(j)cout << " ";
    //         cout << inp[i][j];
    //     }
    //     cout << endl;
    // }


    node now = {start.first, start.second, 0};
    int k = 1;
    queue<node> q;
    q.push({start.second, start.first, 0});

    while(q.size() > 0){
        now = q.front(); q.pop();
        //cout << now.x << ", "<< now.y << ", " << now.cnt << endl;
        rep(i, 4){
            pair<int, int> next = make_pair(now.x + dx[i], now.y + dy[i]);
            if(0 <= next.first && next.first < w && 0 <= next.second && next.second < h )
                if(out[next.second][next.first] == 0 && inp[next.second][next.first] != -1){
                    int a = now.cnt;
                    a++;
                    q.push({next.first, next.second, a});
                    out[next.second][next.first] = 1;
                }
        }
        // cout << now.x << ", " << now.y << endl;
        if(inp[now.y][now.x] == k){
            //cout << now.cnt << endl;
            if(k >= n){
                cout << now.cnt <<endl;
                break;
            }
            while(q.size()>0){
                q.pop();
            }
            q.push(now);
            rep(i, h){
                fill(out[i], out[i]+w, 0);
            }
            k++;
        }
    }

    //cout << "adsf" << endl;

    

    
    return 0;
}



Measured memory_bytes: 10884
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

int main() {
	int n;
	int *x;
	cin >> n;
	x = new int[n];
	int maxX = -1, minX = 101;
	for (int i = 0; i < n; ++i) {
		cin >> x[i];
		maxX = max(maxX, x[i]);
		minX = min(minX, x[i]);
	}
	int res = 10000000;
	for (int p = minX; p <= maxX; ++p) {
		int s = 0;
		for (int j = 0; j < n; ++j) {
			s += (p - x[j]) * (p - x[j]);
		}
		if (s < res) {
			res = s;
		}
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

struct Dijkstra{
  ll INF=1000000000000000009;
  ll MAX_V=1000000;
  ll st = -1;
  struct edge{ll to, cost;};
  typedef pair<ll, ll> p;
  vector<vector<edge>> G;
  vector<ll> pre, d;
  priority_queue<p, vector<p>, greater<p> > que; //class, inner, compair
  Dijkstra(ll s){
    G.resize(s+2);
    pre.resize(s+2, -1);
    d.resize(s+2, INF);
  }
  inline void insert(ll a, ll b, ll c){
    G[a].push_back(edge{b, c});
  }
  void init(){
    for(int i=0;i<d.size();i++) pre[i] = -1, d[i] = INF;
  }
  void dijkstra(int start){
    init();
    st = start;
    d[start]=0;
    que.push(p(0, start));
    while(!que.empty()){
      p p_now=que.top(); que.pop();
      ll v = p_now.second;
      if(d[v]<p_now.first) continue;
      for(int i=0;i<G[v].size();i++){
        edge e = G[v][i];
        if(d[e.to]>d[v]+e.cost){
          d[e.to]=d[v]+e.cost;
          pre[e.to] = v;
          que.push(p(d[e.to], e.to));
        }
      }
    }
  }
  vll get_path(int now){
    vll ret;
    while(now!=-1){
      ret.push_back(now);
      now = pre[now];
    }
    return ret;
  }
};
int main(int argc, char const *argv[]) {
  ll h, w;std::cin >> h >> w;
  vector<string> s(h);
  ll white = 0;
  Dijkstra dj(10000);

  re(i, h) {
    std::cin >> s[i];
    re(j, w) if(s[i][j]=='.') white++;
  }
  re(i, h) {
    re(j, w){
      if(i!=0&&s[i-1][j]=='.') dj.insert(i*100+j, (i-1)*100+j, 1);
      if(j!=0&&s[i][j-1]=='.') dj.insert(i*100+j, i*100+(j-1), 1);
      if(j!=w-1&&s[i][j+1]=='.') dj.insert(i*100+j, i*100+(j+1), 1);
      if(i!=h-1&&s[i+1][j]=='.') dj.insert(i*100+j, (i+1)*100+j, 1);
    }
  }
  dj.dijkstra(0);
  if(dj.d[(h-1)*100+(w-1)]>=1000000) std::cout << -1 << '\n';
  else std::cout << white - (dj.d[(h-1)*100+(w-1)]+1) << '\n';
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef pair< int, int > pii;

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

  int h, w;
  cin >> h >> w;
  bool c[h][w];
  for(int i = 0; i < h; i++){
    string line;
    cin >> line;
    for(int j = 0; j < w; j++){
      if(line[j] == '#') c[i][j] = true;
      else c[i][j] = false;
    }
  }

  int black = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(c[i][j]) ++black;
    }
  }

  int dist[h][w];
  for(int i = 0; i < h; i++){
    fill(dist[i], dist[i] + w, INF_INT);
  }

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

  queue< pii > q;

  q.push(make_pair(0, 0));
  dist[0][0] = 0;
  while(!q.empty()){
    pii p = q.front(); q.pop();
    int i = p.second, j = p.first;
    for(int k = 0; k < 4; k++){
      int ni = i + dy[k];
      int nj = j + dx[k];
      if(!((0 <= ni && ni < h) &&
        (0 <= nj && nj < w)))
        continue;
      if(c[ni][nj]) continue;
      if(dist[ni][nj] == INF_INT){
        dist[ni][nj] = dist[i][j] + 1;
        q.push(make_pair(nj, ni));
      }
    }
  }

  if(dist[h - 1][w - 1] == INF_INT){
    cout << -1 << endl;
    return 0;
  }

  int ans = (h * w) - (black + dist[h - 1][w - 1]) - 1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(x, it) for(auto it = x.begin(); it != x.end(); it++)
#define pr(x) cout << #x << " = " << x << endl
#define fill(x,y) memset(x,y,sizeof(x))
#define endl "\n"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
ld eps = 1e-7;
ll mod = 1000000007;
ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

void solve()
{
	int a[5], ans, i, n = 5;
	rep(i, 0, n)
	{
		cin >> a[i];
		if(!a[i])
			ans = i + 1;
	}
	cout << ans  << endl;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int t = 1;
	//cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }

// メイン
void Solve()
{
	// 入力
	ll H, W, M;
	cin >> H >> W >> M;
	vector<P> bombPos(M);
	VVL bombW(W);
	VVL bombH(H);
	REP(i, M) {
		ll h, w;
		cin >> h >> w;
		h--; w--;
		bombPos[i].first = h;
		bombPos[i].second = w;
		bombW[w].push_back(h);
		bombH[h].push_back(w);
	}

	VL hSum(H, 0);
	for (auto &one : bombPos) {
		hSum[one.first]++;
	}

	multiset<ll> wSet;
	REP(i, W) {
		auto &one = bombW[i];
		wSet.insert(one.size());
	}

	VL ans(H);
	REP(i, H) {
		for (auto &w : bombH[i]) {
			ll one = bombW[w].size();
			wSet.erase(wSet.lower_bound(one));
			one--;
			wSet.insert(one);
		}

		auto it = wSet.rbegin();
		ans[i] = *it + hSum[i];

		for (auto &w : bombH[i]) {
			ll one = bombW[w].size();
			wSet.insert(one);
			one--;
			wSet.erase(wSet.lower_bound(one));
		}
	}

	sort(ALL(ans), greater<ll>());
	cout << ans[0] << endl;

}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 59440
package main

import "fmt"

func main() {
	var result []int
	for {
		var n, a, maxSum int
		fmt.Scan(&n)

		if n == 0 {
			break
		}

		maxSum = 0
		sum := 0
		for i := 0; i < n; i++ {
			fmt.Scan(&a)
			if i == 0 {
				sum = a
				maxSum = sum
			} else if sum+a < a {
				sum = a
				if maxSum < sum {
					maxSum = sum
				}
			} else {
				sum = sum + a
				if maxSum < sum {
					maxSum = sum
				}
			}
		}

		result = append(result, maxSum)
	}

	for _, v := range result {
		fmt.Println(v)
	}
}



Measured memory_bytes: 1288
n,m=map(int,input().split())
q=[list(map(int,input().split())) for _ in range(m)]
for i in range(10**n):
    i=str(i)
    if len(i)!=n:
        continue
    f=1
    for j in q:
        if i[j[0]-1]!=str(j[1]):
            f=0
            break
    if f:
        print(i)
        exit()
print("-1")

Measured memory_bytes: 9156
import numpy as np

N = int(input())
S = input()
alphabet = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(",")

ans = 0
max_num = 0
for n in range(N):
    s1 = S[:n]
    s2 = S[n:]

    h1 = np.zeros(26)
    h2 = np.zeros(26)

    for i in range(len(s1)):
          h1[alphabet.index(s1[i])] = 1
    for i in range(len(s2)):
          h2[alphabet.index(s2[i])] = 1

    h = h1 * h2
    num = np.sum(h)
    if num > max_num:
          max_num = num

print(int(max_num))


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

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

int main(){
  int N; cin>>N;
  if(N==1){
  	cout<<1<<endl;
    return 0;
  }
  vector<int> a(N+1);
  rep1(i,N) cin>>a[i];
  int l=1,r=2;
  ll tmpsum=a[1],tmpxor=a[1],ans=0;
  while(1){
    if((tmpxor^a[r])<(tmpsum+a[r])){//外れる
      ans+=r-l;
      tmpsum-=a[l];
      tmpxor^=a[l++];
    }else{
    	tmpsum+=a[r];
      	tmpxor^=a[r];
      	if(r==N){
          for(int k=l;k<=N;k++) ans+=r-k+1;
          break;
        }
      	r++;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 1152
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn ask(q: &[bool]) -> i32 {
    let mut s = String::new();
    for &c in q.iter() {
        s.push(if c { '1' } else { '0' });
    }
    println!("? {}", s);
    get()
}

fn solve() {
    let n: usize = get();
    // n == 200
    // n * (n - 1) / 2 queries
    let mut pool = Vec::new();
    for i in 0 .. n {
        for j in 0 .. i {
            let mut v = vec![false; n];
            v[i] = true;
            v[j] = true;
            if ask(&v) == 1 {
                pool.push((i, j));
            }
        }
    }
    print!("!");
    for (u, v) in pool {
        print!(" ({},{})", u, v);
    }
    println!("");
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 9416
#include <stdio.h>

int main(void)
{
	int i, p, n, m, out;
	char flag[1000];
	
	while (1){
		scanf("%d %d", &n, &m);
		if (n == 0 && m == 0){
			break;
		}
		
		for (i = 0; i < 1000; i++){
			flag[i] = 0;
		}
		
		out = 0;
		i = 0;
		p = n - 1;
		while (out < n - 1){			
			if (i == m){
				flag[p % n] = 1;
				out++;
				i = 0;
				
			}
			
			p++;
			while (flag[p % n] == 1){
				p++;
			}
			i++;
		}
		
		for (i = 0; i < n; i++){
			if (flag[i] == 0){
				printf("%d\n", i + 1);
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


ll a[500000]={};

int main(){
    int M, D;
    cin >> M >> D;
    int ans=0;
    for(int i=1; i<=M; i++){
        for(int j=1; j<=D; j++){
            if(j/10>=2 && j%10 >=2 && i==(j/10)*(j%10)){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {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;}

//cout<< fixed << setprecision(10)
ll modInv(ll a){
	return powm(a,mod-2)%mod;
}

int main()
{
	fast;
	ll n,i,j;
	cin>>n;
	ll u,v;
	ll x=0;
	for(i=1;i<=n;i++)
	{
		x+=i*(n+1-i);
	}
	ll y=0;
	for(i=1;i<n;i++)
	{
		cin>>u>>v;
		if(u>v)
		swap(u,v);
		y+=u*(n+1-v);
		
	}
	cout<<x-y;
	
    
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9 + 7;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int testCases = 1;
   // cin >> testCases;
    
    while(testCases--)
    {
        int n,i;
        cin >> n;
        int a[n + 1];
        int suf[n + 2] = {0};
        
        for(i = 1;i <= n;++i)
            cin >> a[i];
            
        for(i = n;i >= 1;--i)
        {
            suf[i] = (suf[i + 1] + a[i]) % mod;
        }
        
        int ans = 0;
        
        for(i = 1;i <= n;++i)
        {
            ans += (a[i] * suf[i + 1]) % mod;
            ans %= mod;
        }
        
        cout << ans;
        cout << '\n';
    }
    
}


Measured memory_bytes: 6680
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	ll n,sum=0;
	cin >> n;
	vector<ll>a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i] - 1;
	}
	
	cout << sum << endl;
}

Measured memory_bytes: 256
def mi(): return map(int,input().split())
def lmi(): return list(map(int,input().split()))
def ii(): return int(input())
def isp(): return input().split()

from itertools import combinations_with_replacement
n,m,q=mi()
ll=[i for i in range(1,m+1)]

input_list=[]
for i in range(q):
  abcd=lmi()
  input_list.append(abcd)

ans=0
la=list(combinations_with_replacement(ll,n))
for i in la:
  suma=0
  #print(i)
  for j in input_list:
    a=j[0]
    b=j[1]
    c=j[2]
    d=j[3]
    if (i[b-1]-i[a-1])==c:
      suma+=d
      #print(suma)
  ans=max(ans,suma)
  
print(ans)

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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define fst first
#define snd second
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'

typedef long long ll;

int main() {
  int k; cin >> k;
  string s;
  cin >> s;
  if(s.size() <= k) cout << s << endl;
  else cout << s.substr(0, k) << "..." << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>

using ll = long long;

using namespace std;

ll gcd(ll a, ll b);

ll lcm(ll a, ll b);

int main()
{
	int n, i;
	ll t, g = 1;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		cin >> t;
		g = lcm(g, t);
	}

	cout << g << endl;

	return 0;
}

ll gcd(ll a, ll b)
{
	ll tmp;

	if (b == 0) {
		return a;
	}

	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	return gcd(b, a % b);
}

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

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int64_t dp[1<<21];

int main(){
    int N, A[21][21];
    cin >> N;
    for(int i=0; i<N; i++) for(int j=0; j<N; j++) cin >> A[i][j];
    
    dp[0] = 1;
    for(int bits=0; bits<(1<<N); bits++){
        int cnt = 0;
        for(int i=0; i<N; i++) if(nth_bit(bits, i)) cnt++;
        for(int i=0; i<N; i++){
            if(!nth_bit(bits, i) && A[cnt][i]){
                add(dp[bits + (1<<i)], dp[bits]);
            }
        }
    }
    cout << dp[(1<<N)-1] << endl;
    return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int check(string s)
{
    string r;
    for(int i=s.size()-1;i>=0;i--) r+=s[i];
    if(r==s) return 1;
    return 0;
}
int main()
{
    string s,t1,t2;
    cin>>s;
    for(int i=0;i<(s.size()-1)/2;i++) t1+=s[i];
    for(int i=(s.size()+1)/2;i<s.size();i++) t2+=s[i];
    if(check(s)&&check(t1)&&check(t2)) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	if(a<1 || a>9 || b<1 || b>9)
	{
	    cout<<-1;
	    return 0;
	}
	cout<<(a*b);
    return 0;
}


//252908XL

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
int kaizyo(int a) {
	long long ans = 1;
	for (int i = a; i > 0; i--) {
		ans *= i;
		ans = ans % 1000000007;
		//cout << ans << endl;
	}
	ans = ans % 1000000007;
	return ans;
}
int main() {
	long long a = 0, b = 0, kake = 1;
	cin >> a >> b;
	if (abs(a - b) > 1) {
		cout << '0' << endl;
		return 0;
	}
	kake = kake * kaizyo(a) * kaizyo(b) % 1000000007;
	if ((a + b) % 2 == 0) {
		kake = kake * 2 % 1000000007;
	}
	cout << kake << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;

public class Main {

  private static void solve() {
    int n = ni();
    int[] a = na(n);
    
    Arrays.sort(a);
    if (a[0] == a[n - 1] && a[0] == n - 1) {
      System.out.println("Yes");
    } else {
      int c = a[n - 1];
      int x = (int)Arrays.stream(a).filter(v -> v == c - 1).count();
      
      int d = c - x;
      int y = n - x;
      
      System.out.println(d > 0 && d * 2 <= y ? "Yes" : "No");
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = System.getProperty("debug");
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 37708
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define ll long long
//#define int long long
using namespace std;
void boost()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
void free()
{
	freopen("A.in", "r", stdin);
	freopen("A.out", "w", stdout);
}
int cnt[100001];
main()
{
	//free();
	boost();
	int a, b, k;
	int x = 0;
	cin >> a >> b >> k;
	if(b - a  + 1 < k) 
	{
		for(int i = a; i <= b; i++) cout << i << endl;
		exit(0);
	}
	for(int i = a; i < a + k; i++) cnt[x] = i, x++;
	for(int i = b; i > b - k; i--) cnt[x] = i, x++;
	sort(cnt, cnt + x);
	for(int i = 0; i < x; i++)
		if(cnt[i] != cnt[i + 1]) cout << cnt[i] << endl;
	exit(0);
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);  
    public static void main(String[] args) throws Exception {
        int x = sc.nextInt();
        if (x>=1200) {
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }
    }
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

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


#define mkf(n,MOD)  int fact[(n)+1]={}; mfac((n),fact,(MOD)) //enables to let x!=fact[x]

int mmul(int p,int q,int m){ //O(1)?
    ll lp=p,lq=q; return ((lp%m)*(lq%m))%m;
}

int mpow(int x,int n,int m){ //O(logN)
    ll res=x,ans=1;
    while(n!=0){
        if(n%2==0){ res = mmul(res,res,m);n>>=1;
        }else{      ans = mmul(ans,res,m);--n;}}return ans;}

int mdiv(int p,int q,int m){ //O(logMOD)
    return mmul(p,mpow(q,m-2,m),m);
}

void mfac(int x,int *f,int m){//O(n)
    *f=1; for(int i=1;i<=x;++i)f[i]=mmul(f[i-1],i,m);
}

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n;
    cin >>n;

    mkf(n,MOD);

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << fact[n] << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

double cross_product (xy_t a, xy_t b) {
    return (conj(a) * b).imag();
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed;
    cout << setprecision(12);
    ll N;
    cin >> N;
    xy_t pt[N];
    REP(i, 0, N) {
        ll x, y;
        cin >> x >> y;
        pt[i] = xy_t(x, y);
    }
    sort(pt, pt + N, [](xy_t a, xy_t b) {
        return arg(a) < arg(b);
    });
    double ans = 0;
    REP(i, 0, N) {
        REP(j, 1, N + 1) {
            ll rem = j;
            xy_t sum = 0;
            REP(k, i, N) {
                if (rem == 0) {
                    break;
                }
                sum += pt[k];
                rem--;
            }
            REP(k, 0, i) {
                if (rem == 0) {
                    break;
                }
                sum += pt[k];
                rem--;
            }
            ans = max(ans, abs(sum));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int num[15];

int main()
{
    ll a,b,n;
    cin >> a >> b >> n;
    double t;
    if(b<=n)
        t=double(b-1)/b;
    else
        t=double(n)/b;
    cout << floor(a*t)-a*floor(t);
    return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 1e6 + 9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll, ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}


set<vector<int> > st;
int n;
void fun(vec temp) {

    if(temp.size() == n) {
        st.insert(temp);
    }
    if(temp.size() > n) {
        return;
    }
    for(int i=1; i<=n; i++) {
        if(find(all(temp),i) == temp.end()) {
            temp.pb(i);
            fun(temp);
            temp.pop_back();
        }
    }

}


void test_case()
{


    cin>>n;
    
    vec p(n), q(n);

    rep(i,n) {
        cin>>p[i];
    }

    rep(i,n) {
        cin>>q[i];
    }

    vec temp;
    for(int i=1; i<=n; i++) {
        temp.pb(i);
        fun(temp);
        temp.pop_back();
    }

    vector< vec > te;
    for(auto it : st) {
        // for(auto  ut : it) {
        //     cout<<ut<<" ";
        // }
        // cout<<endl;
        te.pb(it);
    }

    auto it = find(all(te),p) - find(all(te),q);

    cout<<abs(it)<<endl;





    
    
    
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);

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

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

Measured memory_bytes: 13008
import numpy as np
import math


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

p = int(math.floor(N / K))
total = p * p * p
# print(p)
# print(total)

if K % 2 == 0:
    q = int(math.floor((N + K/2) / K))
    total += q * q * q

print(total)


Measured memory_bytes: 12484
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n,k; cin >>n>>k;

    int ans = 0;
    if (k > 1) {
        ans = n-k;
    } 
    cout << ans << endl;

    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(long long i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const double pi = acos(-1.0);
const ll mod = pow(10,9) + 7;
const ll INF = pow(2,31) - 1;

int main()
{
    ll a,b,ans;
    cin >> a >> b;
    if(a+b == 3)ans = 3;
    else if(a+b == 4)ans = 2;
    else if(a+b == 5)ans = 1;

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


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

long long a , sum;

int main ( void )
{
	ios::sync_with_stdio ( false ); cin.tie ( 0 ); cout.tie ( 0 );
	cin >> a;
	for ( int i = 1 ; i <= a ; i++ ) {
		sum += i - 1;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  string S;
  cin >> S;
  bool ans=true;
  for(int i=0; i<(int)S.size()-1; i++){
    if(S[i] == S[i+1]){
      ans = false;
    }
  }
  if(ans){
    cout << "Good" << endl;
  }else{
    cout << "Bad" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N,K,Q = map(int,input().split())
A = []
for _ in range(Q):
  A.append(int(input()))
point_list = [K-Q] * N
for i in range(Q):
  point_list[A[i]-1] += 1
for ii in range(N):
  if point_list[ii] > 0 :
    print('Yes')
  else :
    print('No')

Measured memory_bytes: 10452
#include <bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0; i < n; i++)
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0; i < n; i++) cin >> a[i];
  int b[n];
  for(int i=0; i < n; i++){
    b[a[i]-1]=i+1;
  }
  for(int i=0; i < n; i++){
    cout << b[i] << " ";
  }
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
ll gcd(ll a, ll b)
{
  if(a%b==0)
    return b;
  else
    return gcd(b, a%b);
}
 
int main(void)
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll a, b;
  cin >> a >> b;
  cout << (a*b)/gcd(a,b) << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

map<ll, bool> primes;

bool dup(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            if (primes[i]) { return true; }
            if (i != 1) { primes[i] = true; }
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) {
                if (primes[N/i]) { return true; }
                if (N/i != 1) { primes[N/i] = true; }
            };
        }
    }
    return false;
}

int main() {
    ll N;
    cin >> N;

    ll g1;
    cin >> g1;
    dup(g1);
    bool pairwise = true;
    for (ll i = 2; i <= N; i++) {
        ll a;
        cin >> a;
        if (dup(a)) {
            pairwise = false;
        }
        g1 = __gcd(g1, a);
    }

    if (pairwise) {
        cout << "pairwise coprime\n";
    } else if (g1 == 1) {
        cout << "setwise coprime\n";
    } else {
        cout << "not coprime\n";
    }               
}

Measured memory_bytes: 66088
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(void){
    ll n,m,a;
    cin>>n>>m;
    priority_queue<ll> que;
    for(int i=0;i<n;i++){
        cin>>a;
        que.push(a);
    }
    for(int i=0;i<m;i++){
        que.push(que.top()/2);
        que.pop();
    }
    ll sum=0;
    for(int i=0;i<n;i++){
        sum+=que.top();
        que.pop();
    }
    cout<<sum;
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
int main(){
    int A,B,K;
    cin>>A>>B>>K;
    int count = 0;
    int ans;
  vector<int> num;
    for(int i = 1;i<=max(A,B);i++){
        if(A%i==0&&B%i==0){
            num.push_back(i);
        }
    }
    sort(num.begin(),num.end());
    reverse(num.begin(),num.end());
    cout<<num.at(K-1)<<endl;
}

Measured memory_bytes: 256
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(a + b < 10 ? a + b : "error");
	}
}


Measured memory_bytes: 35664
#include<stdio.h>
#define N 101

int main(){
  int n,Adj[N][N],u,k,i,j,v;
  scanf("%d",&n);
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      Adj[i][j]=0;

  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      Adj[u][v]=1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      printf("%d",Adj[i][j]);
      if(j!=n)printf(" ");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2132
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string t = "KIHBR";
    int idx = 0;
    int flg = false;
    rep(i, n) {
        if (s[i] == t[idx]) {
            ++idx;
            flg = false;
        }
        else if (s[i] != 'A') {
            cout << "NO" << endl;
            return 0;
        }
        else if (!flg && idx != 1 && idx != 2) {
            flg = true;
        }
        else {
            cout << "NO" << endl;
            return 0;
        }
    }
    if (idx != 5)   cout << "NO" << endl;
    else            cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)

ll mo=1000000007;
ll comb(ll N_, ll C_) {
    const int NUM_=100043;
    static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
    if (fact[0]==0) {
        inv[1]=fact[0]=factr[0]=1;
        for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
        for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
    }
    if(C_<0 || C_>N_) return 0;
    return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
    }
int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	ini(n);
	ini(n1);
	vi morty;
	FOR(i,0,n1){
		ini(x);
		morty.push_back(x);
	}
	sort(all(morty));
	vi morty1;
	FOR(i,0,n1-1){
		morty1.push_back(morty[i+1]-morty[i]);
	}
	sort(all(morty1));
	int rick = 0;
	FOR(i,0,n1-n){
		rick+=morty1[i];
	}
	out(rick);














	return 0;
}

Measured memory_bytes: 2548
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}
func nextStr(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	N := nextInt(sc)
	m := make(map[string]int, 0)
	for i := 0; i < N; i++ {
		m[nextStr(sc)]++
	}
	fmt.Println(len(m))
}


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

int main(){
    int N, L; std::cin >> N >> L;
    std::vector<std::string> S(N);
    for (auto& r : S) std::cin >> r;
    std::sort(S.begin(), S.end());
    for (auto& r : S)std::cout << r;
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>
#include <string.h>
int main(int argc, const char * argv[]) {
    int t,i,h,j,p,q;
    int len;
    char s[201];
    char temp[201];
    while(1){
        scanf("%s",s);//?????????
        if(s[0]=='-'){
            break;
        }
        len=strlen(s);
        scanf("%d",&t);//?????£??????????????°
        for(i=1;i<=t;i++){
            scanf("%d",&h);//??\???????????????
            for(j=0;j<h;j++){
                temp[j]=s[j];
            }
            for(p=0;p<len-h;p++){
                s[p]=s[h+p];
            }
            for(q=0;q<h;q++){
                s[len-h+q]=temp[q];
            }
            
        }printf("%s\n",s);
    }memset(s, '\0', sizeof(s));
    memset(temp, '\0', sizeof(temp));
    
    
    return 0;
}

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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define Matrix vector<vector<int>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'
#define double long double

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

map<int, int> primeFactors(int n) {
  set<int> ret;
  map<int, int> m;
  while (n % 2 == 0) {
    ++m[2];
    n /= 2;
  }

  for (int i = 3; i * i <= n; i += 2) {
    while (n % i == 0) {
      ++m[i];
      n = n / i;
    }
    /* OBS1
        IF(N < 1E7)
          you can optimize by factoring with SPF
    */
  }

  if (n > 2)
    ++m[n];

  return m;
}

// #define MULTIPLE_TEST_CASES
void solve() {
  int n;
  cin >> n;
  map<int, int> m = primeFactors(n);

  int ans = 0;
  for (const auto x : m) {
    if (x.ff == 1)
      continue;
    int v = x.ss;
    for (int i = 1; i <= v; ++i) {
      ++ans;
      v -= i;
    }
  }

  cout << ans << endl;
}

signed main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t = 1;

#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

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


int N, K;
long long a[5002];

bool dp[5003][5000];

bool is_needed(int x){
    for(int k = 0; k < K; k++){
            dp[0][k] = false;
    }
    dp[0][0] = true;
    for(int i = 0; i < N; i++){
        for(int k = 0; k < K; k++){
            dp[i+1][k] = dp[i][k];
        }
        if(i != x){
           for(int k = 0; k < K; k++){
               if(a[i] + k < K){
                   dp[i+1][a[i]+k] = dp[i][k] || dp[i+1][a[i]+k];
               }
           }
        }
    }
    bool ret = false;
    for(int k = max(0LL, K - a[x]); k < K; k++){
        ret = ret || dp[N][k];
    }
    return ret;
}

// is_needed(begin) == false, is_needed(end) == true
int find(int begin, int end){
    if(end - begin == 1){
        return begin;
    }
    int mid = (begin + end)/2;
    if(is_needed(mid)){
        return find(begin, mid);
    }else{
        return find(mid, end);
    }
}

int main(){
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(a, a+N);
    if(is_needed(0) == true){
        cout << 0 << endl;
        return 0;
    }
    if(is_needed(N-1) == false){
        cout << N << endl;
        return 0;
    }
    cout << find(0, N-1) + 1 << endl;
}

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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) int x; cin>>(x);
#define SIN(x) string x; cin>>(x);
#define INN(x, y) int x, y; cin>>(x)>>(y);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x,v) lower_bound((x).begin(),(x).end(),(v))-(x).begin();
#define uboundv(x,v) upper_bound((x).begin(),(x).end(),(v))-(x).begin();
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1
#define mp make_pair

typedef long long ll;
typedef long double LD;

using namespace std;

#define N 100005

int main() {
	ios::sync_with_stdio(0);
    INN(a, b);
    cout<<(a<9 && b<9 ? "Yay!" : ":(")<<endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
minval=10**5
ans=0
for i in range(N):
    val=abs(A-(T-H[i]*0.006))
    if val<minval:
        minval=val
        ans=i
print(ans+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 2e3;
#define int long long
int arr[N];
int32_t main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        arr[i] -= i + 1;
    }
    sort(arr, arr + n);
    int b = arr[n / 2];
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += abs(arr[i] - b);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1792