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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

vector<int> g[200010];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    rep(i, M) {
      cin >> A[i] >> B[i];
      A[i]--; B[i]--;
      g[A[i]].pb(B[i]);
      g[B[i]].pb(A[i]);
    }
    
    vector<int> dist(N, -1);
    queue<int> que;

    dist[0] = 0;
    que.push(0);

    while (!que.empty()) {
      int v = que.front();
      que.pop();

      for (int u : g[v]) {
        if (dist[u] != -1) continue;
        dist[u] = v;
        que.push(u);
      }
    }

    REPS(i, 1, N-1) if (dist[i] == -1) {cout << "No" << endl; return 0;}

    cout << "Yes" << endl;
    REPS(i, 1, N-1) cout << dist[i] + 1 << endl;
    return 0;

}

Measured memory_bytes: 13956
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn=100+10;
int a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    int sum=0;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),sum+=a[i];
    if(sum%n==0)
    {
        int k=sum/n;
        int ans=0;
        for(int i=1;i<=n;i++)
            ans+=(a[i]-k)*(a[i]-k);
        printf("%d\n",ans);
    }
    else
    {
        int k=sum/n;
        int ans=0;
        for(int i=1;i<=n;i++)
            ans+=(a[i]-k)*(a[i]-k);
        int ans1=0;
        k++;
        for(int i=1;i<=n;i++)
            ans1+=(a[i]-k)*(a[i]-k);
        printf("%d\n",min(ans,ans1));
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[11];
  int kai=0,a=0,i;
  
  scanf("%s",s);
  for(i=0;i<10;i++){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
      a++;
      if(kai<a){
        kai=a;
      }
    }
    else{
      a=0;
    }
  }
  printf("%d",kai);
  return 0;
}
        

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
  int candy;
  int number;
  while(scanf("%d",&candy)!=EOF){
    number = 0;
    number = candy%39;
    if(number%39==0) number=39;
    if(number<10) printf("3C0%d\n",number);
    else printf("3C%d\n",number);
  }
  return 0;
}



Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] tmpArray = br.readLine().split(" ");
        int m = Integer.parseInt(tmpArray[0]);
        int n = Integer.parseInt(tmpArray[1]);
        
        //System.out.println("m "+m+" n "+n);
        
        if(m < n){
            int tmp = m;
            m = n;
            n = tmp;
        }
        
        if(m - n >= 2){
            System.out.println(0);
        }
        else {
            int combination;
            
            if(m == n){
                combination = 2;
            }
            else {
                combination = 1;
            }
            int mod = 1000000007;
            System.out.println((long)(Calc.Fact(m,mod) * Calc.Fact(n,mod) * combination)%mod);
        }
    }
}

class Calc {
    static long Fact(int n){
        long result = 1;
        for(int i = n; i >= 1;i--){
            result *= i;
        }
        
        System.out.println("fact("+n+") = "+result);
        return result;
    }
    
    static long Fact(int n, int mod){
        long result = 1;
        for(int i = n; i >= 1;i--){
            result *= i;
            result %= mod;
        }
        
        //System.out.println("fact("+n+") = "+result);
        return result;
    }
    
    static int combination(int n, int p){
        
        
        int result = 1;
        /*
        if(n - p < p){
            p = n-p;
        }
        
        for(int i = p; i > 1; i--){
            
        }*/
        
        return result;
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

using namespace std;

int main(int argc, char *argv[]) {
    ll result = 0;
    ll N;
    cin >> N;
    vector<ll> A(N+1);
    vector<ll> B(N);
    
    rep(i, N+1){
        cin >> A[i];
    }
    rep(i, N){
        cin >> B[i];
    }

    repR(i, N-1){
        ll mons = A[i] + A[i + 1];
        
        if(mons <= B[i]){
            result += mons;
            A[i] = 0;
        } else {
            result += B[i];
            if(A[i+1] < B[i]){
                A[i] -= B[i] - A[i+1];
            }
        }
    }
    
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 1792
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/

char a[200010];

int main()
{
	
	
	scanf("%s", a);
	int x = strlen(a) - 1;
	int y = 0;
	while (a[x] != 'Z'){
		x--;
	}
	while (a[y] != 'A'){
		y++;
	}
	printf("%d\n", x - y + 1);
}

Measured memory_bytes: 384
#ABC125_C

N=int(input())
A=list(map(int,input().split()))

def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    return gcd(x%y,y)

LCD=[A[0]]
RCD=[A[-1]]
for i in range(1,N):
    LCD.append(gcd(LCD[-1],A[i]))
    RCD.append(gcd(RCD[-1],A[-i-1]))

ans=1

if RCD[N-2]>ans:
    ans=RCD[N-2]

for i in range(1,N-1):
    if gcd(LCD[i-1],RCD[N-i-2])>ans:
        ans=gcd(LCD[i-1],RCD[N-i-2])

if LCD[N-2]>ans:
    ans=LCD[N-2]
print(ans)

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

int x[100];
long long dp[100][2500];

int main() {
	int n, A, s = 0;
	scanf("%d%d", &n, &A);
	for(int i = 0; i < n; i++) scanf("%d", x + i), s += x[i];
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++)
		for(int k = n; k >= 0; k--)
			for(int j = s; j >= 0; j--)
				if(j - x[i-1] >= 0) dp[k + 1][j] += dp[k][j - x[i-1]];
	long long res = 0;
	for(int i = 1; i <= n; i++) res += dp[i][A * i];
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
int main()
{
	int k, s, ans = 0;
	cin >> k >> s;
	for (int i = 0; i <= k; i++)for (int j = 0; j <= k; j++)if (s - i - j >= 0 && s - i - j <= k)ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>

using namespace std;

char suffix[] = { 'm', 'c', 'x', 'i' };

int decode(string& input)
{
  int number = 0;
  stack<char> st;
  
  for (int i = 0; i != input.size(); i++) {
    if (input[i] >= '2' && input[i] <= '9') {
      st.push(input[i]);
    } else if (input[i] == suffix[0]) {
      if (!st.empty()) {
        number += (st.top() - 0x30) * 1000;
        st.pop();
      } else {
        number += 1000;
      }
    } else if (input[i] == suffix[1]) {
      if (!st.empty()) {
        number += (st.top() - 0x30) * 100;
        st.pop();
      } else {
        number += 100;
      }
    } else if (input[i] == suffix[2]) {
      if (!st.empty()) {
        number += (st.top() - 0x30) * 10;
        st.pop();
      } else {
        number += 10;
      }
    } else {
      if (!st.empty()) {
        number += st.top() - 0x30;
      } else {
        number += 1;
      }
    }
  }
  return number;
}

string encode(int input)
{
  string str = "";
  stack<char> st;

  for (int i = 3; i >=0 ; --i) {
    if (input % 10) {
      st.push(suffix[i]);
      if (input % 10 != 1) {
        st.push(input % 10 + 0x30);
      }
    }
    input /= 10;
  }
  
  while (!st.empty()) {
    str += st.top();
    st.pop();
  }
  
  return str;
}

int main()
{
  int n;
  string input1, input2;
  string output;

  cin >> n;
  while (n--) {
    cin >> input1 >> input2;
    int sum = decode(input1) + decode(input2);
    output = encode(sum);
    cout << output << endl;
  }
}



Measured memory_bytes: 3028
n, k = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]

plus = [0]
minus = []
zeroExist = 0

for i in range(n):
    if x[i] > 0:
        plus.append(x[i])
    elif x[i] == 0:
        zeroExist = 1
    else:
        minus.append(-x[i])
minus.append(0)
minus = list(reversed(minus))

if zeroExist == 1:
    k -= 1

cost = 10**9
for i in range(k + 1):
    if i < len(plus) and k - i < len(minus):
        # print("i:{} k-i:{}".format(i, k-i))
        if i == 0 or i == k:
            cost = min(cost, plus[i] + minus[k - i])
        else:
            cost = min(cost, plus[i] + minus[k - i]
                       + min(plus[i], minus[k - i]))
            # print("{}:{}".format(i, cost))
print(cost)


Measured memory_bytes: 14252
package main

import "fmt"

func ReadInt() int {
	var n int
	fmt.Scan(&n)
	return n
}

func main() {
	towns := []int{0, 0, 0, 0}
	for i := 0; i < 3; i++ {
		towns[ReadInt()-1]++
		towns[ReadInt()-1]++
	}

	var one, two int
	for i := 0; i < 4; i++ {
		if towns[i] == 1 {
			one++
		} else if towns[i] == 2 {
			two++
		}
	}
	if one == 2 && two == 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000000000

vector<int> par;
vector<int> number;

int find(int x){
  int y=par.at(x);
  if(y!=x){
    y=find(y);
  }
  return par[x]=y;
}

void unite(int a,int b){
  int x=find(a);
  int y=find(b);
  if(x!=y){
    par[x]=y;
    number.at(y)+=number.at(x);
  }
}

int main(){
  ll N,M;
  cin>>N>>M;
  vector<int> A(M),B(M);
  for(int i=0;i<M;i++){
    cin>>A.at(i)>>B.at(i);
    A.at(i)--;
    B.at(i)--;
  }
  par.resize(N);
  number.resize(N,1);
  for(int i=0;i<N;i++){
    par.at(i)=i;
  }
  vector<ll> ans(M);
  ans.at(M-1)=N*(N-1)/2;
  for(int i=M-2;i>=0;i--){
    ll num1=number.at(find(A.at(i+1)));
    ll num2=number.at(find(B.at(i+1)));
    if(find(A.at(i+1))!=find(B.at(i+1))){
      ans.at(i)=ans.at(i+1)-num1*num2;
    }else{
      ans.at(i)=ans.at(i+1);
    }
    unite(A.at(i+1),B.at(i+1));
  }
  for(int i=0;i<M;i++){
    cout<<ans.at(i)<<endl;
  }
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cout.precision(40);
    long double a,b,h,m;cin>>a>>b>>h>>m;
    while(m>=720/11)m-=720/11;
    m+=60*h;
    m=m*5.5;
  //  m%=360;
    if(m>180)m=360-m;
    if(m==180){cout<<a+b;return 0;}
    if(m==0){cout<<abs(a-b);return 0;}
    cout<<sqrt(a*a+b*b-2*a*b*cos(m*2.0*M_PI/360));
}


Measured memory_bytes: 4164
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc043/tasks/abc043_b
S = input()
ans = []
for s in S:
    if s == 'B':
        if ans:
            del ans[-1]
    else:
        ans.append(s)
print("".join(ans))


Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll maxn=1e6+100;
ll h,w,a,b;
ll f[maxn],revf[maxn];
ll qpow(ll a,ll n){
	ll ans=1;
	while(n>0){
		if(n&1)	ans=(ans*a)%mod;
		n>>=1;
		a=(a*a)%mod;
	}
	return ans;
}
ll C(ll n,ll m){
	return (((f[n]*revf[m])%mod)*revf[n-m])%mod;
}
void init(){
	f[0]=1;
	revf[0]=qpow(f[0],mod-2);
	for(ll i=1;i<maxn;i++){
		f[i]=(f[i-1]*i)%mod;
		revf[i]=qpow(f[i],mod-2);
	}
}

ll count_ways(ll a,ll b,ll c,ll d){
	ll tot=(c-a)+(d-b);
	ll down=c-a;
	return C(tot,down);
}
int main(){
	init();
	scanf("%lld%lld%lld%lld",&h,&w,&a,&b);
	ll tol=count_ways(1,1,h,w);
	for(ll i=1;i<=b;i++){
		ll tmp=(count_ways(1,1,h-a,i)*count_ways(h-a+1,i,h,w))%mod;
		while(tmp>tol) tol+=mod;
		tol=(tol-tmp)%mod;
	}
	printf("%lld\n",tol);
	return 0;
}


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

int N;
int M;
int D[214514];
int T[214514];
map<int, int> num;

int main() {
  scanf("%d", &N);
  for (int i=0; i<N; i++) {
    scanf("%d", &D[i]);
    num[D[i]]++;
  }
  scanf("%d", &M);
  for (int i=0; i<M; i++) {
    scanf("%d", &T[i]);
    num[T[i]]--;
    if (num[T[i]] < 0) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
}


Measured memory_bytes: 11136
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <set>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t;
    cin >> t;
    REP(x,t){
        ll n;
        cin >> n;
        ll sum = 0;
        priority_queue<pair<ll,ll>, vector<pair<ll,ll> >, greater<pair<ll,ll> >  > vp;
        priority_queue<pair<ll,ll> > vm;
        REP(i,n){
            ll k,l,r;
            cin >> k >> l >> r;
            k--;
            sum += r;
            if(l-r>=0){
                vp.push(make_pair(k ,l-r));
            }else{
                vm.push(make_pair(k,l-r));
            }
        }
        priority_queue<pair<ll,ll>, vector<pair<ll,ll> >, greater<pair<ll,ll> >  > pq;
        REP(i,n){
            while(!vp.empty()&&vp.top().fi==(i)){
                auto now = vp.top();
                vp.pop();
                sum += now.se;
                pq.push(make_pair(now.se, now.fi));
            }
            while((ll)pq.size()>(i+1)){
                auto now = pq.top();
                pq.pop();
                sum -= now.fi;
            }
        }
        priority_queue<pair<ll,ll> > pq1;        
        for(ll i=n-1;i>=0;--i){
            while(!vm.empty()&&vm.top().fi==(i)){
                auto now = vm.top();
                vm.pop();
                pq1.push(make_pair(now.se, now.fi));
            }
            while((ll)pq1.size()>(n-i-1)){
                auto now = pq1.top();
                pq1.pop();
                sum += now.fi;
            }
        }
        cout << sum << "\n";
    }

    return 0;
}

Measured memory_bytes: 11016
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val (_n, k) = readLongList()
    val n = _n.toInt()
    val graph = List(n + 1) { mutableListOf<Int>() }
    readIntList().forEachIndexed { index, i ->
        graph[index + 1].add(i)
    }
    
    val firstVisit = MutableList(n + 1) { -1 }.apply { this[1] = 0 }
    val visitList = mutableListOf(1)
    var current = 1
    var loopFirst = 0
    var loopPeriod = 0
    for (i in 1..n + 1) {
        current = graph[current][0]
        if (firstVisit[current] != -1) {
            loopFirst = firstVisit[current]
            loopPeriod = i - firstVisit[current]
            break
        }
        visitList.add(current)
        firstVisit[current] = i
    }

    if (k < loopFirst+loopPeriod) {
        println(visitList[k.toInt()])
    } else {
        val subList = visitList.subList(loopFirst, visitList.size)
        println(subList[((k - loopFirst) % loopPeriod).toInt()])
    }
}

Measured memory_bytes: 87476
n = int(input())
a = list(map(int,input().split()))
swap_count = 0
for i in range(n):
    minj = i
    for j in range(i,n):
        if a[j] < a[minj]:
            minj = j
    if minj != i:
        a[i],a[minj] = a[minj],a[i]
        swap_count += 1
print(" ".join(map(str,a)))
print(swap_count)


Measured memory_bytes: 5596
#include "bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int X, Y;
    cin >> X >> Y;
    for (int i = 0; i <= X;i++) {
        int j = X - i;
        if (4 * i + 2 * j == Y) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<iostream>
using namespace std;

const double pi = 3.141592653589793;
int main()
{
	double r,l,a;

	cin >> r;

	l = 2 * r*pi;
	a = r*r*pi;

	printf("%.6lf ",a);
	printf("%.6lf\n",l);

	return 0;
}

Measured memory_bytes: 3196
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>

const int N = 500000;

int n, nxt[N];
char s[N + 1];

std::vector<bool> check()
{
    memset(nxt, -1, sizeof(nxt));
    for (int i = 0; i < n - 1; ++ i) {
        int j = i;
        while (~j) {
            j = nxt[j];
            if (s[j + 1] == s[i + 1]) {
                nxt[i + 1] = j + 1;
                break;
            }
        }
    }
    std::vector<bool> ok(n + 1);
    ok[1] = true;
    for (int i = 2; i <= n; ++ i) {
        ok[i] = nxt[i - 1] == -1 || i % (i - nxt[i - 1] - 1) != 0;
    }
    return ok;
}

int main()
{
#ifdef LOCAL_JUDGE
    freopen("D.in", "r", stdin);
#endif
    scanf("%s", s);
    n = strlen(s);
    auto prefix = check();
    std::reverse(s, s + n);
    auto suffix = check();
    if (prefix[n]) {
        printf("1\n1\n");
    } else {
        int cut = 0;
        for (int i = 1; i < n; ++ i) {
            cut += prefix[i] && suffix[n - i];
        }
        if (cut) {
            printf("2\n%d\n", cut);
        } else {
            printf("%d\n1\n", n);
        }
    }
}


Measured memory_bytes: 2816
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[500][500];

int main(){
  cin >> s;
  rep(i,0,s.sz)d[s[i]-'a']++;
  l = 0;
  rep(i,0,26)if(d[i] % 2 != 0)l++;
  if(l != 0)puts("No");
  else puts("Yes");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int sum[26][100005],cnt[26];
int main()
{
    cin>>s;
    memset(cnt,0,sizeof(cnt));
    for(int i=0;i<s.size();i++)
        sum[s[i]-'a'][cnt[s[i]-'a']++]=i+1;
    for(int i=0;i<26;i++)
    {
        for(int j=0;j<cnt[i];j++)
            for(int k=j+1;k<cnt[i];k++)
        {
            if((k-j+1)*2>sum[i][k]-sum[i][j]+1)
            {
                printf("%d %d\n",sum[i][j],sum[i][k]);return 0;
            }
        }
    }
    printf("%d %d\n",-1,-1);
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
unsigned long long a,b;
unsigned long long gcd(unsigned long long a,unsigned long long b)
{
    return b?gcd(b,a%b):a;
}
void solve()
{
    if (gcd(a,b)==b) cout<<-1;
    else if (gcd(a,b)==a) cout<<(b/a+1)*a;
    else cout<<(b/gcd(a,b)+1)*a;
    cout<<endl;
}
int main()
{
    while(cin>>a>>b)
        solve();
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    int A,B,C,X;
    while (cin >> A >> B >> C >> X) {
        int ans = 0;
        FOR(i,0,A+1) FOR(j,0,B+1) FOR(k,0,C+1)
            if (i*500 + j*100 + k*50 == X)
                ans++;
        cout << ans << endl;
    }
    return 0;
}


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

const int MaxN = 100000;
int n, K, a[MaxN + 5];

int gcd(int x, int y)
{
	if (y == 0) return x;
	return gcd(y, x % y);
}

int main()
{
	while (~scanf("%d%d", &n, &K)) {
		int G = 0, MaX = 0;
		for (int i = 1; i <= n; i++) scanf("%d", &a[i]), G = gcd(G, a[i]), MaX = max(MaX, a[i]);
		if (K % G == 0 && K <= MaX) printf("POSSIBLE\n"); else printf("IMPOSSIBLE\n");
	}
	return 0;	
}

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

int main(void){
   int N;
   cin>>N;
   string s=to_string(N);
   string ans="No";
   if(s[0]==s[1]&&s[1]==s[2]) ans="Yes";
   if(s[1]==s[2]&&s[2]==s[3]) ans="Yes";
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 ,-1};
signed main(){
    int N;
    string S,T;
    cin >> N >> S >> T;
    // N == 1　と, N == 2　の組み合わせ
    // Z          aa                 Zの後、Zは、*2で、　Zの後 aa は、2*1で、aa　の後、Zは、*1、   aaの後、aaは、左下と右上が同じことがあるので、
    // Z          bb                 Z　　　Z　　　　　  Z    bb           bb      Z          bb     bb   3通り
    int ans = 3;
    for(int i = 0; i < N; i++) {
        if(i == 0) {
            if(S[i] != T[i]){
                i++;
                ans = 6;
            }
            continue;
        }
        if(S[i] != T[i] && S[i-1] != T[i-1]) {
            ans*=3;
        }
        else if(S[i] == T[i] && S[i-1] != T[i-1]) {
            continue;
        }
        else {
            ans*=2;
        }
        if(S[i] != T[i]) {
            i++;
        }
        ans%=INF;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;

lint dp[55][2];
int n,P;
int ar[55];
int main(){
  cin>>n>>P;
  REP(i,n) cin>>ar[i];
  dp[0][0]=1;
  REP(i,n) REP(t,2){
    dp[i+1][(t+ar[i])%2]+=dp[i][t];
    dp[i+1][t]+=dp[i][t];
  }
  cout<<dp[n][P]<<endl;
  return 0;
}





Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<map>
#include<cstring>
#include<string>
using namespace std;
map<string,int>mp;
char s[15];
int main()
{
	int n;
	scanf("%d\n",&n);
	string tmp;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s);
		//scanf("\n");
		string tmp="";
		int ls=strlen(s);
		for(int i=0;i<ls;i++)
		{
			tmp+=s[i];
		}
		if(mp[tmp]==0)
		{
			mp[tmp]=1;
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
} 


Measured memory_bytes: 19376
n = gets.chomp.to_i
h = Hash.new(0)
n.times do
    h[gets.chomp] += 1
end
m = gets.chomp.to_i
m.times do
    h[gets.chomp] -= 1
end

v = h.max{|a,b|a[1] <=> b[1]}[1]

if v > 0 then
    puts v
else
    puts 0
end

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

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  ll A, V; cin >> A >> V;
  ll B, W; cin >> B >> W;
  ll T; cin >> T;

  if (W >= V) {cout << "NO" << endl; return 0;}
  
  if (abs(A - B) <= T * (V - W)) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 3580
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    while(cin>>n,n){
        vi v(7,0);
        rep(i,n){
            int gotiusa_is_a_god_especially_tiya;
            cin>>gotiusa_is_a_god_especially_tiya;
            if(gotiusa_is_a_god_especially_tiya>=60)gotiusa_is_a_god_especially_tiya=60;
            v[gotiusa_is_a_god_especially_tiya/10]++;
        }
        rep(i,7)cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int n,a,b,c,d,o,p,q;
    cin >> n ;
    
    a = n/1000;
    b = n/100%10;
    c = n/10%10;
    d = n%10;
    
    o = a-b;
    p = b-c;
    q = c-d;
    
    if (o == 0 && p == 0){
        cout<<"Yes"<<endl;
    }
    else if (p == 0 && q == 0){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }

  vector<int> c(n, 0);
  rep(i, m) {
    ++c[a[i]];
    ++c[b[i]];
  }
  rep(i, n) cout << c[i] << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void Yes(bool c) { if (c)print("Yes"); else print("No"); };
void YES(bool c) { if (c)print("YES"); else print("NO"); };

void solve() {
    int N;
    ll K;
    cin >> N >> K;
    vi A(N);
    rep(i,N){
        cin >> A[i];
    }


    // ll ans = 0;
    ll target,count=0,count_r=0;
    rep(i,N){
        // count = 0;
        // count_r = 0;
        target = A[i];
        rep(j,N){
            if(target > A[j]) {
                count++;
                if(i<j) count_r++;
            }
        }
        // ans = ans + count*(K*(K-1)/2) + count_r*K;
        // ans %= MOD;
    }
    ll sumK = K*(K-1)/2%MOD;
    ll ans = (count*sumK)%MOD + (count_r*K)%MOD;
    print(ans%MOD);
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main() {
  char s[10];
  gets(s);
  int a[10], i = 0, min = INT_MAX;
  while(s[i] != '\0') {
    a[i] = s[i] - '0';
    i++;
  }
  for (size_t j = 0; j < i-2; j++) {
    int b = a[j+2] + (a[j+1] * 10) + (a[j] * 100);
    b = abs(b - 753);
    min = (b < min) ? b : min;
  }
  printf("%d\n", min);
  return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000009

LL s[200000];

int main() {
	int n;
	scanf("%d", &n);
	s[0] = 0;
	REP(i, n) {
		LL tmp;
		scanf("%lld", &tmp);
		s[i + 1] = s[i] + tmp;
	}
	sort(s, s + n + 1);
	LL tmp = s[0];
	LL cnt = 0;
	LL ret = 0;
	REP(i, n + 1) {
		if (s[i] == tmp)cnt++;
		else {
			ret += (cnt*(cnt - 1)) / 2;
			cnt = 1;
			tmp = s[i];
		}
	}
	ret += (cnt*(cnt - 1)) / 2;
	cout << ret << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    set<string> ss;
    for(int i=0; i<n; i++){
        cin >> s[i];
        ss.insert(s[i]);
    }

    bool ok = ss.size() == s.size();
    for(int i=0; i<n-1 && ok; i++){
        if(s[i].back() != s[i+1][0]){
            ok = false;
        }
    }
    if(ok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
use proconio::input;

const M: u64 = 1000_000_007;

fn main() {
    input! { n: usize }

    let mut a = vec![0; n];
    for i in 0..n {
        for j in 0..n {
            input! { aij: usize };
            a[i] |= aij << j;
        }
    }

    let mut dp = vec![vec![None; 1 << n]; n + 1];
    println!("{}", calc(0, n, 0, &a, &mut dp));
}

fn calc(i: usize, n: usize, p: usize, a: &Vec<usize>, dp: &mut Vec<Vec<Option<u64>>>) -> u64 {
    if let Some(v) = dp[i][p] {
        v
    } else {
        let v = if i == n {
            1
        } else {
            let rest = a[i] & !p;
            let mut v = 0;
            for j in 0..n {
                if (rest >> j) & 1 == 1 {
                    v = (v + calc(i + 1, n, p | (1 << j), a, dp)) % M;
                }
            }
            v
        };
        dp[i][p] = Some(v);
        v
    }
}


Measured memory_bytes: 723060
#include <iostream>
#include <algorithm>
using namespace std;
int N, K, a[5009], s[5009]; bool dp[5009], dpr[5009][5009];
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> a[i];
	dpr[N][0] = true;
	for (int i = N - 1; i >= 0; i--) {
		for (int j = 0; j < K; j++) dpr[i][j] = dpr[i + 1][j];
		for (int j = a[i]; j < K; j++) {
			if (dpr[i + 1][j - a[i]]) dpr[i][j] = true;
		}
	}
	dp[0] = true;
	int ret = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < K; j++) s[j + 1] = s[j] + dp[j];
		bool ok = false;
		for (int j = 0; j < K; j++) {
			if (dpr[i + 1][j] && s[K - j] != s[max(K - j - a[i], 0)]) ok = true;
		}
		for (int j = K - 1; j >= a[i]; j--) {
			if (dp[j - a[i]]) dp[j] = true;
		}
		if(!ok) ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 24832
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
// #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;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define all(v)          v.begin(), v.end()

#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a, 0, sizeof(a))
#define SET(a)          memset(a, -1, sizeof(a))

// inline int setBit(int n, int pos) { return n = n | (1 << pos); }
// inline int resetBit(int n, int pos) { return n = n & ~(1 << pos); }
// inline bool checkBit(int n, int pos) { return (bool)(n & (1 << pos)); }

// int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
// int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1};

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// unsigned int num = rng();
// shuffle(V.begin(), V.end(), rng);

/******************************************************************************************/

// const int MAX = 500010;
// const int INF = 0x3f3f3f3f;
// const int MOD = 998244353;

// inline int add(int a, int b) { return a + b >= MOD ? a + b - MOD : a + b; }
// inline int sub(int a, int b) { return a - b < 0 ? a - b + MOD : a - b; }
// inline int mul(int a, int b) { return (a * 1LL * b) % MOD; }

map <string, int> M;

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

    // freopen("in", "r", stdin); 
    // freopen("out", "w", stdout);
    
    int n;
    string s;
    cin >> n;
    for(int i=1;i<=n;i++) {
        cin >> s;
        M[s]++;
    }
    cout << "AC x " << M["AC"] << endl;
    cout << "WA x " << M["WA"] << endl;
    cout << "TLE x " << M["TLE"] << endl;
    cout << "RE x " << M["RE"] << endl;

    
    return 0;
}


Measured memory_bytes: 3672
//I am so vegetable
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
	int r;cin>>r;
	cout<<2*pi*r;
	return 0;
}

Measured memory_bytes: 3800
#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++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 100005;
const ll MOD = 1000000007;

int n, k, q, a[MAXN];
/*********************GoodLuck***********************/
int main () {
    IOS();
    cin >> n >> k >> q;
    REP (i, q) {
        int x;
        cin >> x;
        a[x]++;
    }

    REP1 (i, n) {
        a[i] += k - q;
        cout << (a[i] > 0 ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define all(arr) arr.begin(),arr.end()
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#ifdef ONLINE_JUDGE
#define cerr if (false) cerr
#endif 
#define unique(a)       sort((a).begin(), a.end()), (a).erase(unique((a).begin(), (a).end()),(a).end())
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>void __f(const char* name, Arg1&& arg1){cout<<name<<" : "<<arg1<<"\n";}
template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" , ";__f(comma+1, args...);}
const int MOD = 1000000007;
using PII = pair<int, int>;
using LL = long long int;

template <typename T>
void input(vector<T> &arr,LL n) {
	T temp;
	for(LL i=0;i<n;i++) cin>>temp, arr.push_back(temp);
}

template <typename T>
void output(vector<T> arr) {
	T temp;
	for(auto x:arr) cout<<x<<" ";
	cout<<endl;
}


template <typename T>
void input_set(set<T> &arr,LL n) {
	T temp;
	for(LL i=0;i<n;i++) cin>>temp, arr.insert(temp);
}


LL power(LL num,LL base) {
	if(base==0)
		return 1;

	if(base%2)
		return (num%MOD*power(num,base-1)%MOD)%MOD;
	else {
		LL x=power(num,base/2);
		x=(x*x)%MOD;
		return x;
	}
}
const int M = 200000;
vector<int> a;
int main() {

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

	a.resize(M);
	int N;
	cin>>N;
	for (int i = 1; i <= N; i++) {
			cin>>a[i];
	}
	sort(a.begin()+1, a.begin()+1+N, greater<int>());
	LL ans = 0;
  for (int i = 2; i <= N; i++) {
			ans += a[(i+1)/2];
	}
	cout<<ans<<endl;
}

//things to remember:
//1. int array must be memsetted before use



Measured memory_bytes: 3988
N = int(input())
A = list(map(int,input().split()))
count = 0
for i in range(1,N-1):
  if (A[i+1] > A[i] and A[i] > A[i-1]) or (A[i+1] < A[i] and A[i] < A[i-1]):
    count += 1
print(count)                                                     
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a,&b);
#define loop(i,j) for(int i=0;i<j;i++)
typedef long long ll;
using namespace std;

int main()
{
  int N,K;
  scan2(N,K);
  vector<int> v(N);
  loop(i,N) scan1(v[i]);
  sort(v.begin(),v.end());
  int mi=INT_MAX;
  loop(i,N-K+1){
    mi=min(mi,abs(v[i]-v[i+K-1]));
  }
  printf("%d\n",mi);
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace  std;
int main()
{
    int n;
    cin>>n;
    long long a[n],i,j,b;
    long long  sum=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n-1;i++)
    {
        for(j=i+1;j<n;j++)
        {
            b=a[i]*a[j];
            sum+=b;
        }

    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
import sys
N = int(input())
BA = []
for _ in range(N):
    a, b = map(int, input().split())
    BA.append([b, a])
BA.sort()
time=0
for i in range(N):
    time+=BA[i][1]
    
    if time>BA[i][0]:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 105196
#include<bits/stdc++.h>
#define ll long long
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
#define dbg3(x) cerr<<#x<<"\n"
using namespace std;
#define reg register
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
ll N,K,num;ll p3(ll x){return x*x*x;}
int main()
{
	N=read();K=read();
	num=p3(N/K);
	if(K%2==0) num+=p3(N/K+((N%K)>=(K/2)));
	printf("%lld\n",num);
}

Measured memory_bytes: 256