akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

vector<int> A;

void InsertSort(vector<int> a, int b){
    for(int i=1;i<b;i++){
        int v=a[i];
        int j=i-1;
        while(v<a[j]&&j>=0){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;
        for(int t=0;t<a.size();t++){
            if(t==a.size()-1){
                cout << a[t] << endl;
                break;
            }
            cout << a[t] << " ";
        }
    }
}

int main(){
    int n;
    cin >> n;
    A.resize(n);
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    for(int i=0;i<A.size();i++){
            if(i==A.size()-1){
                cout << A[i] << endl;
                break;
            }
            cout << A[i] << " ";
        }
    InsertSort(A, n);
}


Measured memory_bytes: 3140
#include <stdio.h>
#include <math.h>

int main(void) {
	int a,b,c;
	double rad,S, L, h,q;
	scanf("%d %d %d", &a, &b, &c);
	double PI = acos(-1);
	rad = c * PI / 180;

	S =  (a * b * sin(rad))/2;
	q = sqrt(a * a + b * b - 2 * a*b*cos(rad));
	L = a + b + q;
	h = b * sin(rad);

	printf("%lf %lf %lf", S, L, h);
}


Measured memory_bytes: 2124
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, i, j;
	char s[2][53];
	scanf("%d%s%s", &n, s[0], s[1]);
	long ans=((s[0][0]!=s[1][0])+1)*3;
	for(i=1; i<n; i++){
		if(s[0][i]==s[1][i]){
			ans *= (s[0][i-1]==s[1][i-1])+1;
		}else if(s[0][i]!=s[0][i-1]){
			ans *= (s[0][i-1]!=s[1][i-1])+2;
		}
		ans%=P;
	}
	printf("%d\n", ans);
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

ll combi(int n, int r, vector<ll>& fact, vector<ll>& inv_fact)
{
  if (r > n) { return 0; }
  ll ret = (fact[n] * inv_fact[r]) % MOD;
  ret = (ret * inv_fact[n - r]) % MOD;
  return ret;
}

ll modpow(ll a, int n)
{
  ll ret = 1;
  while (n > 0) {
    if (n & 1) {
      ret = (ret * a) % MOD;
    }
    a = (a * a) % MOD;
    n >>= 1;
  }
  return ret;
}

int main()
{
  int N; scanf("%d", &N);
  vector<int> A(N + 1, 0);
  vector<int> pos(1e5 + 5, -1);
  int l = -1, r = -1;
  for (int i = 0; i < N + 1; ++i) {
    scanf("%d", &A[i]);
    if (pos[A[i]] != -1) {
      l = pos[A[i]];
      r = i;
    }
    else {
      pos[A[i]] = i;
    }
  }

  vector<ll> fact(N + 5, 1), inv_fact(N + 5, 1);
  for (int i = 2; i < N + 2; ++i) {
    fact[i] = (i * fact[i - 1]) % MOD;
  }

  inv_fact[N + 1] = modpow(fact[N + 1], MOD - 2);
  for (int i = N; i > 1; --i) {
    inv_fact[i] = ((i + 1) * inv_fact[i + 1]) % MOD;
  }

  int inner = r - l - 1;
  for (int k = 1; k <= N + 1; ++k) {
    ll ans = combi(N + 1, k, fact, inv_fact);
    ans = (ans - combi(N + 1 - inner - 2, k - 1, fact, inv_fact) + MOD) % MOD;
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[]) {
	char s[1000];
	stack<int> ans;
	int a,b,i,j=0,len,count=0;
	memset(s,'\n',sizeof(s));
	scanf("%[^\n]%*c",s);
	len=strlen(s);
	for(i=0;i<len;i++){
		j=0;
		char *s1=(char *)malloc(sizeof(char)*6);
		while(s[i]!=32&&i<len){
			*(s1+j++)=s[i++];
		}
		*(s1+j)='\0';
		string str(s1);
		if(str[0]=='+'){
			b=ans.top();ans.pop();
			a=ans.top();ans.pop();
			ans.push(a+b);
		}else if(str[0]=='-'){
			b=ans.top();ans.pop();
			a=ans.top();ans.pop();
			ans.push(a-b);
		}else if(str[0]=='*'){
			b=ans.top();ans.pop();
			a=ans.top();ans.pop();
			ans.push(a*b);
		}else{
			ans.push(atoi(str.c_str()));
		}
	} 
	cout<<ans.top()<<endl;
	return 0;
}


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

class Rolling_Hash{
private:
  ll n;
  static constexpr ll base1=1007,base2=2009;
  static constexpr ll mod1=(1e9+7),mod2=(1e9+9);
  vector<ll> hash1,hash2,mpow1,mpow2;
public:
  Rolling_Hash(const string& s){
    n=s.size();
    hash1.assign(n+1,0);
    hash2.assign(n+1,0);
    mpow1.assign(n+1,1);
    mpow2.assign(n+1,1);
    for(ll i=0;i<n;++i){
      hash1[i+1] = (hash1[i]*base1+s[i])%mod1;
      hash2[i+1] = (hash2[i]*base2+s[i])%mod2;
      mpow1[i+1] = (mpow1[i]*base1)%mod1;
      mpow2[i+1] = (mpow2[i]*base2)%mod2;
    }
  }
  auto get(ll l,ll r){
    ll lefval = hash1[r]-hash1[l]*mpow1[r-l]%mod1;
    ll rigval = hash2[r]-hash2[l]*mpow2[r-l]%mod2;
    if(lefval<0)lefval+=mod1;
    if(rigval<0)rigval+=mod2;
    return make_pair(lefval,rigval);
  }
  auto get_LCP(ll a,ll b){
    ll len = min( n-a+1,n-b+1 );
    ll low=0,high=len;
    while( high-low>1 ){
      ll mid=(high+low)>>1;
      if(get(a,a+mid)!=get(b,b+mid))high=mid;
      else low=mid;
    }
    return low;
  }
};

main(){

  ll n;
  string s;
  cin>>n>>s;

  Rolling_Hash rh(s);
  ll ans=0;
  rep(i,n){
    for(ll j=i+1;j<n;++j){
      ll lcp=rh.get_LCP(i,j);
      ans=max(ans,min(lcp,j-i));
    }
  }
  cout<<(ans)<<endl;

}


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

int main(){
	int n, t, a;
	float h[1005];
	cin >> n >> t >> a;
	for(int i = 1; i <= n; i++)
		scanf("%f",&h[i]);
	float s = 0x3f3f3f3f;
	int x;
	for(int i = 1; i <= n; i++){
		h[i] = t - h[i] * 0.006;
		if(abs(a - h[i]) < s) {
			s = abs(a - h[i]);
			x = i;
		}
	}
	cout << x << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  rep(i, s.size()-1){
    string t;
    t.push_back(s.at(i));
    t.push_back(s.at(i+1));
    if(t == "AC"){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int main() {
  
  int N, L;
  cin >> N >> L;
  int sou = 0; //総和数
  vector<int> A(N);
  int X = L; //計算用としてXを用意
  bool hantei = false; //最小絶対値の0に対応するためのみ使用
  
  for ( int i = 0; i < N; i++) {
    A.at(i) = X; //配列にリンゴの味を入れる
    X++; //リンゴの味は++されていく
    sou += A.at(i); //配列の中の総数　リンゴの味（総数）
    if ( A.at(i) == 0 ) hantei = true; //0があったら即終了で、
    //0を抜かしたものが答えと言っても、そもそも引かなくてもいいじゃん！
  }
   
  if ( hantei ) cout << sou << endl; //ってことで0の時はそのまま総数が答え
  else if ( sou >= 0 ) cout << sou - A.at(0) << endl;
  else if ( sou <= 0 ) cout << sou - A.at(N - 1) << endl;
  //味は負になるときもあるってことで、負の時は配列の最後尾
  //else cout << sou << endl; //試験
  
}

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

int main(void) {
	int N, L;
	string ans;
	vector<string> vs;

	cin >> N >> L;
	vs.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> vs[i];
	sort(vs.begin(), vs.end());
	ans = "";
	for (int i = 0; i < (int)vs.size(); ++i)
		ans += vs[i];

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int N,M,S,i,j,k,MOD=100000;
	while(scanf("%d%d%d",&N,&M,&S),N)
	{
		int dp[50][3001]={1};
		for(i=M;i>0;--i)
			for(j=N*N;j>0;--j)
				for(k=S-i;k>=0;--k)
				{
					int &r=dp[j][i+k];
					r=(r+dp[j-1][k])%MOD;
				}
		printf("%d\n",dp[N*N][S]);
	}
	return 0;
}

Measured memory_bytes: 1348
import java.util.*;
import java.io.*;
import java.math.BigInteger;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author prem_cse
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solution solver = new Solution();
        solver.solve(1, in, out);
        out.close();
    }

    static class Solution{
  
    	
        public void solve(int testNumber, FastReader sc, PrintWriter out) {
        
        	String s = sc.next();
        	int ans = 0;
        	if(s.contains("RRR")) ans = 3;
        	else if(s.contains("RR")) ans = 2;
        	else if(s.contains("R")) ans = 1;
        	out.print(ans);
        }

	
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream stream) {
            br = new BufferedReader(new
                    InputStreamReader(stream), 32768);
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 32720
N, K = map(int, input().split())
S = input()
happy = 0
for n in range(N):
    if S[n] == "L" and n > 0 and S[n - 1] == "L":
        happy += 1
    elif S[n] == "R" and n < N - 1 and S[n + 1] == "R":
        happy += 1
print(min(happy + 2 * K, N - 1))


Measured memory_bytes: 3316
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int N, C, K;
vector<int> T;

bool isOK(int m) {
  int idx = 0;
  while (idx < N) {
    int deadline = T[idx] + K;
    int people = 1;
    while (idx < N && T[idx] <= deadline && people <= C) {
      idx++;
      people++;
    }
    if (m-- == 0) return false;
  }
  return true;
}

int main(void) {
  cin >> N >> C >> K;
  T.resize(N);
  for (int i = 0; i < N; ++i) cin >> T[i];
  sort(T.begin(), T.end());

  int left = N / C;
  int right = N;
  while (left < right) {
    int mid = left + (right - left) / 2;
    if (isOK(mid)) {
      right = mid;
    } else {
      left = mid + 1;
    }
  }
  cout << left << endl;
  return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Read();
            var t = Read();

            var ans = 0;
            for (int i = 0; i < 3; i++)
            {
                if (s[i] == t[i])
                {
                    ans++;
                }
            }
            WriteLine(ans);
        }
    

    private static string Read() { return ReadLine(); }
    private static string[] Reads() { return (Read().Split()); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }


    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false;

        double sqrtNum = Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                return false;
            }
        }
        return true;
    }

    //最大公約数
    public static int Gcd(int a, int b)
    {
        if (a < b)
        {
            return Gcd(b, a);
        }
        while (b != 0)
        {
            var reminder = a % b;
            a = b;
            b = reminder;
        }
        return a;
    }

    //最小公倍数
    public static int Lcm(int a, int b)
    {
        return a * b / Gcd(a, b);
    }

    //文字数を数える
    public static int CountChar(string s, char c)
    {
        return s.Length - s.Replace(c.ToString(), "").Length;
    }
    public static void debuglist(List<int> x)
    {
        foreach (var item in x)
        {
            WriteLine(item);
        }
    }
    public static void debuglist(List<string> x)
    {
        foreach (var item in x)
        {
            WriteLine(item);
        }
    }
    public static void debugarray(int[] x)
    {
        foreach (var item in x)
        {
            WriteLine(item);
        }
    }
    public static void debugarray(string[] x)
    {
        foreach (var item in x)
        {
            WriteLine(item);
        }
    }
}
}


Measured memory_bytes: 13140
use std::io;


/// https://beta.atcoder.jp/contests/abc064/tasks/abc064_b
fn main() {
    let _ = read_one::<usize>();
    let mut an = read::<isize>();
    an.sort();
    let mut ans = 0;
    let mut prev = an.pop().unwrap();
    for a in an.iter().rev() {
        ans += (a - prev).abs();
        prev = *a;
    }

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


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
N=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

def test(n,x):
    while True:
        if n>=x:
            if n%x==0:
                n/=x
            else:
                n%=x
        else:
            break

    if n==1:
        return True
    else:
        return False

l=make_divisors(N)
la=make_divisors(N-1)

lb=[]
for i in l:
    if i==1 or i==N:
        continue
    if test(N,i):
        lb.append(i)

la.extend(lb)

print(len(set(la)))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	cout<<n/3<<"\n";
	return 0;
}


















Measured memory_bytes: 256
using namespace std;

#include <iostream>
#include <vector>
#include <algorithm>



int main() {
    int n = 0;
    int k = 0;
    cin >> n;
    cin >> k;
    int tmp = (n - 1) / (k - 1);
    int x =  (n - 1) % (k - 1) == 0 ? tmp : tmp + 1;
    cout << x << endl;
    return 0;
}


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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c;
  k = a * c - b;
  for(int i = 0;i < 10; i++){
  	cout << k << endl;
    k = a * k - b;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    vector<int> realv(n);
    for (int i = 0; i < n; i++)
    {
        realv[i] = v[i] - c[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (realv[i] > 0)
        {
            ans += realv[i];
        }
    }    
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from copy import deepcopy

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]

ans = 0
for hh in range(1 << h):
    cp = deepcopy(c)
    for hi in range(6):
        if hh >> hi & 1:
            for wi in range(w):
                cp[hi][wi] = "x"

    for ww in range(1 << w):
        cp2 = deepcopy(cp)
        for wi in range(6):
            if ww >> wi & 1:
                for hi in range(h):
                    cp2[hi][wi] = "x"

        cnt = 0
        for hi in range(h):
            for wi in range(w):
                if cp2[hi][wi] == "#":
                    cnt += 1

        if cnt == k:
            ans += 1

print(ans)



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

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,g;
    cin >> n;
    vector<int> v(n);
    for (int i=0;i<n-1;i++)
    {
        cin >> g;
        v[g-1]++;
    }
    for (int i=0;i<n;i++)
        cout << v[i] << '\n';
}



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

	public static void main(String[] args) {
		Scanner sc= new Scanner (System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X = sc.nextInt();
		int []A = new int[N];
		int total = X;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			for(int a = 0; a < D; a+=A[i]) {
				total++;
			}
		}
		System.out.println(total);
		
	}
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    string S;
    cin >> S;
    ll N = S.size();
    int mod13 = 13;
    mint dp[N+1][mod13] = {};
    dp[0][0] = 1;
    for(int i=0;i<N;i++){
        if(S[i] == '?'){
            for(int j=0;j<mod13;j++)for(int k=0;k<10;k++){
                dp[i+1][(j*10+k)%mod13] += dp[i][j];
            }

        }else{
            
            int t = S[i] -'0';
            for(int j=0;j<mod13;j++){
                dp[i+1][(j*10+t)%mod13] += dp[i][j];
            }
        }
    }
    cout << dp[N][5] << endl;


    return 0;
}

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

#define MAX 20000

static int top = 0;
static int stack[MAX];

void push(int x);
int pop(void);
int isEmpty(void);
int isFull(void);

int main(void){
  int l[MAX/2][2], k = 0, A = 0;
  int i, tmp;
  char str[MAX+1];

  scanf("%s", str);
  for(i = 0; str[i] != '\0'; i++){
    switch(str[i]){
    case '\\':
      push(i);
      break;
    case '_':
      break;
    case '/':
      tmp = pop();
      if(tmp != -1){
	A += i-tmp;
	l[k][0] = i-tmp;
	l[k][1] = tmp;
	while(k > 0 && l[k][1] < l[k-1][1]){
	  l[k-1][0] += l[k][0];
	  l[k-1][1] = l[k][1];
	  k--;
	}
	k++;
      }
      break;
    }
  }
  
  printf("%d\n", A);
  printf("%d", k);
  for(i = 0; i < k; i++){
    printf(" %d", l[i][0]);
  }
  printf("\n");
  return 0;
}


void push(int x){
  if(isFull()){
    printf("?????????????????????\n");
    exit(1);
  }
  stack[++top] = x;
}


int pop(void){
  if(isEmpty()){
    /*
    printf("??¢??????????????????\n");
    exit(1);
    */
    return -1;
  }
  return stack[top--];
}


int isEmpty(void){
  return top == 0;
}


int isFull(void){
  return top >= MAX-1;
}

Measured memory_bytes: 640
x, a, b = map(int, input().split())
n = int(input())
for i in range(n) :
    s = input()
    if s == 'nobiro' :
        x += a
        if x < 0 :
            x = 0
    elif s == 'tidime' :
        x += b
        if x < 0 :
            x = 0
    else :
        x = 0
print(x)


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

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> road(M*2);
    for(int i=0;i<M*2;i++){ cin >> road.at(i); }
    vector<int> count(N);
    
    for(int i=0;i<M*2;i++){
        for(int j=1;j<=N;j++){
            if(road.at(i) == j){ count.at(j-1)++; break; }
        }
    }
    
    for(int i=0;i<N;i++){
        cout << count.at(i) << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		int h,m,s;
		int S=scan.nextInt();
		h=S/3600;
		S=S%3600;
		m=S/60;
		s=S%60;
		System.out.printf("%d:%d:%d\n",h,m,s);
		
		
		scan.close();
	}
}

Measured memory_bytes: 17168
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int N; cin >> N;
  vector<ll> A(N);
  for (auto& a : A) { cin >> a; }
  vector<ll> B(N);
  boost::partial_sum(A, B.begin());
  auto sum = B[N-1];

  ll res = std::numeric_limits<ll>::max();
  for (int i = 0; i < N - 1; ++i) {
    auto sunuke = B[i];
    auto arai = sum - sunuke;
    auto d = std::abs(sunuke - arai);
    chmin(res, d);
  }
  cout << res << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

int vector_finder(vector<int> vec, int n) {
  auto itr = find(vec.begin(), vec.end(), n);
  size_t index =distance( vec.begin(), itr );
  if (index != vec.size()) return 1;
  else return 0;
}

int main() {
  int a, b; cin >> a >> b;
  vector<int> vec1 = {1,3,5,7,8,10,12};
  vector<int> vec2 = {4,6,9,11};
  if(vector_finder(vec1, a) == 1 && vector_finder(vec1, b) == 1)
    cout << "Yes";
  else if(vector_finder(vec2, a) == 1 && vector_finder(vec2, b) == 1)
    cout << "Yes";
  else if(a==2&&b==2) cout << "Yes";
  else cout << "No";
}

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

using i64 = long long;

int main() {
#ifdef HOME
	freopen("arc88a.in", "r", stdin);
	freopen("arc88a.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	i64 x, y;
	int ans(1);

	cin >> x >> y;
	while (x * 2 <= y)
		x*= 2, ans+= 1;

	cout << ans << endl;

	return 0; }


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

#define faster     ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define read       freopen("input.txt", "r", stdin);
#define write      freopen("output.txt", "w", stdout);
#define endd        '\n'
#define ll         long long
#define sq(a)      ((a) * (a))

using namespace std;
int main()
{
      faster;
      double pi = 2 * acos(0.0);
      ll int  t,n,m,i,j,k,a,b,c,d,p,q,r,x=250,y=10,z,count=0;
      cin>>n>>a>>b;
      c=abs(a-b);
      if(c%2==0)cout<<"Alice"<<endl;
      else cout<<"Borys"<<endl;
      return 0;
}
//Sheikh Tafsir Rahman
//CSE IUT


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

int N, Q;
vector<vector<int> > G;
vector<int> ans;
 
void dfs(int now, int ago){
  for(auto next : G[now]){
    if(next == ago) continue;
    ans[next] += ans[now];
    dfs(next, now);
  }
}
 
int main(){
  cin >> N >> Q;
  G.resize(N);
  ans.resize(N, 0);
  for(int i = 0; i < N-1; i++){
    int a, b; cin >> a >> b;
    --a; --b;
    G[a].push_back(b); G[b].push_back(a);
  }
  for(int i = 0; i < Q; i++){
    int p, x; cin >> p >> x;
    ans[p-1] += x;
  }
  dfs(0, -1);
  for(int  i = 0; i < N; i++) cout << ans[i] << " ";
  cout << endl;
}

Measured memory_bytes: 24280
n, k = list(map(int, input().split()))
xs = list(map(int, input().split()))


inv_idx = n

for i, x in enumerate(xs):
    if x >= 0:
        inv_idx = i
        break

ps = []
for i, x in enumerate(xs[inv_idx:]):
    ps.append(x)

ns = []
for i, x in enumerate(reversed(xs[:inv_idx])):
    ns.append(-x)

if inv_idx == 0:
    print(ps[k-1])
    exit(0)
elif inv_idx == n:
    print(ns[k-1])
    exit(0)

n_seach_end = max(0, min(len(ns), k - 1))
p_seach_end = max(0, min(len(ps), k - 1))

n_seach_start = max(0, k - len(ps) - 1)
p_seach_start = max(0, k - len(ns) - 1)

ans = 10 ** 13

for i in range(n_seach_start, n_seach_end):
    ans = min(ans, 2 * ns[i] + ps[k - 2 - i])

for i in range(p_seach_start, p_seach_end):
    ans = min(ans, 2 * ps[i] + ns[k - 2 - i])

if len(ns) >= k:
    ans = min(ans, ns[k - 1])

if len(ps) >= k:
    ans = min(ans, ps[k - 1])

print(ans)


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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    int n;
    cin>>n;
    vector<pair<int,int>> v;
    ffor(i,0,n)
    {
        int x,y;
        cin>>x>>y;
        v.pb(mp(y,x));
    }
    sort(all(v));
    ll t=0,flag=1;
    ffor(i,0,n)
    {
        t+=v[i].ss;
        if(t>v[i].ff)
        {
            flag=0;
            break;
        }
    }
    if(flag) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 2420
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define REP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define REPI(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define REPITER(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    string t="";
    for(int i=0;i<s.size()/2;++i)
    t+=s[i];
    if(t+t==s)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

double dp[305][305][305];

int main(void){
  int n;
  cin >> n;
  
  map<int, int> mp;
  REP(i, n){
    int a;
    cin >> a;
    mp[a]++;
  }

  dp[0][0][0] = 0;

  REP(k, n+1){
    REP(j, n+1){
      REP(i, n+1){
        if(i == 0 && j == 0 && k == 0) continue;
        double p = 0;
        if(i > 0) p += dp[i-1][j][k] * i;
        if(j > 0) p += dp[i+1][j-1][k] * j;
        if(k > 0) p += dp[i][j+1][k-1] * k;
        p += n;
        p *= 1.0 / (i+j+k);
        dp[i][j][k] = p;
      }
    }
  }
  cout << fixed << setprecision(10) << dp[mp[1]][mp[2]][mp[3]] << endl;

  return 0;
}

Measured memory_bytes: 219392
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

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


	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++){
			cin >> c[i][j];
		}
		}


	cout << c[0][0]<<c[1][1]<<c[2][2] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N, K;
int imosb[5050][5050];

void f(int x, int y) {
    imosb[max(0ll, x - K + 1)][max(0ll, y - K + 1)] += 1;
    imosb[x + 1][y + 1] += 1;
    imosb[max(0ll, x - K + 1)][y + 1] -= 1;
    imosb[x + 1][max(0ll, y - K + 1)] -= 1;

    imosb[x + 1][y + 1] += 1;
    imosb[x + K + 1][y + K + 1] += 1;
    imosb[x + 1][y + K + 1] -= 1;
    imosb[x + K + 1][y + 1] -= 1;
}

signed main() {
    cin >> N >> K;
    rep(i, N) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'W')y += K;
        x %= 2 * K;
        y %= 2 * K;
        f(x, y);
        f(x + 2 * K, y);
        f(x, y + 2 * K);
        f(x + 2 * K, y + 2 * K);
    }
    rep(i, 4 * K) {
        for (int j = 1; j < 4 * K; ++j) {
            imosb[i][j] += imosb[i][j - 1];
        }
    }
    for (int i = 1; i < 4 * K; ++i) {
        rep(j, 4 * K) {
            imosb[i][j] += imosb[i - 1][j];
        }
    }
    int ans = 0;
    rep(i, 4 * K) {
        rep(j, 4 * K) {
            ans = max(ans, imosb[i][j]);
            if (imosb[i][j] == 5)cerr << i << " " << j << endl;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 198912
#include<bits/stdc++.h>
using namespace std;
int h,w,n,a[200001],b[200001],mi[200001];
int main()
{
    scanf("%d%d%d",&h,&w,&n);
    int ans=h;
    memset(mi,125,sizeof(mi));
    for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]),mi[a[i]]=min(mi[a[i]],b[i]);
    int t=1;
    for(int i=2;i<=h;i++)
    {
        if(mi[i]<=t) {ans=i-1;break;}
        t=min(mi[i]-1,t+1);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 2560
S = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(",")
for i in range(len(S)):
  S[i] = S[i].strip(" ")
K = int(input())
print(S[K-1])


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

using namespace std;


int main() {
    int n;
    cin>>n;
    int num[n];
    for (int i = 0; i < n; ++i) {
        cin>>num[i];
    }
    sort(num,num+n);
    cout<<num[n-1]-num[0]<<endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

struct LowLink {
    int N;
    vector<vector<int>> G;
    vector<int> low,ord,articulation;
    vector<P> bridge;

    LowLink(int N, vector<vector<int>> &G): N(N),G(G),low(N,-1),ord(N,-1) {}

    void dfs(int v,int time,int p = -1) {
        ord[v] = low[v] = time;
        ++time;

        bool isArticulation = false;
        int cnt = 0;

        for (int e:G[v]) {
            if (low[e] < 0) {
                ++cnt;
                dfs(e,time,v);
                low[v] = min(low[v],low[e]);
                if (p != -1 && ord[v] <= low[e]) isArticulation = true;
                if (ord[v] < low[e]) {
                    if (v < e) bridge.push_back({v,e});
                    else bridge.push_back({e,v});
                }
            }
            else if (p != e) {
                low[v] = min(low[v],ord[e]);
            }
        }

        if (p == -1 && cnt >= 2) isArticulation = true;
        if (isArticulation) articulation.push_back(v);
    }

    void build() {
        dfs(0,0);
    }
};

int main() {
    int V,E; cin >> V >> E;
    vector<vector<int>> G(V);
    rep(_,E) {
        int a,b; cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    LowLink lol(V,G);
    lol.build();
    vector<P> ans = lol.bridge;
    sort(ans.begin(),ans.end());
    rep(i,ans.size()) printf("%d %d\n",ans[i].first,ans[i].second);
    return 0;
}


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

using namespace std;

int main() {
  int count = 0;
  string s;
  cin >> s;
  int a = 0,b=s.length()-1;
  while(a<=b)
  {
    if(s[a]!=s[b]){
      count++;
  }
    a++;
    b--;
}
    cout << count;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
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 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())

int n;
char str[100005];
bool ex[100005];
int main(){
	scanf("%s",&str);
	n = strlen(str);
	rep(i,n) ex[i+1] = str[i] == '1';
	
	bool bad = 0;
	if(ex[n]) bad = 1;
	if(!ex[1]) bad = 1;
	repn(i,n-1){
		if(ex[i] != ex[n-i]){
			bad = 1;
		}
	}
	
	if(bad){
		puts("-1");
		return 0;
	}
	
	int m = n/2;
	vector<int>vec;
	repn(i,m){
		if(ex[i]) vec.pb(i);
	}
	
	vector<P>edge;
	int nxt = 2;
	for(int i=1;i<vec.size();i++){
		int dif = vec[i]-vec[i-1];
		edge.pb(P(nxt-1,nxt+dif-1));
		rep(i,dif-1) edge.pb(P(nxt+i,nxt+dif-1));
		nxt += dif;
	}
	
	edge.pb(P(nxt-1,nxt));
	repn(i,300000){
		if(nxt+i > n) break;
		edge.pb(P(nxt,nxt+i));
	}
	for(auto a:edge){
		cout << a.fi << " " << a.sc << endl;
	}
}

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

int main() {
	int n;
 cin>>n;
 long long int s=0;
 for(int i=1;i<=n;i++)
 {for(int j=1;j<=n;j++)
  {for(int k=1;k<=n;k++)
   {int x=__gcd(i,j);
    s+=__gcd(x,k);   
   }     
  }
 }
 cout<<s;
 
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<map>
#include<queue>
#define dot pair<int,int>
using namespace std;
int main(){
  int dx[6]={1,-1,0,0,1,-1};
  int dy[6]={0,0,1,-1,1,-1};
  int field[300][300];
  int t,n;
  while(cin >>t>>n,t||n){
    for(int i=0; i<300; i++) for(int j=0; j<300; j++) field[i][j] = 0;
    for(int i=0,a,b; i<n; i++){
      cin >>a>>b;
      field[a+100][b+100] = 1;
    }
    int sx,sy;
    cin >>sx>>sy;
    queue<dot > f;
    int ans = 0;
    f.push(make_pair(100+sx,100+sy));
    field[100+sx][100+sy] = 1;
    while(!f.empty()){
      ans++;
      dot x = f.front();
      f.pop();
      if(field[x.first][x.second]<=t){
	for(int i=0; i<6; i++){
	  if(field[x.first+dx[i]][x.second+dy[i]] == 0){
	    field[x.first+dx[i]][x.second+dy[i]] = field[x.first][x.second]+1;
	    f.push(make_pair(x.first+dx[i],x.second+dy[i]));
	  }
	}
      }
    }
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1568
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
  int key;
  Node *next,*prev;
};

Node *nil;

Node* listSearch(int key){
  Node *cur = nil -> next;
  while( cur != nil && cur -> key != key){
    cur = cur -> next;
  }
  return cur;
}

void init(){
  nil =  (Node *)malloc(sizeof(Node));
  nil -> next = nil;
  nil -> prev = nil;
}

void printList(){
  Node *cur = nil -> next;
  int isf = 0;
  while( 1 ){
    if(cur == nil) break;
    if( isf++ > 0) printf(" ");
    printf("%d",cur->key);
    cur = cur -> next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if( t == nil) return;
  t -> prev -> next = t -> next;
  t -> next -> prev = t -> prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil -> next);
}

void deleteLast(){
  deleteNode(nil -> prev);
}
void deleteKey(int key){
  //検索したノードを削除
  deleteNode(listSearch(key));
}
void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  //番兵の直後に要素を追加
  x->next = nil->next;
  nil -> next -> prev = x;
  nil -> next = x;
  x -> prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for(i = 0; i < n; i++){
    scanf("%s%d",com ,&key);
    if( com[0] == 'i') {insert(key); np++; size++;}
    else if( com[0] == 'd' ){
      if( strlen(com) > 6){
        if( com[6] == 'F') deleteFirst();
        else if( com[6] == 'L') deleteLast();
      }else{
        deleteKey(key); nd++;
      }
      size--;
    }
  }
  printList();

  return 0;
}



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

int main()
{
  int X;
  cin >> X;
  int a[100] = {0};
  for(int i=0; i<X; i++){
    cin >> a[i];
  }
  int min = 999999;
  int count = 0;
  for(int i=0; i<101; i++){
    count = 0;
    for(int j=0; j<X; j++){
      count += pow(abs(a[j]-i), 2);
    }
    if(min > count){
      min = count;
    }
  }
  cout << min;
  
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<array>
using namespace std;
int main(){
int N;
cin>>N;

if (N<105){
  cout<<0<<endl;
}else if(N<135){
  cout<<1<<endl;
}else if(N<165){
  cout<<2<<endl;
}else if(N<189){
  cout<<3<<endl;
}else if(N<195){
  cout<<4<<endl;
}else{
  cout<<5<<endl;
}












}


Measured memory_bytes: 256
#include <map>
#include <iostream>

#define int long long

using namespace std;

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
    int n;
    cin >> n;
    map<int, int> m;
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        ++m[x];
        ans += x;
    }
    int q;
    cin >> q;
    while (q--)
    {
        int b, c;
        cin >> b >> c;
        ans -= m[b] * b;
        ans += m[b] * c;
        m[c] += m[b];
        m[b] = 0;
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 9564
from collections import deque

while True:
    w, h = map(int, input().split())
    if w == 0:
        break
    lr_walls = []
    ud_walls = []
    for i in range(2 * h - 1):
        wall = list(map(int, input().split()))
        if i % 2 == 0:
            lr_walls.append(wall)
        else:
            ud_walls.append(wall)
    checked = [[False] * w for _ in range(h)]
    checked[0][0] = True
    que = deque()
    que.append((1, 0, 0))
    while que:
        score, x, y = que.popleft()
        if (x, y) == (w - 1, h - 1):
            print(score)
            break

        if x < w - 1 and lr_walls[y][x] == 0 and not checked[y][x + 1]:
            checked[y][x + 1] = True
            que.append((score + 1, x + 1, y))

        if x > 0 and lr_walls[y][x - 1] == 0 and not checked[y][x - 1]:
            checked[y][x - 1] = True
            que.append((score + 1, x - 1, y))

        if y < h - 1 and ud_walls[y][x] == 0 and not checked[y + 1][x]:
            checked[y + 1][x] = True
            que.append((score + 1, x, y + 1))

        if y > 0 and ud_walls[y - 1][x] == 0 and not checked[y - 1][x]:
            checked[y - 1][x] = True
            que.append((score + 1, x, y - 1))
    else:
        print(0)




Measured memory_bytes: 6012
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

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

    vector<int> vec(n);
    int i;
    for (i = 0; i < n; ++i)
    {
       vec[i] = ((s[i] == '.') ? 1 : 0);
    }
    // 白石の個数(累積)
    for (i = 1; i < n; ++i)
    {
       vec[i] += vec[i-1];
    }

    // 左から白石i個、残りすべて黒石の状態にするための変更数
    vector<int> changes(n + 1);
    changes[0] = vec[n-1];
    for (i = 1; i < (n + 1); ++i)
    {
        changes[i] = vec[n-1] + i - 2 * vec[i-1];
    }

    cout << *min_element(changes.begin(), changes.end());

    return 0;
}

Measured memory_bytes: 2180
N=int(input())
L=list(map(int, input().split()))

import itertools

cnt=0

for pair in itertools.combinations(L, 3):
    lis = sorted(list(pair))
    max_value=lis[2]
    mid_value=lis[1]
    min_value=lis[0]
    if (max_value < mid_value+min_value) and (max_value>mid_value>min_value):cnt+=1

print(cnt)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod 1000000007
#define pb emplace_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define test(t) ll t;cin>>t;while(t--)
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
#define fr(i,n) for(ll i=0;i<(n);++i)
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
signed main()
{
    fast;
    ll N;
    cin>>N;
    ll n,h;
    for(n=1;n<=3500;n++)
    {
    	for(h=1;h<=3500;h++)
    	{
    		ll p = N*h*n;
    		ll pp = 4*n*h-N*h-N*n;
    		if(pp>0 and p%pp==0)
    		{
    			cout<<h<<" "<<n<<" "<<p/pp<<endl;
    			return 0;
    		}
    	}
    }

    
}


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

int n, k;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> k;
	int cnt = 0;
	for(int i = 0; i < n; i++){
		int h;
		cin >> h;
		if(h >= k) cnt++;
	}
	cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N,M;
  cin >> N >> M;
  vector<int> a(50),b(50);
  for(int i=0;i<M;i++)cin >> a[i] >> b[i];
  int ans=0;
  vector<int> q;
  for(int i=1;i<=N;i++)q.push_back(i);
  do{
    int count=0;
    for(int i=0;i<N-1;i++){
      bool w=false; 
      for(int j=0;j<M;j++){
        if(q[i]==a[j] && q[i+1]==b[j] || q[i]==b[j] && q[i+1]==a[j])w=true;
      }
      if(w){count++;}
    }
    if(count==N-1 && q[0]==1)ans++;
  }while(next_permutation(q.begin(),q.end()));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
  
int s[21][41];
int main(void){
    int r, n, xl, xr, h;
    while(cin >> r >> n && r) {
        rep(i, 21) rep(j, 41) s[i][j] = 0;
        rep(i, n) {
            cin >> xl >> xr >> h;
            for(int y=0; y<h; ++y) {
                for(int x=xl+20; x<xr+20; ++x) {
                    s[y][x] = 1;
                }
            }
        }
        double mint = numeric_limits<double>::max();
        rep(y, 21) {
            for(int x=-r+20; x<r+20; ++x) {
                if(s[y][x] == 0) {
                    double t;
                    if(x<20) t = (double) y+r-sqrt(pow((double)r,2.0)-pow(x-19.0, 2.0));
                    else t = (double) y+r-sqrt(pow((double)r,2.0)-pow(x-20.0, 2.0));
                    mint = min(mint, t);
                }
            }
        }
        printf("%.4lf\n", mint);
    }
}

Measured memory_bytes: 1200
N=int(input())
import copy
A = [int(input()) for i in range(N)]


ans = [0]*N
a1 = max(A)
cnt = A.count(a1)

for i in range(N):
    if (A[i]==a1)and(cnt==1):
        B = copy.deepcopy(A)
        del(B[i])
        ans[i]=max(B)
    else:
        ans[i]=a1

for i in range(N):
    print(ans[i])

        



Measured memory_bytes: 16204