akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define modd 998244353
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define ar array
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
lld n,m;
lld arr[300000];
lld brr[300000];
lld fin[300000];
lld getSum(lld BITree[], lld index)
{
    lld sum = 0;
    index = index + 1;
    while (index>0)
    {
        sum += BITree[index];
        index -= index & (-index);
    }
    return sum;
}
void updateBIT(lld BITree[], lld n, lld index, lld val)
{
    index = index + 1;
    while (index <= n){
    BITree[index] += val;
    index += index & (-index);
    }
}
int main()
{
     ios;
     lld TESTS,q,a,s,b,r,l,k,c,p,h,w,d,x,y,z,xs,ys,t;
     TESTS=1;
  // cin>>TESTS;
     while(TESTS--)
     {
         cin>>n>>k;
         rep(i,1,n)cin>>arr[i];
         brr[0]=0;
         rep(i,1,n){
            brr[i]=brr[i-1];
            brr[i]+=arr[i]-k;
         }
         sort(brr,brr+n+1);
         lld sum=0;
         lld ans=0;
         lld ind=lower_bound(brr,brr+n+1,sum)-brr;
         updateBIT(fin,n+1,ind,1);
         rep(i,1,n){
            sum+=arr[i]-k;
            ind=lower_bound(brr,brr+n+1,sum)-brr;
            ans+=getSum(fin,ind);
            updateBIT(fin,n+1,ind,1);
         }
         cout<<ans;
     }
    return 0;
}


Measured memory_bytes: 6016
#include<iostream>
#include<cstdio>
using namespace std;
long long c[101][101];
int main ()
{
	int i,j,k,l;
	scanf("%d%d",&l,&k);
	c[0][0]=1;
	for(i=1;i<=l;++i)
	{
		c[i][0]=1;
		for(j=1;j<=i;++j)
		  c[i][j]=c[i-1][j-1]+c[i-1][j];
	}
	long long ans=0;
	for(i=1;i<=l;i+=2)
	{
		int s=i/2+1;
		for(j=0;j<=s;++j)
		  if((k-1)*j+i<=l) {ans+=c[s][j];}
		  else break;
	}
	printf("%lld\n",ans);
} 


Measured memory_bytes: 3296
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) {
		int price;
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

		try {
			price =Integer.parseInt(reader.readLine());
			System.out.println((10000 - price) % 1000);
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}

	}
}


Measured memory_bytes: 32500
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef vector <int> vi;
int xina(int x,vi A){
	return (find(A.begin(),A.end(),x)==A.end())?0:1;
}
int f0070(vi A,int n,int s){
	if (s<0)return 0;
	if (n==1)return xina(s,A);
	sort(A.begin(),A.end());
	vi::iterator it1=A.begin()+n-1,it2=A.end()-n;
	int b1=0,b2=0,c=0,j=1,i,a=A.size();
	for (i=0;i<n;i++){
		b1+=j*(*it1--);
		b2+=j*(*it2++);
		j++;
	}
	vi A3(a-1);
	if (b1<=s&&s<=b2)
		for (i=0;i<a;i++){
			A3.clear();
			for (j=0;j<a;j++)
				if (j!=i)A3.push_back(A[j]);
			c+=f0070(A3,n-1,s-A[i]*n);
		}
	return c;
}
int main(){
	int n,s,i;
	while (1){
		cin>>n>>s;
		if (cin.eof())break;
		vi A(10);
		for (i=0;i<10;i++)A[i]=i;
		cout<<f0070(A,n,s)<<endl;
	}
}

Measured memory_bytes: 1212
n = int(input())
s = input()
ans = 0
for i in range(1, n):
  t = s[0:i]
  t2 = s[i:n]
  t = list(set(t))
  t2 = list(set(t2))
  cnt = 0
  for j in t:
    if j in t2:
      cnt += 1
  ans = max(ans, cnt)
print(ans)


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

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll K; cin >> K;
	int N = 50;
	vector<ll> a(N, 0LL);
	rep (i, N){
		a[i] = (ll)i;
	} // end rep
	ll t = K / (ll)N;
	rep (i, N){
		a[i] += t;
	} // end rep
	int m = K % N;
	rep (i, m){
		rep (j, N){
			if (i == j){
				a[j] += (ll)N;
			}else{
				--a[j];
			} // end if
		} // end rep
	} // end rep
	cout << N << endl;
	rep (i, N){
		cout << a[i] << (i !=  N - 1 ? ' ' : '\n');
	} // end rep 
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        double[] arr = new double[num];
        for (int i = 0;i < num;i++){
            arr[i] = in.nextDouble();
        }
        Arrays.sort(arr);
        for (int i = 0;i < num - 1;i++){
            arr[i+1] = (arr[i] + arr[i+1]) / 2;
        }
        
        System.out.println(arr[num - 1]);

        
    }
}


Measured memory_bytes: 23124
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
char a[60],b[60];
int z,x,i,n,m;
int main()
{
    gets(a);
    gets(b);
    z=strlen(a);
    x=strlen(b);
    n=min(z,x);
    m=max(z,x);
    for(i=0;i<=n-1;i++)
        printf("%c%c",a[i],b[i]);
    if(z>x)
        for(i=n;i<=m-1;i++)
            printf("%c",a[i]);
    else 
        for(i=n;i<=m-1;i++)
            printf("%c",b[i]);
    printf("\n");
	return 0;
 } 

Measured memory_bytes: 128
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, m = MAP()
print((n - 1) * (m - 1))


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

struct Node{
    int key;
    Node *right,*left,*parent;
};

Node *root,*NIL;

Node* treeMinimum(Node *x){
    while(x->left != NIL) x = x->left;
    return x;
}

Node* find(Node *u,int k){
    while(u != NIL && k != u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

Node* treeSuccessor(Node *x){
    if(x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while(y != NIL && x == y->right){
        x = y;
        y = y->parent;
    }
}

void treeDelete(Node *z){
    Node *y;
    Node *x;

    if(z->left == NIL || z->right == NIL) y = z;
    else y = treeSuccessor(z);

    if(y->left != NIL){
        x = y->left;
    } else {
        x = y->right;
    }

    if(x != NIL) x->parent = y->parent;

    if(y->parent == NIL){
        root = x;
    } else {
        if(y == y->parent->left){
            y->parent->left = x;
        } else {
            y->parent->right = x;
        }
    }
    if(y != z){
        z->key = y->key;
    }

    free(y);
}

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node*)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x!=NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;
    if(y==NIL){
        root = z;
    } else {
        if(z->key < y->key){
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n,i,x;
    string com;
    scanf("%d",&n);

    for(i=0;i<n;i++){
        cin >> com;
        if(com=="find"){
            scanf("%d",&x);
            Node *t = find(root,x);
            if(t!=NIL) printf("yes\n");
            else printf("no\n");
        } else if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        } else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if(com == "delete"){
            scanf("%d",&x);
            treeDelete(find(root,x));
        }
    }

    return 0;
}



Measured memory_bytes: 21928
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    string str = "CODEFESTIVAL2016";
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0;i < s.length();i++){
        if(s[i] != str[i]){
            cnt++;
        }
    }
    cout << cnt << endl;




    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(auto i=0;i<n;i++)
#define s(c) static_cast<int>((c).size())

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

	set<int> A[n+1];
	int v1, v2, deg;
	r(i, n){
		cin >> v1 >> deg;

		r(j, deg){
			cin >> v2;
			A[v1].insert(v2);
		}
	}

	queue<int> s;
	s.push(1);
	int dist[n+1]{0, 1};

	while(!s.empty()){
		int v1 = s.front(); s.pop();
		for(int v2 : A[v1]){
			if(!dist[v2]){
				s.push(v2);
				dist[v2] = dist[v1]+1;
			}
		}
	}

	for(int i = 1; i <= n; i++)
		printf("%d %d\n", i, dist[i]-1);

	return 0;
}



Measured memory_bytes: 3160
def primes(N):
    is_prime = {i: True for i in range(2, N+1)}
    for i in range(2, N+1):
        if is_prime[i]:
            if i**2 <= N:
                for j in range(i**2, N+1, i):
                    is_prime[j] = False
    return is_prime


def main():
    is_prime = primes(10**5)
    cumsum = [0] * (10**5)
    for i in range(3, 10**5):
        cumsum[i] = cumsum[i-1]
        if is_prime[i] and is_prime[(i+1)//2]:
            cumsum[i] += 1
    Q = int(input())
    for _ in range(Q):
        l, r = map(int, input().split())
        print(cumsum[r] - cumsum[l-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 56804
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

long long N;
int main(){
  int A[1000001],x=0;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>A[i];
  }

sort(A,A+N);
for(int i=0;i<N;i++){
  if(A[i]==A[i+1]){
    x=x+1;
  }
}
  if(x==0){
    cout<<"YES";
  }else{
    cout<<"NO";
  }
 return 0;
}


Measured memory_bytes: 2816
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define mod_mul(x, y) x*y%MOD
#define mod_add(x, y) (x+y)%MOD
#define mod_sub(x, y) (x-y)%MOD
#define INF_INT 2147483647

long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}


long nCr(long n, long r){
    if(n==r || r==0){
        return 1;
    } else {
        return mod_add(nCr(n-1,r),nCr(n-1,r-1));
    }
}



int main(){
    
    long long N; cin >> N;
    std::vector<long long> A;
    std::vector<long long> A_aux;
    for(long long i=1;i<N+1;i++){
        long long temp; cin >> temp;
        A.push_back(temp);
        A_aux.push_back(temp-i);
    }


    sort(A_aux.begin(),A_aux.end());
    long long median = A_aux[N/2];
    long long ans = 0;

    for(long long i=0;i<N;i++){
        ans = ans + abs(A[i]-(median+i+1));
    }  

    cout << ans << endl;

    
    return 0;

}


Measured memory_bytes: 3564
n,m = map(int,input().split())
h = list(map(int,input().split()))
count = 0
dic = {}
for i in range(m):
    a,b = map(int,input().split())
    if a not in dic:
        dic[a] = b
    else:
        if h[b-1]>h[dic[a]-1]:
            dic[a] = b
    if b not in dic:
        dic[b] = a
    else:
        if h[a-1]>h[dic[b]-1]:
            dic[b] = a
for key in dic:
    if h[key-1]>h[dic[key]-1] :
        count+=1
if len(dic)<n:
    print(count+n-len(dic))
else:
    print(count)    

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

using namespace std;

#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define LL long long
#define ULL unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<LL,int>
#define PLL pair<LL,LL>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<LL,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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




const int N=1e5+5;
vector<int>adj[N];
bool visited[N];

void DFS(int cur,int par)
{
    if(visited[cur])return;
    visited[cur]=1;
    for(int x : adj[cur])
    {
        if(x ^ par)DFS(x,cur);
    }
}

int main()
{
    FAST();
    int i,m,n,x,y,ans=0;
    cin >> n >> m;
    while(m--)
    {
        cin >> x >> y;
        adj[x].emplace_back(y);
        adj[y].emplace_back(x);
    }
    for(i=1;i<=n;i++)
    {
        if(!visited[i])
        {
            ++ans;
            DFS(i,i);
        }
    }
    cout << ans-1;
    return 0;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    string cell[H], result[H][W];
    for(int i = 0; i < H; i++) {
        cin >> cell[i];
    }
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(cell[i].at(j) == '#') {
                result[i][j] = "#";
                continue;
            }
            int hs = max(i - 1, 0);
            int he = min(i + 1, H - 1);
            int ws = max(j - 1, 0);
            int we = min(j + 1, W - 1);
            int count = 0;
            for(int k = hs; k <= he; k++) {
                for(int m = ws; m <= we; m++) {
                    if(cell[k].at(m) == '#') {
                        count++;
                    }
                }
            }
            result[i][j] = to_string(count);
        }
    }
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cout << result[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define MIN(X,Y) ((X)<(Y)?(X):(Y))
#define INF 1001001001

using namespace std;

int main(void){
  int n,m,x,ans=INF;
  int c[15], a[15][15];
  
  cin >> n >> m >> x;
  for (int i=0; i<n; i++){
    int t; cin >> t;
    c[i] = t;
    for (int j=0; j<m; j++){
      cin >> t;
      a[i][j] = t;
    }
  }
  
  for (unsigned int b=0; b<1<<n; b++){
    int flg=1, cost=0;
    int skl[15] = {0};
    for (int i=0; i<n; i++){
      if (((1<<i) & b) == 0) continue; 
//      cout << i ;
      cost += c[i];
      for (int j=0; j<m; j++){
        skl[j] += a[i][j];
      }
    }
    for (int i=0; i<m; i++){
      if (skl[i]<x) flg=0;
    }
//    cout << b << " " << flg << " " << cost << endl;
    if (flg) ans = MIN(ans, cost);
  }
  cout << (ans==INF?-1:ans) << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,L;cin>>N>>L;
  vector<string> a(N);
  for(int i=0;i<N;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  for(int i=0;i<N;i++)cout<<a.at(i);
  cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

int main(){
  ll n, m;
  cin >> n >> m;
  ll ans = 0;

  ll p = min(n, m / 2);
  ans = p + (m - 2 * p) / 4;

  cout << ans << endl;
}


Measured memory_bytes: 256
import Data.List
main=do
 [x,y,z,k]<-map read.words<$>getLine
 xn<-map read.words<$>getLine
 yn<-map read.words<$>getLine
 zn<-map read.words<$>getLine
 mapM_ print$let xy = take k (sortBy (flip compare) [x+y|x<-xn,y<-yn]) in take k (sortBy (flip compare) [s+z|s<-xy,z<-zn])

Measured memory_bytes: 421244
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;
static const ll max_n = 16;
static const ll max_v = 1LL<<62LL;
vector<ll> xs(max_n);
vector<ll> ys(max_n);
vector<ll> ps(max_n);
vector<vector<ll>> tate_s((1<<max_n), vector<ll>(max_n, max_v));
vector<vector<ll>> yoko_s((1<<max_n), vector<ll>(max_n, max_v));
ll N;




void Main(){
    sll(N);
    rep(i, N){
        sll(xs[i]);
        sll(ys[i]);
        sll(ps[i]);
    }

    // x
    for(ll bit=0;bit<(1<<N);++bit){
        for(ll i=0;i<N;i++){
            tate_s[bit][i] = abs(xs[i]);
            yoko_s[bit][i] = abs(ys[i]);
            rep(k, N){
                if((1<<k) & bit){
                    tate_s[bit][i] = min(tate_s[bit][i], abs(xs[i]-xs[k]));
                    yoko_s[bit][i] = min(yoko_s[bit][i], abs(ys[i]-ys[k]));
                }
            }
        }
    }

    vector<ll> ans(N+1, max_v);
    for(ll bit=0;bit<(1<<N);++bit){
        ll cnt = 0;
        for(ll i=0;i<N;i++){
            if((bit>>i)&1) ++cnt;
        }

        for(ll j=bit;j>=0;--j){
            j &= bit;
            ll v = 0;
            rep(k, N){
                if(!((bit>>k) & 1)){
                    v += min(tate_s[j][k], yoko_s[bit-j][k]) * ps[k];
                }
            }
            ans[cnt] = min(ans[cnt], v);
        }
    }

    rep(i, N+1){
        cout << ans[i] <<endl;
    }


}

int main(){
    Main();
    // string S = "ksdfjl";
    // char v = S[3];
    // S[3] = 'a';
    // cout << S <<endl;
}

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

int main(){
    int N;
    cin>>N;
    int* P=new int[N];
    for(int i=0;i<N;i++){
        cin>>P[i];
    }

    int min=1001001001;
    int count=0;
    for(int i=0;i<N;i++){
        if(P[i]<=min){
            min=P[i];
            count++;
        }
    }

    cout<<count;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define inf 0x7f7f7f7f7f7f7f7f 
#define maxn 1000010
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define mod 998244353
#define db(x) cout << x << endl; 
#define eps 0.0001
using namespace std;
int h[maxn],v[maxn];
int s[maxn]; 
int cal(int x)
{
	return x*x*x*x*x;
}
signed main()
{
	ios::sync_with_stdio(0);
	int x;
	cin >> x;
	for(int i=-120;i<=120;i++)
		for(int j=-120;j<i;j++)
		{
			if(cal(i) - cal(j) ==x)
			{
				cout << i << " " << j;
				return 0;
			}
		}
		//cout << cal(100)-cal(99) << endl << 1000000000;
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define fup(i,a,b) for(int i=a; i<=b; ++i)

int cti(char ch) {
	return ch-'a'+1;
}

int row, col, cnt[33];
char grid[123][123];

void deal()
{
	int need = (row/2)*(col/2);
	need *= 4;
	fup(x,1,26)
	{
		if(need==0) break;
		while(cnt[x]>=4)
		{
			cnt[x] -= 4;
			need -= 4;
		}
	}
	if(need>=1)
	{
		printf("No\n");
		return;
	}
	int odd = 0;
	fup(x,1,26) if(cnt[x]&1)
	{
		odd++;
	}
	if(row&1 && col&1)
	{
		if(odd==1)
		printf("Yes\n");
		else
		printf("No\n");
		return;
	}
	else
	{
		if(odd!=0)
		printf("No\n");
		else
		printf("Yes\n");
	}
}

int main()
{
	scanf("%d %d", &row, &col);
	memset(cnt,0,sizeof cnt);
	fup(r,1,row)
	{
		fup(c,1,col)
		{
			scanf(" %c", &grid[r][c]);
			cnt[cti(grid[r][c])]++;
		}
	}
	deal();
	return 0;
}

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

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void) {
  int key, n, i;
  int size = 0;
  int np = 0, nd = 0;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') {
      insert(key);
      np++;
      size++;
    } else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L')
          deleteLast();
      } else {
        deleteKey(key);
        nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}


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

typedef long long ll;

int main(){
	int n;
	while(cin>>n,n){
		ll m[50]={0};
		ll gather[30]={0};
		int ans=-1;
		for(int i=0;i<n;i++){
			m[i] = 1LL<<i;
			int k,d;
			cin>>k;
			for(int j=0;j<k;j++){
				cin>>d;
				gather[d-1] |= 1LL<<i; 
			}
		}
		for(int i=0;i<30;i++){
			ll s=0;
			for(int j=0;j<n;j++){
				if(gather[i]>>j&1)s |= m[j];
			}
			if(s==(1LL<<n)-1){
				ans=i+1;
				break;
			}
			for(int j=0;j<n;j++){
				if(gather[i]>>j&1)m[j] |= s;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <fstream>

int main(){

    int data_set_num;
    std::string str;
    std::string from = "Hoshino";
    std::string to = "Hoshina";
    std::getline(std::cin,str);
    sscanf(str.c_str(),"%d ",&data_set_num);

    while(data_set_num--){
        std::getline(std::cin,str);
        std::string::size_type pos = str.find(from);
        while(pos != std::string::npos){
            str.replace(pos, from.size(), to);
            pos = str.find(from, pos + to.size());
        }
        std::cout << str << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3212
N = int(input())
if N == 3:
    print(2,5,63)
    exit()
if N == 4:
    print(2,5,20,63)
    exit()
if N == 6:
    print(2,4,6,3,9,24)
    exit()
if N == 19999:
    for i in range(1,30000):
        if i%2 == 0 or i % 3 == 0:
            print(i,end=" ")
    exit()
for a in range(3,15001,3):
    b = N-a
    if 1 < b <= 5000 and b%2 == 0:
        break
for i in range(a):
    print(2*i+2,end=" ")

for i in range(b):
    print(6*i+3,end=" ")


Measured memory_bytes: 3424
#include<stdio.h>


void print(int A[], int N)
{
	int i;
	printf("%d", A[0]);
	for (i = 1; i < N; i++)
	{
		printf(" %d", A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N)
{
	int i, j, key;

	for (i = 1; i < N; i++)
	{
		key = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > key)
		{
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = key;
		print(A,N);
	}
}

int main()
{
	int  N, i;
	int A[100];

	scanf("%d", &N);

	for (i = 0; i < N; i++)
		scanf("%d", &A[i]);

	print(A, N);
	insertionSort(A, N);

	return 0;
}


Measured memory_bytes: 2688
#include<cstdio>
int a[100000];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int t=0;
	int s=1;
	while(s!=2){
		s=a[s-1];
		t++;
		if(s==1){
			printf("%d\n",-1);
		break;
		}
		if(t>=100000){
			printf("%d\n",-1);
		break;
		}
	}
	if(s==2){
		printf("%d\n",t);
	}
	return 0;
}

Measured memory_bytes: 512
n,q=map(int,input().split())
a=list(map(int,input().split()))
size=2*n+1
bit=[0]*size
def bit_update(x,v):
    while x<size:
        bit[x]+=v
        x+=(x&-x)
def bit_sum(n):
    s=0
    if n==0:return 0
    x=n
    while x>0:
        s+=bit[x]
        x-=(x&-x)
    return s
for i,j in enumerate(a,1):
    bit_update(i,j)
for i in range(q):
    a,b,c=map(int,input().split())
    if a==0:
        bit_update(b+1,c)
    else:
        print(bit_sum(c)-bit_sum(b))

Measured memory_bytes: 65072
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <climits>
#include <set>

//#define int long long
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)

#define MOD 1000000007

using namespace std;



signed main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int A, B, C;
    cin >> A >> B >> C;
    if (A <= C && C <= B) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int dp[200005][3];

int main() {
    string s; cin >> s;
    int n = s.size();
    for (int i = 1; i <= n; i++) {
        chmax(dp[i][1],dp[i-1][2]+1);
        if (i-2 >= 0 && s[i-1] != s[i-2]) chmax(dp[i][1],dp[i-1][1]+1);
        if (i-2 >= 0) chmax(dp[i][2],dp[i-2][1]+1);
        if (i-3 >= 0 && s.substr(i-1,2) != s.substr(i-3,2)) {
            chmax(dp[i][2],dp[i-2][2]+1);
        }
    }
    int ans = max(dp[n][1],dp[n][2]);
    cout << ans << endl;
}

Measured memory_bytes: 6076
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,M;
    int minx=1,maxx=INF;
    int u[114514],v[114514],s[114514];
    vector<pair<int,int>> G[114514];
    cin >> N >> M;
    REP(i,M){
        cin >> u[i] >> v[i] >> s[i];
        u[i]--;v[i]--;
        G[u[i]].push_back({v[i],s[i]});
        G[v[i]].push_back({u[i],s[i]});
    }
    
    int al[114514]={};
    pair<int,int> axpb[114514]={};
    
    queue<int> Q;
    Q.push(0);
    axpb[0]={1,0};
    
    while(!Q.empty()){
        int T=Q.front();
        Q.pop();
        al[T]=1;
        
        int a=axpb[T].first;
        int b=axpb[T].second;
        for(int i=0;i<(G[T].size());i++){
            int des=G[T][i].first;
            int cost=G[T][i].second;
            if(al[des]==0){
                Q.push(des);
                axpb[des]={-a,cost-b};
            }else{
                int p=axpb[des].first;
                int q=axpb[des].second;
                if(-a==p){
                    if(!(-a==p && cost-b==q)){
                        //矛盾
                        cout << 0 << endl;
                        return 0;
                    }
                }else{
                    if((cost-b-q)%(a+p)!=0){
                        //矛盾
                        cout << 0 << endl;
                        return 0;
                    }else{
                        int x=(cost-b-q)/(a+p);
                        maxx=min(maxx,x);
                        minx=max(minx,x);
                    }
                }
            }
        }
    }
    
    REP(i,N){
        if(axpb[i].first==-1){
            maxx=min(maxx,axpb[i].second-1);
        }else{
            minx=max(minx,-axpb[i].second+1);
        }
    }
    //REP(i,N){cout << axpb[i].first << " ";}cout << endl;
    //REP(i,N){cout << axpb[i].second << " ";}cout << endl;
    
    cout << max(0LL,maxx-minx+1) << endl;
    return 0;
}



Measured memory_bytes: 16256
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string s;
	int c=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C')c=1;
		if(c&&s[i]=='F')
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

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

	int ans = 0;
	rep(i, 0, 2) {
		if (a > b) {
			ans += a;
			a--;
		}
		else {
			ans += b;
			b--;
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;

signed main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int c = 0;
    for(auto& x : a){
        cin >> x;
        if(x % 2 == 0)
            ++c;
    }
    cout << c << endl;
}



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

int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    int result = 1;
    int count = K;
    for (int i=max(A, B); i>1; i--)
    {
        if (A%i==0 && B%i==0)
        {
            count -= 1;
            if (count==0)
            {
                result = i;
                break;
            }
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	
	scanf("%d",&a);
	scanf("%d",&b);
	
	if ((a + b) >= (a - b) && (a + b) >= (a * b)){
		printf("%d",a+b);
	}
	
	else if ((a - b) >= (a + b) && (a - b) >= (a * b)){
		printf("%d",a-b);
	}
	
	else if ((a * b) >= (a + b) && (a * b) >= (a - b)){
		printf("%d",a*b);
	}
	
	return (0);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
      int w,h,n,fx,fy,tx,ty,solve=0,i=1;
      cin>>w>>h>>n>>tx>>ty;
      for(;i<n;i++){
            fx=tx,fy=ty;
            cin>>tx>>ty;
            solve+=((tx-fx)*(ty-fy)>0)?max(abs(tx-fx),abs(ty-fy)):(abs(tx-fx)+abs(ty-fy));
      }
      cout<<solve<<endl;
}

Measured memory_bytes: 1160
#include <stdio.h>

int a[101] = {0}, s;

int main() {
    int n, k, d, t;
    scanf("%d %d", &n, &k);
    for (int i = 0; i < k; i++) {
        scanf("%d", &d);
        for (int j = 0; j < d; j++) {
            scanf("%d", &t);
            a[t] = 1;
        }
    }
    for (int i = 1; i <= n; i++)
        if (!a[i]) s++;
    printf("%d", s);
    return 0;
}

Measured memory_bytes: 1732
// {{{ Headers
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <cassert>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <deque>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#include <fstream>
#include <iostream>
#include <sstream>

using namespace std;
// }}}

typedef long long int64;
const int INF = 0x3f3f3f3f;
template <class T> inline int len (const T &a) { return a.size (); }
#define ALL(x) (x).begin(), (x).end()

const int MX = 100 * 1000 + 5;
int a [MX][3], dp [MX][3];

int
main () {
    int N;
    scanf ("%d", &N);
    for (int i = 0; i < N; i++)
        for (int j = 0; j < 3; j++)
            scanf ("%d", &a [i][j]);

    for (int i = 0; i < N; i++)
        for (int j = 0; j < 3; j++)
            for (int k = 0; k < 3; k++)
                if (j != k)
                    dp [i][j] = max (dp [i][j], a [i][j] + (i > 0 ? dp [i - 1][k] : 0));

    int ret = max ({ dp [N - 1][0], dp [N - 1][1], dp [N - 1][2] });
    printf ("%d\n", ret);

#ifdef LOCALHOST
	cerr << "time: " << (int64) clock () * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
    return 0;
}



Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

/*bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) { // 素数ではない
			return false;
		}
	}
	// 素数である
	return true;
}*/
/*ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/
/*ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}*/
/*ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}
ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}*/
//printf("%.10f\n", n);

ll a[200];
signed main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	
	string s; cin >> s; ll n; n = s.size();
	rep(i, n) { a[(ll)(s[i])]++; }

	if (s == "zyxwvutsrqponmlkjihgfedcba") { cout << -1 << endl; return 0; }
	if (n == 26) {
		ll cnt = 0;
		for (int i = n - 1; i > 0; i--) {
			if ((ll)(s[i - 1]) < (ll)(s[i])) { cnt = i - 1; break; }
		}
		string t;
		rep(i, cnt) { t += s[i]; }
		ll ans = 0;
		for (int i = cnt + 1; i < n; i++) {
			if ((ll)(s[cnt]) < (ll)(s[i])) { ans = (ll)(s[i]); }
		}
		t += (char)(ans); cout << t << endl;
	}
	else {
		for (int i = 97; i <= 122; i++) {
			if (a[i] == 0) {
				s += (char)(i); cout << s << endl; break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3652
#include <string>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
#include <math.h>

int main()
{
	int N;
	cin >> N;
	int ans = 1;

	while (ans * 2 <= N)
	{
		ans *= 2;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
function Main(input) {
  "use strict"
  const temp = input.split("\n");

  const n = parseInt(temp.shift());
  const positions = temp.shift().split(" ").map(x => parseInt(x));
  
  let minVariance = Infinity
  for(let i = 1; i <= 100; i++){
    const variance = positions.map(x => (x - i) * (x - i)).reduce((a, b) => a + b)
    minVariance = Math.min(minVariance, variance)
  }

  console.log(minVariance)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7672
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ans = "AC";
    if (s.charAt(0) != 'A') ans = "WA";
    int c_count = 0;
    for (int i = 1; i < s.length(); i++) {
      if (Character.isUpperCase(s.charAt(i))) { // 大文字なら
        if (i == 1 || i == s.length() - 1) {
          ans = "WA";
        } else if (s.charAt(i) != 'C') {
          ans = "WA";
        } else if (s.charAt(i) == 'C') {
          c_count++;
        }
      }
    }
    if (c_count != 1) ans = "WA";
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
long long n;
int main()
{
	cin>>n;
	if(n&1)
	{
		cout<<0<<endl;
		return 0;
	}
	n>>=1;
	long long ans=0;
	while(n)
	{
		ans+=n/5;
		n/=5;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    ll D;
    cin >> D;
    vl c(26);
    rep(i,26){
        cin >> c[i];
    }
    ll s[D][26];
    rep(i,D){
        rep(j,26){
            cin >> s[i][j];
        }
    }
    vl latest_t(26,0);
    ll k=0;
    vl answer(D);
    FOR(i,1,D+1){
        vl nt=latest_t;
        ll nk=k;
        ll MX=-INF;
        ll ans;
        rep(j,26){
            nk=k;
            nk+=s[-1+i][j];
            nt[j]=i;
            rep(l,26){
                nk-=c[l]*(i-latest_t[l]);
            }
            if(nk>MX){
                nk=MX;
                ans=j;
            }
            if(j==25){
                k=MX;
            }
        }
        answer[i-1]=ans+1;
        latest_t[ans]=i;
    }
    //rep(i,D){
       //cout << answer[i] << endl;
   // }
    rep(i,pow(10,7)){
        int x=rand();
        x%=D-1;
        vl n_answer=answer;
        swap(n_answer[x],n_answer[x+1]);
        if(s[x][n_answer[x]]+s[x+1][n_answer[x+1]]>s[x][answer[x]]+s[x+1][answer[x+1]]){
            answer=n_answer;
        }
    }
    rep(i,D){
        cout << answer[i] << endl;
    }
}

Measured memory_bytes: 3696
#include <iostream>

int main(){
	
	int a[5];
	int s[5];
	for(int r=0;r<5;r++){
		s[r]=-100000;
	}
	for(int b=0;b<5;b++){
		std::cin>>a[b];
		if(a[b]>s[0]){
			s[4]=s[3];
			s[3]=s[2];
			s[2]=s[1];
			s[1]=s[0];
			s[0]=a[b];
		}else if(a[b]>s[1]){
			s[4]=s[3];
			s[3]=s[2];
			s[2]=s[1];
			s[1]=a[b];
		}else if(a[b]>s[2]){
			s[4]=s[3];
			s[3]=s[2];
			s[2]=a[b];
		}else if(a[b]>s[3]){
			s[4]=s[3];
			s[3]=a[b];
		}else{
			s[4]=a[b];
		}
	}
	for(int q=0;q<5;q++){
		std::cout<<s[q];
		if(q!=4){
			std::cout<<" ";
		}
	}
	std::cout<<std::endl;
	return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int n, m;
    cin >> n >> m;
    vector<ll> acc(n + 1);
    acc.eb(0);
    rep(i, n) { cin >> acc[i + 1]; acc[i + 1] = (acc[i + 1] + acc[i]) % m; }
    // outa(acc, n + 1);
    
    map<ll, int> mp;
    
    ll ans = 0;
    rep(i, n + 1) {
        ans += mp[acc[i]];
        mp[acc[i]]++;
    }
    out(ans);
}






Measured memory_bytes: 4976
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int n;
	cin >> n;
	double licznik = 0;
	for(int i = 0;i < n; i++){
		if(i % 2 == 0){
			licznik++;
		}
	}
	
	double wynik = licznik / n;
	cout << setprecision(10) << fixed << wynik << endl;
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}


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

int main() {

    ll a, b, c;
    cin >> a >> b >> c;

    string ans = "No";

    if ( ((c-a-b) > 0) && ((c-a-b) * (c-a-b) > 4* a* b)) {
        ans = "Yes";
    }

    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>

using namespace std;

typedef long long ll;

#ifdef ONPC
    mt19937 rnd(228);
#else
    mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    ll have = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        have += a[i];
    }
    vector <int> b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    ll sum = 0;
    vector <int> can;
    for (int i = 0; i < n; i++)
    {
        sum += b[i];
        if (b[i] <= a[i])
        {
            can.push_back(a[i] - b[i]);
        }
    }
    if (sum > have)
    {
        cout << -1 << '\n';
        return 0;
    }
    sort(can.begin(), can.end());
    int ans = n;
    for (int x : can)
    {
        if (sum + x <= have)
        {
            sum += x;
            ans--;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1660
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A,B,N=MI()
    y = (N+1)//B
    x = y*B-1
    # print(x)
    x = min(x,N)    

    def f(x):
        # print((A*x)//B, A*(x//B))
        return (A*x)//B - A*(x//B)
    # print(x,y)#####
    x=max(0,x)
    print(max(f(x),f(N),f(N-1)))
if __name__ == '__main__':
    main()

Measured memory_bytes: 77908