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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m;

	(n-m>=0)?cout<<n-m<<endl:cout<<0<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;


int main() {
    
    int n;
    cin >> n;
    map<int, int> a;
    
    for (int i = 0; i < n; ++i)
    {
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }
    
    int ret = 0;
    for (auto itr = a.begin(); itr != a.end(); ++itr)
    {
        if (itr->first > itr->second)
        {
            ret += itr->second;
        }
        else if (itr->first < itr->second)
        {
            ret += (itr->second - itr->first);
        }
    }
    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define MAXN 201
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a > 9 || a < 1 || b > 9 || b < 1) cout << "-1\n";
  else cout << a * b << "\n";
}

Measured memory_bytes: 256
from collections import Counter

import numpy as np

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

mods = np.arange(1, N + 1) % K
counter = Counter(mods)

ans = 0
for a in counter.keys():
    if (a + a) % K == 0:
        ans += counter[a] ** 3

print(ans)


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

int GCD(int ,int);

int main(void){
	
	long long int N,M,G,i,n,m;
	char *S,*T;
  
	scanf("%lld %lld",&N,&M);
	S = (char *)malloc((N+1)*sizeof(char));
	T = (char *)malloc((M+1)*sizeof(char));
	scanf("%s",S);
	scanf("%s",T);

	G = GCD(N,M);
  	n = N/G;
  	m = M/G;

	for(i=0;i<G;i++){
    	if(S[i*n] != T[i*m]){
 			printf("-1\n");       	
			free(S);
			free(T);
			return 0;
        }
    }
  
	printf("%lld\n",(long long int)(N/G*M));

	free(S);
	free(T);
	return 0;
}


int GCD(int a,int b){
	
	int tmp,r;
	
	if(a<b){
		tmp = a;
		a = b;
		b = tmp;
	}
	
	r = a % b;
	
	while(r != 0){
		a = b;
		b = r;
		r = a % b;
	}
  	return b;

}


Measured memory_bytes: 352
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int N; cin >> N;
  if (N%1000 == 0) cout << 0 << endl;
  else cout << 1000 - (N % 1000) << endl;
}


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

using namespace std;

int main()
{
    int n;
    int a[100005];
    while(cin>>n){
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        int ans=0,k=0;
        for(int i=1;i<=n;i++){
            ans+=abs(a[i]-k);
            k=a[i];
        }
        ans+=abs(k);
        //cout<<ans<<endl;
        int sum=ans;
        for(int i=1;i<=n;i++){
            if(i==1){
                cout<<sum-abs(a[i])-abs(a[2]-a[1])+abs(a[2])<<endl;
            }
            else if(i==n){
                cout<<sum-abs(a[i-1]-a[i])-abs(a[i])+abs(a[i-1])<<endl;
            }
            else {
                cout<<sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1])<<endl;
            }
        }
    }
    return 0;
}


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

int main()
{
int A,B;
  cin >> A >> B;
  int i;
i=B-A;
  int c=0;
  while(i>=0)
  {
   if((A/10000 == A % 10) && (A/1000 %10 == A % 100 /10))
    c = c+1;
   
   i--;
   A ++;
   }
  cout << c ;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

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

    ll fh = m / 500;
    ll r = m % 500;

    ll f = r / 5;
    cout << fh * 1000 + f * 5 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
vector<int>G[1<<17];
int n,m;
bool used[1<<17];
bool ans;
void dfs(int u,int p)
{
    used[u]=1;
    if(G[u].size()>2)
    {
        ans=false;
        return;
    }
    for(int i=0;i<G[u].size();i++)
    {
        if(p==G[u][i])continue;
        else if(used[G[u][i]])
        {
            ans=false;
            break;
        }
        else dfs(G[u][i],u);
    }
}
main()
{
    while(cin>>n>>m,n)
    {
        for(int i=0;i<n;i++)G[i].clear(),used[i]=0;
        for(int i=0;i<m;i++)
        {
            int a,b;cin>>a>>b;a--,b--;
            G[a].push_back(b);
            G[b].push_back(a);
        }
        ans=true;
        for(int i=0;i<n;i++)
        {
            if(!used[i])dfs(i,-1);
        }
        cout<<(ans?"yes":"no")<<endl;
    }
}


Measured memory_bytes: 9576
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//
void solve(long long N, std::vector<long long> H){
    ll m=0;
    ll cnt=0;
    ll now=H[0];
    repf(i,1,N){
        if(H[i]<=now){
            now=H[i];
            cnt++;
        }
        else{
            now=H[i];
            m=max(m,cnt);
            cnt=0;
        }
    }m=max(m,cnt);
    op(m)
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, std::move(H));
    return 0;
}


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

typedef pair<int,int> P;
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

int main(){
	int H,W;
	cin >> H >> W;
	vector<string> map(H);
	rep(i,H) cin >> map[i];

	queue<P> que;
	vector<vector<int>> d(H,vector<int>(W,-1));
	d[0][0] = 0;
	que.push(P(0,0));
	while(!que.empty()){
		P p = que.front(); que.pop();
		int x = p.first; int y = p.second;
		if(x==W-1 && y==H-1) break;
		rep(i,4){
			int nx = x + dx[i];
			int ny = y + dy[i];
			if(nx>=0 && nx<W && ny>=0 && ny<H && map[ny][nx]=='.' && d[ny][nx]==-1){
				que.push(P(nx,ny));
				d[ny][nx] = d[y][x] + 1;
			}
		}
	}

	int cnt=0;
	rep(i,H){ cnt += count(map[i].begin(), map[i].end(), '.'); }

	if(d[H-1][W-1]==-1){ cout << -1 << endl; }
	else { cout << cnt-d[H-1][W-1] -1  << endl; }

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

h,w,k=map(int, input().split())
x1,y1,x2,y2=map(int, input().split())
x1-=1;y1-=1;x2-=1;y2-=1
c=[input() for _ in range(h)]
INF=10**14
dp=[[INF for _ in range(w)] for _ in range(h)]
dp[x1][y1]=0
from collections import deque
q=deque()

q.append((x1,y1))
dxy=[(1,0),(0,1),(-1,0),(0,-1)]

while q:
    x,y=q.popleft()
    for dx,dy in dxy:
        for j in range(1,k+1):
            if not 0<=x+dx*j<h:break
            if not 0<=y+dy*j<w:break
            if c[x+dx*j][y+dy*j]=='@':break
            if dp[x+dx*j][y+dy*j]>dp[x][y]+1:
                dp[x+dx*j][y+dy*j]=dp[x][y]+1
                q.append((x+dx*j,y+dy*j))
            elif dp[x+dx*j][y+dy*j]==dp[x][y]+1:continue###
            elif dp[x+dx*j][y+dy*j]<=dp[x][y]:break###
    
            
            if x+dx*j==x2 and y+dy*j==y2:
                print(dp[x2][y2])
                exit()

        
print(-1)

Measured memory_bytes: 149608
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int> 



int main(){
    long int a, b, n;
    cin >> a >> b >> n;
    long int ans;
    if(n >= b){
        ans = ((a * (b - 1)) / b) - (a * ((b - 1) / b));
    }else{
        ans = ((a * n) / b) - (a * (n / b));
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3608
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
#[fastout]
fn main() {
    input! {//
        n:usize,
        mut a:[i64;n],
    }
    a.push(-1);
    let mut pairs = vec![];
    let mut small = 9999;
    let mut big = 0;
    for &x in a.iter() {
        if big > x {
            pairs.push((small, big));
            small = 9999;
            big = 0;
        }
        small = min(small, x);
        big = max(big, x);
    }
    println!(
        "{}",
        pairs
            .iter()
            .fold(1000, |sum, x| sum + (x.1 - x.0) * (sum / x.0))
    );
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, m, d;

int main() {
	cin >> n >> m >> d;
	
	double p = (d == 0 ? 1.0 / n : 2.0 * (n - d) / (n * n));
	
	printf("%.8f\n", p * (m - 1));
	
	return 0;
}


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

int main(){
  char a[3];
  cin >> a;
  int sum = 0;
  char b[] = "1";
  for(int i=0;i<3;i++){
    if(a[i] == b[0]){
      sum = sum + 1;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
#include<string>
#include<math.h>
#define ll long long
using namespace std;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
const ll N= 1e8;
inline void fastio()
{ 
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    char n;
    cin >> n;
    if(n<=90)
        cout << 'A';
    else
        cout << 'a';
    return 0;
}



Measured memory_bytes: 3632
#include <cstdio>
#include <unordered_map>
using namespace std;
typedef long long ll;
const int N=200010;
int n;
int a[N];
ll pre[N];
unordered_map<ll,int> f;
void readData(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
}
void solve(){
	for(int i=1;i<=n;i++) pre[i]=pre[i-1]+a[i];
	f[0]=1;
	ll ans=0;
	for(int i=1;i<=n;i++){
		ans+=f[pre[i]];
		f[pre[i]]++;
	}
	printf("%lld\n",ans);
}
int main(){
	readData();
	solve();
	return 0;
}


Measured memory_bytes: 10824
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
char x,y;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>x>>y;
	if(x<y)
	cout<<"<";
	else if(x>y)
	cout<<">";
	else
	cout<<"=";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main()
{	
	// 入力
	long N;
	cin >> N;
	
	// 最大値を入れる
	long answer = INT64_MAX;
	// i * j = N
	// 対称性から i <= j になるため、回数はsqrt(N)
	for (long i = 1; i <= sqrt(N); i++)
	{
		if (N % i == 0)
		{
			long j = N / i;
			long count = i + j - 2;
			// i + j - 2 の最小値を算出する
			if (answer > count)
			{
				answer = count;
			}
		}
	}
	
	
	// 出力
	cout << answer << endl;
	
	return 0;
}

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

int main(){
    // あとで消す
    //std::ifstream in("cin3.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;

    cin >> N ;

    vector<int> arr(N,0);

    for(int i=0;i<N;i++){
        cin >> arr[i];
    }

    sort(arr.begin(), arr.end());


    double res = (arr[0]+arr[1])/2.0;
    for(int i=2;i<N;i++){
        res = (res + arr[i])/2.0;
    }
    cout << res << endl;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  for (int i = 0; i < N; i++) 
  {
  	int A = 0,amari = 0,cnt = 0;
  	cin >> A;
  	while(amari == 0)
  	{
  		amari = A % 2;
  		A /= 2;
  		cnt++;
  	}
  	if(i == 0||(i > 0 && sum > cnt - 1))
  	{
  		sum = cnt - 1;
  	}
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
from collections import deque


dir_x = [1, 0, -1, 0]
dir_y = [0, 1, 0, -1]
def bfs(y, x):
    for i in range(4):
        next_y = y + dir_y[i]
        next_x = x + dir_x[i]
        if 0 <= next_y < H and 0 <= next_x < W and maze[next_y][next_x] == "." and dist[next_y][next_x] == -1:
            que.append((next_y, next_x))
            dist[next_y][next_x] = dist[y][x] + 1


H, W = map(int, input().split())
sy, sx = 0, 0
maze = []
empty_count = 0
for i in range(H):
    maze.append(input())
    empty_count += maze[i].count(".")

dist = [[-1]*(W+1) for _ in range(H+1)]
dist[sy][sx] = 0
que = deque([(sy, sx)])

while len(que) > 0:
    y, x = que.popleft()
    bfs(y, x)

if dist[H-1][W-1] == -1:
    print(-1)
else:
    print(empty_count - (dist[H-1][W-1] + 1))

Measured memory_bytes: 3316
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
#include <iterator>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
const  long long INF = 1LL << 60;
typedef unsigned long long 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;
}



int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

map<ll,ll> mp;

auto findFactors(ll num){
	
    ll i;
    while (num % 2 == 0){ // 偶数の素数は2のみ
        if(mp.count(2)){
			mp[2] = mp[2] + 1;
		}
		else{
			mp[2] = 1;
		}
        num /= 2;
    }
    for (i = 3; i <= num; i++){ // 他の素数で割っていく
        while (num % i == 0){
			if(mp.count(i)){
			mp[i] = mp[i] + 1;
		}
		else{
			mp[i] = 1;
		}
            num /= i;
        }
    }
    return 0;
}
ll kaizyou(ll n){
    if(n == 1){
        return 1;
    }
    else{
        return (n * kaizyou(n-1)) % 1000000007;
    }
}

int main(){ 
int N, M; cin >> N >> M;
if(abs(N - M) > 1 ){
    cout << 0 << endl;
}
else{
    if(N == M){
        ll ans = kaizyou(N);
        cout << ((ans * ans % 1000000007) * 2)% 1000000007 << endl;
    }
    else{
        if(N > M){
            ll ans = kaizyou(M);
            cout << ((ans * ans % 1000000007) * N)% 1000000007 << endl;
        }
        else{
            ll ans = kaizyou(N);
            cout << ((ans * ans % 1000000007) * M)% 1000000007 << endl;
        }
    }
}
}

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

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

        int h, n;
        cin >> h >> n;

        vector<int> v(n);
        for (auto &x : v) cin >> x;
        sort(v.begin(), v.end(), greater<int>());
        for (int i = 0; i < v.size(); i++) {
                h -= v[i];
                if (h <= 0) {
                        cout << "Yes" << endl;
                        return 0;
                } 
        }
        cout << "No" << endl;
        return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

vector<int> divisors(int x) {
  vector<int> ret;
  int p = 1;
  while((long long)p*p <= x) {
    if(x % p == 0) {
      ret.push_back(p);
      ret.push_back(x/p);
    }
    p++;
  }
  return ret;
}

int N;

bool isvalid(int T,vector<int> s){
  vector<int> ans;
  rep(i,T)ans.push_back(s[i]);
  for(int i=T;i<s.size();i+=T){
    bool f=true;
    rep(j,T){
      if(ans[j]!=s[i+j])return false;
    }
  }
  return true;
}


int main() {

  cin >> N;
  vector<int> S(N);
  rep(i, N) {
    cin >> S[i];
  }

  auto yakusu = divisors(N);
  sort(yakusu.begin(),yakusu.end());

  rep(i, yakusu.size()) {
    int T = yakusu[i];
    if(isvalid(T,S)){
      cout<<N/T<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 6288
#include <iostream>

using namespace std;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    int ans;
    if (A >= B && A >= C){
        cout << 10 * A + B + C << endl;
    }else if (B >= A && B >= C){
        cout << 10 * B + A + C << endl;
    }else{
        cout << 10 * C + A + B << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>

using namespace std;

int main(){
    long long N,T;
    cin >> N >> T;
    long long t[N+1];                                                                 
    for(int i=0;i<N+1;i++) t[i]=LONG_MAX;
    for(int i=0;i<N;i++) cin >> t[i];
    
    long long ans = 0;
    int i=0;
    long long prev = 0;
    while(i < N){ 
        prev = i;
        while(t[i+1] < t[i]+ T){ 
            i += 1;
        }   
        ans += t[i] + T - t[prev];
        i += 1;
    }   
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define rep(i, n) for ((i)=0;(i)<(n);(i)++)

int tmp1, tmp2, tmp3;

typedef struct {
    int top;
    int S;
    int E;
    int W;
    int N;
    int bottom;
} Dice3;

void roll_S(Dice3 *a) {
    tmp1 = a->S;
    a->S = a->top;
    tmp2 = a->bottom;
    a->bottom = tmp1;
    tmp3 = a->N;
    a->N = tmp2;
    a->top = tmp3;
}

void roll_E(Dice3 *b) {
    tmp1 = b->E;
    b->E = b->top;
    tmp2 = b->bottom;
    b->bottom = tmp1;
    tmp3 = b->W;
    b->W = tmp2;
    b->top = tmp3;
}

void roll_N(Dice3 *c) {
    tmp1 = c->N;
    c->N = c->top;
    tmp2 = c->bottom;
    c->bottom = tmp1;
    tmp3 = c->S;
    c->S = tmp2;
    c->top = tmp3;
}

void roll_W(Dice3 *d) {
    tmp1 = d->W;
    d->W = d->top;
    tmp2 = d->bottom;
    d->bottom = tmp1;
    tmp3 = d->E;
    d->E = tmp2;
    d->top = tmp3;
}

int main(void) {
    int i;
    Dice3 dice[2];

    char commands[4] = {'S','E','N','W'};
    char command;

    rep(i, 2) {
        scanf("%d %d %d %d %d %d",&dice[i].top,&dice[i].S,&dice[i].E,&dice[i].W,&dice[i].N,&dice[i].bottom);
    }
    
    srand((unsigned)time(NULL));
    rep(i, 1000) {
        command = commands[rand()%4];
        if (command == 'S') roll_S(&dice[0]);
        else if (command == 'E') roll_E(&dice[0]);
        else if (command == 'N') roll_N(&dice[0]);
        else if (command == 'W') roll_W(&dice[0]);
        
        if (dice[0].top == dice[1].top && dice[0].S == dice[1].S && dice[0].N == dice[1].N && dice[0].W == dice[1].W && dice[0].E == dice[1].E && dice[0].bottom == dice[1].bottom) {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");

    return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007
int main() {
  int n;
  cin >> n;
  vector<ll> data(n + 1);
  map<tuple<ll, ll, ll>, int> mp;
  REP(i, n) { cin >> data[i]; }
  ll ans = 0;
  REP(i, n - 2) {
    FOR(j, i + 1, n - 1) {
      FOR(k, j + 1, n) {
        ll sum = data[i] + data[j] + data[k];
        ll ma = max(max(data[i], data[j]), data[k]);
        ll mi = min(min(data[i], data[j]), data[k]);
        ll md = sum - ma - mi;
        if (sum - ma > ma && (ma != mi && mi != md && ma != md)) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static int f(int n) {
		int count = 0;
		if(n < 10)return n;
		count += n % 10;
		count += f(n / 10);
		return count;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		
		int h = f(n);
		if(n % h == 0)System.out.println("Yes");
		else System.out.println("No");
	}

}


Measured memory_bytes: 22868
S = str(input())
Q = int(input())
s1 = ''
s2 = ''
reverse = False
for i in range(Q):
    query = list(map(str,input().split()))
    if query[0] == '1':
        if reverse == True:
            reverse = False
        else:
            reverse = True
    if query[0] == '2':
        if query[1] == '1':
            if reverse == False:
                s1 = query[2] + s1
            else:
                s2 = s2 + query[2]
        else:
            if reverse == True:
                s1 = query[2] + s1
            else:
                s2 = s2 + query[2]
S = s1 + S + s2
if reverse == True:
    S = S[::-1]
print(S)

Measured memory_bytes: 4492
def main():
  from heapq import heapify,heappush,heappop
  n,m,*a=[-i for i in map(int,open(0).read().split())]
  heapify(a)
  for _ in range(-m):heappush(a,0--heappop(a)//2)
  print(-sum(a))
main()

Measured memory_bytes: 14180
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;

int main() {

	int n, a, b;

	cin >> n >> a >> b;

	int x = a * n;

	if (x < b) { cout << x << endl; };

	if (x >= b) { cout << b << endl; };

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define soja(i,a,n) for(ll i=a;i<=n;i++)
#define ulta(i,n,a) for(ll i=n;i>=a;i--)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ve vector<ll>
#define se set<ll>
#define ma map<ll,ll>
#define pll vector<pair<ll,ll>>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define in insert
ll n,m,k,t,sum=0,temp;
int main()
{
fast;


char s;
cin>>s;
if((int)s>=65&&(int)s<=90)
    cout<<"A"<<endl;
else
     cout<<"a"<<endl;

return 0;
}


Measured memory_bytes: 3580
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var ans=[0,0,0,0];
for(var i=0;i<Arr.length;i++){
   var abc=Arr[i].split(" ").map(Number);
   abc.sort(function(a,b){return a-b;});
   var a=abc[0];
   var b=abc[1];
   var c=abc[2];
   if(c<a+b){
      ans[0]++;
      if(c*c==a*a+b*b)ans[1]++;
      if(c*c<a*a+b*b)ans[2]++;
      if(c*c>a*a+b*b)ans[3]++;
   }else{
      break;
   }
}
console.log(ans.join(" "));

Measured memory_bytes: 8432
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();
        final List<Integer> list = IntStream.range(0, n)
            .mapToObj(i -> scanner.nextInt())
            .sorted()
            .collect(Collectors.toList());
        if (k == 0) {
            System.out.println(list.get(n - 1));
            return;
        }

        final long sum = list.stream()
            .mapToLong(Integer::longValue)
            .sum();

        final PriorityQueue<Log> queue = new PriorityQueue<>(Comparator.comparingDouble(log -> -(double) log.origin / log.divCount));
        int tmp = 0;
        for (int i = 0; i < n; i++) {
            final long value = list.get(i);
            final long div = value * k / sum;
            tmp += div;
            final Log log = new Log(value, 1 + div);
            queue.add(log);
        }
        //final int div = k / n;
        final int mod = k - tmp;
        for (int i = 0; i < mod; i++) {
            final Log log = queue.poll();
            log.divCount++;
            queue.add(log);
        }
        final Log max = queue.poll();
        System.out.println((max.origin + max.divCount - 1) / max.divCount);
    }

    private static class Log {
        final long origin;
        long divCount;

        public Log(final long origin, final long div) {
            this.origin = origin;
            this.divCount = div;
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}
    

Measured memory_bytes: 69344
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int d, g;
    cin >> d >> g;
    
    vector<int> p(d), c(d);
    int res = 0;

    rep(i, d) {
        cin >> p[i] >> c[i];
        res += p[i];
    }

    for(int i = 0; i < (1 << d); i++) {
        int score = 0;
        int num = 0;
        int rest = -1;

        rep(j, d) {
            if( (i >> j) & 1 ) {
                score += (p[j]*100*(j+1) + c[j]);
                num += p[j];
            }
            else {
                rest = j;
            }
        }

        if(g > score) {
            int need = min( (g-score-1)/(100*(rest+1)) + 1, p[rest] );
            score += 100*(rest+1)*need;
            num += need;
        }

        if(score >= g) {
            res = min(res, num);
        }

    }

    cout << res << endl;
    return 0;
}

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

#define int long long int
#define MOD 1000000007
#define N 100001
#define pii pair<int,int>
#define MAX 1e18
#define _mp make_pair
#define pb push_back
#define _sort(v) sort(v.begin(),v.end())
#define _rsort(v) sort(v.rbegin(),v.rend())
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

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

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

vector<int> v;
while(n>=1){
    v.pb(n%26);
    if(n%26==0)
    n--;
    
    n/=26;
}
for(int i=v.size()-1;i>=0;i--){
    if(v[i]==0)
    v[i]=26;
    int x=v[i]+'a'-1;
    cout<<(char)x;
}
    // end_timer = std::chrono::high_resolution_clock::now();
    // ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_timer - start_timer).count();

return 0;
}

Measured memory_bytes: 3648
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {in_x: isize, in_y: isize, in_z: isize};
    let mut x = in_x;
    let mut y = in_y;
    let mut z = in_z;

    std::mem::swap(&mut x, &mut y);
    std::mem::swap(&mut x, &mut z);
    println!("{} {} {}", x, y, z);
}


Measured memory_bytes: 2144
#include<stdio.h>

int main(void)
{
  signed long long int k;
  scanf("%lld",&k);
  signed long long int result;
  int ct=0;
  result=100;
  while(result<k)
  {
    result=result+(result/100);
      ct++;
  }
  printf("%d",ct);
}

Measured memory_bytes: 1736
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    import math
    r = input_int()

    return r * 2 * math.pi


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 9180
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int number1 = sc.nextInt();
		int number2 = sc.nextInt();
		int number3 = sc.nextInt();
		if(number1 + number2 + number3 >=22) {
			System.out.println("bust");
		}else {
			System.out.println("win");
		}

	}

}

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

string shuffer(string src, int m) {
    string tmp = "";
    tmp.assign(src, m, (src.length() - m));
    tmp.append(src.erase(m, (src.length() - m)));

    return tmp;
}

int main() {
//    freopen("in.txt", "r", stdin);

    int n = 0, m;
    string str;

    while (1) {
        cin >> str;
        if (str == "-") {
            return 0;
        }

        cin >> n;
        for (int i = 0; i < n; ++i) {
            cin >> m;
            str = shuffer(str, m);
        }
        cout << str << endl;
    }
}

Measured memory_bytes: 3180
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;
	out << 180 * (N - 2) << std::endl;
}


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

int main() {
  int N,A,B,C,D;
  cin >> N;
  A = N / 1000;
  B = N / 100 % 10;
  C = N / 10 % 10;
  D = N % 10;
  
  if ((A == B && B == C) || (B == C && C == D)){
    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 li = int64_t;
using P = pair<int, int>;
#define F first()
#define S second()

int main() {
    li n, k;
    cin >> n >> k;
    li ans1, ans2;
    ans1 = n % k;
    ans2 = abs((n % k) - k);
    cout << min(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
  /*
    AOJ 1174
    title:Identically Colored Panels Connection
    @kankichi573
   */
function paint($h,$w,$y,$x,&$p,$org,$c)
{
  if($org==$c)
    return;
 
  if($p[$y][$x]!=$org)
    return;
  $p[$y][$x]=$c;
  if($x>0)
    paint($h,$w,$y,$x-1,$p,$org,$c);
  if($x<$w-1)
    paint($h,$w,$y,$x+1,$p,$org,$c);
  if($y>0)
    paint($h,$w,$y-1,$x,$p,$org,$c);
  if($y<$h-1)
    paint($h,$w,$y+1,$x,$p,$org,$c);
  
}

function count_($h,$w,$p,$c)
{
 $r=array();
 $r=$p;
 $newcolor=$c+10;
 paint($h,$w,0,0,$r,$c,$newcolor);
 $cnt=0;
 for($i=0;$i<$h;$i++)
   for($j=0;$j<$w;$j++)
     $cnt+=($r[$i][$j]==$newcolor)?1:0;
 return($cnt);
}
function dump($h,$w,$q)
{
    for($i=0;$i<$h;$i++)
      {
	for($j=0;$j<$w;$j++)
	  fprintf(STDOUT,"%d ",$q[$i][$j]);
	fprintf(STDOUT,"\n");
      }
    fprintf(STDOUT,"---------\n");
}

function solve($h,$w,$p,$c,$turn)
{
  $q=array();
  if($turn==1)
    {
      $q=$p;
      $org=$q[0][0];
      paint($h,$w,0,0,$q,$org,$c);
      $ret=count_($h,$w,$q,$c);
      return($ret);
    }

  $max=0;
   
  for($color=1;$color<=6;$color++)
    {
      if($color==$p[0][0])
	continue;
      $q=$p;
      $org=$q[0][0];
      paint($h,$w,0,0,$q,$org,$color);
      $ret=solve($h,$w,$q,$c,$turn-1);
      $max=max($max,$ret);
    }
  return($max);
}

//MAIN
$p=array();
while(fscanf(STDIN,"%d %d %d",$h,$w,$c)&&($h||$w||$c))
  {
    for($i=0;$i<$h;$i++)
      {
	$buf=fgets(STDIN);
	$p[$i][0]=strtok($buf," \n\t");
	for($j=1;$j<$w;$j++)	
	  $p[$i][$j]=strtok(" \n\t");
      }
    $ret=solve($h,$w,$p,$c,5);
    fprintf(STDOUT,"%d\n",$ret);
  }
return(0);
?>

Measured memory_bytes: 6772
n, x = map(int, input().split())
a = list(map(int, input().split()))

min_list = [[a[i] for i in range(n)] for _ in range(n)]
for i in range(1, n):
	for j in range(n):
		min_list[i][j] = min(min_list[i-1][j], a[(j-i) % n])

ans = float("inf")
for i in range(n):
	ans = min(ans, x * i + sum(min_list[i]))

print(ans)

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

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

    vector<tuple<string, int, string>> restaurantVec;
    set<string> cityNameVec;
    for (int i = 1; i <= n; ++i)
    {
        string restaurantName;
        int restaurantPoint;
        cin >> restaurantName >> restaurantPoint;

        cityNameVec.insert(restaurantName);

        restaurantVec.push_back(make_tuple(restaurantName, restaurantPoint, to_string(i)));
    }

    // sort(cityNameVec.begin(), cityNameVec.end());

    for (const string singleCityName : cityNameVec)
    {
        vector<tuple<int, string>> restaurantVecInSingleCity;
        vector<int> restaurantPointVecInSingleCity;
        for (const auto singleRestaurant : restaurantVec)
        {
            if (get<0>(singleRestaurant) == singleCityName)
            {
                restaurantPointVecInSingleCity.push_back(get<1>(singleRestaurant));
                restaurantVecInSingleCity.push_back(make_tuple(get<1>(singleRestaurant), get<2>(singleRestaurant)));
            }
        }

        sort(restaurantPointVecInSingleCity.begin(), restaurantPointVecInSingleCity.end(), greater<int>());

        for (const auto singleRestaurantPointInCity : restaurantPointVecInSingleCity)
        {
            for (const auto singleRestaurantInCity : restaurantVecInSingleCity)
            {
                if (get<0>(singleRestaurantInCity) == singleRestaurantPointInCity)
                {
                    cout << get<1>(singleRestaurantInCity) << endl;
                }
            }
        }
    }
}

Measured memory_bytes: 256
using System;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int a = sc.NextInt();
        int b = sc.NextInt();
        if (a <= 9 && b <= 9)
        {
            Console.WriteLine(a*b);
        }
        else
        {
            Console.WriteLine("-1");
        }
        
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t a,b;
  cin >> a >> b;

  if((a+b)%2==1){
  cout << "IMPOSSIBLE" << endl;
  }
  else{
    cout << (a+b)/2 << endl;
  }
  
}



Measured memory_bytes: 3640
#![allow(unused_imports)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    n: usize,
    a: [usize; n],
    }
    let l = a.len();
    let mut a:Vec<usize> = a;
    a.sort();
    a.dedup();
    let la = a.len();
    let ans = if l == la {"YES"} else{"NO"};
    println!("{}", ans);
}


Measured memory_bytes: 6396
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,k = readline() |> split |> parseMap
	h = readline() |> split |> parseMap
	dp = Array{Int}(n)
	dp[1] = 0
	for i in 2:min(k,n)
		m = 10000000000
		for j in 1:i-1
			m = min(m,dp[j]+abs(h[i]-h[j]))
		end
		dp[i] = m
	end
	for i in k+1:n
		m = 10000000000
		for j in 0:k-1
			m = min(m,dp[i-k+j]+abs(h[i]-h[i-k+j]))
		end
		dp[i] = m
	end
	println(dp[n])
end

main()


Measured memory_bytes: 124668
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

//search in [left..right)
//return pos: [left..pos)
fn search_longest_seq(sum_vec: &[u64], xor_vec: &[u64], left: usize, right: usize) -> usize{
    let mut l = left;
    let mut r = right;

    while l < r{

        let mid = (l+r)/2;
        if  sum_vec[mid] - sum_vec[left-1] == xor_vec[mid] ^ xor_vec[left-1]{
            l = mid+1;
        }else{
            r = mid;
        }
    }

    return l;

}

fn nh2(n: usize) -> usize{
    let n = n+2-1;

    return n*(n-1)/2;
}

fn main(){
    let n = read_as_vec::<usize>()[0];
    let a = read_as_vec::<u64>();
    let mut sum_vec: Vec<u64> = vec![0;n+1];
    let mut xor_vec: Vec<u64> =vec![0;n+1];


    let mut tmp: u64 = 0;
    for i in 0..n{
        tmp += a[i];
        sum_vec[i+1] = tmp;
    }

    let mut tmp: u64 = 0;
    for i in 0..n{
        tmp ^= a[i];
        xor_vec[i+1] = tmp;
    }

    let mut ans: usize = 0;
    for i in 1..n+1{
        let right = search_longest_seq(&sum_vec, &xor_vec, i, n+1);
        ans += right-i;
    }

    println!("{}", ans);
}


Measured memory_bytes: 10492
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PipedInputStream;
import java.util.*;

public class Main {
    private static final int MOD = (int) Math.pow(10, 9);
    private static final int[][] DIRS = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        long n = sc.nextLong();
        Set<String> set = new HashSet<>();

        for (int i = 0; i < n; i++) {
            set.add(sc.next());
        }
        System.out.println(set.size());

        System.exit(0);
    }
    static private class Point {
        public int x;
        public int y;
        Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    static private int log2(int x) {
        return (int)(Math.log(x) / Math.log(2));
    }

    static private long gcd(long m, long n) {
        if (m < n) { return gcd(n, m); }
        if (m % n == 0) { return n; }
        return gcd(n, m%n);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 71728
/// wa ^3^

#pragma GCC optimize("O3")

#include<bits/stdc++.h>
                           
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

void stndrtn() {
#ifdef accepted    
    freopen(".in", "r", stdin);
#endif
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    deque<char> d;
    string s;
    cin >> s;
    for (char c : s)
        d.pb(c);
    int q;
    cin >> q;
    bool r = 0;
    for (int t; q--;) {
        cin >> t;
        if (t == 1) {
            r ^= 1;
        } else {
            int f;
            cin >> f;
            char c;
            cin >> c;
            if (r)
                f = 3-f;    
            if (f == 2) 
                d.pb(c);
            else 
                d.push_front(c);
        }
    }
    if (r)
        reverse(d.begin(), d.end());
    for (char c : d)
        cout << c;
    return 0;
}



Measured memory_bytes: 976
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<stack>
#include<vector>
#include<map> 
#define maxn 5005
#define INF 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int cnt[maxn],n,x,y;


int main()
{
    cin>>n>>x>>y;
    for(int i=1;i<=n-1;i++)
    {
    	for(int j=i+1;j<=n;j++)
    	{
    		int tmp1,tmp2;
    		tmp1=abs(x-i)+abs(y-j)+1;
    		tmp2=j-i;
    		int tmp;
    		tmp=tmp1>tmp2?tmp2:tmp1;
    		cnt[tmp] ++;
		}
	}
	for(int i=1;i<n;i++)
	{
		cout<<cnt[i]<<endl;
	}
    return 0;
}

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



int main() {
  int N,K; cin >> N>> K;
  int ans = 0;
  rep(i,N){
    int h;
    cin >> h;
    if (h >= K) ans++;
  }

  cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3636