akhauriyash/Code-Regression huggingface dataset:
//https://beta.atcoder.jp/contests/abc113/tasks/abc113_d
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

constexpr int mod = 1e9+7;
using V=vector<LL>;
int main(){
    int r,c,k;
    cin>>r>>c>>k;
    V dp(c,0);
    dp[0]=1;
    if(c==1){
        cout<<1<<endl;return 0;
    }
    vector<bitset<8>> B;
    for(int bit:range(1<<(c-1))){
        bitset<8> b(bit);
        bool ok = true;
        for(int i:range(c-2)){
            if(b[i]&&b[i+1])ok=false;
        }
        if(ok){
            B.push_back(b);
            //cout<<bit<<endl;
        }
    }

    for(int i:range(r)){
        V nxt(c,0);
        for(int now:range(c)){
            dp[now]%=mod;
            for(auto &b:B){
                if(now>0&&b[now-1]){
                    nxt[now-1]+=dp[now];
                }
                else if(now<c-1&&b[now]){
                    nxt[now+1]+=dp[now];
                }
                else{
                    nxt[now]+=dp[now];
                }
            }
        }
        swap(dp,nxt);
    }
    cout<<dp[k-1]%mod<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

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

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;

//とりあえず1-indexedでつくったBIT
template <class T>
struct BinaryIndexedTree {
  T n;
  std::vector<T> bit;

  BinaryIndexedTree(T i) : n(i), bit(i + 1, 0){};

  // a番目にwを加算
  void add(T a, T w) {
    for (T x = a; x <= n; x += (x & -x)) {
      bit[x] += w;
    }
  }

  //[1,a]の和
  T sum(T a) {
    T ret = 0;
    for (T x = a; x > 0; x -= (x & -x)) {
      ret += bit[x];
    }
    return ret;
  }
};
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,k,sum=0;
  std::cin>>n>>k;
  std::vector<ll> b(n+1),zaatsu(n+1);
  b[0]=0;zaatsu[0]=0;
  rep(i,0,n){
    ll a;
    std::cin>>a;
    sum+=a;
    b[i+1]=sum-k*(i+1);
    zaatsu[i+1]=b[i+1];
  }
  std::sort(all(zaatsu));
  rep(i,0,n+1){
    b[i]=(ll)(std::lower_bound(all(zaatsu),b[i])-zaatsu.begin());
  }

  ll ans=0;
  BinaryIndexedTree<ll> bit(n+1);
  rep(i,0,n+1){
    ans+=bit.sum(b[i]+1); 
    bit.add(b[i]+1,1);
  }

  std::cout<<ans;
  return 0;
}

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

using namespace std;

int main()
{
	int N, L;
	cin >> N >> L;
	string s[100];
	for (int i = 0; i < N; i++)
		cin >> s[i];
	for (int i = 1; i < N; i++) {
		string v = s[i];
		int j = i - 1;
		while (j >= 0 && s[j] > v) {
			s[j + 1] = s[j];
			j--;
		}
		s[j + 1] = v;
	}
	for (int i = 0; i < N; i++)
		cout << s[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
// Problem : D - Even Relation
// Contest : AtCoder - AtCoder Beginner Contest 126
// URL : https://atcoder.jp/contests/abc126/tasks/abc126_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a) for (int i=0; i<(a); i++)
#define rep1(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rep(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define imax INT_MAX
#define imin INT_MIN
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	 
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n;
	cin>>n;
	vpi a[n];
	loop(i,n-1)
	{
		int k, l,w;
		cin>>k>>l>>w;
		k--,l--;
		a[k].pb({l,w});
		a[l].pb({k,w});
	}
	stack<int> q;
	q.push(0);
	int ans[n];
	loop(i,n)
	ans[i]=-1;
	ans[0]=0;
	while(!q.empty())
	{
		int s=q.top();
		q.pop();
		trav(i,a[s])
		{
			if(ans[i.f]!=-1)
			continue;
			ans[i.f]=(ans[s]+i.s)%2;
			q.push(i.f);
		}
		
	}
	loop(i,n)
	cout<<ans[i]<<nl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 9924
n = int(input())
ls = list(map(int, input().split()))

ans = 0
flagu = 0
flagd = 0

for i in range(n):
	if i == 0:
		continue
	elif ls[i - 1] < ls[i]:
		if flagd == 1:
			ans += 1
			flagu = 0
			flagd = 0
		elif flagu == 0:
			flagu = 1
	elif ls[i - 1] > ls[i]:
		if flagu == 1:
			ans += 1
			flagu = 0
			flagd = 0
		elif flagd == 0:
			flagd = 1
	
	if i == n - 1:
		ans += 1

if n == 1:
	print(1)
else:
	print(ans)

Measured memory_bytes: 14252
N=int(input())
A=list(map(int,input().split()))
M=10**9+7

L=[0]*N
for a in A:
    L[a]+=1

if N%2:
    F=(L[0]==1)
    for i in range(1,N):
        if i%2:
            F&=(L[i]==0)
        else:
            F&=(L[i]==2)

    if F:
        print(pow(2,(N-1)//2,M))
    else:
        print(0)
else:
    F=True
    for i in range(N):
        if i%2:
            F&=(L[i]==2)
        else:
            F&=(L[i]==0)
    if F:
        print(pow(2,N//2,M))
    else:
        print(0)

Measured memory_bytes: 84484
#include<bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi
#define se second
 
#define forz(i,n) for(long long int i=0;i<n;i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0) 
 
using namespace std;
 
 
int main(){
//	ios_base::sync_with_stdio(0);
	lli n, c1, c2, sum;
	cin >> n;
	c1 = n/500;
	n = n- (c1*500);
	c2 = n/5;

	sum = c1*1000 + c2*5;
	cout << sum <<endl;
	
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int K,T,A,maxi = 0;
    cin >> K >> T;
    for(int i = 0;i < T;i++){
        cin >> A;
        maxi = max(maxi,A);
    }
    if(T == 1)cout << K-1 << endl;
    else cout << max(maxi*2-K-1,0) << endl;
}   

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	string s;

	cin >> s;
	cout << s;
	if (s[s.size() - 1] == 's') {
		cout << "es" << endl;
	}
	else {
		cout << "s" << endl;
	}

	return 0;
}

Measured memory_bytes: 3644
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Discount Fare
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int x, y;
  scanf("%d%d", &x, &y);
  printf("%d\n", x + y / 2);
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  map<int, set<pair<int, int>>> mp;
  for (int i=0; i<N-1; i++){
    int u, v, w;
    cin >> u >> v >> w;
    mp[u].insert(make_pair(v,w));
    mp[v].insert(make_pair(u,w));
  }
  vector<long long> dst(N+1,-1);
  queue<int> q;
  q.push(1);
  dst[1] = 0;
  while (!q.empty()){
    int check = q.front();
    q.pop();
    for (auto k: mp[check]){
      if (dst[k.first]<0){
        q.push(k.first);
        dst[k.first] = dst[check]+k.second;
      }
    }
  }
  for (int i=1; i<=N; i++){
    cout << dst[i]%2 << endl;
  }
  return 0;
}


Measured memory_bytes: 19968
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		long ans = 0;
		for(var i=1;i<=N;i++){
			ans += (long)(N/i)*(1+(long)N/i)/2*i;
		}
		Console.WriteLine(ans);
	}
}

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


int main(){
	long long int x;
	cin >>x;
	int f=0;
	for(long long int a=-118;a<120;a++){
		for(long long int b=-119;b<119;b++){
			if(f==0&&x==a*a*a*a*a-b*b*b*b*b){
				cout << a << " " << b << endl;
				f++;
			}
		}
	}
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//個数カウント付きUnionFind
class UnionFind {
  vector<int> r;
public:
  UnionFind(int n){ r=vector<int>(n,-1); }
  int root(int i){
    if(r[i]<0) return i;
    return r[i]=root(r[i]);
  }
  bool unite(int a,int b){
    a=root(a); b=root(b);
    if(a==b) return false;
    if(r[a]>r[b]) swap(a,b); //多い方に寄せる
    r[a]+=r[b];
    r[b]=a;
    return true;
  }
  int size(int i){ return -r[root(i)]; }
};

int app() {
  int n,m;
  cin>>n>>m;

  UnionFind uf(n);

  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    uf.unite(a,b);
  }

  int ans=0;
  rep(i,n){
    chmax(ans,uf.size(i));
  }
  return ans;
}

int main(){cout<<app()<<endl;return 0;}


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

using namespace std;
using ll = long long;

int g2(int a, int b){
    while(true){
        if(a < b) swap(a, b);
        if(b == 0) break;
        a %= b;
    }
    return a;
}

int g3(int a, int b, int c){
    return g2(g2(a, b), c);
}

int main(){
    int k; cin >> k;
    int ans = 0;
    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int m = 1; m <= k; m++){
                ans += g3(i, j, m);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n;
  cin>>n;
  int d[n];
  for(int i=0;i<n;i++) cin>>d[i];
  sort(d,d+n);
  cout<<d[n/2]-d[n/2-1]<<endl;
  return 0;
}


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

int main() {
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   ll h,w;
   cin>>h>>w;
   char arr[h][w];
   for(int i=0;i<h;i++)
   {
       for(int j=0;j<w;j++)
        cin>>arr[i][j];
   }
   ll x[h][w],f=0;
   for(int i=0;i<h;i++)
     {   if(arr[i][0]=='.' && f==0)
         x[i][0]=1;
         else
        { x[i][0]=0;
          f=1;
        }
     
     
     }
     f=0;
     for(int i=0;i<w;i++)
     {
         if(arr[0][i]=='.' && f==0)
         x[0][i]=1;
         else
         {
             x[0][i]=0;
             f=1;
         }
     }
   
   for(int i=1;i<h;i++)
   {
       for(int j=1;j<w;j++)
       {
           if(arr[i][j]=='#')
           x[i][j]=0;
           else
           x[i][j]=((x[i-1][j])%(1000000007)+(x[i][j-1])%(1000000007))%(1000000007);
       }
   }
//     for(int i=0;i<h;i++)
//   {
//       for(int j=0;j<w;j++)
//       cout<<x[i][j]<<" ";
//       cout<<endl;
//   }
  cout<<x[h-1][w-1]%(1000000007);
   
  
    
}

Measured memory_bytes: 9088
import bisect
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=10**9+7
if len(set(a))!=len(a) or len(set(b))!=len(b):
  print(0)
else:
  a.sort()
  b.sort()
  L=[]
  for i in range(n):
    l=[]
    for j in range(m):
      l.append(0)
    L.append(l)
  if m*n in a and m*n in b:
    L[a.index(m*n)][b.index(m*n)]=m*n
    ct=1
    ctn=1
    ctm=1
    A=set(a)
    B=set(b)
    for k in range(m*n-1,0,-1):
      if k in A and k in B:
        L[bisect.bisect_left(a,k)][bisect.bisect_left(b,k)]=k
        ct*=1
        ctn+=1
        ctm+=1
      elif k in A:
          ct*=ctm
          ctn+=1
      elif k in B:
          ct*=ctn
          ctm+=1
      else:
        ct*=(ctm*ctn-m*n+k)
      if ct==0:
        break
      ct=ct%x
    print(ct)
  else:
    print(0)

Measured memory_bytes: 12020
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  lint n, c; cin >> n >> c;
  V<lint> x(n); for (int i = 0; i < n; i++) cin >> x[i];
  V<lint> cx(n + 1); for (int i = 0; i < n; i++) cx[i + 1] = cx[i] + x[i];
  lint res = 9e18, th;
  for (lint i = n; i; i--) {
    lint tmp = (n + i) * c;
    lint j = 0;
    while (true) {
      tmp += (cx[n - j * i] - cx[max(n - (j + 1) * i, 0LL)]) * max(2 * j + 3, 5LL);
      j++;
      if (n- j * i < 0) break;
    }
    if (i == n) th = tmp;
    if (tmp > th) break;
    res = min(res, tmp);
  }
  cout << res << '\n';
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a( N );
  for ( int i = 0; i < N; i++ )
    cin >> a.at( i );
  int bn = 1;
  for ( int n = 1; n < N; n++ ) {
    bn = a.at( bn - 1 );
    if ( bn == 2 ) {
      cout << n << endl;
      break;
    }
  }
  if ( bn != 2 )
    cout << -1 << endl;  
}


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

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

  if(N == 3) {
    cout << "2 5 63" << endl;
  } else {
    vector<ll> ans = { 2, 3, 4, 9 };
    ll l2 = 8, l3 = 15, l6 = 6;
    while(ans.size() < N) {
      if(l2 <= 30000 && N - ans.size() >= 2) {
        ans.push_back(l2);
        ans.push_back(l2 + 2);
        l2 += 6;
      } else if(l3 <= 30000 && N - ans.size() >= 2) {
        ans.push_back(l3);
        ans.push_back(l3 + 6);
        l3 += 12;
      } else {
        ans.push_back(l6);
        l6 += 6;
      }
    }
    REP(i, 0, ans.size()) cout << ans[i] << (i + 1 != ans.size() ? " " : "\n");
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define forn(i,a,b) for(int i=a; i<=b; i++)
#define ford(i,a,b) for(int i=a; i>=b; i--)
#define MOD 1000000007
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n;
	cin>>n;
	vector<int> dp(3);
	for(int day=0; day<n; ++day){
		vector<int> new_dp(3,0), c(3);
		for(int i=0; i<3; ++i) cin>>c[i];
		for(int i=0; i<3; ++i){
			for(int j=0; j<3; ++j){
				if(i!=j) new_dp[j]=max(new_dp[j],dp[i]+c[j]);
			}
		}
		dp=new_dp;
	}
	cout<<max(dp[0],max(dp[1],dp[2]))<<"\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    int k;
    vector<int> a(5);
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
    sort(a.begin(), a.end());
    if(abs(a[4] - a[0]) > k)
        cout << ":(" << endl;
    else
        cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int a[maxn],ch[maxn];
set<int> vis,buf;
int cnt[maxn],ans[maxn];int n;
int find(int x){
	auto it = vis.upper_bound(x);
	if(it==vis.end())return -1;
	return *it; 
}
void dfs(int cur){
	if(cur==n+1){
		for(int i=1;i<=n;i++)
			printf("%d ",ans[i]);
		puts("");
		exit(0);
	}
//	if(buf.size()<=2){
//		for(int x:buf){
//			if(vis.count(x)&&cnt[x]==n-cur){
//				if(x==a[ans[cur-1]])return ;
//				ans[cur] = x;
//				vis.erase(x);
//				cnt[a[x]]--;
//				if(cnt[a[x]]==0)buf.erase(a[x]);
//				dfs(cur+1);
//				return ; 
//			}
//		}
//	}
	for(int x=find(0);x!=-1;x=find(x)){
		if(x==a[ans[cur-1]])continue;
		if(cnt[a[x]]==n-cur&&vis.count(a[x]))continue;
		vis.erase(x);
		ans[cur] = x;
		cnt[a[x]]--;
		if(cnt[a[x]]==0)buf.erase(a[x]);
		dfs(cur+1);
		cnt[a[x]]++;
		buf.insert(a[x]);
		vis.insert(x);
	} 
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		vis.insert(i);
		buf.insert(a[i]);
		cnt[a[i]]++;
	}
	dfs(1);
	puts("-1");
}

Measured memory_bytes: 17664
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CStrangeBank solver = new CStrangeBank();
        solver.solve(1, in, out);
        out.close();
    }

    static class CStrangeBank {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            final int INF = (int) 1e9;
            int n = in.nextInt();
            int[] dp = new int[n + 1];
            ArrayUtil.fill(dp, INF);
            dp[0] = 0;

            // 1: しらじらしい更新
            for (int i = 0; i < n; i++) {
                dp[i + 1] = Math.min(dp[i] + 1, dp[i + 1]);
            }

            // 6:
            int six = 6;
            while (six <= n) {
                for (int i = six; i <= n; i++) {
                    try {
                        dp[i] = Math.min(dp[i], dp[i - six] + 1);
                    } catch (ArrayIndexOutOfBoundsException ignored) {
                    }
                }
                six *= 6;
            }


            // 9:
            int nine = 9;
            while (nine <= n) {
                for (int i = nine; i <= n; i++) {
                    try {
                        dp[i] = Math.min(dp[i], dp[i - nine] + 1);
                    } catch (ArrayIndexOutOfBoundsException ignored) {
                    }
                }
                nine *= 9;
            }

            out.println(dp[n]);


        }

    }

    static class ArrayUtil {
        public static void fill(int[] array, int val) {
            Arrays.fill(array, val);
        }

    }
}



Measured memory_bytes: 23764
#include <iostream>

#define max(x,y) (x)>(y) ? (x) : (y)

using namespace std;

int main()
{
	int N,Q,c[300001]={0},m=0,q,t;
	cin>>N>>Q;
	for (int i=0; i<N; i++) {
		cin>>t;
		c[t]=1;
		m=max(m,t);
	}
	
	for (int i=0; i<Q; i++) {
		cin>>q;
		if (q>m) {
			cout<<m<<endl;
			continue;
		}
		bool flag=false;
		for (int j=q-1; j>=0; j--) {
			for (int k=0; k+j<=300000; k+=q) {
				if (c[k+j]==1&&(k!=0||j!=0)) {
					flag=true;
					break;
				}
			}
			if (flag) {
				cout<<j<<endl;
				break;
			}
		}
	}
}

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

int main(){
    string s;
    cin>>s;
    if(s=="hi" || s=="hihi" || s=="hihihi" || s=="hihihihi" || s=="hihihihihi"){
        cout<<"Yes"<<endl;
        return 0;
    }
    else{
        cout<<"No"<<endl;
        return 0;
    }
}

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

#define vec(v) vector<int>(v)
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define mapci(mp) map<char*,int>(mp)
#define mapcc(mp) map<char*,char*>(mp)
typedef long long ll;
using namespace std;

int main() {
    ll n,i=0,b,ans=0;
    cin>>n;
    while(i*i<n){
        i++;
    }
    i++;
    for(int j=1;j<i;j++){
        if(n%j==0){
            b=n/j;
        }
    }
    while(b>0){
        b/=10;
        ans++;
    }
    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 REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int X, A;
    cin >> X >> A;
    if (X < A) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N; cin >> N;
	if(N == 2){
		cout << -1 << endl;
		return 0;
	}
	if(N == 3){
		cout << "aab" << endl;
		cout << "d.b" << endl;
		cout << "dcc" << endl;
		return 0;
	}
	if(N == 7){
		cout << "aabbcc." << endl;
		cout << "dde...a" << endl;
		cout << "g.e...a" << endl;
		cout << "gff...b" << endl;
		cout << "...ddeb" << endl;
		cout << "...g.ec" << endl;
		cout << "...gffc" << endl;
		return 0;
	}
	V<string> s[10];
	s[4] = {
		"abcc",
		"abdd",
		"eegh",
		"ffgh"
	};
	s[5] = {
		"aabbc",
		"hii.c",
		"h..jd",
		"g..jd",
		"gffee"
	};
	s[6] = {
		"aabbcc",
		"xxyyzz",
		"a.a.a.",
		"a.a.a.",
		".a.a.a",
		".a.a.a"
	};
	rep(n5,4) rep(n6,4){
		int n4 = N-n5*5-n6*6;
		if(n4<0 || n4%4) continue;
		n4 /= 4;
		V<string> a(N,string(N,'.'));
		int o=0;
		rep(i,n4){
			rep(x,4) rep(y,4) a[o+x][o+y] = s[4][x][y];
			o += 4;
		}
		rep(i,n5){
			rep(x,5) rep(y,5) a[o+x][o+y] = s[5][x][y];
			o += 5;
		}
		rep(i,n6){
			rep(x,6) rep(y,6) a[o+x][o+y] = s[6][x][y];
			o += 6;
		}
		rep(i,N) cout << a[i] << endl;
		return 0;
	}
}


Measured memory_bytes: 2304
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;		

void Main()
{
	int N;
	std::cin >> N;
	std::cout << N * N * N << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <unordered_map>


int main (void) {
  std::string s; std::cin >> s;

  int ans = 0;
  for(int i=0; i<s.size(); i++){
    if ( s[i] == '1' ) ans++;
  }
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long N,A,B,t;
    cin>>N>>A>>B;
    t=N%(A+B);
    if(t>A)
        cout<<A*(N/(A+B))+A;
    else
        cout<<A*(N/(A+B))+t;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  string s;
  cin>>s;
  int cnt=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='1'){cnt++;}
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
/*
ID: thanhvq1
LANG: C++14
PROB: namenum
*/

#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
//#define int long long
#define double long double
#define vec vector
#define vi vector<int>
#define vvi vector<vector<int>>
#define FZ(n) memset((n),0,sizeof())
#define FMO(n) memset((n),-1,sizeof(n))
#define unset unordered_set
#define ii pair<int, int>
#define vii vector<ii>
#define F first
#define S second
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first, l.second+r.second};
}
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
typedef long long ll;

void FILEIO() {  freopen("in.txt", "r", stdin);  freopen("out.txt", "w", stdout); }
//void FILEIO() {  freopen("namenum.in", "r", stdin);  freopen("namenum.out", "w", stdout); }
void input() {   }

// global parameters here:

void solve() {
	int l, r; cin >> l >> r;
	if(r-l>700) {cout << 0 << endl; return;}
	int minV = INT_MAX;
	FORE(i, l, r) {
		int mm1 = (i%2019);
		FORE(j, i+1, r) {
			int mm2 = j%2019;
			minV = min(minV, (mm1*mm2)%2019);
		}
	}
	cout << minV << endl;
}

signed main() {
  ios_base::sync_with_stdio(false); cin.tie();
//  FILEIO();
//auto beginProgram = chrono::steady_clock::now();

// int t, test=0; cin >> t;
//  while(t--)
  {
		solve();
  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=2e5;
const long inf=1e9;
int main(){
	long N,K; cin>>N>>K;
	if(K % 2 == 0){
		long a = N / K;
		long b = (N + K/2) / K;
		cout<<a * a * a + b * b * b<<endl;
	}else{
		long a = N / K;
		cout<<a * a * a<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;
typedef priority_queue<int, vector<int>, greater<int>> min_heap;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const double PI = 4*atan(1);
const ll INF = 1e18;
const int MX = 100001;

string st;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> st;
    int n = st.size();
    for (int i = 0; i < n; i++) {
        if (st[i] == '?') st[i] = 'D';
    }
    cout << st << "\n";

}


Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x;
    return is;
}

ll gcd(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    while (m != n)
    {
        if (m > n)
            m = m - n;
        else
            n = n - m;
    }
    return m;
}

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int main()
{
    int N;

    cin >> N;

    vector<double> x(N);
    vector<string> u(N);

    REP(i,N){
        cin >> x[i] >> u[i] ;
    }

    double ans = 0;

    REP(i,N){
        if(u[i]=="JPY"){
            ans+=x[i];
        }else{
            ans+=x[i]*380000.0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import Data.List
import Data.Maybe
import Data.Bool
import Control.Monad

main = replicateM 2 (map read.words <$> getLine) >>= print.solve

solve [[n,k], as] = fromJust $ find eval ds where
  eval d = sum (take (n - sum rs `div` d) rs) <= k where rs = sort $ map (`mod` d) as
  ds = reverse $ sort $ divisiors $ sum as

divisiors n = concatMap (\x -> bool [] [x, div n x] $ mod n x == 0) $ takeWhile ((<=n).(^2)) [1..]


Measured memory_bytes: 1148
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

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

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let x:i32 = read();
    let y:i32 = read();

    println!("{}", x+y/2);

}


Measured memory_bytes: 4352
var n, i, x : longint;
    cnt : array of longint;

begin
    readln(n);
    setlength(cnt, n);
    for i := low(cnt) to high(cnt) do cnt[i] := 0;
    for i := 1 to n - 1 do
    begin
        read(x);
        inc(cnt[x - 1]);
    end;
    for i := low(cnt) to high(cnt) do writeln(cnt[i]);
end.

Measured memory_bytes: 1392
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define MAX_N 100000
#define INF 100000000
#define MOD 1000000007
#define RANK 1000000000
#define EPS 1e-10
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> IP;

struct UF{
	int par[MAX_N];
	int rank[MAX_N];
	int si[MAX_N];

	void init(int n){
		rep(i,n){
			par[i] = i;
			rank[i] = 0;
			si[i] = 1;
		}
	}

	int find(int x){
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

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

	bool same(int x, int y){
		return find(x) == find(y);
	}
} uf;

int v, ee;
vector<int> e[100000];
int val[100000];
bool dp[2][100001];

P dfs(int x, int now){
    P ret = P(0,0);
    val[x] = now;
    if(now) ret.second++;
    else ret.first++;
    rep(i,e[x].size()){
        if(val[e[x][i]] != 2 && val[e[x][i]] != (now^1)){
            return P(-1,-1);
        }
        if(val[e[x][i]] != 2) continue;
        P tmp = dfs(e[x][i],now^1);
        if(tmp.first == -1) return P(-1,-1);
        ret.first += tmp.first;
        ret.second += tmp.second;
    }
    return ret;
}

int main(){
    cin >> v >> ee;
    rep(i,v) val[i] = 2;
    uf.init(v);
    int ho = 0, ge = 1;
    dp[ho][0] = true;
    rep(i,ee){
        int a, b;
        cin >> a >> b;
        a--; b--;
        e[a].push_back(b);
        e[b].push_back(a);
        uf.unite(a,b);
    }
    rep(i,v){
        if(uf.find(i) != i) continue;
        P d = dfs(i,0);
        if(d.first == -1){
            cout << -1 << endl;
            return 0;
        }
        if(d.first > d.second) swap(d.first,d.second);
        //cout << d.first << " " << d.second << endl;
        memset(dp[ge],0,sizeof(dp[ge]));
        for(int j = v/2+1; j >= 0; j--){
            if(j >= d.first) dp[ge][j] |= dp[ho][j-d.first];
            else break;
            if(j >= d.second) dp[ge][j] |= dp[ho][j-d.second];
        }
        swap(ho,ge);
    }
    ll ans = 0;
    for(ll i = 0; i <= v; i++){
        if(dp[ho][i]) ans = max(ans,i*(v-i));
    }
    cout << ans-ee << endl;
}

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

using namespace std;

typedef long long ll;

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

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

	string s;
	cin >> s;

	int cnt = 0;
	rep(i, n-1) if(s[i] == s[i+1]) cnt++;
	cout << min(cnt + 2 * k, n - 1) << endl; 
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>

int rightTriangle(int a, int b, int c){
  int sortedData[10];
  sortedData[0] = a;
  sortedData[1] = b;
  sortedData[2] = c;
  int i, j, temp;
  for(i=0; i<3; i++){
    for(j=i+1; j<3; j++){
      if(sortedData[i] <= sortedData[j]){
        temp = sortedData[i];
        sortedData[i] = sortedData[j];
        sortedData[j] = temp;
      }
    }
  }
  if(sortedData[0]*sortedData[0] == sortedData[1]*sortedData[1]+sortedD\
ata[2]*sortedData[2]){
    return 1;
  }else{
    return 0;
  }
}

int main(){
  char *ListOfYesOrNo[1000];
  int numberOfData;
  scanf("%d",&numberOfData);
  int a, b, c, i=0;
  while(scanf("%d%d%d", &a, &b, &c)!=EOF){
    if(rightTriangle(a,b,c)){
      ListOfYesOrNo[i] = "YES";
    }else{
      ListOfYesOrNo[i] = "NO";
    }
    i+=1;
  }
  int j;
  for(j=0; j<numberOfData; j++){
    printf("%s\n", ListOfYesOrNo[j]);
  }
  return 0;
}

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

int main() {
  int N,M,point,newpoint;
  point = 0;
  
  cin >> N;
  vector<string> vec1(N);
  for(int i=0;i<N;i++){
    cin >> vec1.at(i);
  }
  
  cin >> M;
  vector<string> vec2(M);
  for(int i=0;i<M;i++){
    cin >> vec2.at(i);
  }
  
  for(int i=0;i<N;i++){
    int newpoint = 0;
    for(int j=0;j<N;j++){
      if(vec1.at(i)==vec1.at(j)){
        newpoint++;
      }
    }
    for(int j=0;j<M;j++){
      if(vec1.at(i)==vec2.at(j)){
        newpoint--;
      }
    }
    if(point<newpoint){
      point = newpoint;
    }
  }
  cout << point << endl;
}

Measured memory_bytes: 256
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  ll k,i;
  cin>>k;
  queue<ll>q;
  for(i=1;i<10;i++)
  q.push(i);
  
  ll ans=0;
  for(i=0;i<k;i++)
  {
      ll x=q.front();
      q.pop();
      if(i==k-1)
      ans=x;
      if(x%10!=0)
      q.push(x*10+(x%10)-1);
      
      q.push(x*10+(x%10));
      
      if(x%10!=9)
      q.push(x*10+(x%10)+1);
      
  }
  cout<<ans;
   
}




Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
vector<int> v[200005];
int color[200005];
int  dfs(int x,int col){
    color[x]=col;
    int ans=1;
    for(auto it:v[x]){
        if(color[it]==-1){
            ans &= dfs(it,col^1);
        }
        else{
            if(color[it]==col){
                ans=0;
            }
        }
    }
    return ans;
}
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    MEMS(color);
    for(int i=0;i<m;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        v[x].pb(y);
        v[y].pb(x);
    }
    LL a=0,b=0,c=0;
    for(int i = 1;i<=n;i++){
        if(color[i]==-1){
            if(v[i].empty())c++;
            else if(dfs(i,0))b++;
            else a++;
        }
    }
    //printf("?%d %d\n",a,b);
    printf("%lld\n",a*(a+b)*2-a*a+b*b*2+c*n*2-c*c);
    return 0;
}


Measured memory_bytes: 12672
#include<bits/stdc++.h>
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define GCD(a, b)       __gcd(a, b)
#define pi              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
using namespace std;

long long powerMod(long long number,long long power,long long mod)
{
    LL ret=0;

    if(power==0) return 1LL%mod;
    if(power==1) return number%mod;
    if(power%2==0)
    {
        ret=powerMod(number,power/2,mod);
        ret=(ret%mod*ret%mod)%mod;
        return ret%mod;
    }
    else
    {
        ret=powerMod(number,power/2,mod);
        ret=(ret%mod*ret%mod*number%mod)%mod;
        return ret%mod;
    }
}



int main()
{
    boost;


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

    if(n>=10)
        cout<<k;
    else
    {
        long long result=k+(100*(10-n));
        cout<<result;
    }


    return 0;
}

/*

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, b, n) for (int i = b; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve(long N, ll K, vector<long> A) {
  long current = 0;
  long loop_length = 0;
  long loop_start = 0;
  vector<long> reachable;
  unordered_map<long, bool> already_reach;
  REP(i, N) {
    reachable.emplace_back(current);
    already_reach[current] = true;
    long next = A[current] - 1;
    // cout << current << " -> " << next << endl;
    if (already_reach[next]) {
      auto itr = find(reachable.cbegin(), reachable.cend(), next);
      loop_start = itr - reachable.cbegin();
      loop_length = i + 1 - loop_start;
      break;
    }
    current = next;
  }
  // cout << "loop_start" << loop_start << endl;
  // cout << "loop_length"<<loop_length << endl;

  long num = 0;
  if (K < loop_start)
    num = K;
  else
    num = loop_start + (K - loop_start) % loop_length;

  // current = 0;
  // REP(i, num) {
  //   long next = A[current] - 1;    
  //   // cout << current << " -> " << next << endl;
  //   current = next;
  // }

  cout << reachable[num] + 1 << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  long N;
  ll K;
  cin >> N >> K;

  vector<long> A(N);
  REP(i, N)
    cin >> A[i];

  solve(N, K, move(A));

  return 0;
}


Measured memory_bytes: 14404
const SieveOfEratosthenes = (n) => {
    let flg = (new Array(n)).fill(0)/* set flg[i] to true when it is seived */
    let primes = []/* list of prime numbers */
    for(let i=2; i*i<=n; i++) {
        if(!flg[i]) {
            primes.push(i)
            for(let j=i; j*j<=n; j+=i) {
                flg[j] = 1
            }
        }
    }
    return primes
}

const factorizationBySoE = (n, primes) => {
    //const primes = SieveOfEratosthenes(n)
    let factors = {}
    primes.some(p => {
        if(n < p) return true
        while(n%p===0) {
            if(!factors[p])factors[p]=1
            else factors[p]++
            n/=p
        }
    })
    if(n>1)factors[n]=1
    return factors
}


const getGCD = (a,b) => {
    if(b===0)return a
    else if(a===0)return b
    return getGCD(b, a%b)
}

const main = (arg) => {
    const N = Number(arg.split("\n")[0])
    const a = arg.split("\n")[1].split(" ").map(Number)
    
    const MAX_A = 10**6+100
  //  const A = Math.max(...a)
    
    //  check if p is in {a} (paircoprime)
    //const primes = SieveOfEratosthenes(A)
//    return
    let set = [...new Array(MAX_A)].fill(0)
    isPairCoprime = true
  /*
    for(let i=0; i<N; i++) {
        const factors = Object.keys(factorizationBySoE(a[i], primes))
        for(let j=0; j<factors.length; j++ ) {
            // console.log(`i=${i}, j=${j}, ${factors[j]}`)
            // console.log(factors)
            if(set[factors[j]] === 1) {
                isPairCoprime = false
            }
            set[factors[j]] = 1
        }
    }
*/
//  return
    for(let i=0; i<N; i++) {
        set[a[i]]++
    }
//  return
    for(let i=2; i<MAX_A; i++) {
         let cnt=0
         for(let j=i; j<MAX_A; j+=i) {
             cnt+=set[j]
         }
        if(cnt>1) {
             isPairCoprime = false
         }
     }
    
    if(isPairCoprime) {
        console.log("pairwise coprime")
        return
    }
     // return
    // setcoprime
    // let gcd = getGCD(a[0], a[1])
    let gcd = 0
    for(let i=0; i<a.length; i++) {
        gcd = getGCD(gcd, a[i])
        // console.log(gcd)
    }
    
    if(gcd===1) {
        console.log("setwise coprime")
        return
    }
    
    console.log("not coprime")
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 109952
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

vector<u64> L;

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

    int N;
    cin >> N;
    L.resize(N, 0);

    rep (i, N)
    {
        cin >> L[i];
    }
    sort(L.begin(), L.end());

    u64 ans = 0;
    for (int low = 0; low < N; ++low)
    {
        for (int mid = low + 1; mid < N; ++mid)
        {
            auto it = lower_bound(L.begin(), L.end(), L[mid] + L[low]);
            ans += it - L.begin() - mid - 1;
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
# -*- coding:utf-8 -*-
s = input()
sub = 0
for tmp in reversed(range(1,len(s)-2,2)):
    factor = s[0:tmp+1]
    sub += 2
    if factor[0:int(len(factor)/2)] == factor[int(len(factor)/2):len(factor)]:
        break
    else:
        pass
print(len(s)-sub)

Measured memory_bytes: 3060