akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;
 
#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif
 
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
 
const int maxn = 100005;
 
set<int> segs[maxn];
char s[maxn];
int need[maxn], deladd[maxn];
int n;
 
 
void merge(set<int> &a, set<int> &b)
{
    if (a.size() < b.size()) a.swap(b);
    for (auto t : b) a.insert(t);
    b.clear();
}
 
int main()
{
    scanf("%s", s);
    int len = strlen(s);
    scanf("%d", &n);
    int mid1 = len / 2 - 1;
    int mid2 = len / 2 + len % 2;
    for (int i = 0; i < n; i++)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        l--, r--;
//             cout << mid1 << ' ' << mid2 << endl;
        while (l > mid1 && l < mid2) l++;
        while (r > mid1 && r < mid2) r--;
        if (l > r) continue;
        if (l <= mid1 && r >= mid2)
        {
            tie(l, r) = make_pair(min(max(-1, mid1 - l), max(-1, r - mid2)) + 1, max(max(-1, mid1 - l), max(-1, r - mid2)));
//             cout << l << ' ' << r << endl;
        } else if (r <= mid1)
        {
            tie(l, r) = make_pair(mid1 - r, mid1 - l);
        } else
        {
            l = l - mid2;
            r = r - mid2;
        }
//         cout << "seg " << l << ' ' << r << endl;
        if (l <= r) segs[l].insert(r);
    }
    int m = len / 2;
    for (int i = 0; i < m; i++)
    {
        need[i] = (s[len / 2 - 1 - i] - s[len / 2 + len % 2 + i]) % 26;
//         cout << need[i] << ' ';
    }
//     cout << endl;
    int curadd = 0;
    for (int i = 0; i < m; i++)
    {
        curadd -= deladd[i];
        curadd %= 26;
        need[i] += curadd;
        need[i] %= 26;
        while (!segs[i].empty() && *segs[i].begin() < i) segs[i].erase(segs[i].begin());
        if (need[i] != 0)
        {
            if (segs[i].empty())
            {
                cout << "NO" << endl;
                return 0;
            }
        }
        if (!segs[i].empty())
        {
            int minr = *segs[i].begin();
            while (!segs[i].empty() && *segs[i].begin() <= i) segs[i].erase(segs[i].begin());
            curadd += -need[i];
            deladd[minr + 1] += -need[i];
            merge(segs[minr + 1], segs[i]);
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 10112
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM 1000000000;
#define mod MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main(){
    ll a, b, c; cin >> a >> b >> c;
    ll ans;
    for(int i = 0; i < 31; i++){
        if(a == b && b == c && a%2==0){
            ans = -1;
            break;
        }
        if(a%2==1 || b%2==1 || c%2==1){
            ans = i;
            break;
        }
        ll s = a, t = b, u = c;
        a = (t+u)/2;
        b = (u+s)/2;
        c = (s+t)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
a, v = gets.split.map(&:to_i)
b, w = gets.split.map(&:to_i)
t = gets.to_i

if w > v
  puts "NO"
  exit
end

diff = (a - b).abs
spd =  v - w

if diff.to_f / spd > t
  puts "NO"
else
  puts "YES"
end


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

int main() {
    int a,b,c,x,y;
    cin >> a>>b>>c>>x;
    y=0;
    
    for(int i =0;i<=a;i++){
        for(int j =0;j<=b;j++){
            for(int k = 0;k<=c;k++){
                if(500*i+100*j+50*k==x){
                    y++;
                }
            }
        }
    }
    
    
    cout << y << endl;
    
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define pii pair<int, int>
#define forr(i,a,n) for (int i = (a); i < (n); ++i)
#define rforr(i,a,n) for (int i = (a); i > (n); --i)
#define ALL(x) x.begin(),x.end()
#define LEN(X) ((int)(X).size())
#define CASET int _T; cin >> _T; forr(caset,0,_T)
#define int ll

main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    //freopen("input.txt","w",stdout);
    int n,x; cin >> n >> x;
    vi a(n);
    forr(i,0,n) cin >> a[i];

    int ops = 0;
    forr(i,0,n-1) {
        if (a[i]+a[i+1] > x) {
            ops += min(a[i+1],a[i+1]+a[i]-x);
            a[i+1] -= min(a[i+1],a[i+1]+a[i]-x);
            if (a[i]+a[i+1] > x) {
                ops += min(a[i],a[i+1]+a[i]-x);
                a[i] -= min(a[i],a[i+1]+a[i]-x);
            } 
        
        }
    }    

    cout << ops << '\n';

}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("1 0 1");
            WillReturn.Add("2 1 2");
            WillReturn.Add("1 0 1");
            //Yes
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2 2 2");
            WillReturn.Add("2 1 2");
            WillReturn.Add("2 2 2");
            //No
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("0 8 8");
            WillReturn.Add("0 8 8");
            WillReturn.Add("0 8 8");
            //Yes
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("1 8 6");
            WillReturn.Add("2 9 7");
            WillReturn.Add("0 7 7");
            //No
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();

        SplitAct(InputList[0]);
        int C11 = wkArr[0], C12 = wkArr[1], C13 = wkArr[2];

        SplitAct(InputList[1]);
        int C21 = wkArr[0], C22 = wkArr[1], C23 = wkArr[2];

        SplitAct(InputList[2]);
        int C31 = wkArr[0], C32 = wkArr[1], C33 = wkArr[2];

        for (int A1 = -100; A1 <= 100; A1++) {
            int B1 = C11 - A1;
            int A2 = C12 - B1;
            int A3 = C13 - B1;

            int B2 = C21 - A1;
            int B3 = C31 - A1;

            if (A1 + B1 != C11) continue;
            if (A2 + B1 != C12) continue;
            if (A3 + B1 != C13) continue;

            if (A1 + B2 != C21) continue;
            if (A2 + B2 != C22) continue;
            if (A3 + B2 != C23) continue;

            if (A1 + B3 != C31) continue;
            if (A2 + B3 != C32) continue;
            if (A3 + B3 != C33) continue;

            Console.WriteLine("Yes");
            return;
        }
        Console.WriteLine("No");
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	set<string> cnt;
	rep(i,n){
		string s;
		cin>>s;
		cnt.insert(s);
	}
	cout<<cnt.size()<<endl;
}

Measured memory_bytes: 19276
#include <stdio.h>
int main(void){
	char s[11],t[11]={},rev[11];
	int b=0;
	scanf("%s",s);
	int i,j=0;
	for(i=0;s[i]!='\0';i++);
	while(i>0){
		i--;
		if((b==0)&&(s[i]!='B')){
			rev[j]=s[i];
			j++;
		}else if(s[i]=='B') b++;
		else b--;
	}
	rev[j]='\0';
	j=0;
	for(i=0;rev[i]!='\0';i++);
	while(i>0){
		i--;
		t[j]=rev[i];
		j++;
	}
	t[j]='\0';
	printf("%s",t);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a; i<=b; ++i)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using vl=vector<ll>;
using vp=vector<pll>;
const ll INF=1e18;
const ll MOD=1e9+7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll s;
    cin>>s;
    ll dp[s+5]={};
    dp[0]=1;
    FOR(i,0,s) FOR(j,0,i-3){
        dp[i]=(dp[i]+dp[j])%MOD;
    }
    cout<<dp[s];
    return 0;
}

Measured memory_bytes: 3660
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_I(): return map(int, stdin)
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))

##### main #####



def main():
	s = sorted(input())
	t = sorted(input(),reverse=True)

	print("Yes" if s<t else "No")


if __name__ == '__main__':
	main()

Measured memory_bytes: 3444
#define _GLIBCXX_DEBUG
#include <bits/stdc++.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++)
#define all(v) v.begin(), v.end()
#define chmin(x, y) x = min(x, y)

int main(){
  string s, t;
  cin >> s >> t;
  sort(all(s));
  sort(all(t));
  reverse(all(t));
  if(s.compare(t) < 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<map>
#define ll long long
using namespace std;

ll arr[4];
int main(){
	ll a,b,c;
	int ind=0;
	while(cin>>a){
		arr[ind++]=a;
		if(ind==3)break;
	}
	if(ind==1){
		cout<<arr[0]<<endl;
	}else if(ind==2){
		cout<<arr[1]<<" "<<arr[0]<<endl;
	}else{
		swap(arr[0],arr[1]);
		swap(arr[0],arr[2]);
		cout<<arr[0]<<" "<<arr[1]<<" "<<arr[2]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all int i=0; i<n; i++
#define pb push_back
typedef long long int ll;

#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define mod 1000000007

bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{ 
       return (a.first > b.first); 
}
vector<pair<ll,ll> >v;
int main(){
	FAST_IO;
	ll n,m,x,ans=0;
	cin>>n>>m;
	ll arr[n];
	for(all)cin>>arr[i];
	sort(arr, arr+n);
	v.resize(m);
	for(int i=0; i<m; i++)cin>>v[i].second>>v[i].first;
	sort(v.begin(), v.end(), sortinrev);
	int j=0, flag=0;
	for(int i=0; i<m; i++){
		if(flag==1)break;
		while(true){
			if(j>=n || v[i].second<=0)break;
			if(arr[j]<v[i].first){
				arr[j]=v[i].first;
				v[i].second--;
				j++;
			}
			else{
				flag=1;
				break;
			}
		}
	}
	for(int i=0; i<n; i++)ans+=arr[i];
	cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int a;
    string c="ABC",b="ABD";
    cin>>a;
    if(a>999){
        cout<<b<<endl;
    }else{
        cout<<c<<endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int five = 0;
    int seven = 0;

    if (a == 5) {
        five++;
    }

    if (a == 7) {
        seven++;
    }

    if (b == 5) {
        five++;
    }

    if (b == 7) {
        seven++;
    }

    if (c == 5) {
        five++;
    }

    if (c == 7) {
        seven++;
    }

    if (five == 2 and seven == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

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

int main()
{
    int N, total;
    cin >> N;
    total = 0;
    for (int i = 0; i < N; i++)
    {
        int l, r;
        cin >> l >> r;
        total += r - l + 1;
    }
    cout << total << endl;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

class Main {
	String s;
	String[] d = { "dream", "dreamer", "erase", "eraser" };

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

	Main(Scanner sc) {
		s = sc.next();
	}

	void solve() {
		Queue<Integer> q = new ArrayDeque<Integer>();
		q.offer(0);
		while(q.size()>0){
			int i = q.poll();
			for(int j=0;j<4;j++){
				if(i+d[j].length()>s.length()) continue;
				if(d[j].equals(s.substring(i,i+d[j].length()))){
					if(i+d[j].length()==s.length()){
						System.out.println("YES");
						System.exit(0);
					}
					q.offer(i+d[j].length());
				}
			}
		}
		System.out.println("NO");
	}
}

Measured memory_bytes: 31844
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>

using namespace std;

int main() {

	unsigned long long K, N;
	cin >> N >> K;

	cout << N - K + 1 << endl;

	return 0;
}

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

typedef struct{
	int x;
	int y;
}point;

const int N=150;

int main(){
	while(1){
		int turn, n;
		int f[N+1][N+1], d[N+1][N+1];
		int dx[6]={1,1,0,-1,-1,0}, dy[6]={0,1,1,0,-1,-1};
		
		//初期化
		for(int i=0; i<=N; ++i){
			for(int j=0; j<=N ;++j){
				f[i][j]=0;
				d[i][j]=-1;
			}
		}
		
		//入力
		scanf(" %d %d", &turn, &n);
		if(turn==0) break;
		for(int i=0; i<n; ++i){
			int a, b;
			scanf(" %d %d", &a, &b);	
			f[a+70][b+70]=1;
		}
		
		point start;
		scanf(" %d %d", &start.x, &start.y);
		start.x+=70;
		start.y+=70;
	
		//BFS	
		queue<point> que;
		d[start.x][start.y]=0;
		que.push(start);
		
		while( !que.empty() ){
			point v=que.front();
			que.pop();	
			//printf(" pop\n");
						
			for(int i=0; i<6; ++i){
				int nx=v.x+dx[i], ny=v.y+dy[i];
								
				if(nx>=0 && nx<=N && ny>=0 && ny<=N && f[nx][ny]!=1 && d[nx][ny]==-1){
					d[nx][ny] = d[v.x][v.y]+1;
					point tmp;
					tmp.x=nx;
					tmp.y=ny;
					que.push(tmp);
					//printf("push\n");
				}
				
			}	
		}
		
		int ans=0;
		for(int i=0; i<=N; ++i){
			for(int j=0; j<=N; ++j){
				if(d[i][j]>=0 && d[i][j]<=turn) ++ans;
				//else printf("%d %d\n", i, j);
			}
		}
	
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1392
# -*- coding: utf-8 -*-
import sys

def main():
	D, G = map(int, input().split(" "))
	
	score_board = []
	all_bms = []
	for i in range(D):
		a, b = map(int, input().split(" "))
		score_board.append((a, b))
		all_bms.append(((i+1) * 100 * a) + b)
	
	ans = 1000000000000
	for i in range(2 ** D):
		total = 0
		turn = 0
		p = 0
		for j in range(D):
			if i >> j & 1 == 1:
				total += all_bms[j]
				a, b = score_board[j]
				turn += a
			else:
				p = j
				
		if G <= total and ans > turn:
			ans = turn
			continue
			
		a, b = score_board[p]
		for i in range(a):
			turn += 1
			total = total + (100 * (p+1))
			if G <= total and ans > turn:
				ans = turn
				continue
		total += b
		if G <= total and ans > turn:
			ans = turn
				
			
	print(ans)
		
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int n, cnt[100];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    cnt[min(x / 400, 3200 / 400)]++;
  }

  int a = 0;
  for (int i = 0; i < 3200 / 400; ++i) {
    a += cnt[i] > 0;
  }

  int l = max(1, a);
  int r = a + cnt[3200 / 400];
  cout << l << ' ' << r << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#define ll long long
#define NUM 1001
#define NUM_ 3001
using namespace std;

ll A[NUM];
ll B[NUM];
ll C[NUM];
ll AB[NUM*NUM];
ll ABC[NUM_*NUM];
int X, Y, Z, K;

void init(){
    for(int i = 0; i < NUM; i++){
        A[i] = 0;
        B[i] = 0;
        C[i] = 0;
    }
}

int main(void){
    scanf("%d", &X);
    scanf("%d", &Y);
    scanf("%d", &Z);
    scanf("%d", &K);

    for(int i = 0; i < X; i++){
        scanf("%lld", &A[i]);
    }
    for(int i = 0; i < Y; i++){
        scanf("%lld", &B[i]);
    }
    for(int i = 0; i < Z; i++){
        scanf("%lld", &C[i]);
    }

    for(int i = 0; i < X; i++){
        for(int j = 0; j < Y; j++){
            AB[Y*i+j] = A[i] + B[j];
        }
    }

    sort(&AB[0], &AB[X*Y], [](ll x, ll y) {return x > y;});
    sort(&C[0], &C[Z], [](ll x, ll y) {return x > y;});

    for(int i = 0; i < K; i++){
        for(int j = 0; j < Z; j++){
            ABC[Z*i+j] = AB[i] + C[j];
        }
    }

    sort(&ABC[0], &ABC[K*Z], [](ll x, ll y) {return x > y;});

    for(int i = 0; i < K; i++){
        printf("%lld\n", ABC[i]);
    }
}


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

int n,m,a[100005],b[100005], cnt;

int b_search(int x, int L, int R) {
    while (L <= R){
        int mid = (L+R)/2;
        if (a[mid] == x) return mid;
        if (a[mid] < x) L = mid + 1;
        else R = mid - 1;
    }
    return -1;
}

void solve() {
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    cin >> m;
    for(int i = 0; i < m; i++) cin >> b[i];
    for(int i = 0; i < m; i++)
        if (b_search(b[i],0,n-1) != -1) {
            cnt++;
        }
    cout << cnt << '\n';
}

int main() {
 
    solve();
}



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

ll num[sz];

int main()
{


   ll n,k,d,p,x,s=0,i,j,mn=1000000000;

   cin>>n;

   for(i=1;i<=n;i++)
   {
       cin>>num[i];
   }

   for(i=0;i<=100;i++)
   {
       s=0;
       for(j=1;j<=n;j++)
       {
           d=(num[j]-i)*(num[j]-i);
           s+=d;
       }
       mn=min(mn,s);
   }

   cout<<mn<<endl;


  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long i,j,k,l,m,n,o,p,q;
    while(cin>>m)
    {
        if(m%2==0)
            cout<<m<<endl;
        else
            cout<<2*m<<endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int N,K,L;
  cin>>N>>K;
  int A[N+1];
  for(int i=1; i<=N; ++i){
    cin>>A[i];
    if(A[i]==1) L=i;
  }
  
  cout<<(N+K-3)/(K-1)<<endl;
}

Measured memory_bytes: 640
N = int(input())
h = list(map(int, input().split()))

dp = [0 for i in range(N)]
dp[1] = dp[0] + abs(h[1] - h[0])

for i in range(2, N):
    cost1 = dp[i-1] + abs(h[i] - h[i-1])
    cost2 = dp[i-2] + abs(h[i] - h[i-2])
    dp[i] = min(cost1, cost2)

    
print(dp[N-1])

Measured memory_bytes: 52720
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(c>min(a,b)&&c<max(a,b))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
struct ocello {
  int white;
  int black;
};
int main() {
  int N, M, K;
  cin >> N >> M >> K;
  REP(i, N+1) {
    REP(j, M+1) {
      ll cnt = i * M + j * N - 2*i * j;
      if (cnt == K) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#define all(v) (v).begin(),(v).end()

using namespace std;

int main(){
  	int N, K;
  	cin >> N >> K;
  	vector<int> a(N);
  	for(int i=0;i<N;i++) cin >> a[i];
  	sort(all(a), greater<int>());
  	auto itr = a.begin() + K;
  	cout << accumulate(a.begin(), itr, 0) << endl;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int h, w;
string a[200];
int dp[200][200][200][2];
int dp2[200][200][200][2];
int s[200][200];
int count(int i, int j, int k, int l){
	return s[j+1][l+1]-s[i][l+1]-s[j+1][k]+s[i][k];
}
int main()
{
	cin>>h>>w;
	for(int i=0; i<h; i++) cin>>a[i];
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			s[i+1][j+1]=s[i+1][j]+s[i][j+1]-s[i][j]+(a[i][j]=='#');
		}
	}
	for(int i=0; i<h; i++){
		for(int j=i; j<h; j++){
			int l=w-1;
			for(int k=w-1; k>=0; k--){
				while(l>=k){
					int x=count(i, j, k, l);
					if(x!=0 && x!=(j-i+1)*(l-k+1)){
						l--;
					}else{
						break;
					}
				}
				dp[i][j][k][0]=l+1;
			}
		}
	}
	if(dp[0][h-1][0][0]==w){
		cout<<0<<endl;
		return 0;
	}
	for(int i=0; i<w; i++){
		for(int j=i; j<w; j++){
			int l=h-1;
			for(int k=h-1; k>=0; k--){
				while(l>=k){
					int x=count(k, l, i, j);
					if(x!=0 && x!=(j-i+1)*(l-k+1)){
						l--;
					}else{
						break;
					}
				}
				dp2[i][j][k][0]=l+1;
			}
		}
	}
	for(int t=1; t<30; t++){
		for(int i=0; i<h; i++){
			for(int j=i; j<h; j++){
				for(int k=0; k<w; k++){
					int l1=dp[i][j][k][(t&1)^1];
					if(l1==w){
						dp[i][j][k][t&1]=w;
						continue;
					}
					int l=l1, r=w+1;
					while(r-l>1){
						int m=(l+r)/2;
						if(dp[i][j][l1][(t&1)^1]>=m){
							l=m;
							continue;
						}
						int l2=dp2[k][m-1][i][(t&1)^1];
						if(j<l2){
							l=m;
							continue;
						}
						if(dp2[k][m-1][l2][(t&1)^1]>j){
							l=m;
						}else{
							r=m;
						}
					}
					dp[i][j][k][t&1]=l;
				}
			}
		}
		if(dp[0][h-1][0][t&1]==w){
			cout<<t<<endl; return 0;
		}
		for(int i=0; i<w; i++){
			for(int j=i; j<w; j++){
				for(int k=0; k<h; k++){
					int l1=dp2[i][j][k][(t&1)^1];
					if(l1==h){
						dp2[i][j][k][t&1]=h;
						continue;
					}
					int l=l1, r=h+1;
					while(r-l>1){
						int m=(l+r)/2;
						if(dp2[i][j][l1][(t&1)^1]>=m){
							l=m;
							continue;
						}
						int l2=dp[k][m-1][i][(t&1)^1];
						if(j<l2){
							l=m;
							continue;
						}
						if(dp[k][m-1][l2][(t&1)^1]>j){
							l=m;
						}else{
							r=m;
						}
					}
					dp2[i][j][k][t&1]=l;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 118912
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

const ll CONS = 1e9 + 7;
const ll INF = 1e16 + 7;

ll factorial(ll n, ll ans) {
	if (n == 0)return ans;

	return factorial(n - 1, n * (ans % CONS) );
}


//65C
int main(void) {
	ll n = 2, m = 2;
	cin >> n >> m;
	ll factN = factorial(n,1), factM = factorial(m, 1);

	if (n == m) cout << (2 * factN * factN) % CONS << endl;
	else if (abs(n - m) == 1)cout << (factN * factM) % CONS << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <set>
#define M(x,y)std::make_pair(x,y)
typedef std::set<std::pair<int,int> >S;
int n,x,y,x1,y1,x2,y2,dx,dy;main(){for(;scanf("%d",&n),n;){
	S s;
	for(;n;n--)scanf("%d%d",&x,&y),s.insert(M(x,y));
	S::iterator it1,it2;
	for(it1=s.begin();it1!=s.end();it1++){
		x1=it1->first,y1=it1->second;
		for(it2=it1,it2++;it2!=s.end();it2++){
			x2=it2->first,y2=it2->second,dx=x2-x1,dy=y2-y1;
			if(dx*dx+dy*dy>n&&(
				s.find(M(x1-dy,y1+dx))!=s.end()&&s.find(M(x2-dy,y2+dx))!=s.end()
			))n=dx*dx+dy*dy;
		}
	}
	printf("%d\n",n);
}}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()

const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    set<string> st;
    for (int i = 0; i < 1000; i++)
    {
        string t = to_string(i);
        if(t.size()==1){
            t = '0' + t;
        }
        if(t.size()==2){
            t = '0' + t;
        }
        char now = t[0];
        int p = 0;
        bool ok1 = false, ok2 = false,ok3 = false;
        for (int j = 0; j < n; j++)
        {
            if(s[j]==t[0]){
                ok1 = true;
                p = j;
                break;
            }
        }
        if(ok1){
            for (int j = p + 1; j < n;j++){
                if(s[j]==t[1]){
                    ok2 = true;
                    p = j;
                    break;
                }
            }
        }
        if(ok2){
            for (int j = p + 1; j < n;j++){
                if(s[j]==t[2]){
                    ok3 = true;
                    break;
                }
            }
        }
        if(ok1&&ok2&&ok3){
            st.insert(t);
        }
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  map<string,int> M;
  rep(i,0,N){
    string X;
    cin>>X;
    M[X]++;
  }
  vector<pair<int,string>> A;
  int memo=0;
  for(auto p:M){
    A.pb(mp(p.second,p.first));
    memo=max(memo,p.second);
  }
  rep(i,0,A.size()){
    if(memo==A[i].first)
      cout<<A[i].second<<endl;
  }
  }



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

int main() {

  char ans, b;
  cin >> b;
  
  if		(b == 'A') ans = 'T';
  else if	(b == 'T') ans = 'A';
  else if	(b == 'G') ans = 'C';
  else				   ans = 'G';
  
  cout << ans << endl;
    
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
string S,T;
  cin>>S>>T;
  sort(all(S));
  sort(all(T));
  reverse(all(T));
  ll N=S.size();
  ll M=T.size();
for(ll i=0;i<min(N,M);i++) {
if(S[i]<T[i]) {
cout<<"Yes"<<endl;
  return 0;
}
  if(S[i]>T[i]) {
cout<<"No"<<endl;
    return 0;
  }
}
  
  if(N>=M) {
cout<<"No"<<endl;
  }
  else {
cout<<"Yes"<<endl;
  }
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
long long g[1000100];
int main()
{
	long long n,a,b,ans;
	cin>>n>>a>>b;
	for(int j=1;j<=n;j++)
		cin>>g[j];
	for(int i=1;i<n;i++)
	{
		if((g[i+1]-g[i])*a>=b)ans+=b;
		else if((g[i+1]-g[i])*a<b)ans+=(g[i+1]-g[i])*a;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

vector<ll> color(200001, -1);
map<ll, bool> m[200001];

void dfs(ll s) {
	for (auto x : m[s]) {
		if (color[x.first] == -1) {
			color[x.first] = (color[s]+1)%2;
			dfs(x.first);
		}
	}
}

int main(){	
	ll N;
	cin >> N;
	vector<ll> a(N-1), b(N-1);
	
	rep(i, N-1) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		m[a[i]][b[i]] = true;
		m[b[i]][a[i]] = true;
	}
	color[0] = 0;
	dfs(0);
	ll white = 0, black = 0;
	rep(i, N) {
		if (color[i] == 0) white++; else black++;
	}
	ll ma = max(white, black), mi = min(white, black);

	queue<ll> q1, q2;
	if (ma > (N/3*2+min(N%3,1LL))) {
		if (white > black) {
			repn(i, N) {
				if (i%3 == 0 && i/3 <= mi) q2.push(i); else q1.push(i);
			}
		} else {
			repn(i, N) {
				if (i%3 == 0 && i/3 <= mi) q1.push(i); else q2.push(i);
			}
		}
	} else {
		if (white > black) {
			repn(i, N) {
				if (i%3 == 0 && i/3 <= white-N/3-min(N%3,1LL)) q1.push(i);
				else if (i%3 == 1) q1.push(i);
				else q2.push(i);
			}
		} else {
			repn(i, N) {
				if (i%3 == 0 && i/3 <= black-N/3-min(N%3,1LL)) q2.push(i);
				else if (i%3 == 1) q2.push(i);
				else q1.push(i);
			}
		}
	}	
	
	rep(i, N-1) {
		if (color[i] == 0) {
			cout << q1.front() << " ";
			q1.pop();
		} else {
			cout << q2.front() << " ";
			q2.pop();
		}
	}
	if (color[N-1] == 0) {
		cout << q1.front() << endl;
		q1.pop();
	} else {
		cout << q2.front() << endl;
		q2.pop();
	}
}


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

using namespace std;

int main() {
  int N;
  int G[2][100];
  int dp[2][100];

  for (int i=0; i<100; i++) {
    dp[0][i] = 0;
    dp[1][i] = 0;
  }

  cin >> N;
  for (int h=0; h<2; h++) {
    for (int w=0; w<N; w++) {
      cin >> G[h][w];
    }
  }

  int h,w;

  dp[0][0] = G[0][0];
  dp[1][N-1] = G[1][N-1];
  for (int w=1; w<N; w++) {
    dp[0][w] = dp[0][w-1] + G[0][w];
    dp[1][N-1-w] = dp[1][N-1-w+1] + G[1][N-1-w];
  }

  int max = 0;
  for (int w=0; w<N; w++) {
    int sum = dp[0][w] + dp[1][w];
    max = (max < sum) ? sum : max;
  }

  cout << max << endl;
}


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

int gcd(int x,int y){
  int tmp;
  while(1){
    if(x%y==0){
      return y;
    }
    tmp=y;
    y=x%y;
    x=tmp;
  }
}

int main(){
  int x,y;
    int g;
    cin>>x>>y;
    g=gcd(x,y);
    cout<<g<<"\n";
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a, b, c;
    cin >> a >> b >> c;
    cout << ((a == 5 && b == 5 && c == 7 || a == 5 && b == 7 && c == 5 || a == 7 && b == 5 && c == 5) ? "YES" : "NO") << endl;
}


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[] array = new int[n];

        for(int i = 0; i < n; i++) {
        	array[i] = sc.nextInt();
        }

        selectionSort(array);

	}

	static void selectionSort(int[] array) {

        int count = 0;
		for(int i = 0; i < array.length; i++) {

			int minj = i;
			for(int j = i; j < array.length; j++) {

				if(array[j] < array[minj]) {
					minj = j;
				}
			}

			if(i != minj) {
				int temp = array[i];
				array[i] = array[minj];
				array[minj] = temp;
				count++;
			}
		}

		printArray(array);
		System.out.println(count);
	}

	static void printArray(int[] array) {

		for(int i = 0; i < array.length - 1; i++) {
			System.out.print(array[i] + " ");
		}

		System.out.println(array[array.length - 1]);
	}
}



Measured memory_bytes: 26284
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int n = in.nextInt();
		int ma = -1, max = -1;

		for (int i=0; i<n; i++) {
			int a = in.nextInt();
			int v = in.nextInt();

			if (max < v) {
				ma = a;
				max = v;
			} else if (max == v && a < ma) {
				ma = a;
			}
		}

		out.println(ma + " " + max);
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 26240
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int d[83][83][12805] = {};


int main() {
	IOS;
	int h, w;
	cin >> h >> w;
	vector<vector<ll>> a(h, vector<ll>(w));
	vector<vector<ll>> b(h, vector<ll>(w));
	vector<vector<ll>> c(h, vector<ll>(w));
	REP(i, h) {
		REP(j, w) {
			cin >> a[i][j];
		}
	}
	REP(i, h) {
		REP(j, w) {
			cin >> b[i][j];
			c[i][j] = a[i][j] - b[i][j];
			c[i][j] = abs(c[i][j]);
		}
	}
	int dx[2] = { 0,1 };
	int dy[2] = { 1,0 };
	int t = 160 * 80;
	d[0][0][c[0][0]] = 1;
	REP(i, h) {
		REP(j, w) {
			REP(k, 2) {
				int ny = i + dy[k];
				int nx = j + dx[k];
				if (ny < h && nx < w) {
					REP(l, t) {
						if (d[i][j][l]) {
							int te = l + c[ny][nx];
							if (te < t) {
								d[ny][nx][te] = d[i][j][l];
							}
							te = abs(l - c[ny][nx]);
							if (te < t) {
								d[ny][nx][te] = d[i][j][l];
							}
						}
					}
				}
			}
		}
	}
	int res = INT_MAX;
	REP(i, t) {
		if (d[h - 1][w - 1][i]) {
			res = i;
			break;
		}
	}
	put(res);
	return 0;
}


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

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int>l(N);

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

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

	int sum = 0;
	for (int i = 0; i < K; i++) {
		sum += l[i];
	}

	cout << sum << endl;

	return 0;
}

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

int main(){
  int m,n;
  cin>>m>>n;
  int array[n];
  int sum=0;
  for(int i=0;i<n;i++){
    cin>>array[i];
    sum=sum+array[i];
  }
  if (m>=sum){
   cout<<m-sum<<endl;
  }
  else{
   cout<<"-1"<<endl;
  }
  
  
  return 0;
}

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

int main(){
	int n = 0;
	string W, T;
	cin >> W;
	for(int j = 0; j < W.size(); j++){
		W[j] = tolower(W[j]);
	}
	while(1){
		cin >> T;
		if(T == "END_OF_TEXT") break;
		for(int i = 0; i < T.size(); i++){
			T[i] = tolower(T[i]);
		}
		if(T == W){
			n = n + 1;
		}
	}
	cout << n << endl;

	return 0;
}

Measured memory_bytes: 1192
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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 n,index=0;
	cin >> n;
	vector<vector<int>> a(n,vector<int>(3));
	REP(i,n){
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	REP(i,n){
		if(a[i][2]!=0){
			index = i;
			break;
		}
	}
	
	int a0 = a[0][0]; a[0][0] = a[index][0]; a[index][0] = a0;
	int a1 = a[0][1]; a[0][1] = a[index][1]; a[index][1] = a1;
	int a2 = a[0][2]; a[0][2] = a[index][2]; a[index][2] = a2;
	
	int X=-1,Y=-1,H=-1;
	bool ok=true;
	REP(x,101){
		REP(y,101){
			int h = 0;
			ok = true;
			REP(k,n){
				if(k==0){
					h = a[k][2] + abs(x-a[k][0]) + abs(y-a[k][1]);
					continue;
				}
				
				int dh = h - abs(x-a[k][0]) - abs(y-a[k][1]);
				if(max(dh,0) !=  a[k][2]){
					ok = false;
					break;
				}
			}
			if(ok){
				X = x;
				Y = y;
				H = h;
			}
		}
	}
	
	printf("%d %d %d\n",X,Y,H);
	
	
	return 0;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using ll=long long;
pair<int,int> p[200010];

int main(){ _;
  int w,h;cin>>w>>h;
  REP(i,w){
    cin>>p[i].first;
    p[i].second=0;
  }
  REP(i,h){
    cin>>p[w+i].first;
    p[w+i].second=1;
  }
  sort(p,p+h+w);//2357
  ll pCnt=h+1,qCnt=w+1;
  ll result=0;
  REP(i,w+h){
    if(p[i].second==0){
      result+=pCnt*p[i].first;
      qCnt--;
    }else{
      result+=qCnt*p[i].first;
      pCnt--;
    }
  }
  cout<<result<<endl;
}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*

	Optimizer

*/
//#pragma GCC optimize("Ofast")

struct GameTree{
	vector<int> next_node;
};



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

	ULL N;
	ULL MOD_CONST = 5;
	cin >> N;

	if (N % 2 == 1) {
		cout << 0 << endl;
	}
	else {
		ULL ans = 0;
		N /= 2;
		while (MOD_CONST <= N){
			ans += (N / MOD_CONST);
			MOD_CONST *= 5;
		}
		cout << ans  << endl;
	}

	return 0;
}


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

bool hi[20001];
bool lo[20001];

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

    for(int i=0; i<t; ++i) {
        cin>>n;
        cin>>s;

        memset(hi, false, sizeof(hi));
        memset(lo, false, sizeof(lo));

        for(int i=0; i<2*n; ++i) {
            if(s[i] == 'Y') hi[(i+1)/2] = true;
        }
        for(int i=0; i<2*n; ++i) {
            if(s[i+2*n] == 'Y') lo[(i+1)/2] = true;
        }

        int ans = 0;
        int pos = 0;
        bool lh = false;
        for(int i=0; i<n+1; ++i) {
//            cout<<i<<" "<<hi[i]<<" "<<lo[i]<<" "<<pos<<" "<<ans<<endl;
            if(pos == 0) {
                if(lo[i]) {
                    ans += 2;
                    pos = 1;
                    lh = false;
                }else if(hi[i]) {
                    ans += 1;
                    pos = 1;
                    lh = true;
                }
            }else if(pos == 1) {
                if(lo[i] && hi[i]) {
                    lh = true;
                    ans += 2;
                }else if(lo[i] || hi[i]) {
                    lh = hi[i];
                    ans += 1;
                }
            }
            ans += 1;
        }

        if(pos == 0) ans -= 1;
        if(lh) ans -= 1;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    String A = sc.next();
    String B = sc.next();
    String C = sc.next();
    
    if(A.equals(B) && B.equals(C)) {
      System.out.println("No");
    } else if(A.equals(B) || B.equals(C) || A.equals(C)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23764
# https://atcoder.jp/contests/abc159/tasks/abc159_b
read S
n=$((${#S}))
a=$(((n-1)/2 - 1))
b=$(((n+3)/2 - 1))
l=$((a+1))
# before=${S:0:a+1}
# after=${S:b:l}
before=${S:0:n/2}
after=${S:n/2+1:l}
revbefore=`echo $before | rev`
revafter=`echo $after | rev`
echo $before >&2
echo $revbefore >&2
echo $after >&2
echo $revafter >&2
if [ $after == $revafter ] && [ $before == $revbefore ] && [ $S == `echo $S | rev` ] ; then
  echo "Yes"
else
  echo "No"
fi


Measured memory_bytes: 968