akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Threading;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var A = cin.ReadInt;
            var B = cin.ReadInt;
            Console.WriteLine(Max(A + B, Max(A - B, A * B)));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 11220
#include <iostream>
using namespace std;
int main(void){
    int n;
    while(true){
        cin>>n;
        if(n==0)    break;
        else{
            int i;
            for(i=0;i<n;i++){
                int m,e,j;
                cin>>m>>e>>j;
                if(m==100)  cout<<"A";
                else if(e==100) cout<<"A";
                else if(j==100) cout<<"A";
                else if(m+e>=180)   cout<<"A";
                else if(m+e+j>=240) cout<<"A";
                else if(m+e+j>=210) cout<<"B";
                else if(m+e+j>=150){
                    if(m>=80||e>=80)   cout<<"B";
                    else cout<<"C";
                }
                else    cout<<"C";
                cout<<endl;
            }
        }
    }
}


Measured memory_bytes: 3072
//abc172_c.cpp
//Sat Jun 27 20:54:54 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll a[n];
	vector<ll> atotal;
	for (int i=0;i<n;i++){
		cin >> a[i];
		if (i==0){
			atotal.push_back(a[0]);
		}else {
			atotal.push_back(atotal[i-1]+a[i]);
		}
	}

	ll b[m];
	vector<ll> btotal;
	for (int i=0;i<m;i++){
		cin >> b[i];
		if (i==0){
			btotal.push_back(b[0]);
		}else {
			btotal.push_back(btotal[i-1]+b[i]);
		}
	}

	ll ans = 0;
	auto itr = upper_bound(atotal.begin(),atotal.end(),k);
	ll tmp = itr-atotal.begin();
	ans = max(ans,tmp);
	// cout << "aonly " << tmp << endl;
	auto itr2 = upper_bound(btotal.begin(),btotal.end(),k);
	tmp = itr2-btotal.begin();
	ans = max(ans,tmp);
	// cout << "bonly " << tmp << endl;

	for (int i=0;i<n;i++){
		if (atotal[i]<k){
			ll tmp = k-atotal[i];
			auto itr = upper_bound(btotal.begin(),btotal.end(),tmp);
			ll tmp2 = itr-btotal.begin()+i+1;
			ans = max(ans,tmp2);
			// cout << i << " " << itr-btotal.begin()+1 << " " << ans << endl;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 10612
n, max_weight = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(n)]
W, V = zip(*WV)
dp = list([0] * (max_weight + 1) for _ in range(n + 1))
for i in range(n):
    for w in range(1, max_weight + 1):
        if w >= W[i]:
            dp[i + 1][w] = max(dp[i][w], dp[i][w - W[i]] + V[i])
        else:
            dp[i + 1][w] = dp[i][w]

print(dp[n][max_weight])


Measured memory_bytes: 120044
room_list = [[[0 for b in range(10)] for f in range(3)] for r in range(4)]

for i in range(int(input())):
    b,f,r,v = map(int, input().split())
    room_list[b-1][f-1][r-1] += v

for b in range(len(room_list)):
    for f in room_list[b]:
        print("", *f)
    if b != len(room_list)-1:
        print("#" * 20)


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
bool sortDescByFirst(const pair<int,int>&a, const pair<int,int>&b){
    return a.first>=b.first;
}
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b;
    while(cin>>a>>b){
        cout<<max(a+b,max(a-b,a*b))<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int che = 30;
    for(int i = 1 ; i <= n ; i++){
      int a = sc.nextInt();
      int zyo = 0;
      int cou = 0;
      while(zyo == 0){
        if(a % 2 == 1){
          zyo = 1;
        }else{
          cou = cou + 1;
          a = a / 2;
        }
      }
      if(cou < che){
         che = cou;
      }
    }
    System.out.println(che);
    sc.close();
  }
}


Measured memory_bytes: 36180
#include <stdio.h>
#include <math.h>
int main(){
	long int x;
    long int p;
  	long double a,b,c;
	x=0;
  	a=100;
  	b=a;
  	scanf("%Lf",&c);
	while(c>b){
	  	b=(long int)(b+b*.01);
      	x++;
    }
	printf("%ld\n",x);  	
  
  
  
  
}

Measured memory_bytes: 1696
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
const int N = 100005;
int32_t main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //int t;cin>>t;while(t--)
    {
        int i, j, k, n, m,a,ans = 0, cnt = 0, sum = 0,b = 0,c = 0;
        cin >> k >> a >> b;
        j =  a ;
        for(i = j ; i <=  b ;i++){
        	if(i % k == 0){
        		ans++;
        	}
        }
        if(ans > 0){
        	cout << "OK";
        }else{
        	cout<< "NG";
        }
    }
}

Measured memory_bytes: 3648
import itertools
import collections
n=int(input())
l=len(str(n))
cnt=0
if l<3:
  print(0)
  exit()
for i in range(3,l+1):
  for k in itertools.product(['7','5','3'],repeat=i):
    j=int(''.join(k))
    k=list(k)
    x=k.count('7')
    y=k.count('5')
    z=k.count('3')
    if all(vv!=0 for vv in [x,y,z]) and j<=n:
      cnt+=1
print(cnt)

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

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var cin = new MyInputStream();
            var a = cin.Read().ToUpper();
            var b = cin.Read().ToUpper();
            var c = cin.Read().ToUpper();
            Write(a[0]);
            Write(b[0]);
            Write(c[0]);
            WriteLine();
        }
    }

    public class MyInputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Trim().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine() => Console.ReadLine();
        public int ReadInt() => int.Parse(Read());
        public long ReadLong() => long.Parse(Read());
        public double ReadDouble() => double.Parse(Read());
        public string r() => Read();
        public int ri() => ReadInt();
        public long rl() => ReadLong();
        public double rd() => ReadDouble();
    }
}


Measured memory_bytes: 13268
n,m = gets.chomp.split(" ").map(&:to_i)
a_arr = gets.chomp.split(" ").map(&:to_i).sort_by{|a| -a}

while m > 0 do
  m -= 1
  max = a_arr.shift
  max_2 = max / 2
  index = a_arr.bsearch_index{|a| a <= max_2} || a_arr.length
  if m >= index
    a_arr.insert(index, max_2)
    (0..(index-1)).each do |i|
      a_arr[i] /= 2
    end
    a_arr = a_arr.sort_by{|a| -a}
    m -= index
  else
    a_arr.insert(index, max_2)
    (0..(m-1)).each do |i|
      a_arr[i] /= 2
    end
    m = 0
  end
end

puts a_arr.inject(&:+)




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

int main(){
  int A, B, C, i;
  cin >> A >> B >> C;
  
  for (i = 0; i < C; i++){
    if(A*i + A > B){
      break;
    }
  }
  
  cout << i << endl;
  
  return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll xorsum = 0;
vector<string> S;
ll l;
int n;
ll beki[61];

void search(string& in){
    if(in.size() > l) return;
    auto itr =lower_bound(S.begin(), S.end(), in);
    if(*itr == in) return;
    string out = *itr;
    if(out.substr(0, in.size()) != in){
        //ans.push_back(in);
        ll now = l - in.size() + 1;
        for(int j = 0; ; j++){
            if(now>>j & 1){
                xorsum ^= beki[j];
                //cout << in << " " << now << " " << beki[j] << endl;
                return;
            }
        }
    }
    in += "0";
    search(in);
    in.pop_back();
    in += "1";
    search(in);
    in.pop_back();
    return;
}

int main() {
    beki[0] = 1;
    for(int i = 1; i <= 60; i++){
        beki[i] = beki[i - 1] * 2;
    }
    //cout.precision(10);
    /*for(int i = 1; i <= 200; i++){
        for(int j = 0; ; j++){
            if(i>>j & 1){
                test[i] = beki[j];
                break;
            }
        }
    }
    out[0] = 0;
    for(int i = 1; i <= 200; i++){
        for(int j = 0; j < Grundy.size(); j++){
            Grundy[j] = Grundy[j] ^ out[i - 1];
        }
        //cout << "a" << endl;
        Grundy.push_back(0);
        //cout << "a" << endl;
        sort(Grundy.begin(), Grundy.end());
        Grundy.erase(unique(Grundy.begin(), Grundy.end()), Grundy.end());
        //cout << "a" << endl;
        out[i] = Grundy.size();
        for(int j = 0; j < Grundy.size(); j++){
            if(Grundy[j] != j){
                out[i] = j;
                break;
            }
        }
        cout << i << " " << out[i] << " " << test[i] << endl;
    }*/
    cin >> n >> l;
    S.push_back("2");
    for(int i = 0; i < n; i++){
        string in;
        cin >> in;
        S.push_back(in);
    }
    sort(S.begin(), S.end());
    string in = "";
    search(in);
    /*int xorsum = 0;
    for(int i = 0; i < ans.size(); i++){
        int now = l - ans[i].size() + 1;
        if(now >= 1){
            if(now % 2 == 0){
                now = 2;
            } else {
                now = 1;
            }
        }
        cout << ans[i] << " " << now << endl;
        xorsum = xorsum ^ now;
    }*/
    if(xorsum == 0){
        cout << "Bob" << endl;
    } else {
        cout << "Alice" << endl;
    }
    return 0;
}


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

int main() {
  int N, max=0, c=0, k;
  cin >> N;
  vector<int> moti(N);
  
  for(int i=0;i<N;i++){
    cin >> moti.at(i);
  }
  
  for(int i=0;i<N;i++){
    max=0;
    for(int j=0;j<N;j++){
      if(i==0){
        if(max < moti.at(j))
          max = moti.at(j);
      }else{
        if(max < moti.at(j) && moti.at(j) < k)
          max = moti.at(j);
      }
    }
    k=max;
    if(max > 0)
      c++;
    else
      break;
  }
  cout << c << endl;
      
      
}


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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  string s;
  cin >> s;
  bool flag = true;
  REP(i,s.length()-1) {
    if(s[i] != s[i+1]) {
      flag = false;
      break;

    }
  }
  if(flag) {
    cout << "No";
  } else {
    cout << "Yes";
  }
   
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

const double eps=1e-8;

int sgn(double d)
{
   if (d>eps) return 1;
   if (d<-eps) return -1;
   return 0;
}

int main()
{
   double d;
   while(scanf("%lf",&d)!=EOF)
   {
      if (sgn(d)==0) break;
	  double x,y,vx,vy;
	  scanf("%lf%lf%lf%lf",&x,&y,&vx,&vy);
	  double b1=x*vy-y*vx;
	  if (sgn(b1)==0)
	  {
		 if (sgn(vx*x)<0||sgn(vy*y)<0)
		 {
			 double dis=sqrt(x*x+y*y);
			 if (sgn(dis-d)>0) printf("impossible\n");
			 else printf("%.6lf\n",dis);
		 }
		 else
		 {
		     double dis=sqrt(x*x+y*y);
			 dis=2.0-dis;
			 if (sgn(dis-d)>0) printf("impossible\n");
			 else printf("%.6lf\n",dis);
		 }
		 continue;
	  }
	  printf("impossible\n");
   }
   return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)
 
 
def main():
    n=int(input())
    a=list(map(int,input().split(" ")))
    dp=[0 for x in range(n+1)]
    dp[0]=0
    dp[1]=abs(a[1]-a[0])
    for x in range(2,n):
        dp[x]=min(dp[x-1]+abs(a[x]-a[x-1]),dp[x-2]+abs(a[x]-a[x-2]))
    print(dp[n-1])




#-----------------------------BOSS-------------------------------------!
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 90428
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_array<T: FromStr>(n: u32) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let c: u32 = read();
    let x: u32 = read();
    let mut ans = 0;

    for i in 0..a + 1 {
        for j in 0..b + 1 {
            for k in 0..c + 1 {
                if 500 * i + 100 * j + 50 * k == x {
                    ans += 1;
                }
            }
        }
    }

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


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

int main () {
  int a, b;
  int d, r;
  double f;
  cin >> a >> b;
  d = a / b;
  r = a % b;
  f = (double)a / b;
  cout.precision(5);
  cout << d << " "
       << r << " "
       << fixed << f << endl;
  return 0;
}

Measured memory_bytes: 1244
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
using namespace std;

int N;

int main(){

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

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

  long a,b;
  int ak=0;
  int bk=0;
  for(int i=N-2;i>0;i--){
    if(ak==0&&A[i+1]==A[i]) {
      ak=1;
      a=A[i];
      continue;}
    else if(ak==1&&bk==0&&A[i]==A[i-1]){
      bk=1;
      b=A[i];
      break;}
  }
 unsigned long long result;
  result=ak*bk*a*b;
    cout<<result<<endl;
       
  return 0;
}



Measured memory_bytes: 1024
using System;
using System.IO;
using System.Linq;

namespace Sandbox
{
    class Program
    {
        static void Main(string[] args)
        {
            var scanner = new Scanner();
            var s = scanner.GetNext();

            var len = s.Length;
            var onum = s.Count(c => c == 'o');

            var b = ((15 - len) + onum) >= 8;

            Console.WriteLine(b ? "YES" : "NO");
        }
    }

    #region String Scanner
    public class Scanner
    {
        private const char Separator = ' ';
        private readonly StreamReader _Stream = new StreamReader(Console.OpenStandardInput());
        private int _Pos;
        private string[] _Line = new string[0];

        #region get a element
        public string GetNext()
        {
            // ReSharper disable once InvertIf
            if (this._Pos >= this._Line.Length)
            {
                // ReSharper disable once PossibleNullReferenceException
                this._Line = this._Stream.ReadLine().Split(Separator);
                this._Pos = 0;
            }
            return this._Line[this._Pos++];
        }
        public int GetNextAsInt()
        {
            return int.Parse(this.GetNext());
        }
        public long GetNextAsLong()
        {
            return long.Parse(this.GetNext());
        }
        public double GetNextAsDouble()
        {
            return double.Parse(this.GetNext());
        }
        #endregion

        #region get array
        public string[] ToArrayFromNextLine()
        {
            if (this._Pos >= this._Line.Length)
            {
                // ReSharper disable once PossibleNullReferenceException
                this._Line = this._Stream.ReadLine().Split(Separator);
            }

            this._Pos = this._Line.Length;
            return this._Line;
        }
        public int[] ToIntArrayFromNextLine()
        {
            return ToIntArray(this.ToArrayFromNextLine());
        }
        public long[] ToLongArrayFromNextLine()
        {
            return ToLongArray(this.ToArrayFromNextLine());
        }
        public double[] ToDoubleArrayFromNextLine()
        {
            return ToDoubleArray(this.ToArrayFromNextLine());
        }
        #endregion

        #region convert array
        private static int[] ToIntArray(string[] array)
        {
            var result = new int[array.Length];
            for (var i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }
            return result;
        }
        private static long[] ToLongArray(string[] array)
        {
            var result = new long[array.Length];
            for (var i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }
            return result;
        }
        private static double[] ToDoubleArray(string[] array)
        {
            var result = new double[array.Length];
            for (var i = 0; i < array.Length; i++)
            {
                result[i] = double.Parse(array[i]);
            }
            return result;
        }
        #endregion
    }
    #endregion
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s[3];cin>>s[0]>>s[1]>>s[2];
  s[0][0]-=32;
  s[1][0]-=32;
  s[2][0]-=32;
  cout<<s[0][0]<<s[1][0]<<s[2][0]<<endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int sutexia_ai_konnpu(const char* a, const char* b) {
	for (;;) {
		int aa = tolower((unsigned char)*a);
		int bb = tolower((unsigned char)*b);
		if (aa > bb) return 1;
		if (aa < bb) return -1;
		if (aa == 0 && bb == 0) return 0;
		a++;
		b++;
	}
}

int main(void) {
	char W[16];
	char T[1024];
	int count = 0;
	if (scanf("%15s", W) != 1) return 1;
	while (scanf("%1023s", T) == 1 && strcmp(T, "END_OF_TEXT") != 0) {
		if (sutexia_ai_konnpu(W, T) == 0) count++;
	}
	printf("%d\n", count);
	return 0;
}



Measured memory_bytes: 2076
# my solution
*a, = map(int,input().split())
if any(map(lambda x: bin(x)[-1]== "1", a)):
    print("0")
    exit()
a = [bin(abs(a[i+1]-a[i]))[::-1].find('1') for i in range(2)]
print(max(a) if a[0]*a[1]<0 else min(a))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define lowbit(x) ((x) & (-x))
#define mem(i, a) memset(i, a, sizeof(i))
#define sqr(x) ((x) * (x))
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
typedef long long ll;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 2e3 + 7;
using namespace std;
vector<int> edge[maxn];
int dis[maxn][maxn];
int cnt[maxn];
queue<int> que;
int main(void) {
#ifdef ljxtt
    freopen("data.in", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        edge[i].push_back(i + 1);
        edge[i + 1].push_back(i);
    }
    int x, y;
    scanf("%d%d", &x, &y);
    edge[x].push_back(y);
    edge[y].push_back(x);
    mem(dis, -1);
    for (int i = 1; i <= n; i++) {
        que.push(i);
        dis[i][i] = 0;
        while (que.size()) {
            int now = que.front();
            que.pop();
            for (int j = 0; j < edge[now].size(); j++) {
                int next = edge[now][j];
                if (dis[i][next] != -1) continue;
                dis[i][next] = dis[i][now] + 1;
                que.push(next);
            }
        }
    }
    mem(cnt, 0);
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            cnt[dis[i][j]]++;
        }
    }
    for(int i = 1; i < n; i++)
        printf("%d\n", cnt[i]);
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int dig = 1;
    int M = N;
    while(M/10 > 0) {
        M= M/10;
        dig++;
    } 
    int ans = 0;
    for (int i = 0;i < dig - 1;i++) {
        if (i%2 == 0) {
            ans += 9 * pow(10,i);
        }
    }
    if (dig%2 == 1) {
        ans += (N - pow(10,dig-1) + 1);
    }
    

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    ll n;
    cin >> n;
    if (n==1) {cout << 0 << "\n"; return 0;}
    ll num = n;
    bool prime = true;
    vector<int> div(1e6);
    for (ll i = 2; i*i<= n; i++) {
        while (num%i == 0) {
            div[i]++;
            num /= i;
            prime = false;
        }
    }
    if (prime) {cout << 1 << "\n"; return 0;}
    ll ans = 0;
    if (num > 1) ans = 1;
    for (ll i = 2; i*i<= n; i++) {
        if (div[i] > 0) {
            ans += int((sqrt(8*div[i] + 1) -1) * 0.5);
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 7284
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, S):
    ans = 1
    for i in range(0, N-1):
        if S[i] != S[i+1]:
            ans += 1

    return ans


def main():
    N = read_int()
    S = read_str()
    print(slv(N, S))


if __name__ == '__main__':
    main()


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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> r;
    vector<int> g;
    vector<int> b;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R'){
            r.push_back(i + 1);
        }else if(s[i] == 'G'){
            g.push_back(i + 1);
        }else{
            b.push_back(i + 1);
        }
    }

    ll ans = 0;
    int l = r.size();
    int p = g.size();
    int q = b.size();
    for(int i = 0; i < l; i++){
        for(int j = 0; j < p; j++){
            int k = abs(r[i] - g[j]);
            if(k % 2 == 0){
                int t = k / 2;
                if(r[i] > g[j]){
                    auto itr = find(b.begin(), b.end(), g[j] + t);
                    if(itr != b.end()){
                        ans--;
                    }
                }else{
                    auto itr = find(b.begin(), b.end(), r[i] + t);
                    if(itr != b.end()){
                        ans--;
                    }
                }
                
            }
            if(r[i] > g[j]){
                auto itr = find(b.begin(), b.end(), r[i] + k);
                auto itr_2 = find(b.begin(), b.end(), g[j] - k);
                if(itr == b.end() && itr_2 == b.end()){
                    ans += q;
                }else if(itr != b.end() && itr_2 != b.end()){
                    ans += q;
                    ans -= 2;
                }else{
                    ans += q;
                    ans--;
                }
            }else{
                auto itr = find(b.begin(), b.end(), r[i] - k);
                auto itr_2 = find(b.begin(), b.end(), g[j] + k);
                if(itr == b.end() && itr_2 == b.end()){
                    ans += q;
                }else if(itr != b.end() && itr_2 != b.end()){
                    ans += q;
                    ans -= 2;
                }else{
                    ans += q;
                    ans--;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3656
import sys
import math

def str_input():
    S = raw_input()
    if S[len(S)-1] == "\r":
        return S[:len(S)-1]
    return S

def float_to_str(num):
    return str("{:.10f}".format(num))

def list_input(tp):
    return map(tp, str_input().split())

# # # # # # # # # # # # # # # # # # # # # # # # #

while 1:
    n = input()

    if n == 0:
        break

    s = list_input(float)
    m = sum(s) / n
    s = map(lambda x: x-m, s)
    s = map(lambda x: x*x, s)
    s = map(lambda x: x/n, s)
    
    print float_to_str(math.sqrt(sum(s)))

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

using namespace std;

typedef long long ll;

ll x;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> x;
    cout << x / 500 * 1000 + (x % 500) / 5 * 5 << "\n";
    return 0;
}


Measured memory_bytes: 256
//Zory-2018
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<stack>
using namespace std;

namespace mine
{
	const int MAX_N=310000;
	typedef long long ll;
	int mymax(int x,int y) {return x>y?x:y;}

	int a[MAX_N];
	int f[MAX_N],g[MAX_N];//最大和次大值的位置
	void update(int x,int pos)
	{
		if(pos<0 or pos==f[x] or pos==g[x]) return;
		if(a[pos]>=a[f[x]]) g[x]=f[x],f[x]=pos;
		else if(a[pos]>=a[g[x]]) g[x]=pos;
	}
	int bin[30];
	void main()
	{
		bin[0]=1;for(int i=1;i<30;i++) bin[i]=bin[i-1]<<1;

		int n;scanf("%d",&n);
		for(int i=0;i<bin[n];i++) scanf("%d",&a[i]),f[i]=i,g[i]=-1;

		int ans=0;
		for(int k=0;k<bin[n];k++)
		{
			for(int i=0;i<n;i++)
			{
				if(k&bin[i]) continue;
				update(k+bin[i],f[k]);
				update(k+bin[i],g[k]);
			}
			ans=mymax(ans,a[f[k]]+a[g[k]]);
			if(k>0) printf("%d\n",ans);
		}
	}
};

int main()
{
	mine::main();
}


Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    vector<bool> num(102);
    rep(i, 102) num[i] = false;
    rep(i, N){
        num[p[i]] = true;
    }
    int min_len = 100001;
    int min_index;
    rep(i, 102){
        if(num[i]) continue;
        else{
            if(min_len > fabs(X - i)){
                min_len = fabs(X-i);
                min_index = i;
            }
        }
    }
    cout << min_index << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;
int n, cnt;
string s, t;
int main(){
  cin >> s >> t;
  int ls = s.size();
  int lt = t.size();
  for(int i = 0; i < ls; i++){
    for(int j = i+1; j<ls; j++){
      if(s[i] > s[j]) swap(s[i], s[j]);
    }
  }
  for(int i = 0; i < lt; i++){
    for(int j = i+1; j<lt; j++){
      if(t[i] < t[j]) swap(t[i], t[j]);
    }
  }
  cout << ((t > s) ?"Yes" :"No") << endl;
}


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

int main()
{
    int n; cin >> n;
    vector<int>  h(n);
    for(int i = 0; i < n; ++i){
        cin >> h[i];
    }
  
    int count = 0;
    bool flag = false;
    while(flag == false){
      bool start = false;
      vector<pair<int,int>>lr;
      int l = 0;
      int r = 0;
      for(int i = 0; i < n; ++i){
        if( (i != n-1 ) && (h[i] != 0) && (start == false)){
          start = true;
          l = i;
        }
        else if( (h[i] == 0) && (start == true)){
          start = false;
          r = i;
          lr.push_back(make_pair(l,r));
        }
        else if( (i == n - 1) && (start == true)){
          r = i + 1;
          lr.push_back(make_pair(l,r));
        }
        else if( (i == n - 1) && (start == false)){
          lr.push_back(make_pair(n-1,n));
        }
      }
    for(int t = 0; t < lr.size(); t++){
      int min_ = INT_MAX;
      for(int i = lr[t].first; i < lr[t].second; ++i){
        if( min_ > h[i] ) {
          min_ = h[i];
        }
      }
      for(int i = lr[t].first; i < lr[t].second; ++i){
        h[i] -= min_;
      }
      count += min_;
    }
      
      flag = true;
      int test = 0;
      for(int i = 0; i < n; ++i){
        if(h[i] != 0){
          flag = false;
        }
      }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Queue;

public class Main {

	static Queue<Integer> stackX = new ArrayDeque<>();
	static Queue<Integer> stackY = new ArrayDeque<>();

	static int matrix[][];
	static int color[];
	static int dist[];
	static int n;

	static final int WHITE = 0;
	static final int GRAY = 1;
	static final int BLACK = 2;

	public static void main(String args[]) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		// String str[] = br.readLine().split(" ");
		n = Integer.parseInt(br.readLine());
		matrix = new int[n][n];
		color = new int[n];
		dist = new int[n];
		Arrays.fill(color, WHITE);
		Arrays.fill(dist, Integer.MAX_VALUE);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				matrix[i][j] = Integer.MAX_VALUE;
			}
		}

		for (int i = 0; i < n; i++) {
			String str[] = br.readLine().split(" ");
			int u = Integer.parseInt(str[0]);
			int k = Integer.parseInt(str[1]);
			for (int j = 2; j < str.length; j += 2) {
				int v = Integer.parseInt(str[j]);
				int c = Integer.parseInt(str[j + 1]);
				matrix[u][v] = c;
			}
		}
		dijkstra();
		for (int i = 0; i < n; i++) {
			System.out.println(i + " " + dist[i]);
		}
	}

	static void dijkstra() {
		int vertex, min_d;
		PriorityQueue<Integer> pqX = new PriorityQueue<>();
		PriorityQueue<Integer> pqY = new PriorityQueue<>();

		dist[0] = 0;
		color[0] = GRAY;

		while (true) {
			vertex = -1;
			min_d = Integer.MAX_VALUE;
			for (int i = 0; i < n; i++) {
				if (color[i] == GRAY && dist[i] < min_d) {
					min_d = dist[i];
					vertex = i;
				}
			}
			if (vertex == -1)
				break;
			color[vertex] = BLACK;

			for (int i = 0; i < n; i++) {
				if (color[i] != BLACK && matrix[vertex][i] < Integer.MAX_VALUE) {
					color[i] = GRAY;
					if (dist[i] > dist[vertex] + matrix[vertex][i]) {
						dist[i] = dist[vertex] + matrix[vertex][i];
					}
				}
			}
		}
	}
}


Measured memory_bytes: 27728
import java.util.Random;
import java.util.Scanner;

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

		int[] heights = new int[10];

		for (int i = 0; i < 10; i++) {
			heights[i] = in.nextInt();
		}
		
		quicksort(heights, 0, heights.length - 1);
		
		for (int i = heights.length - 1; i >= heights.length - 3; i--) {
			System.out.println(heights[i]);
		}
	}

	private static void quicksort(int[] data, int start, int end) {
		if (start > end) {
			return;
		}

		int index = partition(data, start, end);
		quicksort(data, start, index - 1);
		quicksort(data, index + 1, end);
	}

	private static int partition(int[] data, int start, int end) {
		int index = -1;
		Random rd = new Random();

		while (index < start || index > end) {
			index = rd.nextInt(end + 1);
		}

		swap(data, index, end);
		int pivot = data[end];

		int i = -1, j = 0;

		for (; j < end; j++) {
			if (data[j] <= pivot) {
				swap(data, ++i, j);
			}
		}
		
		swap(data, ++i, end);
		
		return i;
	}

	private static void swap(int[] data, int i, int j) {
		int tmp = data[i];
		data[i] = data[j];
		data[j] = tmp;
	}
}

Measured memory_bytes: 12000
package main

import "fmt"

var h, w int
var s []string

func main() {
	fmt.Scan(&h, &w)

	s = make([]string, h)
	for i := 0; i < h; i++ {
		fmt.Scan(&s[i])
	}

	ans := 0
	for sy := 0; sy < h; sy++ {
		for sx := 0; sx < w; sx++ {
			if s[sy][sx] != '.' {
				continue
			}

			c := bfs(sy, sx)
			if ans < c {
				ans = c
			}
		}
	}
	fmt.Println(ans)
}

func bfs(sy, sx int) int {
	ps := make([][]int, h)
	for i := 0; i < h; i++ {
		ps[i] = make([]int, w)
		for j := 0; j < w; j++ {
			ps[i][j] = -1
		}
	}
	ps[sy][sx] = 0

	q := make([][]int, 0)
	q = append(q, []int{sy, sx})
	for len(q) > 0 {
		y, x := q[0][0], q[0][1]
		q = q[1:]

		dd := [][]int{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}
		for _, d := range dd {
			ny, nx := y+d[0], x+d[1]
			if 0 <= ny && ny < h && 0 <= nx && nx < w {
				if s[ny][nx] == '.' && ps[ny][nx] == -1 {
					ps[ny][nx] = ps[y][x] + 1
					q = append(q, []int{ny, nx})
				}
			}
		}
	}

	max := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			c := ps[i][j]
			if max < c {
				max = c
			}
		}
	}

	return max
}


Measured memory_bytes: 5504
# -*- coding: utf-8 -*-

while True:
    n = list(map(int, input().split()))
    if n[0] == 0 & n[1] == 0:
        break

    for i in range(n[0]):
        for j in range(n[1]):
            if i in (0, n[0] - 1):
                print('#', end='')
            elif j in (0, n[1] - 1):
                print('#', end='')
            else:
                print('.', end='')

        print()

    print()



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

int main()
{
    int n;
    cin >> n;
    int array[4][13]={};
    char mark;
    int t;
    for(int i=0;i<n;i++)
    {
        cin >> mark >> t;
        switch(mark)
        {
            case 'S':
            array[0][t-1]=1;
            break;
            
            case 'H':
            array[1][t-1]=1;
            break;
            
            case 'C':
            array[2][t-1]=1;
            break;
            
            case 'D':
            array[3][t-1]=1;
            break;
        }
    }
    for(int i=0;i<4;i++)
    {
        for(int j=0;j<13;j++)
        {
            if(array[i][j]==0)
            {
                switch(i)
                {
                    case 0:
                    mark='S';
                    break;
                    
                    case 1:
                    mark='H';
                    break;
                    
                    case 2:
                    mark='C';
                    break;
                    
                    case 3:
                    mark='D';
                    break;
                }
                cout << mark << " " << j+1 << endl;
            }
        }
    }
}


Measured memory_bytes: 3060
// Problem : C - Special Trains
// Contest : AtCoder - AtCoder Beginner Contest 084
// URL : https://atcoder.jp/contests/abc084/tasks/abc084_c
// Memory Limit : 256 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

void solve()
{
	//do it using tuple
	int n;cin>>n;
	vector<pair<int,pii>> v;
	for(int i=0;i<n-1;i++)
	{
		int c,s,f;
		cin>>c>>s>>f;
		v.push_back({c,{s,f}});
	}
	for(int i=0;i<n-1;i++)
	{
		int time=v[i].se.f+v[i].f;
		for(int j=i+1;j<n-1;j++)
		{
			if(time<v[j].se.f)
			{
				time+=(v[j].se.f-time);
			}
			else
			{
				int x=time-v[j].se.f;
				//x%f==0
				int left=x%v[j].se.se;
				time+=(v[j].se.se-left)%v[j].se.se;
			}
			time+=v[j].f;
		}
		cout<<time<<"\n";
	}
	cout<<0<<"\n";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define PSB push_back
#define M 1000000007
typedef long long LL;
//#define int long long

/*
//booooooooooooost
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int)
*/

int inv_mod(int a, int m)
{
	int b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}



signed main() {

	int N;
	vector<int> a;
	cin >> N;
	REP(i, N) {
		int tmp;
		cin >> tmp;
		a.PSB(tmp);
	}

	double sum = 0;
	REP(i, N) {
		sum += a[i];
	}
	sum /= N;
	if (ceil(sum) - sum < sum - floor(sum)) {
		sum = ceil(sum);
	}
	else {
		sum = floor(sum);
	}

	int ans = 0;
	REP(i, N) {
		ans += (sum - a[i]) * (sum - a[i]);
	}

	cout << ans << endl;

	return 0;
}

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

#define min(a,b) {a > b ? b:a}
#define max(a,b) {a > b ? a:b}
using namespace std;

int seg[1000000 * 2];
int id[1000000 * 2];
void q99() {
	for (int i = 0; i < 1000000; i++) {
		id[1000000 + i] = i;
	}
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < q; i++) {
		int a, v;
		cin >> a >> v;
		a += 1000000 - 1;
		seg[a] += v;
		for (int j = a >> 1; j > 0; j = j >> 1) {
			if (seg[j * 2] < seg[j * 2 + 1]) {
				seg[j] = seg[j * 2 + 1];
				id[j] = id[j * 2 + 1];
			}
			else if (seg[j * 2] > seg[j * 2 + 1]) {
				seg[j] = seg[j * 2];
				id[j] = id[j * 2];
			}
			else {
				seg[j] = seg[j * 2];
				id[j] = min(id[j * 2], id[j * 2+1]);
			}
		}
		cout << id[1] + 1 << " " << seg[1] << endl;
	}
}
int main() {
	q99();
	return 0;
}

Measured memory_bytes: 18708
X=int(input())
if X>=400 and X<=599:
  print(8)
elif X>=600 and X<=799:
  print(7)
elif X>=800 and X<=999:
  print(6)
elif X>=1000 and X<=1199:
  print(5)
elif X>=1200 and X<=1399:
  print(4)
elif X>=1400 and X<=1599:
  print(3)
elif X>=1600 and X<=1799:
  print(2)
elif X>=1800 and X<=1999:
  print(1)

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

int main() {
    int K;
    cin >> K;

    int A[100000];
    for (int i=0; i<K; i++) {
        cin >> A[i];
    }

    long long Nmax = 2;
    for (int i=K-1; i>0; i--) {
        //if (Nmax % A[i-1] != 0)
        Nmax = (Nmax + A[i] - 1) / A[i-1] * A[i-1];
    }
    Nmax += A[0] - 1;

    long long Nmin = 2;
    for (int i=K-1; i>0; i--) {
        if (Nmin % A[i-1] != 0)
            Nmin = Nmin + A[i-1] - (Nmin % A[i-1]);
    }

    long long check = Nmax;
    for (int i=0; i<K; i++) {
        if (check % A[i] != 0)
            check -= (long long) check % A[i];
        if (check < 2) break;
    }

    if (check != 2) {
        cout << -1 << endl;
        return 0;
    }

    check = Nmin;
    for (int i=0; i<K; i++) {
        if (check % A[i] != 0)
            check -= (long long) check % A[i];
        if (check < 2) break;
    }

    if (check != 2) {
        cout << -1 << endl;
        return 0;
    }

    cout << Nmin << " " << Nmax << endl;

    return 0;
}


Measured memory_bytes: 640
fn input_line() -> Vec<String> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).unwrap();
  return buf
    .split_whitespace()
    .map(|word| String::from(word))
    .collect();
}

fn main() {
  let inputs = input_line();
  let n: usize = inputs[0].parse().unwrap();
  let k: usize = inputs[1].parse().unwrap();
  let inputs = input_line();
  let mut a: Vec<i64> = Vec::new();
  for i in 0..n {
    a.push(inputs[i].parse().unwrap());
  }

  for i in k..n {
    if a[i - k] < a[i] {
      println!("Yes");
    } else {
      println!("No");
    }
  }
}

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

t = list(range(L, L + N))
s = sum(t)

if 0 in t:
    print(s)
else:
    if abs(t[0]) < abs(t[N - 1]):
        print(s - t[0])
    else:
        print(s - t[N - 1])



Measured memory_bytes: 2940