akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#define endl '\n'
//#define ll long long
#define mod 1000000007
#define NCONS 100001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
#define int long long
#define double long double
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
typedef long long ll;

ll gcd(ll a, ll b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

#define YYYY cout << "YES" << endl
#define NNNN cout << "NO" << endl
#define yyyy cout << "Yes" << endl
#define nnnn cout << "No" << endl

map<string, int> mp;

int32_t main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int N; cin >> N; //vector<string> vec;
    
    for(int i = 0; i < N; i++)
    {
        string t; cin >> t; sort(t.begin(), t.end()); //vec.push_back(t);
        mp[t] += 1;
    }
    int cnt = 0;
    
    for(auto ptr = mp.begin(); ptr != mp.end(); ptr++)
    {
        int n = ptr->second;
        cnt += n * (n-1) / 2;
    }
    
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
ll c[200100], d[200100]; 


int main() {
	int m;
	cin >> m;
	rep(i,m) cin >> d[i] >> c[i];
	ll s = 0, len = 0;
	rep(i,m) {
		s += c[i] * d[i];
		len += c[i];
	}
	ll ans = (len-1) + ((s-1)/9);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6748
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int h,w;
int c[220][220];
int main(){
    cin >> h >> w;
    for(int i=0;i<10;i++)
        for(int j=0;j<10;j++)
            cin >> c[i][j];
    for(int k=0;k<10;k++)
        for(int i=0;i<10;i++)
            for(int j=0;j<10;j++)
                if(c[i][j]>(c[i][k]+c[k][j])) c[i][j] = c[i][k]+c[k][j];

    ll ans = 0;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++){
            int tmp;
            cin >> tmp;
            if(tmp!=-1){
                ans += (ll)c[tmp][1];
            }
        }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
    int n,x;cin>>n>>x;
    if(n==0&&x==0)break;
    int count=0;
    for(int i=1;i<=n-2;i++){
        for(int j=i+1;j<=n-1;j++){
            if(x-i-j<=n&&x-i-j>j)count++;
        }
    }
    cout<<count<<endl;
    }
}


Measured memory_bytes: 3104
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>  
#include<set>
#include<iterator>
#include<list>
#include<utility>
#include<cstdlib>
#include<queue>
#include<stack>
#include<bitset>
//#include<bits/stdc++.h>
#define PI  2*acos(0.0)
#define pb push_back

       
using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;



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

ll x,y;
cin>>x>>y;

if(y%2==0 && 2*x<=y && 4*x>=y)
{
	cout<<"Yes"<<"\n";
}

else
{
	cout<<"No"<<endl;
}













	
	
	return 0;
	
	
	       /***Israil Hosen
	            Computer Science & Engineering
	         University Of Rajshahi.
	         ***/
	
	
	
}

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

int main(){
  int N;
  cin >> N;
  int ans = 0;
  vector<int> v(N);
  
  for(int i=0;i<N;i++){
    cin >> v.at(i);
  }
  
  bool flag1 = 1;
  bool finished = 0;

  while(flag1){
    for(int i = 0;i<N;i++){ //割り切れないものがあれば
      //cout << i << endl;
      if(v.at(i) % 2 != 0){ //flag1をfalseに
        flag1 = 0;
        finished = 1;
        break;
      }
    }
    //cout << "hey" << endl;
    if(finished == 0){
      for(int i = 0;i<N;i++){
        v.at(i) = v.at(i) / 2;
        //cout << v.at(i) << endl;
      } 
      ans++;
      //cout << "heyhey" << endl;
    }else{break;}
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int main()
{
  int a;
  cin >> a;
  cout << a * a * a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
	int n, l;
	vector<string> v;
	string s;

	cin >> n >> l;
	for(int i=0;i<n;i++){
		cin >> s;
		v.push_back(s);
	}
	sort(v.begin(), v.end());
	for(int i=0;i<n;i++)cout << v[i];
	puts("");

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>
#include <iomanip>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

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

typedef unsigned long long u64;
typedef long long i64;

int n;
int h;
int cx, cy;
int x[101];
int y[101];
int z[101];

int calc(int p, int q) {
        int aa = p - cx;
        int bb = q - cy;
        aa = aa > 0 ? aa : -aa;
        bb = bb > 0 ? bb : -bb;
        return max(h- aa-bb, 0);
}

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

        cin >> n;
        REP(i, n) {
                cin >> x[i] >> y[i] >> z[i];
        }


        REP(p, 101) {
                REP(q, 101) {
                        int zzz = 0;
                        cx = p;
                        cy = q;
                        h = 0;
                        REP(i,n) {
                                if (z[i] > 0) {
                                        int aa = x[i] - cx;
                                        int bb = y[i] - cy;
                                        h = (aa > 0 ? aa : -aa) + (bb > 0 ? bb : -bb) + z[i];
                                        break;
                                }
                        }

                        REP(i,n) {
                                int k = calc(x[i], y[i]);
                                if (k != z[i]) {
                                        zzz = 1;
                                        break;
                                }
                        }
                        if (h == 0) continue;
                        if (!zzz) {
                                cout << p << " " << q << " " << h << endl;
                                return 0;
                        }
                }
        }



        return 0;
}


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

// 迷路を解いて、最小歩数を返す
int solve_maze(pair<int, int> start, pair<int, int> goal, pair<unsigned int, unsigned int> hw, vector<vector<char>>& maze) {
	// 初期化
	unsigned int H, W;
	tie(H, W) = hw;
	vector<vector<bool>> decision(H, vector<bool>(W, false)); // 確定フラグ
	vector<vector<int>> steps(H, vector<int>(W, 0)); // スタートからの最小歩数
	queue<pair<int, int>> que;

	// スタート地点
	decision.at(start.first).at(start.second) = true;
	que.push(make_pair(start.first, start.second));

	// 幅優先探索
	int y, x;
	while (!que.empty()) {
		// キューの先頭を拾う
		tie(y, x) = que.front();
		que.pop();

		// 4箇所を確定、キューに投げる
		if (y+1 < H && !decision.at(y+1).at(x) && maze.at(y+1).at(x) != '#') {
			decision.at(y+1).at(x) = true;
			steps.at(y+1).at(x) = steps.at(y).at(x) + 1;
			que.push(make_pair(y+1, x));
		}
		if (x+1 < W && !decision.at(y).at(x+1) && maze.at(y).at(x+1) != '#') {
			decision.at(y).at(x+1) = true;
			steps.at(y).at(x+1) = steps.at(y).at(x) + 1;
			que.push(make_pair(y, x+1));
		}
		if (y-1 >= 0 && !decision.at(y-1).at(x) && maze.at(y-1).at(x) != '#') {
			decision.at(y-1).at(x) = true;
			steps.at(y-1).at(x) = steps.at(y).at(x) + 1;
			que.push(make_pair(y-1, x));
		}
		if (x-1 >= 0 && !decision.at(y).at(x-1) && maze.at(y).at(x-1) != '#') {
			decision.at(y).at(x-1) = true;
			steps.at(y).at(x-1) = steps.at(y).at(x) + 1;
			que.push(make_pair(y, x-1));
		}
	}

	return steps.at(goal.first).at(goal.second);
}

int main() {
	unsigned int H, W;
	cin >> H >> W;
	vector<vector<char>> maze(H, vector<char>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> maze.at(i).at(j);
		}
	}

	// 一番愚直な方法
	int max_steps = 0;
	pair<unsigned int, unsigned int> hw = make_pair(H, W);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (maze.at(i).at(j) == '#') {
				continue;
			}
			for (int k = 0; k < H; k++) {
				for (int l = 0; l < W; l++) {
					if (maze.at(k).at(l) == '#') {
						continue;
					}
					int t = solve_maze(make_pair(i,j), make_pair(k,l), hw, maze);
					if (max_steps < t) {
						max_steps = t;
					}
				}
			}
		}
	}

	cout << max_steps << endl;
}


Measured memory_bytes: 384
#!/usr/bin/python3

import sys
# input = sys.stdin.readline
sys.setrecursionlimit(100000)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7

#N = int(input())
#A = [int(x) for x in input().split()]
#V = [[0] * 100 for _ in range(100)]

N,A,B = [int(x) for x in input().split()]

def f(n):
    r = 0
    for s in str(n):
        r += int(s)
    return r

ans = 0
for i in range(1,N+1):
    s = f(i)
    if A <= s and s <= B:
        ans += i

print(ans)



Measured memory_bytes: 3060
#include <cstdio>
#include <cstdint>
#include <algorithm>
using namespace std;

constexpr int MOD = 1000000007;

int main() {
  int N, M; scanf("%d%d", &N, &M);
  static int dp[301][301];
  for(int i = 1; i <= N; ++i) {
    for(int j = 1; j <= i; ++j) {
      dp[i][j] = 0;
    }
  }
  dp[1][1] = 1;
  for(int cnt = 0; cnt < M; ++cnt) {
    static int dp2[301][301];
    for(int i = 1; i <= N; ++i) {
      for(int j = 1; j <= i; ++j) {
        dp2[i][j] = 0;
      }
    }
    for(int i = 1; i <= N; ++i) {
      for(int j = 1; j <= i; ++j) {
        dp2[i][i] = (dp2[i][i] + (int64_t)dp[i][j] * j) % MOD;
        dp2[i][j] = (dp2[i][j] + (int64_t)dp[i][j] * (i - j)) % MOD;
        if(i < N) {
          dp2[i+1][j] = (dp2[i+1][j] + (int64_t)dp[i][j] * (N - i)) % MOD;
        }
      }
    }
    for(int i = 1; i <= N; ++i) {
      for(int j = 1; j <= i; ++j) {
        dp[i][j] = dp2[i][j];
      }
    }
  }
  printf("%d\n", dp[N][N]);
  return 0;
}


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

ll Pow(ll a, ll b, ll c){
    ll ans = 1;
    a %= c;
    while (b){
        if (b & 1) ans = (ans * a) % c;
        a = (a * a) % c;
        b >>= 1;
    }
    return (ans % c);
}

bool cmp(const int &a, const int &b){
    return a < b;
}

ll gcd(ll x, ll y){
    return x % y == 0 ? y : gcd(y, x % y);
}

ll lcm(ll x, ll y){
    return x / gcd(x, y) * y;
}

int main(){
    int a[3];
    scanf("%d%d%d", &a[0], &a[1], &a[2]);
    sort(a, a + 3);
    printf("%d\n", a[0] + a[1]);
    return 0;
}


Measured memory_bytes: 256
N, X = map(int, input().split(' '))
L = list(map(int, input().split(' ')))
D = [0 for _ in range(N + 1)]
for i in range(1, N + 1):
  D[i] = D[i-1] + L[i-1]
  count = 0
for i in range(N + 1):
  if D[i] <= X:
    count += 1
print(count)

Measured memory_bytes: 38724
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

int main() {
	int N;
	cin >> N;
	set<char>st;
	for (int i = 0;i < N;++i) {
		char a;
		cin >> a;
		st.insert(a);
	}
	if (st.size() == 3)cout << "Three" << "\n";
	else cout << "Four" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define mod 1000000000+7
#define rep(i,n) for(int i=0;i<(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
string s,t;
cin>>s>>t;
cout<<t<<s;
}


Measured memory_bytes: 256
S = [s for s in input()]
h = 'hi'
if len(S)%2 != 0:
    print('No')
    exit()
flag = 1
while S:
    if len(S) >= 2:
        s1 = S.pop(0)
        s2 = S.pop(0)
        tmp = s1+s2
        if tmp == h:
            continue
        else:
            flag = 0
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static IEnumerable<string> GetTexts() { return Console.ReadLine().Split(' '); }
    public static int GetInteger() { return int.Parse(Console.ReadLine()); }
    public static IEnumerable<int> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)); }
}

namespace AtCoderBeginnerContest
{
    public class Program
    {
        public static int N { get; private set; }
        public static int M { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = CR.GetIntegers().ToList();
            N = inputs[0];
            M = inputs[1];

            return N == M ? "Yes" : "No";
        }
    }
}


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

int main(){
    int time;
    cin >> time;
    int h, m, s;
    h = time / 3600;
    time %= 3600;
    m = time / 60;
    time %= 60;
    s = time;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <cstring>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;

const int N_MAX = 1000000;
/*
 pre: 4 2 3 1 5
 in:  3 2 4 5 1

*/
struct Node{
  int data;
  Node* left = NULL;
  Node* right = NULL;
};

int ans[N_MAX];
int ans_ix = 0 ;
void append_to_answer(int n){
  ans[ans_ix] = n;
  ans_ix++;
}

void postorder(Node* root){

  if(root == NULL) return;
  postorder(root->left);
  postorder(root->right);

  append_to_answer(root->data);
  // ans += (to_string(root->data) + " ");
}


void print_array(int* arr, int len){
  rep(i, 0, len){
    cout << arr[i];
    if(i==len-1) cout << endl;
    else cout << " ";
  }
}

Node* solve(int* inorder, int* preorder, int len){


  // find root
  int root_data = preorder[0];
  Node* root_node = new Node;
  root_node->data = root_data;
  if(len==1) return root_node;
  
  // count all the num left
  int left_num=0;
  while(inorder[left_num] != root_data) left_num++;
  int right_num = len - left_num - 1;
  
  int* left_inorder = new int[left_num];
  int* right_inorder = new int[right_num];
  
  int* left_preorder = new int[left_num];
  int* right_preorder = new int[right_num];

  int ix=0;
  int l_ix=0, r_ix=0;

  rep(ix, 0, len){
    if(inorder[ix] == root_data) continue;
    if(l_ix<left_num){
      left_inorder[l_ix] = inorder[ix];
      l_ix++;
    }
    else if(r_ix<right_num){
      right_inorder[r_ix] = inorder[ix];
      r_ix++;
    }
  }
  
  ix = 0; l_ix = 0; r_ix = 0;
  
  rep(ix, 1, len){
    if(l_ix < left_num){
      left_preorder[l_ix] = preorder[ix];
      l_ix++;
    }
    else if(r_ix < right_num){
      right_preorder[r_ix] = preorder[ix];
      r_ix++;
    }
  }

  if(left_num>0) root_node->left = solve(left_inorder, left_preorder, left_num);
  if(right_num>0) root_node->right = solve(right_inorder, right_preorder, right_num);
  
  delete[] left_inorder;
  delete[] right_inorder;
  delete[] left_preorder;
  delete[] right_preorder;
  
  return root_node;
  
}

int main(){
  int n; cin >> n;
  int* inorder = new int[n];
  int* preorder = new int[n];
  
  int tmp;
  rep(i, 0, n){
    cin >> tmp;
    preorder[i] = tmp;
  }
  rep(i, 0, n){
    cin >> tmp;
    inorder[i] = tmp;
  }

  Node* root = NULL;
  root = solve(inorder, preorder, n);
  postorder(root);
  //rep(i, 0, 2*n-1) cout << ans[i];
  rep(i, 0, n){
    cout << ans[i];
    if(i==n-1) cout << endl;
    else cout << " ";
  }

  delete[] inorder;
  delete[] preorder;
  delete root;
  
  return 0;
}



Measured memory_bytes: 3092
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 100002;

int n, A, B, C, x, y;
long long ats;

int main() {
    scanf("%d %d %d %d %d", &A, &B, &C, &x, &y);

    if (2 * C < A + B) {

        int minxy = min(x, y);

        ats += (long long)minxy * (long long)(2 * C);

        x -= minxy;
        y -= minxy;
    }

    if (x > 0 && 2*C < A) {
        ats += (long long)x * (long long)(2 * C);
        y -= x;
        x = 0;
    }

    if (y > 0 && 2*C < B) {
        ats += (long long)y * (long long)(2 * C);
        x -= y;
        y = 0;
    }

    if (x > 0) {
        ats += (long long)x * (long long)A;
    }

    if (y > 0) {
        ats += (long long)y * (long long)B;
    }

    cout << ats << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N first
#define D second
using namespace std;

typedef long long ll;

const int MAXN = 1e5 + 1;


int main() {
	ios_base::sync_with_stdio(0);
	
	int n, k;
	cin >> n >> k;
	if(k == 1) cout << "0\n";
	else cout << n-k << '\n';

	return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  int min = 0; 
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    if (a.at(i) < a.at(min))
      min = i;
  }
  cout << (n+k-3)/(k-1) << endl;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> pque;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        pque.push(a);
    }
    for (int i = 0; i < m; i++) {
        int t = pque.top();
        pque.pop();
        pque.push(t / 2);
    }
    long ans = 0;
    while (!pque.empty()) {
        int t = pque.top();
        pque.pop();
        ans += t;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 892
let results = ["AC", "WA", "TLE", "RE"]

var count = ["AC": 0, "WA": 0, "TLE": 0, "RE": 0]
let N = Int(readLine()!)!
for _ in 0..<N {
    count[readLine()!]! += 1
}

results.forEach({
    print($0 + " x " + String(count[$0]!))
})


Measured memory_bytes: 8104
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N = int(input())
A = list(map(int,input().split()))
MOD = 10**9 + 7
ans = 1
count = [0]*N
for a in A:
    if a == 0:
        ans *= (3-count[0])
        ans = ans % MOD
        count[0]+= 1
    else:
        ans *= (count[a-1]-count[a])
        ans = ans % MOD
        count[a] += 1
print(ans%MOD)

Measured memory_bytes: 25668
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s, t;
	cin >> s;
	int x[110000] = { 0 }, p = 0;
	for (auto c : s) {
		if (c == 'x')
			x[p]++;
		else {
			p++;
			t.push_back(c);
		}
	}
	for (int i = 0; i < t.length() / 2; i++)
		if (t[i] != t[t.length() - i - 1]) {
			cout << -1 << endl;
			return 0;
		}
	int n = 0;
	for (int i = 0; i < (p + 1) / 2; i++) {
		if (x[i] < x[p - i])
			n += x[p - i] - x[i];
		else n += x[i] - x[p - i];
	}
	cout << n << endl;
	return 0;
}


Measured memory_bytes: 1024
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);

		int[] mini = new int[]{ -1, -2, -3 }; // -1 > -2 > -3
		int temp;
		for (int i = 0; i < 10; i++) {
			temp = sc.nextInt();
			if (temp > mini[0]) {
				mini[2] = mini[1];
				mini[1] = mini[0];
				mini[0] = temp;
			} else if (temp > mini[1]) {
				mini[2] = mini[1];
				mini[1] = temp;
			} else if (temp > mini[2]) {
				mini[2] = temp;
			}
		}

		for (int i = 0; i < 3; i++)
			System.out.println(mini[i]);
	}

}

Measured memory_bytes: 26060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main(int argc, char* argv[]){
        char buf[128]={0};
        char* p=NULL;
        int a = 0;
        int b = 0;
        int c = 0;
        int x = 0;

        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        a = atoi(buf);

        memset(buf, 0, sizeof(buf));
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        p = strtok(buf, " ");
        b = atoi(p);

        memset(buf, 0, sizeof(buf));
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        p = strtok(buf, " ");
        c = atoi(p);

        memset(buf, 0, sizeof(buf));
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        p = strtok(buf, " ");
        x = atoi(p);

#ifdef DEBUG1
        printf("input: a=%d, b=%d, c=%d, x=%d\n", a, b, c, x);
#endif
        int ans=0;

        for(int i=0; i<a+1; i++){
                for(int j=0; j<b+1; j++){
                        for(int k=0; k<c+1; k++){
                                int v = 500*i+100*j+50*k;
                                if(v==x){ans++;}
                        }
                }
        }

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef DEBBY
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define ll long long
#define rep(i,a,b) for(int i=int(a); i<=int(b); i++)
#define sz(v)  (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define fs first
#define sd second
#define pb push_back


void solve(){
   string s; cin >> s;
   int count = 0; for(char c:s)
   if(c=='1') count++;
   cout << count;
} 

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}
    





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const int INF = 1e9;
const double pi=acos(-1);
using namespace std;

int main(){
  string s;
  cin >> s;
  if(s[0]==s[1] && s[1] == s[2] ) cout <<"No"<<endl;
  else cout <<"Yes"<<endl;
  return 0;
}

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


namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            
            while(true)
            {

                string[] s = Console.ReadLine().Split(' ');
                int a = int.Parse(s[0]);
                string op = (s[1]);
                int b = int.Parse(s[2]);
                

                if (op == "+")
                {int pulus =a+b;
                    Console.WriteLine(pulus);
                }
                else if (op == "-")
                {
                    int minas = a - b;
                     Console.WriteLine(minas);
                }
                else if (op == "*")
                {
                    int seki = a * b;
                     Console.WriteLine(seki);
                }
                else if (op == "/")
                {
                    int syou = a / b;
                    Console.WriteLine(syou);
                }
                else if (op == "?")
                {
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 5616
#include "bits/stdc++.h"
#include <cmath>

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    int N;
    cin >> N;
    ll C, K;
    cin >> C >> K;
    vector<ll> Ti(N);
    for(int i = 0; i < N; i++) cin >> Ti[i];
    sort(all(Ti));
    queue<ll> T;
    for(int i = 0; i < N; i++) T.push(Ti[i]);

    ll sum = 0;
    while(!(T.empty())){
        sum++;
        ll T_f = T.front();
        for(ll i = 0; i < C; i++){
            if(T.front() <= T_f + K){
                if(!T.empty()) {
                    T.pop();
                }
            }else break;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 1920
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        
        String[] s = new String[h];
        
        for(int i = 0; i < h; i++){
            s[i] = sc.next();
        }
        
        for(int i = 0; i < w+2; i++) System.out.print("#");
        System.out.println();
        
        for(String str : s){
            System.out.print("#");
            System.out.print(str);
            System.out.print("#");
            System.out.println();
        }
        for(int i = 0; i < w+2; i++) System.out.print("#");
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main(){
    string number;
    cin >> number;
    int count=0;
    int N;
    N=number.size();
    for(int j=0;j<N-1;j++){
        if(number.at(j)==number.at(j+1)){
            count ++;
            if(number.at(j+1)=='0'){
                number.at(j+1)='1';
            }else{
                number.at(j+1)='0';
            }
        }
    }
cout << count;
}
    
    
    
    
    
    


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

int main(){
  int n; cin>>n;
  int ans=0;
  vector<int> num(100001,0);
  for(int i=0;i<n;i++){
    int a; cin>>a;
    if(n<a){
      ans++;
      continue;
    }num[a]++;
  }
  for(int i=1;i<=n;i++){
    if(num[i]==0) continue;
    if(num[i]<i) ans+=num[i];
    else if(i<num[i]) ans+=num[i]-i;
  }
  cout<<ans<<endl;
}   


Measured memory_bytes: 640
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
def distant(A,B,p):
    count=0
    for i in range(len(A)):
        count +=(abs(A[i]-B[i]))**p
    count=count**(1/p)
    return print("%.10f"%count)
distant(A,B,1)
distant(A,B,2)
distant(A,B,3)

point=0
for i in range(n):
    point=max(point,abs(A[i]-B[i]))
print("%.10f"%point)


Measured memory_bytes: 5644
A,B,C,D=map(int,input().split())

HP_T=A
HP_A=C

for i in range(1,1000):
    if i%2==1:
        HP_A -= B
    else:
        HP_T -= D

    if HP_A<=0:
        print('Yes')
        exit()
    elif HP_T<=0:
        print('No')
        exit()
    else:
        pass

Measured memory_bytes: 9168
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto a1 = readln.chomp.split.to!(int[]);
  auto a2 = readln.chomp.split.to!(int[]);

  auto cnt = a1.sum + a2[$-1];
  auto cm = cnt;
  foreach (i; 1..n) {
    cnt += a2[$-i-1] - a1[$-i];
    cm = max(cnt, cm);
  }

  cm.writeln;
}


Measured memory_bytes: 256
import java.util.*;

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

    while(true){
      String s = sc.nextLine();
      if(s.equals(".")) break;

      s = s.replaceAll("[a-zA-Z \\.]+","");

      while(!s.equals("")){
        String before = s;
        s = s.replaceAll("\\(\\)|\\[\\]","");
        if(before.equals(s)) break;
      }
      System.out.println(s.equals("") ? "yes" : "no");
    }
  }
}

Measured memory_bytes: 0
#include <cstdint>
#include <iostream>
#include <vector>
using namespace std;

vector<int64_t> solve(int64_t N, const vector<int64_t> & A) {
    vector<int64_t> t1(N + 1);
    t1[0] = INT64_MIN;
    for (int i1 = 0; i1 < N + 1 - 1; ++ i1) {
        t1[i1 + 1] = ((0 <= i1) ? max<int64_t>(t1[i1], A[i1]) : INT64_MIN);
    }
    auto & g1 = t1;
    vector<int64_t> t2(N + 1);
    t2[0] = INT64_MIN;
    for (int i2 = 0; i2 < N + 1 - 1; ++ i2) {
        t2[i2 + 1] = ((((N - i2) - 1) < N) ? max<int64_t>(t2[i2], A[((N - i2) - 1)]) : INT64_MIN);
    }
    auto & g2 = t2;
    vector<int64_t> t3(N);
    for (int i3 = 0; i3 < N; ++ i3) {
        t3[i3] = max<int64_t>(max<int64_t>(max<int64_t>(INT64_MIN, g1[i3]), g2[(((N - (i3 + 1)) - 1) + 1)]), 0);
    }
    auto & f = t3;
    return f;
}

int main() {
    int64_t n; cin >> n;
    vector<int64_t> a(n);
    for (int64_t i = 0; i < n; ++ i) {
        cin >> a[i];
    }
    auto b = solve(n, a);
    for (int64_t i = 0; i < n; ++ i) {
        cout << b[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	ll n;
	cin >> n;
	ll ans = 0;
	vector<ll> a(100);
	rep(i, 100) a[i] = (i + 1) * (i + 2) / 2 - 1;
	for (ll i = 2; i*i <= n; i++) {
		int cnt = 0;
		while (n%i == 0) {
			n /= i;
			cnt++;
		}
		ans += lower_bound(all(a), cnt) - a.begin();
	}
	if (n != 1) ans++;
	cout << ans << '\n';
}

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

const int mod = 1e9+7;

int power(int a, int b){
    int ans = 1;
    while(b){
        if (b&1){
            ans = (ans*a)%mod;
        }
        a = (a*a)%mod;
        b>>=1;
    }
    return ans;
}


signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    int n;
    cin>>n;

    if (n==1){
        cout<<0<<endl;
        return 0;
    }

    int both = power(10, n) - power(8, n);
    both = (both%mod+mod)%mod;
    int sep = power(10, n) - power(9, n);
    sep = (sep%mod+mod)%mod;
    int uni = 2*sep - both;
    uni = (uni%mod+mod)%mod;

    int ans = uni;

    cout<<ans<<endl;

    return 0;
}






Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<int> s(n);
	rep(i, 0, n - 1)cin >> s[i];
	int ans = 0;
	sort(all(s));
	rep(i, 0, n - 1)ans += s[i];
	if (ans % 10 == 0)
	{
		rep(i, 0, n - 1)
		{
			if (s[i] % 10 != 0)
			{
				ans -= s[i];
				break;
			}
			if (i == n - 1)
			{
				cout << 0 << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)
func main(){
	var N,M int
	fmt.Scan(&N,&M)
	H := make([]int,N)
	A := make([]int,M)
	B := make([]int,M)
	for i:=0;i<N;i++{
		fmt.Scan(&H[i])
	}
	for i:=0;i<M;i++{
		fmt.Scan(&A[i],&B[i])
	}
	t := make([]int,N)
	for i:=0;i<N;i++{
		t[i] = 1
	}

	for i:=0;i<M;i++{
		if H[A[i]-1]>H[B[i]-1]{
			t[B[i]-1] = 0
		}else if H[A[i]-1]<H[B[i]-1]{
			t[A[i]-1] = 0
		}else{
			t[A[i]-1] = 0
			t[B[i]-1] = 0
		}
	}
	 ans := 0
	for i:=0;i<N;i++{
		ans +=t[i] 
	}

	fmt.Println(ans)

}

Measured memory_bytes: 7788
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define NL << endl
#define REP(i,n) for(int (i) = 0; i < (n); ++(i))
#define Yes cout << "Yes" NL
#define No cout << "No" NL

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int INTMAX = numeric_limits<int>::max();
constexpr int INTMIN = numeric_limits<int>::min();
constexpr ll LLMAX = numeric_limits<long long>::max();
constexpr ll LLMIN = numeric_limits<long long>::min();
constexpr int MOD = 1000000007;


int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

using namespace std;

struct T {
	int y, p, i;
	bool operator<(const T& o) {
		return y < o.y;
	}
};

signed main() {
	int n, m;
	cin >> n >> m;
	vector<T> in(m);
	for(int i = 0; i < m; i++) {
		int p, y;
		cin >> p >> y;
		in[i].y = y;
		in[i].p = p;
		in[i].i = i;
	}

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

	vector<string> ans(m+1);
	vector<int> cnt(n+1, 0);
	for (int i = 0; i < m; i++) {
		int t = ++cnt[in[i].p];
		char ss[15];
		sprintf(ss,"%06d%06d", in[i].p, t);
		ans[in[i].i] = string(ss);
	}

	for (int i = 0; i < m; i++) {
		cout << ans[i] NL;
	}

	return 0;

}



Measured memory_bytes: 8576
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;




int main(void) {
    ll N;
    cin >> N;
    ll cnt[111]={};
    ll i;
    ll R=0;
    
    for(i=0; i<N; i++) {
        ll a;
        cin >> a;
        chmax(R, a);
        cnt[a]++;
    }
    
    ll min=-1;
    if(R%2==0) {
        min=R/2;
        for(i=R; i>=min+1; i--) {
            if(cnt[i]<2) {
                puts("Impossible");
                return 0;
            }
            cnt[i]-=2;
        }
        if(cnt[R/2]!=1) {
            puts("Impossible");
            return 0;
        }
        cnt[R/2]=0;
    }else {
        min=R/2+1;
        for(i=R; i>=min; i--) {
            if(cnt[i]<2) {
                puts("Impossible");
                return 0;
            }
            cnt[i]-=2;
        }
    }
    
    for(i=0; i<=min; i++) {
        if(cnt[i]) {
            puts("Impossible");
            return 0;
        }
    }
    
    puts("Possible");
    
}








Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::*;
use std::collections::*;
use std::cmp::*;
use std::mem::swap;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        K: usize,
    }

    let mut ans = vec![];
    let mut que = VecDeque::new();
    for i in 1..10 {
        que.push_back(i as i64);
    }

    while ans.len() <= K {
        let mut num = que.pop_front().unwrap();
        ans.push(num);

        let d = num % 10;
        num *= 10;
        for i in max(0, d - 1)..min(10, d + 2) {
            que.push_back(num + i);
        }
    }

    println!("{}", ans[K - 1]);
}


Measured memory_bytes: 4832
#詳しくはcollections pythonで検索。出てきた文字列の数をカウントする。
from collections import Counter
#入力。文字列は扱いやすくするためリスト化した。
#先に空のリスト作らないとリストに入れられないので作る。
N = int(input())
S = [None for _ in range(N)]
for i in range(N):
  S[i] = input()
count = Counter(S)
countkey = list(count.keys())
countval = list(count.values())
lcv = len(countval)
maxval = max(countval)
Se = [None for _ in range(N)]
for i in range(lcv):
  if countval[i] == maxval:
    Se[i] = countkey[i]
Seprint = [se for se in Se if type(se) == str]
Seprint = sorted(Seprint)
lSe = len(Seprint)
for i in range(lSe):
  print(Seprint[i])

Measured memory_bytes: 39644
from sys import stdin
N = int(stdin.readline().rstrip())
data = []
for _ in range(N):
    data.append((int(input())))

pos = 0
cnt = 0
flag = False 
for _ in range(N):
    cnt += 1
    if data[pos] == 2:
        flag = True
        ans = cnt
        break
    pos = data[pos] - 1
    
if flag:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 7084
import numpy as np
import math
N = int(input())


X = list(map(int, input().split()))
X.sort()

# med = int(math.sqrt((sum(out2)/N)))

cal = [0]*N
r = min(X)
l = max(X)
mid = (l - r) // 2
out = []

for j in range(X[0], X[-1]+1):
    for i in range(N):
        cal[i] = (X[i] - j) ** 2
    out.append(sum(cal))

out.sort()
print(out[0])


Measured memory_bytes: 12544
#include <iostream>

 using namespace std;

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600 ;
   m = i / 60 - h * 60;
   s = i % 60 ;
   cout << h << ":" << m << ":" << s << endl;

   return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
// typedef Graph vector<vector<int>>; // グラフ型
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#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)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int a, b;
    cin >> a >> b;
    cout << max(0, a - b - b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dif(int a, int b)
{
    int ans=a-b;
    if(ans<0) ans*=-1;
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, h[100005],i,j;
    int f1,f2;
    cin>>N;
    for(i=0;i<N;i++)
        cin>>h[i];
    int M[100005]={0};
    M[N-2]=dif(h[N-1],h[N-2]);
    for(i=N-3;i>=0;i--)
    {
        f1=dif(h[i+1],h[i])+M[i+1];
        f2=dif(h[i+2],h[i])+M[i+2];
        M[i]=min(f1,f2);
    }
    cout<<M[0]<<endl;
    return 0;
}


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

int main(){
  string s;
  int i,m,b;

  cin >> s ;
    while(s!="-"){
      cin >> m;
    for(i=0;i<m;i++){
      cin >> b;
    s=s.substr(b,s.size()-b)+s.substr(0,b);
  }
  cout << s << endl;
  cin >> s;
}
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int n,a=0,b=0;
      cin >> n;
      vector<int> num(n);
      for (int i=0; i<n; i++) cin >> num.at(i);
      sort(num.begin(),num.end());
      for (int i=0; i<n; i++){
        if(i%2 == 0){
          a += num.at(num.size()-1);
          num.pop_back();
        }
        else{
          b += num.at(num.size()-1);
          num.pop_back();
        }
      }
      cout << a-b;
    }

Measured memory_bytes: 256
import java.util.*;

class MyClass {
    private int number;
	private String city;	
	private int point;

	public MyClass (int number,String city,int point){
        this.number=number;
		this.city=city;
		this.point=point;
	}

    public int getnumber(){
        return number;
    }

	public String getcity(){
		return city;
	}

	public int getpoint(){
		return point; 
	}
}

class MyComp implements Comparator<MyClass>{
	public int compare(MyClass  c1,MyClass  c2){
		if((c1.getcity().compareTo(c2.getcity()))==0){
            return(Integer.compare(c2.getpoint(),c1.getpoint()));

        }else{
            return (c1.getcity().compareTo(c2.getcity()));
        }
            
        }
            
		}


public class Main {
	public static void main(String[] args) {
		ArrayList<MyClass> foo = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        int N = 0;
        String S = "";
        int P = 0;

        N = sc.nextInt();
        for(int i=1;i<=N;i++){
            S = sc.next();
            P = sc.nextInt();
            foo.add(new MyClass(i,S,P));
        }

        Collections.sort(foo,new MyComp());

        for(MyClass c : foo){
        	System.out.println(c.getnumber());
        }
    }
}

Measured memory_bytes: 36036
#B
N,M = map(int,input().split())
A = list(map(int,input().split()))
total = sum(A)
ans = []
for n in A:
    if 4*M*n < total:
        pass
    else:
        ans.append(n)
if len(ans) >= M:
    print('Yes')
else:
    print("No")

Measured memory_bytes: 9112
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
using namespace std;

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	if ((a + b)<(c + d)) cout << "Right" << endl;
	else if ((a + b)>(c + d)) cout << "Left" << endl;
	else cout << "Balanced" << endl;
	return 0;
}

Measured memory_bytes: 256
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define ll 		int
#define int 		long long
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define vpi 		vector<pii>
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}
const int N=1e5+10;
int dp[N][3],n,k,A[N],B[N],C[N];
int recur(int x,int id)
{
    if(x==n)
    return 0;
    if(dp[x][id]!=-1)
    return dp[x][id];
    int ans=0;
    
    if(id!=0)
    ans=max(ans,A[x]+recur(x+1,0));
    if(id!=1)
    ans=max(ans,B[x]+recur(x+1,1));
    if(id!=2)
    ans=max(ans,C[x]+recur(x+1,2));

    return dp[x][id]=ans;
}
signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	
    cin>>n;

    for(int i=0;i<n;i++)cin>>A[i]>>B[i]>>C[i];
    memset(dp,-1,sizeof(dp));
    int x = max(A[0]+recur(1,0),max(B[0]+recur(1,1),C[0]+recur(1,2)));
    cout<<x;

return 0;
}

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

#define rep(i, n) for(int i=0;i<(int)n;i++)
int INF=1e9;

int main() {
  int N;
  cin >> N;
  int a[N];
  vector<int> dp(N+1);
  rep(i,N) {
    cin >> a[i];
    int j=0;
    if(a[i]==dp[i]+1) j++;
    dp[i+1]=dp[i]+j;
  }
  if(dp[N]) cout << N-dp[N] << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a=0,b=0;
    for(int i=0;i<n;i++){
        string s,t;
        cin>>s>>t;
        if(s==t){
            a++;
            b++;
        }else if(s>t){
            a+=3;
        }else{
            b+=3;
        }
    }
    cout<<a<<" "<<b<<endl;
    
}



Measured memory_bytes: 3224
from collections import deque
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
UV = [[]for _ in range(n)]
for _ in range(m):
    u, v = list(map(lambda x: int(x)-1, input().split()))
    UV[u].append(v)
s, t = list(map(lambda x: int(x)-1, input().split()))

NV = 3*n
edges = [[]for _ in range(NV)]


def to_v(i, j):
    return 3*i+j


for i in range(n):
    for i2 in UV[i]:
        for j in range(3):
            edges[to_v(i, j)].append(to_v(i2, (j+1) % 3))

init_v = to_v(s, 0)
INF = 10**18
dist = [INF]*NV
dist[init_v] = 0
next_v = deque([init_v])
while next_v:
    v = next_v.popleft()
    for v2 in edges[v]:
        if dist[v2] <= dist[v]+1:
            continue
        dist[v2] = dist[v]+1
        next_v.append(v2)

print(dist[to_v(t, 0)]//3 if dist[to_v(t, 0)] != INF else -1)


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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
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; }

int main() {
    int K;
    cin >> K;
    
    REP(i,K){
        cout << "ACL" ;
    }
    cout << endl;
    
    
    return 0;
}


Measured memory_bytes: 3620