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

#define forn(i,x,n)       for(int i=x; i<n; i++)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

void zeus()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int h, w, k;
vector<pii> dir = {{0, 1}, {1, 0}, { -1, 0}, {0, -1}};
bool isin(int i, int j) {
	return (i > 0 && j > 0 && i <= h && j <= w);
}
void bfs(int x1, int y1, int x2, int y2, vector<vector<char>> pond, vector<vi>& visited, vector<vi>& dist) {

	visited[x1][y1] = 1;
	dist[x1][y1] = 0;
	queue<pii> q;
	q.push({x1, y1});

	while (!q.empty()) {
		pii x = q.front();
		q.pop();
		// cout << x.ff << " " << x.ss << endl;

		forn(i, 0, 4) {

			forn(j, 1, k + 1) {
				int i1 = x.ff + j * dir[i].ff;
				int j1 = x.ss + j * dir[i].ss;

				if (!isin(i1, j1)) {
					break;
				}
				if (pond[i1][j1] == '@') {
					break;
				}
				if (visited[i1][j1] && dist[i1][j1] < 1 + dist[x.ff][x.ss]) {
					break;
				}
				if (!visited[i1][j1]) {
					visited[i1][j1] = 1;
					dist[i1][j1] = 1 + dist[x.ff][x.ss];
					q.push({i1, j1});
					// cout << i1 << " " << j1 << endl;
				}
				if (i1 == x2 && j1 == y2) {
					return;
				}
			}
		}
	}

}
int32_t main()
{
	zeus();
	cin >> h >> w >> k;
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	vector<vector<char>> pond(h + 1, vector<char>(w + 1));
	vector<vector<int>> visited(h + 1, vector<int>(w + 1));
	vector<vector<int>> dist(h + 1, vector<int>(w + 1));

	forn(i, 1, h + 1) {
		forn(j, 1, w + 1) {
			cin >> pond[i][j];
		}
	}

	if (pond[x1][y1] == '@' || pond[x2][y2] == '@') {
		cout << -1 << endl;
		return 0;
	}
	bfs(x1, y1, x2, y2, pond, visited, dist);

	if (visited[x2][y2] == 0) {
		cout << -1 << endl;
	}
	else {
		cout << dist[x2][y2] << endl;
	}



}

Measured memory_bytes: 44136
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int dx[]={1,0,-1,0};
constexpr int dy[]={0,1,0,-1};
constexpr int ddx[] = {1,1,-1,-1,2,2,2,2,2,-2,-2,-2,-2,-2,1,0,-1,1,0,-1};
constexpr int ddy[] = {1,-1,1,-1,0,1,2,-1,-2,2,1,0,-1,-2,2,2,2,-2,-2,-2};
constexpr int INF = 1<<28;
int main(){
  int H,W,C_h,C_w,D_h,D_w;
  cin>>H>>W>>C_h>>C_w>>D_h>>D_w;
  C_h--,C_w--,D_h--,D_w--;
  vector S(H,vector<char>(W));
  rep(i,H)rep(j,W)cin>>S[i][j];
  

  vector dist(H,vector(W,INF));
  dist[C_h][C_w] = 0;
  priority_queue<int,vector<int>,greater<>> que;
  que.emplace(C_h*W+C_w);
  while(!que.empty()){
    int cur = que.top();
    que.pop();
    int y = cur/W;
    int x = cur%W;
    rep(i,4){
      int ny = y+dy[i];
      int nx = x+dx[i];
      if(ny<0||nx<0||ny>=H||nx>=W)continue;
      if(S[ny][nx]=='#')continue;
      if(dist[ny][nx]>dist[y][x]){
        dist[ny][nx] = dist[y][x];
        que.emplace(ny*W+nx);
      }
    }
    rep(j,20){
      int ny = y+ddy[j];
      int nx = x+ddx[j];
      if(ny<0||nx<0||ny>=H||nx>=W)continue;
      if(S[ny][nx]=='#')continue;
      if(dist[ny][nx]>dist[y][x]+1){
        dist[ny][nx] = dist[y][x]+1;
        que.emplace(ny*W+nx);
      }
    }
  }
  int ans = dist[D_h][D_w];
  cout<<(ans==INF?-1:ans)<<endl;
}

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

int main(){
  int n; cin >> n; n++;
  int cnt=0;
  for(int i=0;(2*i+1)<n;i++){
    int tmp=0;
    for(int j=1;j<=(2*i+1);j++){
      if((2*i+1)%j == 0) tmp++;
    }
    if(tmp == 8) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ARC71_C
{
    class Program
    {
        static void Main(string[] args)
        {

            var n = int.Parse(Console.ReadLine());
            var s = new char[n][];
            for (int i = 0; i < n; i++)
            {

                s[i] = Console.ReadLine().ToCharArray();
            }

            for (int i = 0; i < n; i++)
            {
                Array.Sort(s[i]);
            }
            bool f = true;
            var ans = new List<char>();
            var c = new char[n];
            var sc = new int[n];
            for (int i = 0; i < n; i++)
            {
                c[i] = s[i][0];
                sc[i] = 0;
            }
            while(true){

                if (c.All(x => x == c[0]))
                {
                    ans.Add(c[0]);
                    for (int i = 0; i < n; i++) sc[i]++;
                }
                else
                {
                    var cmin = c.Min();
                    for (int i = 0; i < n; i++)
                    {
                        if (c[i] == cmin)
                        {
                            sc[i]++;
                        }
                    }

                }
                for (int i = 0; i < n; i++)
                {
                    if (sc[i] >= s[i].Length)
                    {
                        goto last;
                    }
                    c[i] = s[i][sc[i]];
                }
            }
            last:
            Console.WriteLine(new String(ans.ToArray()));
        }
    }
}


Measured memory_bytes: 13524
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[N];
        double Asum = 0;

        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            Asum += A[i];
        }

        Asum=Asum/(4*M);

        Arrays.sort(A);

        for (int i = 0; i < M; i++) {
            if(A[A.length-1-i]>=Asum){
                continue;
            }else{
                System.out.println("No");
                System.exit(0);
            }
        }

        System.out.println("Yes");
    }
}

Measured memory_bytes: 35708
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        sx, sy, sh = x, y, h
    lis.append((x, y, h))
for i in range(101):
    for j in range(101):
        high = sh + abs(sx - i) + abs(sy - j)
        judge = True
        for x, y, h in lis:
            if h > 0 and high != h + abs(x - i) + abs(y - j):
                judge = False
                break
            if h == 0 and high > abs(x - i) + abs(y - j):
                judge = False
                break
        if judge:
            print(i, j, sh + abs(sx - i) + abs(sy - j))
            exit()

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>

#define WMAX 10000

int n , allmin ,*arr ,*sortarr ,*nextarr;
bool *booarr;
int part ( int [],int ,int);
void quickSort( int [],int ,int);

int main(){
	scanf("%d",&n);
	arr = malloc (n * sizeof(int));
	sortarr = malloc (n * sizeof(int));
	nextarr = malloc (WMAX * sizeof(int));
	booarr = malloc (n * sizeof(bool));
	allmin = INT_MAX;
	for(int i = 0;i<n;i++){
		scanf("%d",&arr[i]);
		sortarr[i] = arr[i];
		allmin = allmin < arr[i] ? allmin : arr[i];
		booarr[i] = false;
	}
	
	int outp =0;
	quickSort(sortarr, 0,n-1);
	makeNextArr();
	
	for(int i= 0 ; i <n ; i++)
	{
	if(booarr[i] == true){continue;}
	int csum = 0 ,cn =0 , cmin = INT_MAX , nowi = i ;
	do	{
	booarr[nowi] = true;
	csum += arr[nowi];
	cn++;
	cmin = cmin < arr[nowi] ? cmin : arr[nowi];
	nowi = nextarr[arr[nowi]];
	}while(booarr[nowi] == false);

	int incr = (cn - 2) * cmin + csum;
	int lent = cmin + (cn + 1) * allmin + csum;	
	outp += incr < lent ? incr : lent;

	}
	
	printf("%d\n",outp);
	return 0;
}

void makeNextArr()
{
	for( int i = 0 ; i < n;i++ ){
		nextarr[sortarr[i]] = i;
	}
}

void quickSort( int a[],int p,int r){
  if ( p < r){
    int q = part(a , p ,r);
    quickSort(a,p,q-1);
    quickSort(a,q+1,r);
  }
}

int  part (int a[] ,int p ,int r){
  int x = a[r] ,t ;
  int j, i = p-1;
  for ( j = p ; j < r ; j++ ){
    if ( a[j]  <= x){
      i++;
      t = a[i]; a[i] = a[j]; a[j] =t;
    }
  }
  t = a[i+1]; a[i+1] = a[r] ; a[r]=t;
  return i+1;
}



Measured memory_bytes: 2056
#include<bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define ad pair<int,pair<int,int>>  
using namespace std;	

vector<string> a;
int h,wi,k,x1,y11,x2,y2;
bool isValid(int x,int y)
{
	if(x<h && x>=0 && y<wi && y>=0)
			return true;
	return false;
}
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	// #ifndef ONLINE_JUDGE 
	// 	freopen("_input.txt", "r", stdin); 
	// freopen("_output.txt", "w", stdout); 
	// #endif 
	cin>>h>>wi>>k;
	cin>>x1>>y11>>x2>>y2;
	//cout<<h<<" "<<wi<<"\n";
	x1--,y11--,x2--,y2--;
	a.resize(h);
	int w[h][wi];
	for(int i=0;i<h;i++)
		for(int j=0;j<wi;j++)
			w[i][j]=LLONG_MAX;
	for(int i=0;i<h;i++)
		cin>>a[i];
	priority_queue<ad,vector<ad>,greater<ad>> pq;
	pq.push({0,{x1,y11}});
	w[x1][y11]=0;
	while(!pq.empty())
	{
		ad pp=pq.top();
		pq.pop();

		int x=pp.ss.ff,y=pp.ss.ss,dist=pp.ff;
		//cout<<x<<" "<<y<<"\n";
		if(x==x2 && y==y2)
		{
			cout<<dist<<"\n";
			return 0;
		}
		for(int i=0;i<4;i++)
		{
			for(int j=1;j<=k;j++)
			{
				int new_x=x+dx[i]*j,new_y=y+dy[i]*j;
				bool f=isValid(new_x,new_y);
				//cout<<new_x<<" "<<new_y<<" "<<f<<"\n";
				if(f && a[new_x][new_y]=='@')
					break;
				if(f)
				{
					if(dist+1<w[new_x][new_y])
					{
						w[new_x][new_y]=dist+1;
						pq.push({w[new_x][new_y],{new_x,new_y}});
					}
					else if(dist+1>w[new_x][new_y])
						break;
				}
				else
					break;
			}
		}
	}
	cout<<"-1\n";
}

Measured memory_bytes: 15352
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

long long digit[100];
int main(){
  long long N;
  scanf("%lld", &N);
  int c=0;
  while(N>0){
    N--;
    digit[c]=N%26;
    N=N/26;
    c++;
  }
  std::string ans;
  for (int i=c-1; i>=0; i--){
    ans += 'a'+digit[i];
  }
  std::cout << ans << std::endl;
  return 0;
}
 

Measured memory_bytes: 3200
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

# ・最適解をとってみる
# ・最適解に仮定できる構造を探す
# ・探索空間が小さくなったら、既知の手法に当てはまる（dpなど）

N, T = map(int, input().split())
FOOD = [[int(x) for x in input().split()] for _ in range(N)]

FOOD.sort()
dp = np.array([np.zeros(T + 1, dtype=np.int64) for _ in range(N + 1)])
ans = 0
for i in range(N):
    a, b = FOOD[i]
    dp[i + 1][a:] = np.maximum(dp[i][:-a] + b, dp[i][a:])

    # if len(dp[i][-a+1:T]) > 0:
    # dp[i + 1][T] = max(dp[i + 1][T], max(dp[i][-a+1:T]) + b)
    now = 0
    if i != N-1:
        now = dp[i + 1][T - 1] + max(FOOD[i + 1:], key=lambda x: x[1])[1]
        #print(FOOD[i + 1:])
        #print(max(FOOD[i + 1:], key=lambda x: x[1])[1])
        #print(now)

    ans = max(ans, now)

    # print(dp[i+1])

print(ans)


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

#define int long long

using namespace std;

signed main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int n, a[200010];
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    if(a[0] != 0){
        cout << -1 << endl;
        return 0;
    }
    int steps = 0;
    for(int i = n-1; i > 0; i--){
        if(a[i] == a[i-1] + 1) steps++;
        if(a[i] <= a[i-1]    ) steps+=a[i];
        if(a[i] >  a[i-1] + 1){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << steps << endl;
    return 0;
}


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

using i64 = int_fast64_t;
using f64 = double;

void solve() {
    i64 n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<i64> a(n);
    for (auto& e : a) cin >> e;
    sort(begin(a), end(a), greater<>());

    i64 l = 0, r = n;
    while (abs(r - l) > 1) {
        i64 mid = (l + r) / 2;

        if (mid < p) {
            l = mid;
            continue;
        }

        if (a[p - 1] > a[mid] + m) {
            r = mid;
            continue;
        }

        i64 sum = 0;
        for (i64 i = 0; i < n; i++) {
            sum += i < p - 1 || i >= mid ? m : a[mid] + m - a[i];
        }

        (sum >= m * v ? l : r) = mid;
    }

    cout << l + 1 << endl;
}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
using pl = pair<ll,ll>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

const int M=10000;

int main(int argc,char* argv[])
{
    int n,m,ans=0;
    cin>>n>>m;
    int a[n][m]={0};
    rep(i,n){
        int k,q;
        cin>>k;
        rep(j,k) cin>>q,a[i][q-1]=1;
    }
    rep(i,m){
        int sum=0;
        rep(j,n)sum+=a[j][i];
        ans+=(sum==n);
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, n, m);
  vector<string> a(n), b(m);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < m; ++i) cin >> b[i];

  int len = n - m + 1;

  bool ans = false;
  for (int i = 0; i < len; ++i) {
    for (int j = 0; j < len; ++j) {
      bool ok = true;
      for (int k = 0; k < m; ++k) {
        if (a[k + i].substr(j, m) != b[k]) ok = false;
      }
      if (ok) ans = true;
    }
  }

  puts(ans ? "Yes" : "No");

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
#define INF (int)10000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 1000000007

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int a, b;
	cin>>a>>b;
	string s1= "", s2 = "";
	for (int i=0;i<b;++i)
		s1+=to_string(a);
	for (int i=0;i<a;++i)
		s2+=to_string(b);
	if (s1<=s2)
		cout<<s1;
	else if (s1>s2)
		cout<<s2;


	



	return 0;
}

Measured memory_bytes: 256
//fizzbuzz
#include "iostream"
#define ll long long int
using namespace std;
int main()
{
    int n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        if((i%3)==0 || i%5==0)
        {
            sum+=0;
        }
        
        else
            sum+=i;
    }
    cout<<sum<<endl;
    
}


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

int main()
{
  long long w,h,x,y;
  cin >> w >> h >> x >> y;
  double tot = w*h;
  cout << tot/2 << " ";
  if(2*x == w && 2*y == h)
    cout << 1 ;
  else
    cout << 0;
}

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

using namespace std;

int a[222];

void solve() {
    a[1] = 3e5;
    a[2] = 2e5;
    a[3] = 1e5;
    int x,y;
    cin >> x >> y;
    int res = a[x] + a[y];
    if (x == 1 && y == 1) {
        res += 4e5;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc115/tasks/abc115_c

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int H_I_MAX = 1e9;
const int INF = 2e9;

int N, K;
int h[N_MAX];

void solve() {
  sort(h, h + N);
  int ans = INF;
  REP(i, N - K + 1) {
    ans = min(ans, h[i + K - 1] - h[i]);
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &K);
  REP(i, N) scanf("%d", h + i);
}

int main() {
  input();
  solve();
  return 0;
}


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

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        mut p_vec: [i64; n],
    };
    p_vec.sort();
    let mut ans: i64 = 0;
    for i in 0..k {
        ans += p_vec.get(i).expect("error at for loop");
    }
    println!("{}", ans);
}


Measured memory_bytes: 2204
N, K = map(int, input().split())
A = list(map(int, input().split()))

b = [0] * 40
for i in range(40):
    for k in A:
        b[i] += (k & (1 << i)) >> i

c = [0] * 40
for i in range(39):
    if b[i] > N - b[i]:
        c[i + 1] = c[i] + (b[i] << i)
    else:
        c[i + 1] = c[i] + (N - b[i] << i)

ans = 0
cnt = 0
for i in reversed(range(40)):
    if K & (1 << i):
        ans = max(ans, cnt + (b[i] << i) + c[i])
        cnt += N - b[i] << i
    else:
        cnt += b[i] << i
print(max(ans, cnt))


Measured memory_bytes: 85996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
int main(){
  ll n;cin>>n;
  string ans="YES";
  vll a(n);
  ll odd,even;
  for (ll i=0;i<n;i++) {
    cin>>a[i];
    if (a[i]%2==1) odd++;
    else even++;
  }
  while (odd>=2) {
    odd-=2;
    even++;
  }
  if (even>0&&odd==1) ans="NO";
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;

int main(){
  string S;
  cin >> S;
  int N=S.size();
  int L_1=(N-1)/2;
  int L_2=N-(N+3)/2+1;
  string S_1(L_1,'a'),S_2(L_2,'a');

  for(int i=0;i<L_1;i++){
    S_1.at(i)=S.at(i);
  }

  for(int i=0;i<L_2;i++){
    S_2.at(i)=S.at(i+(N+3)/2-1);
  }
  
  for(int i=0;i<N/2;i++){
    if(S.at(i)!=S.at(N-1-i)){
      cout << "No" << endl;
      return 0;
    }
  }

  for(int i=0; i<L_1/2; i++){
    if(S_1.at(i)!=S_1.at(L_1-1-i)){
      cout << "No" << endl;
      return 0;
    }
  }

  for(int i=0; i<L_2/2; i++){
    if(S_2.at(i)!=S_2.at(L_2-1-i)){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define N 300
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
/*最大流(Dinic法) O(|E||V|^2)*/

class Dinic{
public:
  struct edge{
    int to,cap,rev;
    edge(){};
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){};
  };

  int V;
  vector<vector<edge> > G; //グラフの隣接リスト表現
  vector<int> level;       //sからの距離
  vector<int> iter;        //どこまで調べ終わったか

  Dinic():V(-1){};
  Dinic(int V):V(V),G(V),level(V),iter(V){}

  //fromからtoへ向かう容量capの辺をグラフに追加。
  void add_edge(int from,int to,int cap){
    assert(from < V && to < V);
    G[from].push_back(edge(to,cap,G[to].size()));
    G[to].push_back(edge(from,0,G[from].size()-1));
  }

  //sからの最短距離をBFSで計算する
  void bfs(int s){
    level.clear(); level.resize(V,-1);
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while(!que.empty()){
      int v = que.front(); que.pop();
      for(edge &e : G[v])
        if(e.cap > 0 && level[e.to] < 0){
          level[e.to] = level[v] + 1;
          que.push(e.to);
        }
    }
  }

  //増加パスをDFSで探す。
  int dfs(int v,int t,int f){
    if(v==t) return f;
    for(int &i= iter[v]; i<(int)G[v].size(); i++){
      edge &e = G[v][i];
      if(e.cap > 0 && level[v] < level[e.to]){
        int d = dfs(e.to, t, min(f, e.cap));
        if(d > 0){
          e.cap -= d;
          G[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  //sからtへの最大流を求める
  int max_flow(int s,int t){
    assert(V >= 0);
    int flow=0;
    for(;;){
      bfs(s);
      if(level[t] < 0) return flow;
      iter.clear();iter.resize(V,0);
      int f;
      while((f=dfs(s ,t ,INF)) > 0 ) flow += f;
    }
  }
};

signed main(){
  
  int n;
  cin>>n;
  vector<int> A(n);
  int sum = 0;
  for(int i=0;i<n;i++) cin>>A[i],sum += max(0LL,A[i]);
  
  
  Dinic dinic(N);
  int S = N-1,T = N-2;
  for(int i=1;i<=n;i++) if(A[i-1] < 0) dinic.add_edge(S,i,-A[i-1]);
  for(int i=1;i<=n;i++) if(A[i-1] > 0) dinic.add_edge(i,T,A[i-1]);
  
  for(int i=1;i<=n;i++)
    for(int j=i;j<=n;j+=i) dinic.add_edge(i,j,INF);
  
  cout << sum-dinic.max_flow(S,T) <<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int maxn=0x7fffff;
int a,b;
int main(){
	cin>>a>>b;
	if(b%a==0){
		cout<<a+b;
	}
	else cout<<b-a;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	int N;
	cin >> N;
	for(int i=0; i<N; ++i){
		char s;
		cin >> s;
		if(s=='Y'){
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
}

Measured memory_bytes: 3640
X = int(input())

A_ = X//4+1
B_ = X//7+1

ans = 0
for a in range(A_):
  for b in range(B_):
    c = 4*a + 7*b
    if c > X:
      break
    if c == X:
      ans = 1
      break
if ans == 1:
  print("Yes")
else:
  print("No")


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, Z, W = MAP()
A = [W] + LIST()

memo = list2d(N+1, 2, -1)
def rec(cur, prev, turn):
    if cur == N:
        return abs(A[cur] - A[prev])
    if memo[cur][turn] != -1:
        return memo[cur][turn]
    
    if turn == 0:
        res = 0
        for nxt in range(cur+1, N+1):
            res = max(res, rec(nxt, cur, 1 - turn))
    else:
        res = INF
        for nxt in range(cur+1, N+1):
            res = min(res, rec(nxt, cur, 1 - turn))
    memo[cur][turn] = res
    return res
print(rec(0, 0, 0))


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

using namespace std;

using ll = long long;
const ll mod = (1e9) + 7;

const ll intll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
  is >> p.first >> p.second;
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < (int)v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

template <typename T = ll>
vector<T> make_v(size_t a) {
  return vector<T>(a);
}

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
  t = v;
}

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename F>
struct FixPoint : F {
  FixPoint(F &&f) : F(forward<F>(f)) {}

  template <typename... Args>
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};

template <typename F>
inline decltype(auto) MFP(F &&f) {
  return FixPoint<F>{forward<F>(f)};
}

ll powMod(ll n, ll p, ll mod) {
  ll res = 1;
  while (p) {
    if (p & 1) (res *= n) %= mod;
    (n *= n) %= mod;
    p >>= 1;
  }
  return res;
}
ll invMod(ll n, ll mod) { return powMod(n, mod - 2, mod); }

ll Combination(ll n, ll r, ll mod) {
  if (n < r) return 0;
  ll ans = 1;
  if (n < 2 * r) r = n - r;
  for (int i = 1; i <= r; ++i) {
    ans *= n - i + 1;
    ans %= mod;
    ans *= powMod(i, mod - 2, mod);
    ans %= mod;
  }
  return ans;
}

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

  int ans = powMod(2, n, mod) - 1;
  ans -= Combination(n, a, mod);
  ans %= mod;
  ans -= Combination(n, b, mod);
  ans %= mod;
  if (ans < 0) ans += mod;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
def solve():
  n=int(input())
  arr1=list(map(int,input().split()))
  arr2=list(map(int,input().split()))
  tlist=[0]
  for val in arr1:
    tlist.append(tlist[-1]+val)
  t=tlist[-1]
  ans=0
  for i in range(1,2*t):
    tt=i/2
    tmp=10**18
    for j in range(n):
      if tt<=tlist[j]:
        tmp=min(tmp,arr2[j]+(tlist[j]-tt))
      elif tlist[j+1]<=tt:
        tmp=min(tmp,arr2[j]+(tt-tlist[j+1]))
      else:
        tmp=min(tmp,arr2[j])
    tmp=min(tmp,tt)
    tmp=min(tmp,t-tt)
    ans+=tmp
  print(ans/2)
solve()

Measured memory_bytes: 41968
#include <stdio.h>
int main(){
    int N;
    scanf("%d",&N);
    for(int i=1;i<=N;i++){
        int x=i;
        if(x%3==0){
            printf(" %d",x);
        }else{
            while(x){
                if(x%10==3){
                    printf(" %d",i);
                    break;
                }
                x/=10;
            }
        }
    }
    printf("\n");
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+10;
vector<int>v[N];
priority_queue<int>q;
struct node{
	int a,b;
}arr[N];
int n,m;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	cin>>arr[i].a>>arr[i].b;
	for(int i=1;i<=n;i++)
	{
		if(arr[i].a<=m)
		v[m-arr[i].a].push_back(arr[i].b);
	}
	int ans=0;
	for(int i=m-1;i>=0;i--)
	{
		for(int j=0;j<v[i].size();j++)
		q.push(v[i][j]);
		if(!q.empty())
		{
			ans+=q.top();
			q.pop();
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
#define inf 1000000000
#define ll long long
using namespace std;
int main()
{
    int n,k,ans=0;
    scanf("%d%d",&n,&k);
    for(int i=1; i<=n; i++)
    {
        int x;
        scanf("%d",&x);
        if(x>=k)
            ans++;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	const inputLines = input.split("\n");
	const line0 = inputLines[0];
	const line0vars = line0.split(" ");

	const n = parseInt(line0vars[0], 10);
	const x = parseInt(line0vars[1], 10);
	const t = parseInt(line0vars[2], 10);

	console.log(Math.ceil(n/x) * t);
	

	// tmp = input[1].split(" ");
	// //文字列から10進数に変換するときはparseIntを使います
	// var a = parseInt(input[0], 10);
	// var b = parseInt(tmp[0], 10);
	// var c = parseInt(tmp[1], 10);
	// var s = input[2];

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

// node index.js
// 1
// 2 3
// test
// (Ctrl + D)


Measured memory_bytes: 29632
S=set(x for x in input())
if len(S)==4:
  print('Yes')
elif len(S)==2:
  if 'W' in S and 'E' in S:
    print('Yes')
  elif 'N' in S and 'S' in S:
    print('Yes')
  else:
    print('No')
else:
  print('No')  

Measured memory_bytes: 9116
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define pii pair<int,int>
typedef long long llong;
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	
	vector<pii > v;
	REP(i,n){
		int a;
		cin>>a;
		v.push_back(make_pair(a,1));
	}
	
	REP(i,m){
		int b,c;
		cin>>b>>c;
		v.push_back(make_pair(c,b));
	}
	
	sort(ALL(v));
	reverse(ALL(v));
	
	llong ans=0;
	int cnt=0;
	int j=0;
	while(1){
		if(v[j].second<n-cnt){
			ans+=(llong)v[j].first*v[j].second;
			cnt+=v[j].second;
			j++;
		}else break;
	}
	
	ans+=(llong)v[j].first*(n-cnt);
	
	cout<<ans<<endl;
}


Measured memory_bytes: 2420
c=[]
for i in range(3):
    sub_list=list(map(int,input().split()))
    c.append(sub_list)
a=[0]*3
b=[0]*3
for i in range(101):
    a[0]=i
    b[0]=c[0][0]-i
    b[1]=c[0][1]-i
    b[2]=c[0][2]-i
    a[1]=c[1][0]-b[0]
    a[2]=c[2][0]-b[0]
    count=0
    for j in a:
        if not 0<=j<=100:
            count=1
    for j in b:
        if not 0<=j<=100:
            count=1
    if count==1:
        continue
    count=0
    for m in range(3):
        for n in range(3):
            if not c[m][n]==a[m]+b[n]:
                count=1
    if count==1:
        continue
    else:
        print('Yes')
        import sys
        sys.exit()
print('No')


Measured memory_bytes: 38384
#include <stdio.h>

int main(void){
    int s;
    scanf("%d", &s);
    
    int hour = s / (60*60);
    int amariS = s % (60*60);
    int minutes = amariS / 60;
    int sec = amariS % 60;
    printf("%d:%d:%d\n",hour ,minutes,sec);


return 0;
}


Measured memory_bytes: 2084
#include <iostream>

int main() {
    while (true) {
        int h, w;
        std::cin >> h >> w;
        if (h == 0 && w == 0) {
            return 0;
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                std::cout << '#';
            }
            std::cout << std::endl;
        }
        std::cout << std::endl;
    }
    return 0;
}



Measured memory_bytes: 3112
#include<stdio.h>
#define N 36

typedef struct{
  char kind;
  int num;
}Card;

void bubblesort(Card * ,int);
void selectionsort(Card *,int);
int isStable(Card *,Card *,int n);

int main(){
  int a,i,f = 0;
  Card card1[N],card2[N];
  
  scanf("%d",&a);
  for(i = 0;i < a;i++){
    scanf(" %c%d",&card1[i].kind,&card1[i].num);
    card2[i]=card1[i];
  }
  
  
  bubblesort(card1,a);
  for(i = 0;i < a-1;i++){
    printf("%c%d ",card1[i].kind,card1[i].num);
  }
  printf("%c%d\n",card1[a-1].kind,card1[a-1].num);
  printf("Stable\n");
  
  selectionsort(card2,a);
  for(i = 0;i < a-1;i++){
    printf("%c%d ",card2[i].kind,card2[i].num);
  }
  printf("%c%d\n",card2[a-1].kind,card2[a-1].num);
  for(i = 0;i < a;i++){
    f = f+isStable(card1,card2,a);
  }
  if(f == 0)printf("Not stable\n");
  else printf("Stable\n");
  return 0;
}

void bubblesort(Card A[],int a){
  int i,j;
  Card temp;
  for(i = 0;i <= a-1;i++){
    for(j = a-1;j >= i+1;j--){
      if(A[j].num < A[j-1].num){
	temp = A[j];
	A[j] = A[j-1];
	A[j-1] = temp;
      }
    }
  }
}

void selectionsort(Card A[],int a){
  int i,j,min;
  Card temp;
  for(i = 0;i <= a-1;i++){
    min=i;
    for(j = i;j <= a-1;j++){
      if(A[j].num<A[min].num)
	min=j;
      }
      temp=A[i];
      A[i]=A[min];
      A[min]=temp;
    } 
}
 
int isStable(Card *x,Card *y,int a){
  int i;

  for(i = 0;i < a;i++){
    if(x[i].kind != y[i].kind) return 0;
  }
  return 1;
}




Measured memory_bytes: 2056
N = int(input())
A = list(map(int, input().split()))
cnt = 0
while True:
    amari = 0
    for i in range(N):
        amari += A[i] % 2
        A[i] /= 2
        if amari != 0:
            print(cnt)
            exit()
    cnt += 1

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

int main(){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    string A;
    for(int i=0;i<n;i++){
        A.push_back(s[i]);
        A.push_back(t[i]);
    }
    cout << A <<endl;
}

Measured memory_bytes: 256
import java.awt.Point;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	final int INF = 1 << 28;
	int s;
	int t;
	int b;
	double dp[][];

	void run() {
		Scanner sc = new Scanner(System.in);
		while (true) {
			// n
			// s t b
			//
			// n はバッテリーの残ポイント数を示す整数である。 s, t, b
			// はそれぞれ、最初にロボットがいる部屋、充電器のある部屋、倉庫として使っている部屋を示す大文字のアルファベットである。
			int n = sc.nextInt();
			if (n == 0)
				break;

			s = sc.next().charAt(0) - 'A';
			t = sc.next().charAt(0) - 'A';
			b = sc.next().charAt(0) - 'A';
			int x = s % 3;
			int y = (s - x) / 3;
			dp = new double[n + 1][9];
			for (int i = 0; i <= n; i++) {
				Arrays.fill(dp[i], -1);
			}
			double ans = solve(n, new Point(x, y));
			System.out.printf("%.8f\n", ans);
		}
	}

	double solve(int rest, Point pos) {
		int x = pos.x;
		int y = pos.y;
		if (dp[rest][x + 3 * y] >= 0) {
			return dp[rest][x + 3 * y];
		}
		double res = 0;
		if (rest == 0) {
			if (x + 3 * y == t) {
				res = 1.0;
			} else
				res = 0.0;
		} else {
			int dx[] = { 0, 1, 0, -1 };
			int dy[] = { 1, 0, -1, 0 };
			for (int i = 0; i < 4; i++) {
				int nx = x + dx[i];
				int ny = y + dy[i];
				if (nx < 0 || ny < 0 || nx > 2 || ny > 2 || nx + 3 * ny == b) {
					res += 1.0 / 4 * solve(rest - 1, pos);
				} else {
					res += 1.0 / 4 * solve(rest - 1, new Point(nx, ny));
				}
			}
		}
		return dp[rest][x + 3 * y] = res;
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

}

Measured memory_bytes: 0
from collections import Counter
n = int(input())
word_l = list()
for _ in range(n):
  word = ''.join(sorted(list(input())))
  word_l.append(word)
  
word_counter = Counter(word_l)
print('{}'.format(sum(map(lambda x: sum(range(x)), word_counter.values()))))

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

template<typename integer>
integer __lcm(integer a, integer b) {
  return (a * b) / __gcd(a, b);
}

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  // a1枚 b1枚を買うために必要なコスト
  int d = min(a + b, 2 * c);
  int ans1 = 2 * c * max(x, y);

  int ans2 = 0;

  while (!(x == 0 && y == 0)) {
    // cout << x << ", " << y << endl;

    if (x >= 1 && y >= 1) {
      x--;
      y--;
      ans2 += d;
    }

    else if (x >= 1) {
      x--;
      ans2 += a;
    }

    else if (y >= 1) {
      y--;
      ans2 += b;
    }
  }

  cout << min(ans1, ans2) << endl;
  return 0;
}



Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())

cnt = max(x, y)

ans = 1 << 60
for i in range(cnt + 1):
    ans = min(ans, 2 * i * c + max(x - i, 0) * a + max(y - i, 0) * b)

print(ans)

Measured memory_bytes: 9168
from heapq import heapify,heapreplace,heappop
N=int(input())
A=list(map(int,input().split()))
A=[a for a in A]
heapify(A)
while len(A)>1:
    t = heappop(A)
    heapreplace(A,(t+A[0])/2)
print(A[0])


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

int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int n; cin >> n;
        if (n  & 1) {
                cout << "0";
                return 0;
        }
        int ar[100001] = {};
        for (int i = 0; i < n; i++) cin >> ar[i];
        sort(ar, ar + n);
        int md = n / 2;
        cout << ar[md] - ar[md - 1];
return 0;
}


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

using namespace std;

int n,m;
string s,t;
vector<int> a[260];

int main() {
    
    cin >> s >> t;
    
    for (int i = 0; i < (int)s.size(); ++i)
        a[int(s[i])].push_back(i);


    int ini = -1;
    long long cnt = 0;
    for (int i = 0; i < (int)t.size(); ++i) {
        bool flag = 0;
        again:
        int pos = upper_bound(a[(int)t[i]].begin(), a[(int)t[i]].end(), ini) - a[(int)t[i]].begin();
        if(pos == (int)a[(int)t[i]].size()) {
            if(flag) return puts("-1"), 0;
            cnt++;
            ini = -1;
            flag = 1;
            goto again;
        } else ini = a[(int)t[i]][pos];
    }
    
    long long ans = (long long)s.size() * cnt + ini + 1;
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

ll f(ll n)
{
    ll r=0;
    while (n)
    {
        r+=n%10;
        n/=10;
    }
    return r;
}

main()
{
    fast;
    ll n;
    cin>>n;
    if (n%f(n)==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int num = int.Parse(Console.ReadLine());
        String[] arynum = Console.ReadLine().Split(' ');
        int[] aryIntnum = new int[num];

        for (int i = 0; i < num; i++)
        {
            aryIntnum[i] = int.Parse(arynum[i]);
        }

        //Array.Sort(aryIntnum);
        Array.Reverse(aryIntnum);

        for ( int i = 0 ; i < num ; i++ ){

            if (i == 0)
            {
                Console.Write(aryIntnum[i]);
            }
            else
            {
                Console.Write(" " + aryIntnum[i]);
            }
            
        }
        Console.WriteLine();

    }
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0, cnt = 1;
    REP(i, 1, n) {
        if(a[i] == a[i-1]) cnt++;
        else {
            ans += cnt/2;
            cnt = 1;
        }
    }
    ans += cnt/2;

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

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

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

	ll arr[n];
	ll maxi = 0;
	for(ll i=0;i<=n-1;i++){
		cin>>arr[i];
		maxi = max(maxi,arr[i]);
	}


	bool sieve[maxi+1];
	for(ll i=1;i<=maxi;i++){
		sieve[i]=false;
	}

	unordered_map<ll,ll> um1;
	for(ll i=0;i<=n-1;i++){
		if(um1.find(arr[i])==um1.end()){
		for(ll j=arr[i]*2;j<=maxi;j+=arr[i]){
			sieve[j]=true;
		}

	}
	um1[arr[i]]++;

	}

	ll ans  =0;
	for(ll i=0;i<=n-1;i++){
		if(um1[arr[i]]==1 && sieve[arr[i]]==false){
			ans++;
	}
}
cout<<ans;


}

Measured memory_bytes: 13940
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    P = [int(x) - 1 for x in input().split()]
    C = [int(x) for x in input().split()]

    ans = max(C)
    for i in range(N):
        next = P[i]
        cnt = 0
        tmp = 0

        while True:
            tmp += C[next]
            ans = max(ans, tmp)
            cnt += 1
            if cnt == K or next == i:
                break
            next = P[next]

        if cnt == K or tmp <= 0:
            continue

        q = K // cnt
        r = K % cnt
        next = P[i]
        if q != 0:
            tmp *= (q - 1)
            q -= 1
            r += cnt
            ans = max(ans, tmp)
        else:
            tmp = 0
        while r > 0:
            tmp += C[next]
            ans = max(ans, tmp)
            next = P[next]
            r -= 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74196
import java.util.Scanner;
class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int n=scan.nextInt();
    int k=scan.nextInt();
    if(n>=2*k-1){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 23764
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<vector<int>>v(N, vector<int>(N-1));
	rep(i, 0, N)rep(j, 0, N - 1) { cin >> v[i][j]; v[i][j]--; }

	int ans = 0;

	int cnt = 0;
	vector<int>idx(N);
	queue<int>q;
	rep(i, 0, N)q.push(i);
	vector<int>m(N,-1);
	while (cnt < N) {
		if (q.empty()) {
			cout << -1 << endl;
			return 0;
		}
		queue<int>qq;
		while (q.size()) {
			int x = q.front();
			q.pop();
			int y = v[x][idx[x]++];
			if (idx[x] == N - 1) {
				cnt++;
			}
			m[x] = y;
			if (m[y] == x) {
				if(idx[x]<N-1)qq.push(x);
				if(idx[y]<N-1)qq.push(y);
			}
		}
		swap(qq, q);
		ans++;
	}
	cout << ans << endl;

	return 0;
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int j=0,k=1;
    a[0] = 0;
    for (int i = 1; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) b[i] = 0;

    sort(a,a+n);
    // for (int i = 0; i < n; i++) cout << a[i];

    while(1){
        // if (k == n) {
        //     j += 1;
        //     k = 1;
        // }
        if (a[k] == j+1) {
            b[j] ++;
            k ++;
        }else{
            // j += 1;
            j ++;   
        }
        if (j == n || k == n) break;
        
    }

    for (int i = 0; i < n; i++) cout << b[i] << endl;
}

Measured memory_bytes: 5192
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef int status;
typedef long long ll;
typedef unsigned long long ull;
const ull base = 343;
const int INF = int(1e9);
const int MAX = 200002;

int N = 0,n = 0;
char a[10] = {'P','W','G','Y'};

int main()
{
    cin>>n;
    for(int i = 1;i<=n;i++){
        char temp;
        cin>>temp;
        for(int j = 0;j<4;j++){
            if(a[j]==temp){
                N++;
                a[j]=0;
            }
        }
    }
    if(N==3)
        cout<<"Three"<<endl;
    else if(N==4)
        cout<<"Four"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

using namespace std;

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


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}



long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


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

	string s;
	cin>>s;
	char last=s[s.length()-1];

	set<string> words;
	words.insert(s);
	FOR(i,1,N){
		string S;cin>>S;
		words.insert(S);
		if(last!=S[0]){
			cout<<"No"<<endl;
			return 0;
		}
		last=S[S.length()-1];

	}

	if(words.size()==N)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
    int N,M,A[1005],B,i,j,V[1005]={0};
    scanf("%d%d",&N,&M);
    for(i=0;i<N;i++)scanf("%d",&A[i]);
    for(i=0;i<M;i++)
    {
        scanf("%d",&B);
        for(j=0;A[j]>B;j++);
        V[j]++;
    }
    for(i=B=0;i<N;i++)B=V[i]>V[B]?i:B;
    printf("%d\n",B+1);
    return 0;
}

Measured memory_bytes: 2712
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main() {
  int c, a, b;
  cin >> c >> a >> b;
  cout << a * c / 2 << endl;
  return 0;
}

Measured memory_bytes: 256