akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ITP1_5_B
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] inputs = Console.ReadLine().Split(' ');

                int height = Convert.ToInt32(inputs[0]);
                int width = Convert.ToInt32(inputs[1]);

                if (height == 0 && width == 0) break;

                for (int i = 0; i < height; i++)
                {
                    for (int j = 0; j < width; j++)
                    {
                        if (i == 0 || i == height - 1 || j == 0 || j == width-1)
                        {
                            Console.Write("#");

                        }
                        else
                        {
                            Console.Write(".");                          
                        }
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}

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

int main() {
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans = 0;
    if(k>a+b){
        ans = a - (k-a-b);
    }else if(k>a){
        ans += a;
    }else{
        ans = k;
    }
    cout<<ans<<endl;
}

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

void get_distribution(string S, map<char, int> &dist){
    for (int i = 0; i < (int) S.length(); i++) {
        dist[S[i]]++;
    }
}

void initialize_huffman_tree(map<char, int> &dist, vector<tuple<int, vector<int>, string> > &T){
    int i = 0;
    vector<int> temp = {};
    for (auto itr : dist){
        T[i] = make_tuple(dist[itr.first], temp, "");
        i++;
    }
}

void initialize_priority_queue(map<char, int> &dist, priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > &pque){
    int i = 0;
    for (auto itr : dist){
        pque.push(make_pair(itr.second, i));
        i++;
    }
}

void make_huffman_tree(map<char, int> &dist, vector<tuple<int, vector<int>, string> > &T, priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > &pque){
    for (int i = dist.size(); i < 2*dist.size()-1; i++){
        pair<int, int> temp1 = pque.top();
        pque.pop();
        pair<int, int> temp2 = pque.top();
        pque.pop();
        pair<int, int> temp3 = make_pair(temp1.first+temp2.first, i);
        pque.push(temp3);
        vector<int> temp4 = {temp1.second, temp2.second};
        T[i] = make_tuple(temp3.first, temp4, "");
    }
}

void huffman_tree_dfs(vector<tuple<int, vector<int>, string> > &T, int v) {
    vector<int> temp1 = {};
    if (get<1>(T[v]) != temp1){
        for (int i = 0; i < 2; i++) { 
            string temp2 = get<2>(T[v]) + (char) (i+'0');
            int idx = get<1>(T[v])[i];
            T[idx] = make_tuple(get<0>(T[idx]), get<1>(T[idx]), temp2);
            huffman_tree_dfs(T, idx); //再帰的に探索
        }
    }
}

int main(){
    //入力
    string S;
    cin >> S;


    //① 文字の出現頻度を求める
    map<char, int> dist;
    get_distribution(S, dist);
    int N = dist.size();
    if (N == 1) {
        cout << (int) S.length() << endl;
        return 0;
    }


    //②.① 各文字に対応するノードを1つずつ作る
    vector<tuple<int, vector<int>, string> > T(2*N-1);
    initialize_huffman_tree(dist, T);


    //②.② 親を持たないノードのうち、出現頻度が小さい2つのノードを選ぶ
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pque;
    initialize_priority_queue(dist, pque);
    

    //②.③ その2つの出現頻度を足し合わせたノードを新たに作る
    //②.④ 新たなノードをその2つのノードの親とする
    //②.⑤ 2-4の手順を全てのノードがつながれるまで繰り返す
    make_huffman_tree(dist, T, pque);
    

    //③ ハフマン木の各エッジに0と1を当てはめていく
    //④ ハフマン木の根から文字までのノードを辿ってできたビット列が符号語となる
    huffman_tree_dfs(T, 2*N-2);


    //出力

    long long ans = 0;
    map<char, string> cw;
    int i = 0;
    for (auto itr : dist){
        cw[itr.first] = get<2>(T[i]);
        i++;
    }
    
    for (int i = 0; i < (int) S.length(); i++){
        ans += cw[S[i]].length();
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3368
#include<bits/stdc++.h>
using namespace std;
int n,l,r,ans;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
	{
        cin>>l>>r;
        ans+=r-l+1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
     int n;
     cin>>n;
     string s;
     cin>>s;
     int cnt=0;
     int ch = s[0];
     for(int i=1;i<n;i++)
     {
        if(ch==s[i])
            continue;
        else
        {
            ch = s[i];
            cnt++;
        }
     }
     cout<<cnt+1<<endl;

}

Measured memory_bytes: 512
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    broken = 0
    cnt = 1
    for i in range(N):
        if cnt == A[i]:
            cnt += 1
        else:
            broken += 1
    print(broken if broken != N else -1)

    

if '__main__' == __name__:
    resolve()


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

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

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

int main(){
  ll i,o,t,j,l,s,z;
  cin >> i >> o >> t >> j >> l >> s >> z;
  ll ans = o + (i/2)*2 + (l/2)*2 + (j/2)*2;
  if(i>0&&l>0&&j>0) ans = max(ans,o+3+(i-1)/2*2+(l-1)/2*2+(j-1)/2*2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(a,b) for(ll i=a;i<=b;i++)
#define show(x) cout<<x<<"\n"
#define vr vector<ll> 
ll fact(ll n); 
  
ll nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
// Returns factorial of n 
ll fact(ll n) 
{ 
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
int main()
{
	string s;
	cin>>s;
	string temp=s;
	reverse(temp.begin(),temp.end());
	if(temp==s)
	{
		string str;
		f(0,(s.length()/2)-1)
		{
			str+=s[i];
		}
		string strtemp=str;
		reverse(strtemp.begin(),strtemp.end());
		if(strtemp==str)
		{
			show("Yes");
			return 0;
		}
	}
	show("No");


}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int H = stdIn.nextInt();
		int W = stdIn.nextInt();
		int K = stdIn.nextInt();
		String[][] s = new String[H][W];
		int[][] a = new int[H][W];
		for(int i = 0; i < H; i++) {
			char[] words = stdIn.next().toCharArray();
			for(int j = 0; j < W; j++) {
				s[i][j] = String.valueOf(words[j]);
			}
		}
		
		int p = 1;
		for(int i = 0; i < H; i++) {
			boolean flag = false;
			for(int k = 0; k < W; k++) {
				if(s[i][k].equals("#")) {
					flag = true;
					break;
				}
			}
			if(flag) {
				int j = 0;
				while(j < W && s[i][j].equals(".")) {
					a[i][j] = p;
					j++;
				}
				a[i][j] = p;
				j++;
				while(j < W && s[i][j].equals(".")) {
					a[i][j] = p;
					j++;
				}
				for(; j < W; j++) {
					if(s[i][j].equals(".")) a[i][j] = p;
					else {
						p++;
						a[i][j] = p;
					}
				}
				p++;
			}
			else {
				if(i == 0) {
					for(int j = 0; j < W; j++) {
						a[0][j] = 0;
					}
				}
				else {
					for(int j = 0; j < W; j++) {
						a[i][j] = a[i-1][j];
					}
				}
			}
		}
		
		if(a[0][0] == 0) {
			int temp = 0;
			for(int i = 0; i < H; i++) {
				if(a[i][0] != 0) {
					temp = i;
					break;
				}
			}
			for(int i = 0; i < temp; i++) {
				for(int j = 0; j < W; j++) {
					a[i][j] = a[temp][j];
				}
			}
		}
		
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				System.out.println(a[i][j]);
			}
		}

	}

}

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

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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;
}

typedef long long ll;

#define MAX_N 10000

struct Edge {
    int to;
    int weight;
    Edge(int t, int w)
        : to(t)
        , weight(w)
    {
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;

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

    ll sum = 0;
    int n = s.size();

    for (int temp = 0; temp < (1 << n - 1); temp++) {
        ll t = s[0] - '0';

        for (int i = 0; i < n - 1; i++) {
            if (temp & (1 << i)) {
                sum += t; // 1がたってたらプラス記号を入れる
                t = s[i + 1] - '0';
            } else {
                t *= 10; // 1がたってなければプラス記号を入れない
                t += s[i + 1] - '0';
            }
        }
        sum += t;
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)

    val t1, s1, e1, w1, n1, b1 = scanner.nextInt
    var dice1 = Dice(t1, n1, e1, s1, w1, b1)
    val t2, s2, e2, w2, n2, b2 = scanner.nextInt
    var dice2 = Dice(t2, n2, e2, s2, w2, b2)

    var areSame = false
    for(_ <- 1 to 4) {
      for(_ <- 1 to 4) {
        for(_ <- 1 to 4) {
          for(_ <- 1 to 4) {
            if(dice1.equals(dice2)) areSame = true
            dice1 = dice1.rotN()
          }
          dice1 = dice1.rotE()
        }
        dice2 = dice2.rotN()
      }
      dice2 = dice2.rotE()
    }
    println(if(areSame) "Yes" else "No")
  }
}

case class Dice(t: Int, n: Int, e: Int, s: Int, w: Int, b: Int) {
  def rotN(): Dice = Dice(s, t, e, b, w, n)
  def rotS(): Dice = Dice(n, b, e, t, w, s)
  def rotW(): Dice = Dice(e, n, b, s, t, w)
  def rotE(): Dice = Dice(w, n, t, s, b, e)
  def rot(): Dice = Dice(t, e, s, w, n, b)
  def equals(that: Dice): Boolean = (t == that.t && n == that.n && e == that.e && s == that.s && w == that.w && b == that.b)
}



Measured memory_bytes: 45292
#include <stdio.h>
int main(void){
	int num[5] = {0}, onemin = 20, min = 10, sum = 0;
	for(int i = 0; i < 5; i++){
		scanf("%d", &num[i]);getchar();
		if(num[i] % 10 < onemin && num[i] % 10 != 0){
			onemin = num[i] % 10;
			min = i;
		}
	}
	for(int i = 0; i < 5; i++){
		if(i == min){
			sum += num[i];
		}else{
			if(num[i] % 10 == 0){
				sum += num[i];
			}else{
				sum += 10 - (num[i] % 10) + num[i];
			}
		}
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ill long long int
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  ill n;
  cin >> n;
  vector<ill> v(n);
  rep(i, 0, n) cin >> v[i];
  ill sm = 0, mx = v[0];
  rep(i, 1, n){
    if(v[i] < mx){      
      sm += mx - v[i];
    }
    else{
      mx = v[i];
    }
  }
  
  cout << sm << "\n";
}

Measured memory_bytes: 4836
#include <stdio.h>

#define N 100

void swap(int *, int *);

/*ここからがmain関数*/
int main()
{
  int i, j, n, A[N], count = 0, minj, k;


  scanf("%d", &n);

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

  //printf("\n");

  /*
  if(n == 1){
    printf("%d\n%d\n", A[0], count);
    return 0;
  }

  */
 
  
  /*ここからがSelection Sort*/
  for(i = 0; i < n; i++){
    minj = i;
    for(j = i; j < n; j++){
      if(A[j] < A[minj])
	minj = j;

    }
    /*交換するswap関数*/
    if(A[i] > A[minj]){
    swap(&A[i], &A[minj]);
    count++;
    }
    
    /*確認のprintf*/
    /*
    for(k = 0; k < 6; k++){
      if(k != 0) 
	printf(" ");
      printf("%d", A[k]);
    }
    */
  
    //printf("\n");
  }


  /*ここからが出力*/
  for(i = 0; i < n; i++){
      if(i != 0) 
	printf(" ");
      printf("%d", A[i]);
    }
  
  printf("\n%d\n", count);

  return 0;
}


void swap(int *x, int *y)
{
  int tmp = 0;

  tmp = *x;
  *x = *y;
  *y = tmp;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < n;i ++ )
#define ll long long

using namespace std;
typedef pair<int, int> P;
// input


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, start, deadline;
	cin >> N;
	vector<P> task(N); 
	rep(i,N) {
		cin >> start >> deadline;
		task[i] = make_pair(deadline, start);
	}

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

	int time = 0;
	bool death = false;
	rep(i,N) {
		time +=task[i].second;
		if(time > task[i].first) {
			death = true;
			break;
		}
	}

	if(death) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 1792
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back

#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define all(r)(r).begin(),(r).end()
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define inf 1000000000000000000
#define N 200010
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};



//=============================================ASIFAZAD==============================================//
vector<vi > adj;
int vis[N], n, m, ac;

void dfs(int nod)
{
//    dbg(nod);
    vis[nod] = 1;
    ac++;
    for(auto x: adj[nod])
        if(vis[x] == 0)
            dfs(x);
}

int32_t main()
{
    io;
    cin>>n>>m;
//    dbg(n);
    adj.clear();
    adj.resize(n+2);
//    for(int i = 0; i< N; i++)
//        adj[i].clear();
//    dbg(m);
    for(int i = 0; i< m;i++)
    {
        int u, v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    int ans = 0;
    memset(vis, 0, sizeof(vis));
    for(int i = 1; i<= n; i++)
    {
        if(vis[i] == 0)
        {
            ac = 0;
            dfs(i);
            ans = max(ans, ac);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 21116
#include<bits/stdc++.h>
using namespace std;
vector<int> h, dp;

long long solve(int i) {
    if(dp[i] != -1) return dp[i];
    if(i == 0) return 0;
    else if(i == 1) return abs(h[i] - h[i-1]);
    else return dp[i] = min(abs(h[i] - h[i-1]) + solve(i-1), abs(h[i] - h[i-2]) + solve(i-2));
}

int main() {
    int N;
    cin >> N;
    h.resize(N);
    dp.resize(N);
    for(int i = 0; i < N; i++) cin >> h[i];
    fill(dp.begin(), dp.end(), -1);
    cout << solve(N - 1) << endl;
    return 0;
}

Measured memory_bytes: 3328
N = int(input())
B = [int(i) for i in input().split()]
A = [0]*N

for i in range(N):
    if i == 0:
        A[i] = B[0]
    else:
        if i < N-1:
            if B[i-1] <= B[i]:
                A[i] = B[i-1]
                A[i+1] = B[i]
            else:
                A[i] = B[i]
                # A[i+1] = B[i+1]
        else:
            A[i] = B[-1]
print(sum(A))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;


int main() {
    int k, n; cin >> k >> n;
    vector<ll> nums;
    for(int i = 0; i < n; ++i){
    	int x; cin >> x;
    	nums.pb(x);
    }
    sort(nums.begin(), nums.end());
    vector<ll> res;
    ll ans = 1000000009;
    for(int i = 0; i < n; ++i){
    	if(i == 0){
    		ll x = nums[n - 1] - nums[0];
    		ll y = (k - x) + (nums[n - 1] - nums[1]);
    		//cout << i << " " << min(x, y) << endl;
    		res.pb(min(x, y));
    	}
    	if(i == n - 1){
    		ll x = nums[n - 1] - nums[0];
    		ll y = (k - x) + (nums[n - 2] - nums[0]);
    		//cout << i << " " << min(x, y) << endl;
    		res.pb(min(x, y));
    	}
    	else{
    		ll x = nums[i] + (k - nums[i + 1]);
    		ll y = (k - nums[i]) + nums[i - 1];
    		ll z = (nums[i] - nums[0]) * 2 + (nums[n - 1] - nums[i]);
    		ll q = (nums[n - 1] - nums[i]) * 2 + (nums[i] - nums[0]);
    		//cout << i << " " << x << " " << y << " " << z << " " << q << endl;
    		res.pb(x);
    		res.pb(y);
    		res.pb(z);
    		res.pb(q);
    	}
    }
    for(int i = 0; i < res.size(); ++i){
    	if(res[i] < ans) ans = res[i];
    }
    cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 12012
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  long long ans = 0;
  REP(i, n) {
    ans += a[i] / 2;
    a[i] %= 2;
    if (a[i] == 1 && i + 1 < n && a[i + 1] > 0) {
      ++ans;
      --a[i];
      --a[i + 1];
    }
  }
  cout << ans << '\n';
  return 0;
}


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

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 1 ; i <= a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second
#define INF 1000000000

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1

long long binpow(long long a, long long b) {
	long long res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}



void solve()
{
	ll n;
	ll limit = 1e18;
	ll p = 1;
	cin >> n;

	//cout << limit << "\n";

	bool isZero = false;

	ll a[n];
	for (ll i = 0 ; i < n  ; i++)
	{
		cin >> a[i];
		if (a[i] == 0) isZero = true;
	}

	if (isZero)
	{
		cout << "0\n";
		return;
	}

	for (ll i = 0 ; i < n ; i++)
	{
		if (a[i] <=  1000000000000000000 / p)
			p *= a[i];
		else {
			cout << "-1\n";
			return;
		}
	}

	cout << p << "\n";
}



int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);


	int t = 1;
	//cin >> t;


	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 4420
from bisect import bisect_left
from bisect import bisect_right

N = int(input())

A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
num_a = 0
num_c = 0
res = 0
pre_b = -1


for b in B:
    if b == pre_b:
        res += num_a * num_c
        continue
    num_a = bisect_left(A, b) # a < b となるAの要素数
    pre_num_c = bisect_right(C, b)
    num_c = N - pre_num_c # c > b となるAの要素数
    res += num_a * num_c
    pre_b = b
print(res)



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

int main()
{
    string w;
    cin >> w;
    int cnt[26] = {},flag = 0;
    for(int i = 0; i < w.length(); i++) cnt[w[i]-'a']++;
    for(int i = 0; i < 26; i++) if(cnt[i] % 2 != 0) flag = 1;

    cout << (flag == 0 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>
#include <fstream>
#include <cfloat>
#include <complex>
using namespace std;
int main() {
	int n, k; cin >> n >> k;
	vector<int> logs(n);
	for (auto& log : logs) cin >> log;
	int min = 1, max = 1000000000;
	while (min < max) {
		const auto mid = (min + max) >> 1;
		int count_rest = k;
		for (auto log : logs) {
			if (log > mid) {
				count_rest -= log / mid;
			}
			if (count_rest < 0) break;
		}
		if (count_rest < 0) {
			min = mid + 1;
		}
		else {
			max = mid;
		}
	}
	cout << max << '\n';
}

Measured memory_bytes: 3956
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}
bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};

int main(){
    ll N; cin >> N;
    const ll al = 1e6 + 10;
    map<ll, ll> m;
    REP(i, al) m[i] = 0;
    REP(i, N){
        ll a; cin >> a; m[a]++;
    }
    
    ll ret = 0;
    REP(i, al - 2){
        ll tmp = m[i] + m[i+1] + m[i+2];
        ret = max(ret, tmp);
    }
    cout << ret << endstr;
    return 0;
}


Measured memory_bytes: 62848
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var dic = new Dictionary<long, long>() { };
        for (int i = 0; i < a.Length; i++)
        {
            if (!dic.ContainsKey(a[i]))
            {
                dic.Add(a[i], 1);
            }
            else
            {
                dic[a[i]]++;
            }
        }


        // 出力
        //Console.WriteLine(ans);

        for (int i = 1; i <= n; i++)
        {
            if (!dic.ContainsKey(i))
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(dic[i]);
            }

        }
    }
}

Measured memory_bytes: 56844
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
ll dp[401][401];
ll sum[401][401];
ll solve(ll arr[], ll i, ll j){
    if(i==j){
        return 0;
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    ll minCost=100000000000000000;
    for(int k=i;k<j;k++){
        minCost=min(minCost,sum[i][j]+solve(arr,i,k)+solve(arr,k+1,j));
    }
    dp[i][j]=minCost;
    return dp[i][j];
}
void calcSum(ll arr[], ll n){
    for(int i=1;i<=n;i++){
        for(ll j=1;j<=n;j++){
            sum[i][j]=arr[j];
            if(j>i){
                sum[i][j]+=sum[i][j-1];
            }
        }
    }
}
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    for(int x=1;x<=t; x++) {
        ll n;
        cin>>n;
        ll arr[n+1];
        for(ll i=1;i<=n;i++){
            cin>>arr[i];
        }
        memset(dp,-1, sizeof(dp));
        memset(sum,0, sizeof(sum));
        calcSum(arr,n);
        cout<<solve(arr,1,n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t 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) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;}


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

int S, W; cin >> S >> W;

if (W >= S) cout << "unsafe\n";
else cout << "safe\n";




return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 問題文から考える。自分ができることから考える。
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索。逆から考える。
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



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

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 507;
const int MX = 1e9 + 7;
const LL INF = 1LL * MX * MX;

int n, m, k;
char in[N][N];

int cnt;
int ans[N][N];

void solve(int from, int to){
	int last = 0;
	for(int i = 1; i <= m; ++i){
		if(in[to][i] == '.')
			continue;
		
		++cnt;
		for(int a = from; a <= to; ++a)
			for(int b = last + 1; b <= i; ++b)
				ans[a][b] = cnt;
		last = i;
	}
	
	for(int i = from; i <= to; ++i)
		for(int j = last + 1; j <= m; ++j)
			ans[i][j] = cnt;
}

int main(){
	scanf("%d %d %d", &n, &m, &k);
	for(int i = 1; i <= n; ++i)
		scanf("%s", in[i] + 1);
	
	int last = 0;
	for(int i = 1; i <= n; ++i){
		bool empty = true;
		for(int j = 1; j <= m; ++j)
			empty &= in[i][j] == '.';
		
		if(!empty){
			solve(last + 1, i);
			last = i;
		}
	}

	for(int i = last + 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			ans[i][j] = ans[i - 1][j];
	
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= m; ++j)
			printf("%d ", ans[i][j]);
		puts("");
	}

	return 0;
}

Measured memory_bytes: 1536
fun main(args: Array<String>) {
    cf17finalb()
}

fun cf17finalb() {
    val s = readLine()!!

    if (s.length == 1) return println("YES")

    if (s.length == 2) return println(if (s[0] == s[1]) "NO" else "YES")

    val grouped = s.groupBy { it }.map { it.value.size }

    if (grouped.size < 3) return println("NO")

    val (a, b, c) = grouped.sorted()

    val answer = when (s.length % 3) {
        0 -> a == b && b == c
        1 -> a == b && b + 1 == c
        else -> a + 1 == b && b == c
    }.let { if (it) "YES" else "NO" }

    println(answer)
}


Measured memory_bytes: 39576
catch(:label) do

  while line = gets  
    throw :label if line == "0 0\n"
    a = line.chomp.split(" ")

    p_0 = a[0].to_i
    p_1 = a[1].to_i
    if p_0 > p_1
      a[0] = p_1
      a[1] = p_0
    else
      a[0] = p_0
      a[1] = p_1
    end
    puts  a[0].to_s + " " + a[1].to_s + "\n"    
  end
end

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

const int offset = 12800;
bitset<2 * offset + 1> dp[81][81];

int main() {
  int H, W; cin >> H >> W;
  vector<vector<int>> X(H + 1, vector<int>(W + 1, 0));
  rep(h, H) rep(w, W) cin >> X[h][w];
  rep(h, H) rep(w, W) {
    int B; cin >> B;
    X[h][w] -= B;
    if (X[h][w] < 0) X[h][w] = -X[h][w];
  }

  dp[0][0][offset + X[0][0]] = 1;

  rep(h, H) rep(w, W) {
    dp[h][w + 1] |= (dp[h][w] << X[h][w + 1]) | (dp[h][w] >> X[h][w + 1]);
    dp[h + 1][w] |= (dp[h][w] << X[h + 1][w]) | (dp[h][w] >> X[h + 1][w]);
  }

  const int INF = 1e9 + 10;
  int ans = INF;
  rep(i, 2 * offset + 1) {
    if (dp[H - 1][W - 1][i]) ans = min(ans, abs(i - offset));
  }

  cout << ans << endl;
}

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

int main() {
    vector<int> st(5);
    for(int i=0; i<5; i++){
        cin >> st[i];
    }
    int minin=0;
    for(int i=1; i<5; i++){
        int pre = st[minin]%10;
        int next = st[i]%10;
        if(next < pre && next != 0){
            minin = i;
        }
    }
    int ans=0;
    for(int i=0; i<5; i++){
        if(i==minin){
            ans+=st[i];
            continue;
        }
        if(st[i]%10 == 0){
            ans += st[i];
        }else{
            int aa = st[i]/10 + 1;
            ans += aa*10;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char ca[100005];
const int INF=1<<30;
int main(){
	int n;
	int a,b;
	int s=INF;
	int i,j,k;
	cin>>ca;
	n=strlen(ca);
	s=n;
	for(i=1;i<n;i++){
		if(ca[i]!=ca[i-1]){
			s=min(s,max(n-i,i));
		}
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 384
import sys
h, w, k = map(int, input().split())

mod = 10 ** 9 + 7

if w == 1:
    print(1)
    sys.exit()

n_join = [0 for i in range(w-1)]
n_unjoin = [0 for i in range(w-1)]
cnt = 0

for i in range(2 ** (w-1)):
    p = 0
    f = 1
    tmp_join = []
    tmp_unjoin = []
    for j in range(w-1):
        c = i & (1 << j)
        if c:
            tmp_join.append(j)
        if not (c or p):
            tmp_unjoin.append(j)
        if p and c:
            f = 0
            break
        p = c
    if f:
        cnt += 1
        for j in tmp_join:
            n_join[j] += 1
        for j in tmp_unjoin:
            n_unjoin[j] += 1

n_unjoin.append(cnt - n_join[-1])

dp = [[0 for j in range(w)] for i in range(h)]
dp[0][0] = n_unjoin[0]
dp[0][1] = n_join[0]

for i in range(1,h):
    for j in range(w):
        dp[i][j] += dp[i-1][j] * n_unjoin[j] % mod
        dp[i][j] %= mod
        if j > 0:
            dp[i][j] += dp[i-1][j-1] * n_join[j-1] % mod
            dp[i][j] %= mod
        if j < w - 1:
            dp[i][j] += dp[i-1][j+1] * n_join[j] % mod
            dp[i][j] %= mod
        
print(dp[h-1][k-1])

Measured memory_bytes: 3188
/* ex3_3
    riverstone*/

#include <stdio.h>
 
int main(void){
    // 数値N、進数baseをintで定義し入力する。
    int N,base; 
    scanf("%d%d", &N, &base);
    
    // 桁数
    int digit = 1; 

    //Nをbaseで何回割れるかを数える。
    //while文によりbaseで割った商が0より大きい間繰り返す
    while (N / base > 0)
    {
        N /= base;     //NにNをbaseで割った商を代入
        digit += 1;
    }

    // digitを出力
    printf("%d\n", digit);
 
    return 0;
    
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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 end



int main(){
    string s; cin>>s; int n=s.size();
    bool f=0;
    rep(i,0,n-1)if(s[i]!=s[n-i-2])f=1;
    if(s[0]=='0'||s[n-1]=='1')f=1;
    if(f){
        printf("-1\n"); return 0;
    }
    vector<pair<int,int>> ans; int cur=0;
    rep(i,0,n-1){
        ans.push_back({cur,i+1});
        if(s[i]=='1')cur=i+1;
    }
    rep(i,0,n-1)printf("%d %d\n",ans[i].first+1,ans[i].second+1);
    return 0;
}

Measured memory_bytes: 2420
def pow_k(x, n, mod):
  if n == 0:
    return 1

  K = 1
  while n > 1:
    if n % 2 != 0:
      K = (x * K) % mod
        
    x = (x * x) % mod

    n //= 2

  return (x * K) % mod

#nCr % mod
def comb_mod(n, r, mod):
  x = 1
  y = 1
  for i in range(r):
    x = (x * (n - i)) % mod
    y = (y * (i + 1)) % mod
    
  ans = x * pow_k(y, mod-2, mod)
  
  return ans % mod

MOD = 10 **9 +7
s = int(input())

ans = 0
for i in range(1, s // 3 + 1):
  count = 0
  tmp = s - i * 3
  c = max(1, comb_mod(tmp+i-1, i-1, MOD))
  ans += c
  ans %= MOD
  
print(ans)

Measured memory_bytes: 67544
#include<iostream>
#include<cmath>
using namespace std;
void backtracking(int depth);

int n = 0;

int s1[8] = {};
int s2[8] = {};
int temp[8] = {};

bool test[9] = {};

int count1 = 0;

int counts1 = 0;
int counts2 = 0;

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> s1[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> s2[i];
    }
    backtracking(0);
    cout << abs(counts1 - counts2);
    return 0;
}
void backtracking(int depth)
{
    if (depth == n)
    {
        count1++;
        int flag1 = 1;
        int flag2 = 1;
        for (int i = 0; i < n; i++)
        {
            if (temp[i] != s1[i])
            {
                flag1 = 0;
            }
        }
        if (flag1)
        {
            counts1 = count1;
        }
        for (int i = 0; i < n; i++)
        {
            if (temp[i] != s2[i])
            {
                flag2 = 0;
            }
        }
        if (flag2)
        {
            counts2 = count1;
        }
    }
    else
    {
        for (int i = 1; i <= n; i++)
        {
            if (test[i])
            {
                continue;
            }
            test[i] = 1;
            temp[depth] = i;
            backtracking(depth + 1);
            test[i] = 0;
            temp[depth] = 0;
        }
    }
}

Measured memory_bytes: 256
from math import radians, sin, cos
import sys
x, y, a = 0, 0, 0
for l in sys.stdin.readlines()[:-1]:
    d, _a = map(int, l.split(","))
    x += d * sin(radians(a))
    y += d * cos(radians(a))
    a += _a

print(int(x), "\n", int(y), sep="")

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

int main()
{
    string s;
    cin >> s;
    int price = 700;

    for(int i = 0; i < 3; i++)
    {
        if(s.at(i) == 'o')price += 100;
    }

    cout << price << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, M;
string S;

int main() {

	cin >> N >> M >> S;

	ll c = 0;
	for (auto s : S) {
		if (s == '1') c++;
		else c = 0;
		if (c >= M) {
			cout << -1 << endl;
			return 0;
		}
	}

	vector<int> ans;
	int l = N;
	while (l > M) {
		for (int i = M;; --i) {
			if (S[l - i] == '0') {
				ans.push_back(i);
				l -= i;
				break;
			}
		}
	}
	ans.push_back(l);

	for (auto ritr = ans.rbegin(); ritr != ans.rend(); ++ritr) {
		cout << *ritr << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1144
def solve(N, M, X, A):
    a = sum(A[:X])
    if x == N:
        return 0
    b = sum(A[X+1:])
    return min(a, b)
if __name__ == "__main__":
    s = input()
    N, M, X = list(map(lambda x: int(x), s.split()))
    A = [0 for x in range(N)]
    for x in map(lambda x: int(x), input().split()):
        A[x] = 1 
    print(solve(M, N, X, A))


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pill;
typedef pair<ll, int> plli;

vector<ll> bfs(vector<vector<pill>>& graph, int s) {
  vector<ll> ret;
  ret.resize(graph.size());
  for(int i = 0; i < ret.size(); i++) ret[i] = 1e15;
  ret[s] = 0;
  priority_queue<plli> q;
  q.push({0, s});
  while(!q.empty()) {
    plli curr = q.top();
    q.pop();
    if(ret[curr.second] != -curr.first) continue;
    for(pill out: graph[curr.second]) {
      if(ret[out.first] > ret[curr.second] + out.second) {
        ret[out.first] = ret[curr.second] + out.second;
        q.push({-ret[out.first], out.first});
      }
    }
  }
  return ret;
}

void solve() {
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  vector<vector<pill>> sEdges;
  vector<vector<pill>> tEdges;
  s--;
  t--;
  sEdges.resize(n);
  tEdges.resize(n);
  while(m--) {
    int a, b;
    ll c, d;
    cin >> a >> b >> c >> d;
    a--;
    b--;
    sEdges[a].push_back({b, c});
    sEdges[b].push_back({a, c});
    tEdges[a].push_back({b, d});
    tEdges[b].push_back({a, d});
  }
  vector<ll> sDP = bfs(sEdges, s);
  vector<ll> tDP = bfs(tEdges, t);
  vector<ll> ret;
  ll bestCost = 1e15;
  for(int i = n-1; i >= 0; i--) {
    bestCost = min(bestCost, sDP[i] + tDP[i]);
    ret.push_back(1e15 - bestCost);
  }
  reverse(ret.begin(), ret.end());
  for(ll out: ret) cout << out << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 19964
// AOJ 585 Nearest Two Points
// 2017.9.24 bal4u
// 2018.3.17

#include <stdio.h>

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define INF     1e7
#define EPS     1e-5
#define RANGE	110
#define SIN     0.70710678118654752440084436210485    // Sin(45)
#define COS     0.70710678118654752440084436210485    // Cos(45)
#define SINCOS  SIN

typedef struct { double x, y; } T;
T tbl[500000+RANGE];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	if (c == '-') {	c = getchar_unlocked();
		do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int cmp(T *a, T *b)
{
	if (fabs(a->x - b->x) < EPS) {
		if (fabs(a->y - b->y) < EPS) return 0;
		if (a->y < b->y) return -1; return 1;
	}
	if (a->x < b->x) return -1;	return 1;
}

int main()
{
	int N, i, j, lim;
	int x, y;
	double dx, dy, d, t, ans;

	N = in();
	for (i = 0; i < N; i++) {
		x = in(), y = in();
		tbl[i].x = (x - y) * SINCOS;
		tbl[i].y = (x + y) * SINCOS;
	}
	qsort(tbl, N, sizeof(T), cmp);

	ans = INF; d = 0;
	for (i = N; i < N+RANGE; i++) tbl[i].x = INF, tbl[i].y = 0;
	for (i = 0; i < N; i++) {
		lim = i+RANGE; for (j = i+1; j < lim; j++) {
			dx = tbl[i].x-tbl[j].x; if (dx > d) continue;
			dy = tbl[i].y-tbl[j].y; if (dy > d) continue;
			t = dx*dx + dy*dy;
			if (t < ans) ans = t, d = sqrt(t);
		}
	}
	printf("%.0lf\n", ans);
	return 0;
}


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

int main(){
  int N;
  cin >> N ;
  vector<int>a(N);
  rep(i,N) cin >> a[i];
  
  int mx = a[0], mn = a[0];
  rep(i,N){
    mx = max(mx,a[i]);
    mn = min(mn,a[i]);
  }
   
  int ans = 1000100;
  for( int i = mn; i <= mx; i++){
    int sum = 0;
    rep(j,N){
      sum += (a[j]-i)*(a[j]-i);
    }
    ans = min( ans, sum );
  } 
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#define LL long long
using namespace std;
bitset <4000010> t;
int n;
int b[4000010], bl;
int main() {
	int i, j, k;
	scanf("%d", &n);
	t[0] = 1;
	int zs = 0;
	for(i = 1; i <= n; i++){
		int x;
		scanf("%d", &x);
		t |= (t<<x);
		zs += x;
	}
	for(i = 1; i <= zs; i++) if(t[i] == 1) b[++bl] = i;
	printf("%d\n", b[bl+1>>1]);
	return 0;
}

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

int main()
{
    char s[20];

    while(cin >>s)
    {
        if(s[0] == 'S')
            cout << "Cloudy\n";
        else if(s[0] == 'C')
            cout << "Rainy\n";
        else
            cout << "Sunny\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    char c[n];
    REP(i,n){
        cin >> c[i];
    }

    int ans = 0;
    int left = 0;
    int right = n-1;
    bool left_end = false;
    bool right_end = false;
    while(left < right){
        while(c[left] == 'R'){
            left++;
            if(n-1 <= left){
                left_end = true;
                break;
            }
        }
        while(c[right] == 'W'){
            right--;
            if(right <= 0){
                right_end = true;
                break;
            }
        }
        if(left_end == true || right_end == true || left >= right){
            break;
        }
        left++;
        right--;
        ans++;
    }
 
    cout << ans << "\n";


    return 0;
}

Measured memory_bytes: 3844
// fahadmd16(IIEST Shibpur)
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define ll long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define db double
#define pll pair<ll, ll>
#define ALL(a) (a).begin(),(a).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i < n; i++)
#define forab(i,a,b) for(ll i=a;i<b;i++)
#define clr(x) memset(x, 0, sizeof(x))
#define count_bit(x) __builtin_popcount(x)
#define endl "\n"
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define eps 1e-10
#define nedl endl
const ll sz = 1e6;
const ll mod = 1e9+7;
typedef vector<ll> VL;
typedef vector<pll > VLL;
typedef vector<vector<ll> > VVL;
 
ll power(ll n,ll k,ll m){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%m;
        k/=2;
        n=(n*n)%m;
    }
    return ans;
}



int main() {
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ll T=1;//cin>>T;
    
    while(T--){
        ll x,y,a,b,c;cin>>x>>y>>a>>b>>c;
        VLL v;
        forn(i,a){ll k;cin>>k;v.eb(k,1);}
        forn(i,b){ll k;cin>>k;v.eb(k,2);}
        forn(i,c){ll k;cin>>k;v.eb(k,3);}
        sort(ALL(v),greater<pll >());
        ll tot=x+y,ans=0;
        forn(i,v.size()){
            ll val=v[i].ff,type=v[i].ss;
            if(!tot)break;
            if(type==1){
                if(x){
                    ans+=val;
                    x--;
                    tot--;
                }
            }
            else if(type==2){
                if(y){
                    ans+=val;
                    y--;
                    tot--;
                }
            }
            else{
                ans+=val;
                tot--;
            }
        }
        cout<<ans<<endl;       

        

    }
    return 0;
}


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

using namespace std;

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

    int n;
    cin >> n;

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

    int number = 1, k = 0;
    for(int i=0; i<n; i++){
        if(a[i] == number){
            k++;
            number++;
        }
    }

    cout << (n-k < n ? (n-k) : -1)  << "\n";


    return 0; 
} 

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

long long Pow(long long m, int n) {
  if (n == 0)
    return 1;
  long long res = Pow(m * m % 1000000007, n / 2);
  if (n % 2 == 1)
    res = res * m % 1000000007;
  return res;
}

int main() {
  int m, n;
  cin >> m >> n;
  cout << Pow(m, n) << endl;
}


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

using namespace std;

int main (void){
  int n, k;
  cin >> n >> k;
  cin.ignore();
  int l[n] = {0};

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

  sort(l, l + n);
  int sum = 0;
  for (int i = n - k; i < n; i++){
    sum += l[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int n  = sc.nextInt();
		int[] x = new int[n];
		
		for(int i =0;i<n;i++) {
			x[i]= sc.nextInt();
		}
		
		long min=1000000000;
		int best=-1;
		for(int j=1;j<101;j++) {
			long sum= 0;
			for(int i=0;i<n;i++) {
				sum+=(j-x[i])*(j-x[i]);
			}
			if(sum<min) {
				min=sum;
			}
		}
		for(int i=0;i<n;i++) {
			long sum= 0;
			
		}

		System.out.println(min);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  string u;
  cin>>u;
  if(u==s){
    cout<<a-1<<" "<<b<<endl;
  }
  else{
    cout<<a<<" "<<b-1<<endl;
  }
}

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

int main(){
	int n, ans = 100000;
	cin >> n;
	for(int i = 0; i < n; i++){
		ans *= 1.05;
		if(ans % 1000 != 0) ans += (1000 - (ans % 1000));
	}
	cout << ans << endl;

}

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

int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;
    cin >> n >> k;

    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }

    int ind = -1;
    int idx = 0;
    for (int i = 0; i < n; i++) {
        if (ind * v[i] <= 0) {
            idx = i;
            break;
        }
        ind = v[i];
    }

    int ans = INT32_MAX;
    for (int i = 0; i < n - k + 1; i++) {
        int te1, te2;
        te1 = fabs(v[i]) + fabs(v[i] - v[i + k - 1]);
        te2 = fabs(v[i + k - 1]) + fabs(v[i + k - 1] - v[i]);

        ans = min(te1, ans);
        ans = min(te2, ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int gcd(int a,int b){
	int tmp;
	while(a%b!=0){
	tmp=a;
	a=b;
	b=tmp%b;
}
return b;
}
int tgcd(int a,int b,int c){
	return gcd(gcd(a,b),c);
}
int main() {
	int K;
	long int sum=0;
	cin>>K;
	for(int i=1;i<=K;i++){sum+=i;}
	for(int i=1;i<=K;i++){
		for(int j=i+1;j<=K;j++){sum+=6*gcd(i,j);}
	}
	for(int i=1;i<=K;i++){
		for(int j=i+1;j<=K;j++){
			for(int k=j+1;k<=K;k++){
				sum+=6*tgcd(i,j,k);
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3632