akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {

    RemovingCoins.init()
    RemovingCoins.execute()

}

class RemovingCoins {

    companion object {

        var N = 0

        var mostFarIndex = 0

        lateinit var matrix: Array<MutableList<Int>>

        fun init() {

            N = readLine()!!.toInt()

            matrix = Array(N) {
                mutableListOf<Int>()
            }

            for (index in 1 until N) {
                val inputs = readLine()!!.split(" ").map(String::toInt)
                matrix[inputs[0] - 1].add(inputs[1] - 1)
                matrix[inputs[1] - 1].add(inputs[0] - 1)
            }

        }

        fun execute() {
            val diametor = calcDiameter()

            if (diametor % 3 == 2) {
                println("Second")
            } else {
                println("First")
            }
        }

        /**
         * 木の直径を求める
         */
        fun calcDiameter(): Int {
            val maxDepthInfo = bfs(0, 0, 0)

//            println(maxDepthInfo)

            val maxDepthInfo2 = bfs(0, maxDepthInfo[1], maxDepthInfo[1])

//            println(maxDepthInfo2)
            // 直径=最大深さ+1
            return maxDepthInfo2[0] + 1
        }

        /**
         * 最大深さとindexを算出
         * 0=>深さ
         * 1=>最大深さのindex
         */
        fun bfs(depth: Int, index: Int, from: Int): MutableList<Int> {

            var maxDepth = mutableListOf(depth, index)
            matrix[index].forEach loop1@{

                // 来た辺には戻らない
                if (it == from) return@loop1

                val targetDepth = bfs(depth + 1, it, index)

                if (maxDepth[0] < targetDepth[0]) {

                    maxDepth = targetDepth
                }
            }

            return maxDepth
        }
    }
}






Measured memory_bytes: 132820
#include<iostream>
#include<cstring>
using namespace std;
int n,m;
int cnt;
bool p[100000];
main()
{
	while(cin>>n>>m,n)
	{
		cnt=n;
		for(int i=0;i<n;i++)p[i]=1;
		int i=0,j=1;
		for(;cnt>1&&j<=m;j++)
		{
			string s;cin>>s;
			string t=to_string(j);
			if(j%15<1)t="FizzBuzz";
			else if(j%5<1)t="Buzz";
			else if(j%3<1)t="Fizz";
			if(s!=t)cnt--,p[i]=0;
			i=(i+1)%n;
			while(!p[i])i=(i+1)%n;
		}
		for(;j<=m;j++)
		{
		    string s;cin>>s;
		}
		int f=0;
		for(int i=0;i<n;i++)if(p[i])cout<<(f++?" ":"")<<i+1;
		cout<<endl;
	}
}



Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
using namespace std;

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

const int INF = 1e9;
const int MAX_V = 1e6+1;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

int a, b;

int main() {
  cin >> a >> b;
  cout << ((max(a, b) > 8) ? ":(" : "Yay!") << endl;
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    string s,t;
    cin >> s >> t;

    int translation[26], used[26];
    fill(translation, translation+26, -1);
    fill(used, used+26, 0);
    for(int i=0;i<s.length();i++){
        int c = s[i] - 'a';
        if(translation[c] == -1){
            int cc = t[i] - 'a';
            if(used[cc]){
                cout << "No" << endl;
                return 0;
            }else{
                translation[c] = cc;
                used[cc] = 1;
            }
            
        }else{
            if(translation[c] != t[i] - 'a'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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



accum = [0] * N
accum[0] = A[0]
for i in range(1,N):
    accum[i] = accum[i-1] + A[i]


# +-+-+-+-
ans1 = 0
tmp = [0] * N
for i in range(N):
    if i == 0:
        tmp[i] = A[i]
    else:
        tmp[i] = tmp[i-1] + A[i]

    if i % 2 == 0:
        if tmp[i] <= 0:
            ans1 += abs(tmp[i]) + 1
            tmp[i] = 1
    else:
        if tmp[i] >= 0:
            ans1 += abs(tmp[i]) + 1
            tmp[i] = -1

# -+-+-+-+
ans2 = 0
tmp = [0] * N
for i in range(N):
    if i == 0:
        tmp[i] = A[i]
    else:
        tmp[i] = tmp[i-1] + A[i]

    if i % 2 == 1:
        if tmp[i] <= 0:
            ans2 += abs(tmp[i]) + 1
            tmp[i] = 1
    else:
        if tmp[i] >= 0:
            ans2 += abs(tmp[i]) + 1
            tmp[i] = -1

print(min(ans1,ans2))



Measured memory_bytes: 63216
fn main(){
  let n: u32 = read();

  for _ in 0 .. n {
    let mut v: Vec<Vec<usize>> = Vec::new();
    
    v.push(vec![0; 10]);
    
    for _ in 0 .. 10 {
      v.push(read_vec());
    }

    for i in 0 .. 1024 {
      let mut cv = v.clone();
      for j in 0 .. 10 {
        if i & (1 << j) > 0 {
          cv[0][j] = 1;
        } else {
          cv[0][j] = 0;
        }
      }
      match pass(&mut cv) {
        Some(ans) => {print_vec(&ans); break;},
        None => {},
      }
    }
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}

fn print_vec(v: &Vec<Vec<usize>>) -> (){
  let l = v[0].len();

  for x in v {
    for i in 0 .. l {
      if i == l - 1 {
        println!("{}", x[i]);
      } else {
        print!("{} ", x[i]);
      }
    }
  }
}

fn pass(v: &mut Vec<Vec<usize>>) -> Option<Vec<Vec<usize>>> {
  let mut ans: Vec<Vec<usize>> = vec![vec![0; 10]; 10];
  let dv: Vec<(isize, isize)> = vec![(0, 0), (-1, 0), (1, 0), (0, -1), (0, 1)];
  
  for i in 1 .. 11 {
    for j in 0 .. 10 {
      if v[i-1][j] == 1 {
        ans[i-1][j] = 1;
        for &(di, dj) in &dv {
          let ni = i as isize + di;
          let nj = j as isize + dj;
          if ni >= 0 && ni <= 10 && nj >= 0 && nj <= 9 {
            v[ni as usize][nj as usize] = 1 - v[ni as usize][nj as usize];
          }
        }
      }
    }
  }
  
  if v[10] == vec![0; 10] {
    Some(ans)
  } else {
    None
  }
}



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

int main() {
  int N,M,cnt; cin >> N >> M;
  string A[50],B[50];
  for ( int i = 0; i < N; i++ ) cin >> A[i];
  for ( int i = 0; i < M; i++ ) cin >> B[i];
  if ( M > N ) {
    cout << "No" << endl;
    return 0;
  } else if ( M == N ) {
    cnt = 0;
    for ( int i = 0; i < N; i++ ) {
      for ( int j = 0; j < N; j++ ) {
	if( A[i][j] == B[i][j] ) cnt++;
      }
    }
  
    if ( cnt == N*N ) {
      cout << "Yes" << endl;
      return 0;
    } else {
      cout << "No" << endl;
      return 0;
    }
  } else {
    for ( int k = 0; k < N-M; k++ ) {
      for ( int l = 0; l < N-M; l++ ) {
      	int cnt = 0;
	for ( int i = 0; i < M; i++ ) {
	  for ( int j = 0; j < M; j++ ) {
	    if ( A[i+k][j+l] == B[i][j] )cnt++;
	    if ( cnt == M*M ) {
	      cout << "Yes" << endl;
	      return 0;
	    }
	  }
	}
      }
    }
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=next[i])
#define repvc(i,vc) for(int i=0,_sz=vc.size();i<_sz;++i)
using namespace std;

const int INF=1<<30;
typedef long long ll;

inline int read()
{
	int ret=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0'&&ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

const int maxn=100000+10;

int bom[maxn],dp[maxn];

int main()
{
	int n,m;cin>>n>>m;
	rep(i,1,m) {
		bom[read()]=1;
	}
	dp[0]=1;
	rep(i,1,n) if(!bom[i]) dp[i]=(dp[i-1]+(i>1?dp[i-2]:0))%(int)(1e9+7);
//	rep(i,1,n) printf("dp[%d]=%d bom[%d]=%d\n",i,dp[i],i,bom[i]);
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main()
{
    int A, B;
    char S[20], T[20], U[20];
    scanf("%s %s", S, T);
    scanf("%d %d", &A ,&B);
    scanf("%s",U);
    if((strcmp(U,S)) == 0){
    	A--;
    }
    else{
    	B--;
    }
    printf("%d %d", A, B);
    return 0;
}

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

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

const ll INF = 1LL << 60;

int main() {
    int N, M; cin >> N >> M;
    vector<pair<ll, ll>> S(N);
    for (int i = 0; i < N; i++) {
        ll f, s; scanf("%lld %lld", &f, &s);
        S[i] = make_pair(f, s);
    }
    sort(S.begin(), S.end());

    ll sum = 0;
    int rem = M;
    for (auto s : S) {
        ll price = s.first;
        ll drink = s.second;
        if (rem - drink <= 0) {
            sum += price * rem;
            break;
        }
        sum += price * drink;
        rem -= drink;
    }

    cout << sum << endl;

    return 0;
}

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

int main()
{
    int n; cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    for (int i = 0; i < n; i++) cin >> y[i];
    
    double a = 0.0, b = 0.0, c = 0.0, d = 0.0, e;
    for (int i = 0; i < n; i++) {
        e = abs((double)x[i] - y[i]);
        a += abs(e);
        b += pow(e, 2);
        c += pow(e, 3);
        d = max(e, d);
    }
    
    printf("%.10lf\n%.10lf\n%.10lf\n%.10lf\n", a, sqrt(b), cbrt(c), d);
}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    string t = "KIHBR";
    string tmp = "";
    rep (i, s.size()) {
        if (s[i] == 'A') continue;
        else tmp += s[i];
    }
    if (tmp != t) {
        cout << "NO" << endl;
        return 0;
    }
    int cnt = 0;
    int pos = 0;
    bool ok = true;
    rep (i, s.size()) {
        if (s[i] != 'A') {
            if ((pos == 0 || pos == 3 || pos == 4) && cnt > 1) ok = false;
            else if ((pos == 1 || pos == 2) && cnt > 0) ok = false;
            cnt = 0;
            pos++;
        } else {
            cnt++;
            if (pos > 4 && cnt > 1) ok = false;
        }
    }
    if (ok) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef pair<int, int> P;
typedef pair<int, P> state;
const int INF = 1 << 28;

map<string, int> cnt;
bool used[20][20];
string s[20];
int h, w;
int dx[] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy[] = {0, -1, 1, -1, 1, 0, -1, 1};

void make_string(int y, int x){
  
  rep(k, 8){
    int i = y;
    int j = x;
    string str;
    memset(used, 0, sizeof(used));
    while(!used[i][j]){
      str += s[i][j];
      cnt[str]++;
      used[i][j] = true;
      i += dy[k];
      j += dx[k];
      i = (i + h) % h;
      j = (j + w) % w;
    }
  }
}

int main(){
  while(cin >> h >> w && (h || w)){
    string res = "";
    cnt.clear();
    rep(i, h) cin >> s[i];
    rep(i, h)rep(j, w){
      make_string(i, j);
    }
    
    for(map<string, int>::iterator iter = cnt.begin(); iter != cnt.end(); iter++){
      if(iter->second > 1 && (iter->first).size() > res.size()) res = iter->first;      
    }
  
    if((int)res.size() < 2) res = "0";
    cout << res << endl;
  }
  return 0;
}

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

int** make2dArray(int x,int y){
	int** array = (int**)malloc(sizeof(int*) * x);
	for (int i = 0; i < x; i++) {
		array[i] = (int*)malloc(sizeof(int) * y);
	}
	return array;
}
void printArray(int* a, int length) {
	for (int i = 0; i < length; i++) {
		printf("%d ", a[i]);
	}
}
void print2dIntArray(int** a,int x,int y) {
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			if (j == y - 1) {
				printf("%d\n", a[i][j]);
			}
			else {
				printf("%d ", a[i][j]);
			}
		}
	}
}
void print2dLongArray(long long** a, int x, int y) {
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			if (j == y - 1) {
				printf("%llu\n", a[i][j]);
			}
			else {
				printf("%llu ", a[i][j]);
			}
		}
	}
}
int* getColFromArray(int** array, int x, int j) {
	int* a = (int*)malloc(sizeof(int) * x);
	for (int i = 0; i < x; i++) {
		a[i] = array[i][j];
	}
	return a;
}
long long int arrayTimes(int* a1, int* a2, int length) {
	long long int res = 0;
	for (int i = 0; i < length; i++) {
		res = res + a1[i] * a2[i];
	}
	return res;
}
int main() {
	int n, m, l;
	scanf("%d%d%d", &n, &m, &l);
	int** a = make2dArray(n, m);
	int** b = make2dArray(m, l);
	unsigned long long int** c = (unsigned long long int**)malloc(sizeof(unsigned long long int*) * n);
	for (int i = 0; i < n; i++) {
		c[i] = (unsigned long long int*)malloc(sizeof(unsigned long long int) * l);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < l; j++) {
			scanf("%d", &b[i][j]);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			int* bCol = getColFromArray(b, m, j);
			c[i][j] = arrayTimes(a[i], bCol, m);
		}
	}
	print2dLongArray(c, n, l);
}




Measured memory_bytes: 6028
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;

int findIndex( int value );

int main(void){
    char c[3][3];

    REP(i,3)
        REP(j,3)
            cin >> c[i][j];
    
    REP(i,3)
        cout << c[i][i];

    return 0;
}

Measured memory_bytes: 256
//
// Created by chuan on 2020-04-11.
//

//
// Created by chuan on 2020-04-11.
//


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <numeric>

using ll = long long;

using namespace std;

const ll MOD = 1e9+7;
int main() {
    ios_base::sync_with_stdio(false);
    ll N, K; cin>>N>>K;

    ll total = 0;
    //expand with gcd vals, then count how many possible ways we can construct such array, the rest only has gcd of 1.
    vector<ll> powN(K+1,0);
    auto power_ = [](ll a, ll b) {
        ll r=1;
        while(b){
            if(b&1) r= (r * a) % MOD;
            a= ((a * a) % MOD);
            b>>=1;
        }
        return r;
    };
    for (int i = K; i >= 1; -- i) {
        auto q = K/i;
        powN[i] = power_(q, N);

        for (int j = 2; j*i <= K; ++ j){
            powN[i] = (powN[i] + MOD - powN[j*i]) % MOD;
        }
    }
    for (int j = 1; j <= K; ++ j) {
        total = (total + powN[j] * j) % MOD;
    }
    cout<<total<<endl;

    return 0;
}


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

int main()
{
 
 long long  int H;
  cin>>H;
  
  long long int A;
  cin>>A;
  
  long long int attack=0;
  
  while(H>0)
  {
    H=H-A;
    attack++; 
  }
  cout<<attack<<endl;
  return 0;
}
  
  


Measured memory_bytes: 256
n, m, l = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
c = [[0 for i in range(l)] for j in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
for i in range(n):
    print(" ".join(map(str, c[i])))



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

using namespace std;

#define ll long long
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef set<int> si;
typedef set<vi> svi;
typedef set<ll> sll;
typedef set<vll> svll;
typedef set<pii> spii;
typedef set<vpii> svpii;
typedef set<pll> spll;
typedef set<vpll> svpll;
typedef vector<si> vsi;
typedef vector<sll> vsll;
typedef vector<spii> vspii;
typedef vector<spll> vspll;
#define ft first
#define sc second
#define pb push_back
#define ins insert
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define sortarr(a,n) sort(a,a+n)
#define tt ll tc; cin >> tc; while(tc--)
#define rep(var,start,end,interval) for(ll var=start;(interval>0 and var<end) or (interval<0 and var>end);var+=interval)
#define each(x,v) for(auto x : v)
#define takearr0(a,n) rep(z,0,n,1) cin >> a[z];
#define takearr1(a,n) rep(z,1,n+1,1) cin >> a[z];

ll x,k,d;

int main()
{
	io;
	cin >> x >> k >> d;
	x = abs(x);
	ll ans;
	if(k <= (x/d))
		ans = x - (k*d);
	else
	{
		k -= x / d;
		x -= d * (x / d);
		if(k&1)
			ans = abs(x-d);
		else
			ans = x;
	}
	cout << ans << endl;
	return 0;
}

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

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        long sum= 0;

        for(int i =1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                for(int k = 1; k<=n; k++){
                    sum += getGCD(i,getGCD(j,k));
                }
            }
        }
        System.out.println(sum);
    }

    private static long getGCD(long a, long b){
        if(a%b == 0){
            return b;
        }
        else {
            return getGCD(b, a%b);
        }
    }
}

Measured memory_bytes: 32708
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;


int main(void)
{
	int n, k;

	while(scanf("%d%d", &n, &k)==2)
	{
		vi s(n+1);

		for(;k>0;k--)
		{
			int d;
			scanf("%d", &d);
			for(;d>0;d--)
			{
				int a;
				scanf("%d", &a);
				s[a]++;
			}
		}

		int ans=0;
		for(int i=1;i<=n;i++)
		{
			if(s[i]==0) ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll x,y;cin>>x>>y;
	ll ans;
	if (x <= y){
		ans = abs(y - x);
		if (x < 0 && abs(x) <= y){
			ans = min(ans,1 + y - abs(x));
		}
		else if (x < 0 && abs(x) > y){
			ans = min(ans,1 + abs(abs(y) - abs(x)));

		}
	}
	else{
			ans = 1 + abs(abs(y) -  abs(x));
			if(x * y > 0){
			ans = 2 + abs(abs(y) - abs(x));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;

const ll DENOMI = 1000000007;

int main()
{
	ll h, w, k;
	cin >> h >> w >> k;
	auto ans = vector<vector<ll>>(h + 1, vector<ll>(w + 1, 0));
	ans[0][0] = 1;
	auto select = vector<bool>(w);
	auto rec = [&](auto rec, int f, int rem, int s) -> void {
		if(rem == 0){
			for(auto i = 0; i < w; ++i){
				if(select[i]){
					ans[f][i] = (ans[f][i] + ans[f - 1][i + 1]) % DENOMI;
					ans[f][i + 1] = (ans[f][i + 1] + ans[f - 1][i]) % DENOMI;
					++i;
				} else{
					ans[f][i] = (ans[f][i] + ans[f - 1][i]) % DENOMI;
				}
			}
			return;
		}
		if(s >= w - 1){
			return;
		}
		rec(rec, f, rem, s + 1);
		select[s] = true;
		rec(rec, f, rem - 1, s + 2);
		select[s] = false;
	};

	for(auto i = 1; i <= h; ++i){
		for(auto j = 0; j <= w / 2; ++j){
			rec(rec, i, j, 0);
		}
	}

	cout << ans[h][k - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string>
#include <sstream>

#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define repr(i, a, b) for(int i = (a); i >= (b); i--)
#define range(x) begin(x), end(x)

#define dump(x) cerr << #x << " : " << x << '\n'

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

const int iinf = 1 << 29;
const ll linf = 1l << 61;

int main(int argc, char* argv[])
{
	ll N;
	scanf("%lld", &N);
	ll s = std::pow(N, 0.5);
	printf("%lld", s * s);
	return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<Integer> s = new HashSet<>();

        for (int i = 0; i < n; i++) {
            if(!s.add(sc.nextInt())){
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}

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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
int ncr(int n,int r)
{
    int ans=1;
    for(int i=1;i<=r;++i)
    {
        ans = (((ans*n)%mod)*(powmod(i,mod-2)))%mod;
        n--;
    }
    return ans;
 
}
const int N = 5e5+5;
		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int s;
		cin>>s;
		if(s<3)
		cout<<0;
		else
		{
			int ans = 0;
			for(int i=0;i<s;++i)
			{
				int res = s-3*(i+1);
				if(res<0)
				break;
				(ans+=ncr(res+i,res))%=mod;
			}
			cout<<ans;
		}		
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    map<string, int> mp;
    int N, M;
    cin >> N;
    vector<string>S(N,"");
    for (int i = 0; i < N; i++) {
        cin >> S[i];
        mp[S[i]]++;
    }
    cin >> M;
    vector<string>T(M,"");
    for (int i = 0; i < M; i++) {
        cin >> T[i];
        mp[T[i]]--;
    }
    
    int ans = 0;
    for (auto i : mp) {
        ans = max(ans ,i.second);
    }
    cout << ans << endl;
}


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

int main() {
  int K;
  string S;
  cin >> K >> S;
  
  if(S.size() <= K){
    cout << S;
  }
  else{
    for(int i = 0; i < K; i++){
      cout << S.at(i);
    }
    cout << "...";
  }
}



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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 998244353;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);


    ll n, s;
    cin >> n >> s;
    vector<ll> a(n);
    for(auto &e: a) cin >> e;
    vector<vector<int>> dp(n+1, vector<int>(s+1));
    dp[0][0] = 1;
    for(ll i=1; i<=n; i++)
        for(ll j=0; j<=s; j++) {
            (dp[i][j] = dp[i-1][j] * 2) %= MOD;
            if(j-a[i-1]>=0)
                (dp[i][j] += dp[i-1][j-a[i-1]]) %= MOD;
        }
    cout << dp[n][s] << endl;
}


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

typedef long long ll;

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

    if( a == b )
	cout << c << endl;
    if( c == b )
	cout << a << endl;
    if( a == c )
	cout << b << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
$stdin.read.split(?\n).map { |line| line.split(?\s).map(&:to_i) }.tap do |(n, k), *ls|
  ps = []
  xs = []
  ys = []
  ls.each do |x, y|
    ps << [x, y]
    xs << x
    ys << y
  end
  xs.sort!
  ys.sort!

  ss = Array.new(n+1) { Array.new(n+1) { 0 } }

  n.times do |i|
    n.times do |j|
      ss[j+1][i+1] = ps.select { |x, y| x <= xs[i] && y <= ys[j] }.length
    end
  end

  min_size = 1.0/0
  0.upto(n-1) do |xi|
    xi.upto(n-1) do |xj|
      0.upto(n-1) do |yi|
        yi.upto(n-1) do |yj|
          if (ss[yj+1][xj+1] - ss[yi][xj+1] - ss[yj+1][xi] + ss[yi][xi] >= k)
            size = (xs[xj] - xs[xi]) * (ys[yj] - ys[yi])
            min_size = min_size < size ? min_size : size
          end
        end
      end
    end
  end
  puts min_size
end

Measured memory_bytes: 3836
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int n;
  cin >> n;
  int p[n], q[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> q[i];
  }

  vector<int> array(n);
  for (int i = 1; i <= n; i++) {
    array[i - 1] = i;
  }
  int pn = 0, qn = 0;
  do {
    int a = 0;
    int pp = 0;
    int qq = 0;
    for (int i = 0; i < n; i++) {
      a = a * 10 + array[i];
      pp = pp * 10 + p[i];
      qq = qq * 10 + q[i];
    }
    if (pp > a) {
      pn++;
    }
    if (qq > a) {
      qn++;
    }
  } while (next_permutation(array.begin(), array.end()));
  cout << abs(pn - qn) << endl;
}

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


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int[] time = new int[5];
      	for(int i = 0; i < 5; i++){
        	time[i] = sc.nextInt();
		}
      	int[] dt = new int[5];
        for(int i = 0; i < 5; i++){
        	if(time[i] % 10 == 0){
            	dt[i] = time[i];
            }else{
            	dt[i] = (time[i] / 10) * 10 + 10;
            }
        }
        
        int max = 0;
        int total = 0;
        for(int i = 0; i < 5; i++){
        	if(dt[i] - time[i] > max){
            	max = dt[i] - time[i];
            }
            total += dt[i];
        }
        System.out.println(total - max);
     }
}

Measured memory_bytes: 35796
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
//#define sz(x) (int)(x.size())
#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
const int N=1000005;
void solve()
{
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
    sort(h,h+n);
    k=min(n,k);
    int ans=0;
    for(int i=n-k-1;i>=0;i--)
    {
        ans=ans+h[i];
    }
    cout<<ans<<endl;
        
}
int32_t main()
{
   
    IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}




Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int n, k;
  scanf(" %d %d", &n, &k);

  string ans = "NO";
  if(n >= k * 2 - 1) {
    ans = "YES";
  }
  cout << ans << '\n';

  return 0;
}


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

int main(){
    int n,m,x;
    cin>>n>>m>>x;
    int sr=0,sl=0;
    for(int i=0;i<m;i++){
        int a;cin>>a;
        (a>x)?sr++:sl++;
    }
    int ans=min(sr,sl);
    cout<<ans<<endl;
}

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

#define mod 1000000007
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repx(i,x,n) for(int i=x;i<n;i++)


int main(void) {
    int n;cin>>n;
    int cnt=0;
    repx(i,1,n+1)if(i%2!=0)cnt++;
    double ans=(double)cnt/n;
    cout<<ans;
}

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

using namespace std;

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

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


// ******************************CODE**********************************//




struct UnionFind {
        vector<int> par;

        UnionFind(int N) : par(N){
                for(int i = 0; i < N; i++) par[i] = i;
        }

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

        void Union(int x, int y){
                int rx = root(x);
                int ry = root(y);
                if(rx == ry) return;
                par[rx] = ry;
        }

        bool same(int x, int y){
                int rx = root(x);
                int ry = root(y);
                return rx == ry;
        }
};

int main(){
        int N,M;
        cin >> N >> M;
        vector<int> p(N);
        for(int i = 0; i < N; i++){
                cin >> p[i];
                p[i]--;
        }

        UnionFind tree(N);

        vector<int> x(M), y(M);
        for(int i = 0; i < M; i++){
                cin >> x[i] >> y[i];
                x[i]--;
                y[i]--;
                tree.Union(x[i],y[i]);
        }

        int ans = 0;
        for(int i = 0; i < N; i++){
                if(tree.same(i,p[i])){
                        ans++;
                }
        }

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



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

int main() {
  int N,K;
  cin >> N >> K;
  
  int A;
  vector<int> cnt(N);
  for(int i=0; i<N; i++){
    cin >> A;
    cnt.at(A-1)++;
  }
  
  sort(cnt.begin(),cnt.end());
  
  int ans=0;
  for(int i=0; i<N-K; i++){
    ans += cnt.at(i);
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 4048
import numpy as np
N, W = map(int, input().split())
wvs = [list(map(int, input().split())) for _ in range(N)]

INF = 10 ** 12
L = 10 ** 5 + 1

dp = np.full(L, INF, dtype=int)
dp[0] = 0

for w, v in wvs:
    np.minimum(
        dp[:L-v] + w,
        dp[v:],
        out=dp[v:]
    )

answer, = np.where(dp <= W)
print(answer[-1])


Measured memory_bytes: 13980
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const int INF = INT_MAX;
const ll inf = 1e18;
const ll mod = 998244353;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x, ll y){ if(x>y) swap(x, y);while(x!=0){ y%=x; swap(x, y); }return y; }
ll mpow(ll x, ll r){if(r==0) return 1;if(r%2==1){ return x*mpow(x, r-1)%mod; }else{ ll aa = mpow(x, r/2); return aa*aa%mod; }}

void Z_algo(vector<int> s, vector<int>& z){
	int c = 0, n = s.size();
	z.resize(n, 0);
	for(int i=1; i<n; i++){
		if(i+z[i-c] < c+z[c]){
			z[i] = z[i-c];
		}else{
			int j = max(0, c+z[c]-i);
			while(i+j < n && s[j] == s[i+j]) j++;
			z[i] = j;
			c = i;
		}
	}
	z[0] = n;
}

int main(){
	int N; cin >> N;
	vector<int> a(N), b(N);
	vector<int> s, z;
	rep(i, N) cin >> a[i];
	rep(i, N) cin >> b[i];
	rep(i, N) s.pb(b[i]^b[(i+1)%N]);
	rep(i, 2*N) s.pb(a[i%N]^a[(i+1)%N]);
	Z_algo(s, z);
	REP(i, N, 2*N){
		if(z[i] >= N) cout << i%N << " " << (a[i%N]^b[0]) << endl;
	}
	return 0;
}


Measured memory_bytes: 11076
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

n = int(input())
a = list(map(int, input().split()))
r = []
l = []
t = a[0]
for i in a:
    t = gcd(t, i)
    l.append(t)
t = a[-1]
for i in a[::-1]:
    t = gcd(t, i)
    r.append(t)
r = r[::-1]
ans = 0
for i in range(n):
    if i == 0:
        ans = max(ans, r[1])
        continue
    if i == n - 1:
        ans = max(ans, l[-2])
        continue
    ans = max(ans, gcd(l[i-1], r[i+1]))

print(ans)


Measured memory_bytes: 69996
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

vecveci dp(110,veci(100010,0));

int main() {
    int N,W;
    cin >> N >> W;
    veci v(N),w(N);
    REP(i,N) cin >> v[i] >> w[i];
    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= W; j++) {
            if(w[i] > j) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i]);
        }
    }
    cout << dp[N][W] << endl;
}



Measured memory_bytes: 46280
N = int(input())
x = input().split()
y = input().split()

x = [int(j) for j in x]
y = [int(z) for z in y]
d1 = 0
d2 = 0
d4 = []
d3 = 0
for i in range(N):
    d1 += abs(x[i]- y[i])
    d2 += (x[i]-y[i])**2
    d3 += abs(x[i]-y[i])**3
    d4.append(abs(x[i]- y[i]))
d2_root = d2**0.5
d3_root = d3**(1/3)
print('{:.08f}'.format(d1))
print('{:.08f}'.format(d2_root))
print('{:.08f}'.format(d3_root))
print('{:.08f}'.format(max(d4)))


Measured memory_bytes: 5656
S = input()
T = input()

count_s = []
count_t = []
# 要素の出現回数のリストを作成
iterator = 'abcdefghijklmnopqrstuvwxyz'
for a in iterator:
    count_s.append(S.count(a))
    count_t.append(T.count(a))

count_s.sort()
count_t.sort()

if count_s == count_t:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3632
#include<iostream>

using namespace std;

int main(){
    int N,M;cin>>N>>M;
    int a[2];
    int tmp1,tmp2;
    cin >> a[0] >> a[1];
  	if(M==1) cout << a[1]-a[0]+1<<endl;
  	else {
      for(int i=1;i<=M;i++){
          cin >> tmp1 >> tmp2;
          if(a[0]<tmp1) a[0] = tmp1;
          if(a[1]>tmp2) a[1] = tmp2;
      }
      if(a[1]-a[0]>=0){
         cout << a[1]-a[0]+1 << endl;
      } else {
          cout<<0<<endl;
      }
    }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10**9 + 7

YArea = 0
for i in range(M - 1):
    YArea += (Y[i + 1] - Y[i]) * (i + 1) * (M - 1 - i)
    YArea %= MOD

ans = 0
for i in range(N - 1):
    ans += YArea * (X[i + 1] - X[i]) * (i + 1) * (N - 1 - i)
    ans %= MOD

print(ans)

Measured memory_bytes: 18624
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
int main()
{
	char s[5];
	cin>>s;
	if(s[1]=='R')
	cout<<"ABC"<<endl;
	else
	cout<<"ARC"<<endl;
}

Measured memory_bytes: 3632
#include<cstdio>

using namespace std;

int main()
{
    int i,n,a,ans=0,b[100000]={0};
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a);
        if(a<=n)b[a-1]++;
        else ans++;
    }
    
    for(i=1;i<=n;i++)
    {
        if(b[i-1]>=i)ans+=(b[i-1]-i);
        else if(b[i-1]>0)ans+=b[i-1];
    }
    printf("%d",ans);
}

Measured memory_bytes: 512
"""
A = a1,a2,a3,a4,...
同じ色のとき、i<jならai<aj

が成り立つときの最小の色の数
"""

from bisect import bisect_right

prev = 10**9+7
cnt = 0
As = [-prev]
n = int(input())
for _ in range(n):
    a = int(input())
    update = bisect_right(As,-a)
    if update-1 == cnt:
        As.append(-a)
        cnt += 1
    else:
        As[update] = -a 
    prev = a

print(cnt)



Measured memory_bytes: 7068
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
	int n, * ddd = NULL, sum = 0;
	if (scanf("%d", &n) == 1)
	{
		ddd = (int*)calloc(n, sizeof(int));
		for (int i = 0; i < n; i++)
		{
			scanf("%d", ddd + i);
		}
		for (int x = 0; x < n - 1; x++)
		{
			for (int y = x + 1; y < n; y++)
			{
				sum += (*(ddd + x)) * (*(ddd + y));
			}
		}
		printf("%d", sum);
		free(ddd);
	}
}

Measured memory_bytes: 128
#include<iostream>//hdu1565
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<map>
#include<cmath>
#include<queue>
#include<set>
#include<string>
using namespace std;
typedef pair<int,int> P;
typedef long long LL;
typedef unsigned long long ULL;
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
const int maxn=40005;
int main()
{
    string s;
    cin>>s;
    string str;
    char pre='h';
    for(int i=0;i<s.size();i++){
        str+=pre;
        if(pre=='h'){
            pre='i';
        }
        else{
            pre='h';
        }
    }
    if(s.size()%2){
        printf("No\n");
    }
    else{
        int f=0;
        for(int i=0;i<s.size();i++){
             if(s[i]!=str[i]){
                f=1;
                break;
             }
        }
        if(f){
            printf("No\n");
        }
        else{
            printf("Yes\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
precount = 0
if n==1:
    ans = 1
for i in range(1, n+1):
    tmp = i
    flag = 1
    count = 0
    while flag :
        flag = 0
        if i%2 == 0:
            i = i//2
            flag = 1
            count += 1
    if precount < count :
        precount = count
        ans = tmp
        
    
            

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

ll a[5005], dp[5005] = { 0 };

int main() {
	ll N, K;
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		a[i] = min(K, a[i]);
	}
	dp[0] = 1;
	for (int i = 0; i < N; ++i) {
		for (int j = K - a[i] - 1; j >= 0; --j) dp[j + a[i]] += dp[j];
	}
	ll ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < K - a[i]; ++j) dp[j + a[i]] -= dp[j];
		bool b = 1;
		for (int j = K - a[i]; j < K; ++j) {
			if (dp[j]) b = 0;
		}
		ans += b;
		for (int j = K - a[i] - 1; j >= 0; --j) dp[j + a[i]] += dp[j];
	}
	cout << ans << '\n';
}

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

using namespace std;

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

    int n;
    while (cin >> n, n)
    {
        char a[52] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
        int k[n + 1];
        for (int i = 0; i < n; i++)
            cin >> k[i];
        string s;
        cin >> s;
        int len = s.length();
        for (int i = 0; i < len; i++)
        {
            int idx;
            if (s[i] >= 'a')
                idx = (s[i] - 'a');
            else
                idx = s[i] - 'A' + 26;
            idx = ((idx + 52 - k[i % n]) % 52);
            cout << a[idx];
        }
        cout << endl;
    }
}


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

int main() {
	int n, d; cin >> n >> d;
	int p[10][20];

	for (int i = 0; i < n; i++)
		for (int j = 0; j < d; j++)
			cin >> p[i][j];

	int ans = 0;

	for (int a = 0; a < n; a++)
		for (int b = a + 1; b < n; b++) {
			int e = 0;
			for (int dd = 0; dd < d; dd++) {
				int x = p[a][dd] - p[b][dd];
				e += x * x;
			}
			for (int i = 0;; i++) {
				if (i * i == e) {
					ans++; break;
				}
				else if (i*i > e) {
					break;
				}
			}
		}

	cout << ans << endl;

	return 0;
}


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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            char sArr[] = makeCharArr(br.readLine());
            sArr = charSortAsc(sArr);
            char tArr[] = makeCharArr(br.readLine());
            tArr = charSortDesc(tArr);
            int length;
            if (sArr.length > tArr.length) {
                length = tArr.length;
            } else {
                length = sArr.length;
            }
            String ans = "";
            for (int i = 0; i < length; i++) {
                char s = sArr[i];
                char t = tArr[i];
                if (t > s) {
                    ans = "Yes";
                    break;
                } else if (s > t) {
                    ans = "No";
                    break;
                }
            }
            if ("".equals(ans)) {
                if (tArr.length > length) {
                    ans = "Yes";
                } else {
                    ans = "No";
                }
            }
            System.out.println(ans);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static char[] makeCharArr(String str) {
        char charArr[] = new char[str.length()];
        for (int i = 0; i < str.length(); i++) {
            charArr[i] = str.charAt(i);
        }
        return charArr;
    }

    public static char[] charSortAsc(char charArr[]) {
        for (int i = 0; i < charArr.length - 1; i++) {
            for (int j = i + 1; j < charArr.length; j++) {
                if (charArr[i] > charArr[j]) {
                    char tmp = charArr[i];
                    charArr[i] = charArr[j];
                    charArr[j] = tmp;
                }
            }
        }
        return charArr;
    }

    public static char[] charSortDesc(char charArr[]) {
        for (int i = 0; i < charArr.length - 1; i++) {
            for (int j = i + 1; j < charArr.length; j++) {
                if (charArr[i] < charArr[j]) {
                    char tmp = charArr[i];
                    charArr[i] = charArr[j];
                    charArr[j] = tmp;
                }
            }
        }
        return charArr;
    }
}


Measured memory_bytes: 21200
#include<iostream>
#include<fstream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<string.h>
#include<algorithm>
using namespace std;
int n,a[30],b[30];
string st;
int main()
{
	cin>>n;
	for(int i=1; i<=26; i++)
		b[i]=100;
	for(int i=1; i<=n; i++)
	{
		cin>>st;
		for(int j=1; j<=26; j++)
			a[j]=0;
		for(int j=0; j<st.size(); j++)
			a[st[j]-96]++;
		for(int j=1; j<=26; j++)
			b[j]=min(a[j],b[j]);
	}
	for(int i=1; i<=26; i++)
		if(b[i]!=100)
			for(int j=1; j<=b[i]; j++)
				cout<<char(i+96);
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize, r: usize
    };

    let res = if n >= 10 { r } else { r + (100 * (10 - n)) };
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (abs(a - b) >= 1e18) {
        cout << -1 << endl;
        return 0;
    }
    if (k % 2) cout << b - a << endl;
    else cout << a - b << endl;
    
    return 0;
}



Measured memory_bytes: 256