akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Program {
    static Scanner sc = new Scanner();

    internal static void Main(string[] args) {
        int N = sc.nextInt();
        int K = sc.nextInt();
        var x = sc.ArrayInt(N);

        var idx = 0;
        for (int i = 0; i < N; i++) {
            idx = i;
            if (x[i] >= 0) { break; }
        }

        var hoge = new List<long>();
        var init = Math.Max(idx - K, 0);
        var end = idx;
        if (idx + K > x.Length) {
            end = N - K;
        }

        for (int i = init; i <= end; i++) {
            var piyo = 0;
            if (x[i] < 0) {
                piyo = x[i];
            }

            var foo = 0;
            if (x[i + K - 1] >= 0) {
                foo = x[i + K - 1];
            }

            //sum = Math.Abs(0 - x[i]) + Math.Abs(x[i] - x[i + K - 1]);
            var sum1 = Math.Abs(0 - piyo) + Math.Abs(piyo - x[i + K - 1]);
            var sum2 = Math.Abs(0 - foo) + Math.Abs(foo - x[i]);
            hoge.Add(Math.Min(sum1, sum2));
        }




        WriteLine(hoge.Min());
    }
}




class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {

        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

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

int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];

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

  int64_t res = 0;
  for (int i = 1; i < N; ++i) {
    res += A[i / 2];
  }

  cout << res << endl;

  return 0;
}



Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  string s; cin >> s;
  string ans;
  for (auto c : s) {
    if (c == '0') {
      ans.push_back('0');
    }
    else if (c == '1') {
      ans.push_back('1');
    }
    else if (c == 'B' && ans != "") {
      ans.pop_back();
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
use std::io;

fn read_lines() -> Vec<i32> {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    return line.split_whitespace().map(|x| x.trim().parse::<i32>().unwrap()).collect::<Vec<i32>>();
 }

 fn calcu_overlap(start_a: i32, end_a: i32, start_b: i32, end_b: i32) -> i32 {
     if end_a <= start_b  || start_a >= end_b{
         return 0;
     }
     let start = if start_a < start_b {
         start_b
     } else {
         start_a
     };

     let end = if end_a < end_b {
         end_a
     } else {
         end_b
     };
     return end - start
}

 fn main() {
     let input = read_lines();
     println!("{}", calcu_overlap(input[0], input[1], input[2], input[3]))
 }


Measured memory_bytes: 4476
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>

using namespace std;
using ll = long long;

int main() {
	int argN;
	ll argX;
	cin >> argN >> argX;

	vector<int> argA(argN);
	for (int i = 0; i < argN; ++i) {
		cin >> argA.at(i);
	}

	sort(argA.begin(), argA.end());
	ll sum = 0;
	for (int i = 0; i < argN; ++i) {
		sum += argA.at(i);
		if (sum == argX) {
			cout << i + 1 << endl;
			return 0;
		}
		else if (sum > argX) {
			cout << i << endl;
			return 0;
		}
	}

	cout << argN - 1 << endl;
}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
int main( void ){
	// initialize();
	int N, X;
	cin >> N >> X;
	int ans; cin >> ans; ans = abs(ans-X);
	rep(i,1,N){
		int input; cin >> input;
		ans = __gcd(ans, abs(input-X));
	}
	cout << ans << endl;

}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn=1e5+5;
int h[maxn];
bool good[maxn];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>h[i];
    for(int i=1;i<=m;i++)
    {
        int u,v;
        cin>>u>>v;
        if(h[u]>=h[v]) good[v]=true;
        if(h[v]>=h[u]) good[u]=true;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        ans+=(!good[i]);
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 4132
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
  let (a, b) = read_touple::<usize>();
  let ans = if a > 2 * b {
     a - 2 * b
  } else {
     0
  };

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


Measured memory_bytes: 4352
#include <cstdio>
#include <cassert>
#define MAXN 100005
using namespace std;

int n;
bool can[32];

int main() {

    scanf("%d", &n);

    int nimVal = 0;
    for(int i = 1; i <= n; ++i) {
        int x;
        
        scanf("%d", &x);
        nimVal ^= x;

        int cnt = 0;
        while((x & 1) == 0) {
            ++cnt;
            x >>= 1;
        }
        can[cnt] = 1;
    }

    int sol = 0;
    for(int i = 29; i >= 0; --i) {
        if(nimVal & (1 << i)) {
            if(!can[i]) {
                return 0 * printf("-1\n");
            }
            ++sol;
            nimVal ^= ((1 << (i + 1)) - 1);
        }
    }
    assert(nimVal == 0);

    printf("%d\n", sol);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	Pi st,en;
	int k;
	int ans=0;
	cin >>st>>en>>k;
	int ids = 0, ide = 0;
	ids = st.F * 60 + st.S;
	ide = en.F * 60 + en.S;
	cout<<ide-ids-k<<endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
int main(){
  int n,x,y;
  cin >> n >> x >> y;
  x--; y--;
  int dist[2200]={0};
  rep(i,n){
    for(int j=i+1;j<n;j++){
      int distij = min(j-i,abs(x-i)+abs(y-j)+1);
      dist[distij]++;
    }
  }
  rep1(i,n-1){
    cout << dist[i] << endl;
  }
}
//出来た...？(๑>◡<๑)

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String a = sc.next();
		String b = sc.next();

      	if(a.equals(b)){
            System.out.println("H");   
        }else{
            System.out.println("D");   
        }
    }
}

Measured memory_bytes: 35508
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,C,K,S=0;cin>>N>>C>>K;
  vector<int>T(N);
  for(int i=0;i<N;i++)cin>>T.at(i);
  sort(T.begin(),T.end());
  for(int i=0;i<N;i++){
    S++;int j=1;
    while(i+j<N&&j<C&&T.at(i)+K>=T.at(i+j))j++;
    i+=j-1;
  }
  cout<<S<<endl;
}

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

int main(void){
    int h,w;
    cin>>h>>w;
    string t(w+2,'#');
    cout<<t<<endl;
    rep(i,h){
        string s;
        cin>>s;
        cout<<"#"+s+"#"<<endl;
    }
    cout<<t<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
start = 0
end = 3
counter = 0
for i in range(N-2):
    ls = a[start:end]
    if ls[0] < ls[1] and ls[2] < ls[1]:
        counter = counter
        start = start + 1
        end = end + 1
    elif ls[1] < ls[0] and ls[1] < ls[2]:
        counter = counter
        start = start + 1
        end = end + 1
    else:
        counter = counter + 1
        start = start + 1
        end = end +1
print(counter)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <climits>
using namespace std;

int main()
{
	int N = 0;
	cin >>  N;
	vector<char> v;
	for (int i = 0; i< N; ++i)	
	{
		char t; cin >> t; v.push_back(t);
	}

	vector<int> left;
	int num = 0;
	for(int i = 0;  i < N; ++i)	{
		left.push_back(num);
		if(v[i] == 'W') 
			++num;
	}

	vector<int> right;
	right.resize(N, 0);
	num = 0;
	for(int i = N-1;  i >= 0; --i)	{
		right[i] = num;
		if(v[i] == 'E') 
			++num;
	}
	int ret = INT_MAX;
	for(int i = 0; i < N; ++i)	{
		ret = min(left[i] + right[i], ret);
	}
	cout << ret ;
	return 0;
}


Measured memory_bytes: 3056
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

vector<string> split(const string &str, char delim){
  vector<string> res;
  size_t current = 0, found;
  while((found = str.find_first_of(delim, current)) != string::npos){
    res.push_back(string(str, current, found - current));
    current = found + 1;
  }
  res.push_back(string(str, current, str.size() - current));
  return res;
}

vector<int> dx, dy;

int dfs(int x, int y, bool used[4][4]) {

  int result = 0;
  int new_x, new_y;

  // cout << x << " " << y << endl;
  // for(int i = 0;i < 4;i++) {

  //   for(int j = 0;j < 4;j++) {

  //     cout << used[j][i];
  //   }

  //   cout << endl;

  // }

  // cout << endl;
  
  while(used[x][y] == true) {

    x++;

    if(x == 4) {

      y++;
      x = 0;
      
      if(y == 4) {

	return 1;

      }

    }

  }

  used[x][y] = true;

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

    new_x = x + dx[i];
    new_y = y + dy[i];

    if(new_x >= 0 && new_x <= 3 && new_y >= 0 && new_y <= 3 && (used[new_x][new_y] == false)) {

      used[new_x][new_y] = true;

      // cout << dx[i] << "," << dy[i] << endl;
      // for(int i = 0;i < 4;i++) {

      // 	for(int j = 0;j < 4;j++) {

      // 	  cout << used[j][i];
      // 	}

      // 	cout << endl;

      // }
      // cout << endl;
      if(x == 3) result += dfs(0, y+1, used);
      else result += dfs(x+1, y, used);
      used[new_x][new_y] = false;
	
    }
    
  }

  used[x][y] = false;

  return result;
  
}

int solve() {

  bool used[4][4];

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

    for(int j = 0;j < 4;j++) {

      used[j][i] = false;

    }

  }
  
  return dfs(0, 0, used);

}

int main() {

  string line;
  vector<string> strarray;

  while(getline(cin, line)) {
    
    if(line.length() == 1 && atoi(line.c_str()) > 4) break;

    else {

      dx.clear();
      dy.clear();

      strarray = split(line, ' ');

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

      	if(i % 2 == 0) dx.push_back(atoi(strarray[i].c_str()));

      	else dy.push_back(atoi(strarray[i].c_str()));

      }

      cout << solve() << endl;
      
    }

  }
  
  return 0;

}

Measured memory_bytes: 1220
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <stdio.h>
#include <vector>
#include <functional>
#include <unordered_set>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

const int N = 4;
vector <int> g[N];

int dfs(int v, int p = -1) {
	int ans = 0;
	for (auto x : g[v]) {
		if (x == p) continue;
		ans = max(ans, dfs(x, v));
	}
	return ans + 1;
}

int main()
{
	for (int i = 0; i < 3; ++i) {
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for (int i = 0; i < 4; ++i) {
		if (dfs(i) == 4) {
			cout << "YES\n";
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{ 
long long a,b,c;
cin >> a >> b;
if(a==1){
if(b==1){c=1;}
else{c=b-2;}
;}
else{
if(b==1){c=a-2;}
else{c=(a-2)*(b-2);}
;}
printf("%lld",c)
;}

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

using namespace std;

int main(void) {
  long long H, W;
  cin >> H >> W;

  if (H == 1 || W == 1) {
    cout << 1 << endl;
  } else {
    cout << H*W/2 + H*W%2 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 26
typedef struct t{
  int p;
  int l;
  int r;
}tree;
int Depth(int);
void hantei(int,int,int);
int sibling(int,int);
int degree(int);
int height(int);
int max(int,int);
tree T[MAX];
int main(){
  
  int n,k,i,j,id,c,l,num = 0;
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
  }
  for(i = 0;i < n;i++){
    scanf("%d",&id);
      scanf("%d",&T[id].l);
      T[T[id].l].p = id;
      scanf("%d",&T[id].r);
      T[T[id].r].p = id;
  }
  for(i = 0;i < n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
	   ,i,T[i].p,sibling(i,n),degree(i),Depth(i),height(i));
    hantei(T[i].p,i,n);
    printf("\n");
  }
  return 0;
}
int Depth(int x){
  int d = 0;
  while(T[x].p != -1){
    x = T[x].p;
    d++;
  }
  return d;
}

void hantei(int p,int node,int n){
  int i,j,wr = 0,x;
  if(p == -1){
    printf("root");
    return;
  }
  if(T[node].l == -1 && T[node].r == -1){
    printf("leaf");
    
  }
  else{
    printf("internal node");
    
  }
}
int sibling(int node,int n){
  int i,j;
  for(i=0;i < n;i++){
    if(T[node].p == T[i].p && i != node){
      return i;
    }
  }
  return -1;
}
int degree(int node){
  int deg=0;
  if(T[node].r != -1){
      deg++;
  }
  if(T[node].l != -1){
    deg++;
  }
  return deg;
}
int height(int x){
  int dl = 0,dr = 0;
  if(T[x].l != -1){
      dl = 1+height(T[x].l);
  }
  if(T[x].r != -1){
    dr = 1+height(T[x].r);
  }
  return max(dl,dr);
}
int max(int x,int y){
  if(x > y)return x;
  return y;
}





Measured memory_bytes: 2076
#include <bits/stdc++.h>
#define fto(i,a,b) for(int i=a; i<=b; ++i)
#define fdto(i,a,b) for(int i=a; i>=b; --i)
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define st first
#define nd second
#define maxn 200005
#define Ntu "bai5"

using namespace std;

struct edge{
	int u,v,w;
};

long long rs=0;
int par[maxn],ed[maxn]={},sz[maxn];

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

void Merge(int u, int v, int w){
	int ru=root(u),rv=root(v);
	if(ru==rv){
		if(sz[ru]>ed[ru]){
			ed[ru]++;
			rs+=w;
		}
	}
	else{
		if(sz[ru]+sz[rv]>ed[ru]+ed[rv]){
			par[rv]=ru;
			sz[ru]+=sz[rv];
			ed[ru]+=ed[rv]+1;
			rs+=w;
		}
	}
}

int main(){
    ios_base::sync_with_stdio(0);
    //freopen(Ntu".inp","r",stdin);
    //freopen(Ntu".out","w",stdout);
    cin.tie(NULL);cout.tie(NULL);
	int p,h,w;
	cin >> p >> h >> w;
	for(int i=0;i<h+w;i++){
		par[i]=i;
		sz[i]=1;
	}
	vector <edge> e(p);
	for(int i=0;i<p;i++)
    {
		cin >> e[i].u >> e[i].v >> e[i].w;
		e[i].u--;e[i].v--;
	}
	sort(e.begin(),e.end(),[](edge &a, edge &b)
    {
		return (a.w>b.w);
	});
	for(int i=0;i<p;i++) Merge(e[i].u,h+e[i].v,e[i].w);
	cout << rs;
	return 0;
}


Measured memory_bytes: 4224
#C - Monsters Battle Royale(ABC118)
N=int(input())
A=list(map(int, input().split()))
B=min(A)
i=0
n=1
while i<N:
    a=A[i]%B
    i+=1
    if 0<a<B:
        B=a
        i=0
    elif 0<a:
        i-=1
        A[i]=a
    elif B==1:
        break
print(B)
    

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

#define X first
#define Y second
#define ll long long
#define mP make_pair
#define pB push_back 

vector<pair<ll , ll > > adj[200010];
ll dist[200100];
bool vis[200100];

int main(){
	ll n,m;
	cin >> n >> m;
	for(int i = 0 ; i < m ; ++i){
		ll x , y , w;
		cin >> x >> y >> w;
		--x;
		--y;
		adj[x].pB(mP(y , w));
		adj[y].pB(mP(x , -1 * w));
	}


	bool flag = true;
	queue<ll> q;
	for(int i = 0 ; i < n ; ++i){
		if(vis[i])
			continue;
		q.push(i);
		dist[i] = 0;
		while(!q.empty()){
			if(!flag) break;
			ll u = q.front();
			q.pop();
			for(int i = 0 ; i < adj[u].size() ; ++i){
				ll v = adj[u][i].X;
				if(!vis[v]){
					q.push(v);
					dist[v] = dist[u] + adj[u][i].Y;
					vis[v] = true;
				}else{
					if(dist[v] != dist[u] + adj[u][i].Y){
						flag = false;
						break;
					}
				}
			}
		}
	}
	

	if(flag)
		cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 16896
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n;
  cin >> n;
  bool answer = true;
  int a[n];
  int candidate[3] = {-1, -1, -1};
  int count[3] = {0, 0, 0};
  for(int i= 0; i<n;++i){
    cin >> a[i];
    if(candidate[0] == -1){
      candidate[0] = a[i];
      count[0]++;
    }else if(candidate[0] == a[i]){
      count[0]++;
    }else if(candidate[1] == -1){
      candidate[1] = a[i];
      if(n % 3 != 0){
        answer = false;
      	break;
      }
      count[1]++;
    }else if(candidate[1] == a[i]){
      count[1]++;
    }else if(candidate[2] == -1){
      candidate[2] = a[i];
      count[2]++;
    }else if(candidate[2] == a[i]){
      count[2]++;
    }else{
      answer = false;
      break;
    }
  }
  if(answer){
    answer = false;
    if(n % 3 != 0){
      if(count[0] == n & candidate[0] == 0){
        answer = true;
      }
    }else if((count[0] == n & candidate[0] == 0) 
       | (count[0] == count[1] & count[1] == count[2])){
      if((int)(candidate[0]^candidate[1]^candidate[2]) == 0){
        answer = true;
      }
    }else if((count[1] == n/3 & count[2] == 0 & candidate[1] == 0)
             | (count[0] == n/3 & count[2] == 0 & candidate[0] == 0)){
      answer = true;
    }
  }
  if(answer) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 640
IN=lambda:map(int,input().split())
N,W=IN()
INF=float("inf")
dp=[INF]*(1000*N)
dp.insert(0,0)
c=0
ans=0
for i in range(N):
    w,v=IN()
    for j in range((1000*N+1),-1,-1):
        if dp[j-v]!=INF:
            dp[j]=min(dp[j],dp[j-v]+w)
for i in range(1000*N+1):
    if dp[i]<=W:
        ans=i
print(ans)   

Measured memory_bytes: 77336
def square(n)
   n * n
end
#main

arr = Array.new
while n = gets
   arr << n.to_i
end
arr.each do |d|
   sum = 0
   0.upto(600 / d - 1) do |i|
      sum += square(i * d) * d
   end
   puts sum
end

Measured memory_bytes: 6092
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 2e5 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, s = 0;
    cin >> n;
    map<ll, ll> f;
    for (ll i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        s += f[i - a];
        f[i + a]++;
    }
    cout << s;
}

Measured memory_bytes: 26316
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int a,b;cin>>a>>b;
  
  int ans;
  int now=1;
  ireps(i,2,999){
    now+=i;
    int front=now-i;
    if(now-b==front-a){
      ans=now-b;
      break;
    }
  }
  cout(ans);
  return 0;
}

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

int main() {
	int N; cin >> N;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		while (a%2==0) {
			ans++;
			a /= 2;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);
    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

ll dp[110][4][4][4];

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

    int n; cin >> n;
    rep(i, 4) rep(j, 4) rep(k, 4){
        if( (i==0 && j==1 && k==2) || (i==1 && j==0 && k==2) || (i==0 && j==2 && k==1)) dp[3][i][j][k] = 0;
        else dp[3][i][j][k] = 1;
    }

    repr(len, 3, n) rep(i, 4) rep(j, 4) rep(k, 4) {
        rep(a, 4){
            if(j==0 && k==2 && a==1) continue;
            if(i==0 && j==1 && a==2) continue;
            if(j==0 && k==1 && a==2) continue;
            if(i==0 && k==1 && a==2) continue;
            if(j==1 && k==0 && a==2) continue;

            dp[len+1][j][k][a] += dp[len][i][j][k];
            chmod(dp[len+1][j][k][a]);
        }
    }

    ll ans = 0;
    rep(i, 4) rep(j, 4) rep(k, 4) {
        ans += dp[n][i][j][k];
        chmod(ans);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College
    Date:24/03/2020
'''

def main():
    
    # for _ in range(ii()):
    
    a=list(map(int,input().split()))
    if(len(set(a))==2):
        print('Yes')
    else:
        print('No')
        
















    
    
if __name__ =="__main__":
    main()

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
ll mod = 1000000007;


int main(){
    vll a(32);
    a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll k;
    cin >> k;
    cout << a.at(k - 1) << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    static int[] r;
    static long[][] map;
    static long ans = Long.MAX_VALUE;
    static boolean[] visited;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int R = sc.nextInt();
        r = new int[R+1];
        for(int i=1;i<=R;i++) r[i] = sc.nextInt();
        int[] A = new int[M+1];
        int[] B = new int[M+1];
        int[] C = new int[M+1];
        for(int i=1;i<=M;i++){
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
            C[i] = sc.nextInt();
        }
        long[][] g = new long[N+1][N+1];
        for(int row=1;row<=N; row++){
            for(int col=1; col<=N; col++) {
                if(row==col) g[row][col]=0;
                else g[row][col] = Long.MAX_VALUE/64;
            }
        }
        for(int i=1;i<=M;i++){
            int a = A[i];
            int b = B[i];
            g[a][b] = (long) C[i];
            g[b][a] = (long) C[i];
        }
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++){
                for(int k=1;k<=N;k++){
                    if(g[j][k]>g[j][i]+g[i][k]) {
                        g[j][k]=g[j][i]+g[i][k];
                        g[k][j]=g[j][i]+g[i][k];
                    }
                    //g[j][k] = Math.min(g[j][k], g[j][i]+g[i][k]);
                }
            }
        }
        map = new long[R+1][R+1];
        for(int row=1; row<=R; row++){
            for(int col=1; col<=R; col++){
                map[row][col] = g[r[row]][r[col]];
            }
        }
        visited = new boolean[R+1];
        for(int i=1;i<=R;i++){
            visited[i] = true;
            dfs(i,0);
            visited[i] = false;
        }
        System.out.println(ans);
    }
    private static void dfs(int start, long sum){
        boolean flag = true;
        for(int i=1;i<visited.length;i++) flag = flag&visited[i];
        if(flag) {
            ans = Math.min(sum,ans);
            return;
        }
        for(int i=1;i<r.length;i++){
            if(!visited[i]){
                visited[i] = true;
                dfs(i,map[i][start]+sum);
                visited[i] = false;
            }
        }
    }
}


Measured memory_bytes: 46496
import java.util.*;

class Main{

    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	int N = sc.nextInt();

	int[] A = new int[N];
	
	int[] B = new int[N];

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

	A[i] = sc.nextInt();	

	B[A[i]-1] = i+1;

  }

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

	System.out.println(B[i]);	

  }
	  
 }
}

Measured memory_bytes: 60960
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    string s,t; cin>>s>>t;
    reverse(btoe(s));
    if(s==t) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    char a[3];
    while(scanf("%s",a)!=EOF)
    {
        int b[3]={0};
        for(int i=0;i<3;i++)
        {
            if(a[i]=='a')  b[0]++;
            if(a[i]=='b')  b[1]++;
            if(a[i]=='c')  b[2]++;
        }
        int ju=0;
        for(int j=0;j<3;j++)
        {
            if(b[j]!=1)
            {
                ju=1;
                break;
            }
        }
        if(ju==0)  printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void readin(T &x) {
	x = 0;
	T fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	x *= fh;
}
inline void d_read(double &x) {
	x = 0.0;
	int fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	if (ch == '.') {
		double num = 1.0;
		ch = getchar();
		for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
	}
	x *= fh;
}

template <typename T>
inline void wt(T x) {
	if (x > 9) wt(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
inline void writeln(T x, char c) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	wt(x);
	putchar(c);
}

int main() {
	int a, b, c, k;
	readin(a); readin(b); readin(c);
	readin(k);
	while(b <= a) {
		b *= 2;
		k --;
	}
	while(c <= b) {
		c *= 2;
		k --;
	}
	if (k >= 0) puts("Yes");
	else puts("No");
	return 0;
}




Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

int32_t main()
{
	
	string str;cin>>str;

	int flag=0;
	for(int i=1;str[i];i++){
		if(str[i]==str[i-1]){
			flag=1;
			break;
		}
	}

	if(!flag){
		cout<<"Good"<<endl;
	}	
	else
		cout<<"Bad"<<endl;
	return 0;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <random>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <chrono>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
// #define int long long


using namespace std;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;





signed main()
{
	int n, m;
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	priority_queue<int> pq;
	for(int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		pq.push(x);
	}
	while(m--) {
		int x = pq.top(); pq.pop();
		pq.push(x / 2);
	}
	long long tot = 0;
	for(int i = 0; i < n; ++i) {
		int x = pq.top(); pq.pop();
		tot += x;
	}
	cout << tot << endl;
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
double dis(vector<int> A,vector<int> B,int D){
	double res=0;
	for(int i=0;i<D;i++){
		res+=pow(B.at(i)-A.at(i),2);
	}
	return sqrt(res);
}
int main(){
  int N,D;
  cin >>N>>D;
  vector<vector<int>> data(N,vector<int>(D));
  for(int i=0;i<N;i++){
	  for(int j=0;j<D;j++){
		  cin >>data.at(i).at(j);
	  }
  }
  int count=0;
  for(int i=0;i<N-1;i++){
 	  for(int j=i+1;j<N;j++){
 		 if(ceil(dis(data.at(i),data.at(j),D))==floor(dis(data.at(i),data.at(j),D))){count++;}
 	  }
   }
  cout <<count<<endl;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint gcd( lint m, lint n )
{
	lint a=max(m,n),b=min(m,n);
	if(m==0) return n;if(n==0) return m;
	if(a%b==0) return b;
	return gcd(b,a-b*(a/b));
}
int main()
{
	lint n,m;string s,t;
	cin>>n>>m;cin>>s;cin>>t;
	lint x=gcd(n,m);
	rep(i,x){
		if(s[n/x*i]!=t[m/x*i]){
			cout<<-1<<endl;return 0;
		}
	}
	cout<<n/x*m<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
main() {
	int n=read(),l=read(),sum=0,minx=21475832,ans=0;
	for(int i=1; i<=n; i++)
		sum+=l+i-1;
	for(int i=1; i<=n; i++) {
		int p=abs(l+i-1);
		if(p<minx) ans=sum-l-i+1,minx=p;
	}
	cout<<ans;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end(), greater<int>());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) ans += a[i];
		else ans -= a[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
from sys import exit
a = input()

p = ["R", "U", "D"]
odd = ["L", "U", "D"]

for i in range(len(a)):
    if (i+1) % 2 == 0:
        if a[i] not in odd:
            print("No")
            exit()
    elif (i+1) % 3 == 0 or i == 0:
        if a[i] not in p:
            print("No")
            exit()
    else:
        if a[i] not in p:
            print("No")
            exit()
print("Yes")
        

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 3572
#ifdef ONLINE_JUDGE

#include "bits/stdc++.h"
using namespace std;

#define ui unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double

#define all(v) v.begin(), v.end()

#define speed ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ld PI = 3.1415926535897932384626;
ll MOD = 1000000007;
const ld EPS = 1e-9;
const int N = 3e5 + 7;

inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ui setBits(ui v) { ui c; for(c = 0 ; v; ++c) v &= (v - 1); return c; }
inline bool isPowerOfTwo(ui v) { return (v && !(v & (v - 1))); }
ll power(ll base, ull exp, ll mod = MOD) { 
	ll res = 1; base %= mod; 
	while(exp) { 
		if(exp & 1) res = (res * base)%mod; 
		exp >>= 1; base = (base * base)%mod; 
	} 
	return res; 
}
ll modInv(ll a, ll mod = MOD) { 
	if(mod == 1) return 0; 
	ll x = 1, y = 0, m = mod; 
	while(a > 1) { 
		ll q = a/m, t = m; m = a%m; a = t; t = y; y = x - q * y; x = t; 
	} 
	if(x < 0) x += mod; 
	return x; 
}
inline ui iabs(int x) { ui y = x; return (y > 0) ? y : -y; }
inline ll add(ll a, ll b, ll mod = MOD) { ll res = (a%mod + b%mod)%mod; return res; }
inline ll sub(ll a, ll b, ll mod = MOD) { ll res = (a%mod - b%mod + mod)%mod; return res; }
inline ll mult(ll a, ll b, ll mod = MOD) { ll res = (a%mod * b%mod)%mod; return res; }
inline ll div(ll a, ll b, ll mod = MOD) { ll res = (a%mod * modInv(b, mod))%mod; return res; }

#else

#include "custom.h"
using namespace std;

#endif

void openf() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	
}

int main() {
	speed;
	openf();
	int n, k, sum = 0;
	cin >> n >> k;
	vector<int> p(n);
	for(int i = 0 ; i < n ; ++i) {
		cin >> p[i];
	}	
	sort(all(p));
	for(int i = 0 ; i < k ; ++i) {
		sum += p[i];
	}
	cout << sum << endl;
	return 0;
}  

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


void solve(std::string S, std::string T){
    long long ans = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) {
            ans ++;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 4124
n = int(input())
v = list(map(int, input().split()))

judge_2n_1 = {}
judge_2n = {}

for i in range(n):
    if i % 2 == 0:
        if v[i] not in judge_2n_1.keys():
            judge_2n_1[v[i]] = 1
        else:
            judge_2n_1[v[i]] += 1
    else:
        if v[i] not in judge_2n.keys():
            judge_2n[v[i]] = 1
        else:
            judge_2n[v[i]] += 1

judge_2n = sorted(judge_2n.items(), key=lambda x: x[1], reverse=True)
judge_2n_1 = sorted(judge_2n_1.items(), key=lambda x: x[1], reverse=True)
answer = n - 1

for i in judge_2n[:2]:
    for j in judge_2n_1[:2]:
        if i[0] != j[0]:
            answer = min(answer, n - i[1] - j[1])
        else:
            answer = min(answer, n - max(i[1], j[1]))

print(answer)


Measured memory_bytes: 17688
#include<iostream>
using namespace std;
int main()
{
	int n,a,b,c,d,x,y;
	cin>>n>>a>>b>>c>>d;
	x=(n/a)*b;
	if(n%a!=0)
		x=x+b;
	y=(n/c)*d;
	if(n%c!=0)
		y=y+d;
	if(x>y)
		cout<<y<<endl;
	else
		cout<<x<<endl;
	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

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

    int ans = 0;
    rep(i, n){
        int h; cin >> h;
        if(k <= h) ans++;
    }
    OP(ans);
}


Measured memory_bytes: 256
# Panasonic2020 C

import math

def main():
    a, b, c = map(int, input().split())

    if 4*a*b < (c-a-b)**2 and c-a-b > 0:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
//============================================================================
// Name        : Test.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int A[100][100];
	int b[100],c[100];
	int n,m;

	for(int i = 0; i < 100; i++){
		for(int j = 0; j < 100; j++){
			A[i][j] = 0;
			b[j] = 0;
			c[j] = 0;
		}
	}

	cin >> n >> m;
	//cout << n << m << endl;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> A[i][j];
			//cout << A[i][j];
		}
	}

	for (int i = 0; i < m; i++){
		cin >> b[i];
		//cout << b[i] << endl;
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			c[i] += A[i][j] * b[j];
		}
	}

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

		return 0;
}

Measured memory_bytes: 3144
H,W=map(int,input().split())

L=[]
l=["." for i in range(W+2)]
L.append(l)
for i in range(H):
    a=list(input())
    a=["."]+a+["."]
    L.append(a)
L.append(l)
#print(L)

X=[1,-1,0,0]
Y=[0,0,1,-1]

for i in range(1,H+1):
    for j in range(1,W+1):
        if L[i][j]=="#":
            F=1
            for k in range(4):
                if L[i+X[k]][j+Y[k]]=="#":
                    F=0
            if F==1:
                print("No")
                exit()
print("Yes")
                 

Measured memory_bytes: 39792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];
int A[3][3];
bool app[3][3];


int main(){
    int N;
    for(int i=0; i<3;i++){
        for(int j=0; j<3; j++){
            cin >> A[i][j];
        }
    }
    cin >> N;
    vector<int> b(N+3);
    for(int i = 0; i < N; i++) cin >> b[i];
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            app[i][j] = false;
            for(int k = 0; k < N; k++) {
                if(A[i][j] == b[k]) app[i][j] = true;
            }
        }
    }
    string ANS = "No";
    for(int i = 0; i < 3; i++) {
        if(app[i][0] and app[i][1] and app[i][2]) ANS = "Yes";
    }
    for(int i = 0; i < 3; i++) {
        if(app[0][i] and app[1][i] and app[2][i]) ANS = "Yes";
    }
    if(app[0][0] and app[1][1] and app[2][2]) ANS = "Yes";
    if(app[0][2] and app[1][1] and app[2][0]) ANS = "Yes";
    cout << ANS << endl;
    return 0;
}

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

int main(){
	int x,y,s,origin,i,ans=0,j;
	while(1){
		ans = 0;
		cin>>x>>y>>s;
		if(x==y && x == s && x == 0)
			break;
		for(i=1; ;i++){
			if((i*(100+x))/100 + (100+x)/100 >s)
				break;
			for(j=((s-(i*(100+x))/100)*100)/(100+x);;j++){
				if((i*(100+x))/100+(j*(100+x))/100 == s){
					if((i*(100+y))/100 + (j*(100+y))/100 >ans)
						ans = (i*(100+y))/100 + (j*(100+y))/100;
				}
				else if((i*(100+x))/100+(j*(100+x))/100 > s)
					break;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
def main():
    import sys
    input = sys.stdin.readline

    N, q = map(int, input().split())
    S = input().rstrip('\n')
    Q = [None] * q
    for i in range(q):
        Q[i] = tuple(input().split())

    ok = N
    ng = -1
    mid = (ok+ng)//2
    while ok - ng > 1:
        flg = 1
        i = mid
        for s, d in Q:
            if S[i] == s:
                if d == 'L':
                    i -= 1
                else:
                    i += 1
                if i == -1:
                    flg = 0
                    break
                elif i == N:
                    break
        if flg:
            ok = mid
        else:
            ng = mid
        mid = (ok+ng)//2
    ok1 = ok

    ok = -1
    ng = N
    mid = (ok + ng) // 2
    while ng - ok > 1:
        flg = 1
        i = mid
        for s, d in Q:
            if S[i] == s:
                if d == 'L':
                    i -= 1
                else:
                    i += 1
                if i == -1:
                    break
                elif i == N:
                    flg = 0
                    break
        if flg:
            ok = mid
        else:
            ng = mid
        mid = (ok + ng) // 2
    ok2 = ok

    print(ok2 - ok1 + 1)



if __name__ == '__main__':
    main()


Measured memory_bytes: 79180
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// まずは全探索
// 偶奇，逆から，ソート
// 存在判定：構成方法，入力の特徴
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

int N; cin >> N;
int X = 0;
rep(i, 0, N) {
    int a;
    cin >> a;
    X ^= a;
}

if (X) cout << "No\n";
else cout << "Yes\n";

}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	h, n := iScan(), iScan()
	as := iSScan(n)
	if sum(as) >= h {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main() {
  int N;
  cin >> N;
  vector<unsigned long long> L(100);
  L[0] = 2ll;
  L[1] = 1ll;
  for (int i = 2; i <= N; i++) {
    L[i] = L[i - 2] + L[i - 1];
  }
  cout << L[N] << endl;
}

Measured memory_bytes: 256