akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

class SWAG(object):
    def __init__(self,dot):
        self.__front=[]
        self.__back=[]
        self.__dot=dot

    def __bool__(self):
        return True if(self.__front or self.__back) else False

    def __len__(self):
        return len(self.__front)+len(self.__back)

    def sum(self):
        assert(self)
        front=self.__front; back=self.__back
        if(not front): return back[-1][1]
        elif(not back): return front[-1][1]
        else: return self.__dot(front[-1][1],back[-1][1])

    def append(self,x):
        back=self.__back
        if(not back): back.append((x,x))
        else: back.append((x,self.__dot(back[-1][1],x)))

    def popleft(self):
        assert(self)
        front=self.__front; back=self.__back
        if(not front):
            front.append((back[-1][0],back[-1][0]))
            back.pop()
            while(back):
                front.append((back[-1][0],self.__dot(back[-1][0],front[-1][1])))
                back.pop()
        front.pop()

def resolve():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    ans=[None]*n
    swag=SWAG(min)
    for i,a in enumerate(A):
        swag.append(a)
        ans[i]=swag.sum()
        if(i-k+1>=0): swag.popleft()
    print(*ans[k-1:])
resolve()


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

using namespace std;

int N, M;

int main() {
    cin >> N >> M;
    vector<long long> a[3];
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            long long num; cin >> num;
            a[j].push_back(num);
        }
    }
    long long res = 0;
    for (int bit = 0; bit < (1<<3); ++bit) {
        vector<long long> b;
        for (int i = 0; i < N; ++i) {
            long long tmp = 0;
            for (int j = 0; j < 3; ++j) {
                if (bit & (1<<j)) tmp += a[j][i];
                else tmp -= a[j][i];
            }
            b.push_back(tmp);
        }
        sort(b.begin(), b.end(), greater<long long>());
        long long sum = 0;
        for (int i = 0; i < M; ++i) {
            sum += b[i];
        }
        res = max(res, sum);
    }
    cout << res << endl;
}


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

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

        Node[] nodes;

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var Q = cin.ReadInt;

            nodes = new Node[N];
            for (int i = 0; i < N; i++)
            {
                nodes[i] = new Node();
            }
            for (int i = 1; i < N; i++)
            {
                var a = cin.ReadInt - 1;
                var b = cin.ReadInt - 1;
                nodes[a].Neighbors.Add(b);
                nodes[b].Neighbors.Add(a);
            }
            for (int i = 0; i < Q; i++)
            {
                var p = cin.ReadInt - 1;
                var x = cin.ReadInt;
                nodes[p].Value += x;
            }
            Dfs(0, -1, 0);

            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(nodes[i].Value);
            }
        }

        void Dfs(int index, int parent, int value)
        {
            nodes[index].Value += value;
            foreach (var neightbor in nodes[index].Neighbors)
            {
                if (neightbor == parent) continue;
                Dfs(neightbor, index, nodes[index].Value);
            }
        }
    }

    public class Node
    {
        public int Value = 0;
        public HashSet<int> Neighbors = new HashSet<int>();
    }

    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: 89664
<?php
fscanf(STDIN, '%d', $n);
fscanf(STDIN, '%s', $s);
for ($i = 0; $i < 26; $i++) {
    $alpha[] = chr(65 + $i);
}
$ans = '';
$cnt = strlen($s);
for ($i = 0; $i < $cnt; $i++) {
    $ans .= $alpha[(array_search($s[$i], $alpha) + $n) % 26];
}
echo $ans . PHP_EOL;

Measured memory_bytes: 4728
n, s = map(int, input().split())
a = list(map(int, input().split()))
mod = 998244353

lst = [0 for i in range(s+1)]
lst[0] = 1
dp = [lst]
for i in range(n):
    lst = [0 for i in range(s+1)]
    ai = a[i]
    for j in range(s+1):
        if j-ai >= 0:
            lst[j] = (2*dp[-1][j] + dp[-1][j-ai]) % mod
        else:
            lst[j] = (2*dp[-1][j]) % mod
    dp.append(lst)

print(dp[-1][-1])

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

const int N = 5e5 + 9;

vector<int>V[2], ans, ret;

int n, sum;

int main () {
	scanf("%d%d", &sum, &n);
	for (int i = 1, j; i <= n; ++i) {
		scanf("%d", &j);
		V[j & 1].emplace_back(j);
	}
	if (V[1].size() > 2) return puts("Impossible"), 0;
	if (V[1].size()) ans.emplace_back(V[1][0]);
	for (auto v : V[0]) ans.emplace_back(v);
	if (V[1].size() > 1) ans.emplace_back(V[1][1]);
	int s = 0;
	for (auto v : ans) {
		printf("%d ", v);
		if (s + v - 1 > 0) ret.emplace_back(s + v - 1);
		s = 1;
	}
	if (n == 1) ret.push_back(1);
	else ++ret.back();
	putchar('\n');
	printf("%d\n", ret.size());
	for (auto v : ret) printf("%d ", v);
	return 0;
}
/*
16 7
3 2 2 2 2 2 3
*/

Measured memory_bytes: 256
h, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(k)]
maxa = max(a for a,b in ab)
dp = [0 for i in range(h+maxa)]
for i in range(1, h+maxa):
    dp[i] = min(dp[i - a]+b for a,b in ab)
print(min(dp[h:]))

Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int X, Y;
//---------------------------------------------------------------------------------------------------
map<int,int> G;
void _main() {
    cin >> X >> Y;

    G[1] = G[3] = G[5] = G[7] = G[8] = G[10] = G[12] = 1;
    G[4] = G[6] = G[9] = G[11] = 2;
    G[2] = 3;

    if (G[X] == G[Y]) printf("Yes\n");
    else printf("No\n");
}

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

int main() {
  int n, p;
  string s;
  
  cin >> n >> p >> s;
  
  long long res = 0;
  
  if(p == 2||p == 5){
    int count = 0;
    for(int i = n-1; i >= 0; --i){
      if((s[i] - '0') % p == 0){
        ++count;
      }
      res += count;
    }
  }else{
    vector<int> counter(p);
    counter[0] = 1;
    
    int t = 1;
    int x = 0;
    for(int i = n-1; i >= 0; --i){
      x = (x + (s[i] - '0') * t) % p;
      //cout << "i = " << i << ", x = " << x << endl;
      res += counter[x];
      ++counter[x];
      
      t = (t * 10) % p;
        
      //cout << counter[0] << "," << counter[1] << endl;
      //cout << "res = " << res << endl; 
    }
  }
  
  cout << res << endl;
  
  return 0;
  
}

Measured memory_bytes: 640
/*~~~~~~~~~~~~~~~~~ K++ code ~~~~~~~~~~~~~~~~~~~
in(n, m, X, Y)
in(x[n])
in(y[m])
for(int i in  (X+1~Y)){
    if(max(x) < i <= min(y)) out("No War"); return 0
}
out("War")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

;;;
;
int main(){
  ;;;
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    ;
    int x[n];
    for(int i = 0; i < n; ++i) {cin >> x[i];};
    ;
    int y[m];
    for(int i = 0; i < m; ++i) {cin >> y[i];};
    ;
    if(X+1<Y){;
        for(int i = X+1; i <= Y; ++i){;;;;
    int mx_0_ = x[0];
    for(int i_1_ = 0; i_1_ < sizeof(x)/sizeof(x[0]); ++i_1_){;
        if(mx_0_<x[i_1_]) {; mx_0_ = x[i_1_];};
    };
    int mn_4_ = y[0];
    for(int i_5_ = 0; i_5_ < sizeof(y)/sizeof(y[0]); ++i_5_){;
        if(mn_4_>y[i_5_]) {; mn_4_ = y[i_5_];};
    };
        if((mx_0_<i &&i <= mn_4_)) {;;cout << ("No War") << endl;; return (0);;};
    ;}
    ;}
    else {;
        for(int i = X+1; i >= Y; --i){;;;;
    int mx_2_ = x[0];
    for(int i_3_ = 0; i_3_ < sizeof(x)/sizeof(x[0]); ++i_3_){;
        if(mx_2_<x[i_3_]) {; mx_2_ = x[i_3_];};
    };
    int mn_6_ = y[0];
    for(int i_7_ = 0; i_7_ < sizeof(y)/sizeof(y[0]); ++i_7_){;
        if(mn_6_>y[i_7_]) {; mn_6_ = y[i_7_];};
    };
        if((mx_2_<i &&i <= mn_6_)) {;;cout << ("No War") << endl;; return (0);;};
    ;}
    ;};;;;
    cout << ("War") << endl;;
    ;
}

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

typedef long long ll;
#define rep(i, n) for(int i=0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define fill(x,y) memset(x,y,sizeof(x))
#define debug1(i) cout << i << '\n'
#define debug2(i,j) cout << i << j << '\n'

using namespace std;

ll a,b,c,d;
vector <ll>vec;


int main(){
    cin >>a;
    rep(i,a){
        cin >> b;
        vec.push_back(b);
    }
    sort(all(vec));
    rep(i,a-1)vec[a-1]-=vec[i];
    
    if(vec[a-1]<0)cout << "Yes"<<endl;
    else cout << "No"<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
bool isOK(const string& s,int i,int m,int f){
    string memo=s.substr(m-i+f,i);
    reverse(memo.begin(),memo.end());
    return memo==s.substr(m+1,i);
}
//(ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9+7;
    int n;
    cin>>n;
    vector<int> vec(n);
    rep(i,n) {
        int in;
        cin>>in;
        vec[in-1]=i;
    }
    int ans=n-1,cnt=1;
    rep(i,1,n){
        if(vec[i-1]<vec[i])cnt++;
        else{
            ans=min(ans,n-cnt);
            cnt=1;
        }
    }
    ans=min(ans,n-cnt);
    cnt=1;
    cout<<ans<<endl;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> grade(n - k +1);
  for(int i = 0;i < n; i++){
    cin >> a.at(i);
  }
  for(int i= 0; i<n-k;i++){
    if(a.at(i) < a.at(k + i)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 4760
import java.util.*;

public class Main{
        public static void main(String[] args){
                Scanner scan = new Scanner(System.in);
                int cntA = scan.nextInt();
                int cntB = scan.nextInt();
                int cntK = scan.nextInt();
                int tmp = 0;
                int count =0;

                if(cntA<cntB){
                        tmp = cntA;
                }else{
                        tmp = cntB;
                }

                for(int i=tmp ; i>=1 ; i--){
                        if(cntA%i==0 && cntB%i==0){
                                count += 1;
                                if(count==cntK){
                                        System.out.println(i);
                                }
                        }
                }
        }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  vector<ll> c(1000);
  rep(i, 1000)
    c[i] = i * i;
  bool h;
  ll n, d, a, k;
  a = 0;
  in2(n, d);
  vector<vector<ll>> s(n, vector<ll> (d));
  rep(i, n){
    rep(j, d)
      in(s[i][j]);
  }
  rep(i, n){
    rep2(j, i + 1, n){
      k = 0;
      rep(l, d)
        k += (s[i][l] - s[j][l]) * (s[i][l] - s[j][l]);
      h = false;
      rep(l, 1000){
        if(k == c[l])
          h = true;
      }
      if(h)
        a++;
    }
  }
  out(a);
  memi;
}

Measured memory_bytes: 256
N,x=map(int,input().split())
A=list(map(int,input().split()))
A.append(0)
ans=0
for i in range(N):
    d=A[i]+A[i+1]-x
    ans+=max(0,d)
    if d>=1 and A[i+1]-d>=0:A[i+1]-=d
    elif d>=1 and A[i+1]-d<=-1:A[i+1]=0
print(ans)

Measured memory_bytes: 14052
#include <iostream>
#include <string.h>
using namespace std;

bool dfs(string& S, int index) {
    int n = index + 1;
    if (n == 0) {
        return true;
    }
    if (n >= 5 && S.substr(n-5, 5) == "dream" && dfs(S, index-5)) {
        return true;
    }
    if (n >= 7 && S.substr(n-7, 7) == "dreamer" && dfs(S, index-7)) {
        return true;
    }
    if (n >= 5 && S.substr(n-5, 5) == "erase" && dfs(S, index-5)) {
        return true;
    }
    if (n >= 6 && S.substr(n-6, 6) == "eraser" && dfs(S, index-6)) {
        return true;
    }
    return false;
}

int main() {
    string S; cin >> S;
    int n = S.length();
    if (dfs(S, n-1)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 2816
#include<stdio.h>
int main(void)
{
   int n, i, p;
   int h = 0;
   int max = 0;
   int sum = 0;

   scanf("%d", &n);

   for (i=0; i < n; i++)
   {  p = h;
      scanf("%d", &h);
      if(max < h) max = h;
      if(h >= max && p <= h) {
         sum++;
      }
      
   }
   printf("%d",sum);

   return 0;

   
}


Measured memory_bytes: 128
#import sys
#input = sys.stdin.buffer.readline
import numpy as np

def main():
    H,W = map(int,input().split())
    S = np.array([list(input()) for _ in range(H)]) == '.' #'.'に一致するならTrueしなければFalse

    up = np.zeros((H,W), dtype=int)
    down = np.zeros((H,W), dtype=int)
    left = np.zeros((H,W), dtype=int)
    right = np.zeros((H,W), dtype=int)
    
    for i in range(H-1):
        up[i+1,:] = (up[i,:] + 1) * S[i,:] #npの変数名[k,l]でk行l列を取り出す
    for i in range(H-1):                   #:なら全部をそれぞれについて見ていく
        down[H - 2 - i,:] = (down[H - 1 - i,:] + 1) * S[H - 1 - i,:]
    for i in range(W-1):
        left[:,i+1] = (left[:,i] + 1) * S[:,i]
    for i in range(W-1):
        right[:,W - 2 - i] = (right[:,W - 1 - i] + 1) * S[:,W - 1 - i]
        
    print(((up+down+left+right)*S).max()+1) #カケザンデ要素ごとの掛け算可能
    
if __name__ == "__main__":
    main()


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

int main(){
  int N;
  string S,ans;
  cin>>N;
  cin>>S;
  if(S.size()%2==0){
    ans ="Yes";
    for(int i=0;i<S.size()/2;i++){
      if(S.at(i)!=S.at(i+S.size()/2)){
        ans ="No";
        break;
      }
    }
  }else{
    ans = "No";
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair, tuple

int main(){
      char c;cin >> c;
      if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')cout << "vowel";
      else cout << "consonant";
}

Measured memory_bytes: 256
//2018年  3月 22日 木曜日 16:26:08 JST- 16:33:37
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int one, two, four;

void solve() {
	cin >> N;
	rep(i, 0, N) {
		int a; cin >> a;
		if(a % 4 == 0) four++;
		else if(a % 2 == 0) two++;
		else one++;
	}
	// debug(one, two, four);
	if(four + 1 < one) {
		cout << "No\n";
		return;
	}
	else if(four + 1 == one) {
		if(two >= 1) cout << "No\n";
		else cout << "Yes\n";
		return;
	}
	else {
		cout << "Yes\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
# coding: utf-8

N = int(input())
A = list(map(int,input().split()))
ans = float('inf')

mean = int(sum(A)/N)
mean_ceil = mean + 1

ans = 0
tmp = 0
for i in range(N):
    ans += (mean - A[i]) ** 2
for i in range(N):
    tmp += (mean_ceil - A[i]) ** 2
print(min(ans,tmp))

Measured memory_bytes: 3064
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, k, sum = 0;
	cin >> n >> k;
	vector<int>v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	sort(v.begin(), v.end());
	for (int i = 0; i < k; i++)
		sum += v[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3604
a,b,c,d = map(int, input().split())
def battle(a,b,c,d):
    while a>0 or c>0:
        c-=b
        if c<=0:
            return "Yes"
        a-=d
        if a<=0:
            return "No"

print(battle(a,b,c,d))


Measured memory_bytes: 9104
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        long[] l = new long[N];
        for(int i=0;i<N;i++){
            l[i] = sc.nextLong();
        }
        int count = 0;
        for(int a=0;a<N;a++){
            if(a >= N-2)
                break;
            for(int b=a+1;b<N;b++){
                if(b >= N-1)
                    break;
                for(int c=b+1;c<N;c++){
                    if(l[a] != l[b] && l[b] != l[c] && l[c] != l[a]) {
                        if (l[a] < l[b] + l[c] && l[b] < l[c] + l[a] && l[c] < l[a] + l[b]) {
                            count++;
                        }
                    }
                }
            }
        }
        System.out.println(count);
    }
}


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

using namespace std;

long long inf=1000000007;

long long solve(long long n,long long mod){
	if(n==0) return 1;

	if(n%2==0) return (solve(n/2,mod)*solve(n/2,mod))%mod;

	if(n%2==1) return (solve(n-1,mod)*2)%mod;
}

int main(){
	long long n;
	cin>>n;
	vector<long long> anss(200001);
	for(long long i=0;i<=200000;i++){
		long long now=i;
		long long cnt=0;

		while(now>0){
			cnt++;
			long long bitcnt=0;
			long long pre=now;
			while(pre>1){
				if(pre%2==1) bitcnt++;
				pre/=2;
			}
			if(pre==1) bitcnt++;

			now%=bitcnt;
		}

		anss.at(i)=cnt;
	}

	string s;
	cin>>s;
	reverse(s.begin(),s.end());
	long long original=0;
	for(auto a:s){
		if(a=='1') original++;
	}
	map<long long,long long> maekesan;

	for(long long i=original-1;i<=original+1;i++){
		if(i<=0){
			maekesan[i]=0;
			continue;
		}

		long long sum=0;
		for(long long j=0;j<n;j++){
			if(s.at(j)=='1'){
				sum+=solve(j,i);
				sum%=i;
			}
		}
		maekesan[i]=sum;
	}

	for(long long i=n-1;i>=0;i--){
		bool plus=true;
		long long waru=original;
		if(s.at(i)=='1'){
			plus=false;
			waru--;
		}else{
			waru++;
		}

		if(waru==0){
			cout<<0<<endl;
			continue;
		}

		long long hoge=maekesan.at(waru);

		if(plus){
			hoge+=solve(i,waru);
			hoge%=waru;
		}else{
			hoge-=solve(i,waru);
			if(hoge<0) hoge+=waru;
		}

		cout<<anss.at(hoge)+1<<endl;
	}

	return 0;
}


Measured memory_bytes: 5176
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
static const double PI=6*asin(0.5);

double x[5],y[5];
char tmp;
double h[6];
double ang[8];//0:bac 1:bca 2:acd 3:cad 4:cba 5:cdb 6:bda 7:dba


int main(){
	while(cin>>x[0]>>tmp>>y[0]){
		bool flag=true;
		rep(i,3){
			cin>>tmp>>x[i+1]>>tmp>>y[i+1];
		}
		x[4] = x[0]; y[4] = y[0];
		rep(i,4){
			double X = x[i+1]-x[i],Y = y[i+1]-y[i];
			h[i] = sqrt(X*X+Y*Y);
			//cout << "h["<<i<<"] = "<<h[i]<<endl;
		}
		//cout<<acos(0.5)<<endl;
		h[4] = sqrt((x[2]-x[0])*(x[2]-x[0])+(y[2]-y[0])*(y[2]-y[0]));
		h[5] = sqrt((x[3]-x[1])*(x[3]-x[1])+(y[3]-y[1])*(y[3]-y[1]));
		ang[0] = acos((h[0]*h[0]+h[4]*h[4]-h[1]*h[1])/(2*h[0]*h[4]));
		ang[1] = acos((h[1]*h[1]+h[4]*h[4]-h[0]*h[0])/(2*h[1]*h[4]));
		ang[2] = acos((h[2]*h[2]+h[4]*h[4]-h[3]*h[3])/(2*h[2]*h[4]));
		ang[3] = acos((h[3]*h[3]+h[4]*h[4]-h[2]*h[2])/(2*h[3]*h[4]));
		ang[4] = acos((h[1]*h[1]+h[5]*h[5]-h[2]*h[2])/(2*h[1]*h[5]));
		ang[5] = acos((h[2]*h[2]+h[5]*h[5]-h[1]*h[1])/(2*h[2]*h[5]));
		ang[6] = acos((h[5]*h[5]+h[3]*h[3]-h[0]*h[0])/(2*h[5]*h[3]));
		ang[7] = acos((h[0]*h[0]+h[5]*h[5]-h[3]*h[3])/(2*h[0]*h[5]));
		//cout << (h[0]*h[0]+h[4]*h[4]-h[1]*h[1])/(2*h[0]*h[4])<<endl;
		//rep(i,4) cout<<ang[i]<<endl;
		//cout<<2*ang[0]<<" "<<PI<<endl;
		if(PI>(ang[0]+ang[3])&&PI>ang[1]+ang[2]){
			
		}
		else{
			flag = false;
		}
		if(PI>(ang[4]+ang[7])&&PI>ang[5]+ang[6]){
		}
		else{
			flag = false;
		}
		if(flag) cout<<"YES\n";
		else cout<<"NO\n";
		
	}
	return 0;
}

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

#define int long long

void solve(int tt)
{
    int x;cin>>x;
    int temp=100;
    for(int i=1;;i++)
    {
        temp+=(temp/100);
        if(temp>=x)
        {
            cout<<i;
            return;
        }
    }
}

int32_t main()
{
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
        solve(i);
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
    cout << fixed << setprecision(10);
    int a,b,c;
    cin >> a>>b>>c;
    if (a + b + c >= 22)
    {
        cout << "bust";
    }
    else
    {
        cout << "win";
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	k := getNextInt(scanner)
	x := getNextInt(scanner)

	for i := x - k + 1; i < x+k; i++ {
		if i < -1000000 || i > 1000000 {
			continue
		}
		fmt.Fprint(writer, i)
		if i < x+k-1 {
			fmt.Fprint(writer, " ")
		}
	}

	fmt.Fprintln(writer, "")
	writer.Flush()
}


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

int main(){

  string s;
  cin >> s;
  int count = 0;
  if(s[0]== '1') count = count +1;
  if(s[1]== '1') count = count +1;
  if(s[2]== '1') count = count +1;
  
  cout << count << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<utility>
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define ll long long
using namespace std;
int main() {
	std::ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int t;
	cin >> t;
	int drct = 0;
	while (t--) {
		int op;
		cin >> op;
		if (op==1) {
			drct++;
		}
		else {
			int f;
			string ad;
			cin >> f >> ad;
			if ((f+drct)%2==0) {
				s += ad;
			}
			else {
				s.insert(0,ad);
			}
		}
	}
	if (drct%2==1) {
		reverse(s.begin(),s.end());
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 912
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.Map.Entry;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] a = in.nextIntArray(n);

			Map<Integer, Integer> map = new HashMap<>();
			for (int i = 0; i < n; i++) {
				map.merge(a[i], 1, Integer::sum);
			}

			int count = 0;
			for (Entry<Integer, Integer> e : map.entrySet()) {
				if (e.getValue() % 2 == 0) {
					count++;
				}
			}

			if (count % 2 == 0) {
				out.println(map.size());
			} else {
				out.println(map.size()-1);
			}

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

	static void print(int[][] dp) {
		int n = dp.length;
		int m = dp[0].length;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				System.out.print(dp[i][j] + " ");
			}
			System.out.print("\n");
		}
		System.out.print("\n");
	}

}


Measured memory_bytes: 43716
#include<iostream>
#include<cstdio>
#include<map>
#include<sstream>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
long long ans = 0;
int main()
{
    int n,a,x;
    cin >> n >> a;
    long long f[60][2600];
    memset(f,0,sizeof(f));
    f[0][0] = 1;//零个数字的和为零的状况有一种
    for(int i = 1; i <= n; i ++)
    {
        cin >> x ;
        for(int j = i; j > 0; j --)//对于前i个数字
        {
            for(int k = x; k <= 2500; k ++)
            {
                f[j][k]+=f[j-1][k-x];
                //if(f[j][k])cout <<"j: " << j << " k: " << k <<" fjk " << f[j][k] <<endl;
            }
        //cout << f[j][j*a] <<endl;
        }
    }
    long long ans = 0;
    for(int i = 1; i <= n; i ++)ans += f[i][a*i];
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 1408
c=[[] for _ in range(3)]

for i in range(3):
    c[i]=list(map(int,input().split()))
    
a=[0,0,0]
b=[0,0,0]
    

a[0]=0
for i in range(3):
    b[i]=c[0][i]-a[0]
for i in range(3):
    a[i]=c[i][0]-b[0]
    
f=1

for i in range(3):
    for j in range(3):
        if a[i]+b[j]!=c[i][j]:
            f=0
            
if f==1:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 38384
N, K = map(int, input().split())
hs = [int(input()) for _ in range(N)]
hs_sort = sorted(hs)
diff_min = 1e10
for i in range(N-K+1):
    diff = hs_sort[i+K-1] - hs_sort[i]
    if diff <= diff_min:
        diff_min = diff
    else:
        continue
print(diff_min)

Measured memory_bytes: 8280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m;
  cin >> n >> m;
  vl c(m);
  rep(i, m) cin >> c[i];
  vl dp(n * 2, 1e18);
  dp[0] = 0;
  rep(k, m) rep(i, n) dp[i + c[k]] = min(dp[i + c[k]], dp[i] + 1);
  cout << dp[n] << endl;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main(void) {
	int m, f, r;
	while (scanf("%d%d%d", &m, &f, &r) == 3 && (m != -1 || f != -1 || r != -1)) {
		int grade;
		int total = m + f;
		if (m < 0 || f < 0) grade = 'F';
		else if (total >= 80) grade = 'A';
		else if (total >= 65) grade = 'B';
		else if (total >= 50) grade = 'C';
		else if (total >= 30) grade = (r >= 50 ? 'C' : 'D');
		else  grade = 'F';
		printf("%c\n", grade);
	}
	return 0;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << max(0, a - b - b) << '\n';
}


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

#define INF 0x3f3f3f3f
#define MOD 10000

typedef long long ll;
typedef pair<int, string> P;

int n;
map<ll, int> mp;
int cnt;

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

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

  for (auto x : mp) {
    if (x.second % 2 == 1) cnt++;
  }

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 6528
class Unionfind():
    def __init__(self, progsize):
        self.table = [-1 for _ in range(progsize)]
        self.size = [1 for _ in range(progsize)]

    def find(self, x):
        while(self.table[x] >= 0):
            x = self.table[x]
        return x

    def union(self, x, y):
        xl = self.find(x)
        yl = self.find(y)
        if xl != yl:
            if self.table[xl] <= self.table[yl]:
                self.table[yl] = xl
                self.table[xl] -= 1
                self.size[xl] += self.size[yl]
            else:
                self.table[xl] = yl
                self.table[yl] -= 1
                self.size[yl] += self.size[xl]

n, m = map(int, input().split())
bridge = [tuple(map(int, input().split())) for _ in range(m)]
bridge.reverse()
uf = Unionfind(n)
cur = n * (n-1) // 2
ans = [cur]
for a, b in bridge:
    ap = uf.find(a-1)
    bp = uf.find(b-1)
    if ap != bp:
        cur -= uf.size[ap] * uf.size[bp]
    uf.union(a-1, b-1)
    ans.append(cur)
for a in reversed(ans[0:m]):
    print(a)

Measured memory_bytes: 25600
//#include <bits/stdc++.h>
#include <cstdio>
#include <iostream>
#include <algorithm>
#define repe(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define mst(a, b)   memset((a), (b), sizeof(a))
#define gc() gutchar()
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pr;
typedef long long ll;
const double eps = 1e-5;
const int inf = 0x3f3f3f3f;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
const ll mod = 1e9+7;
const int N = 1e4+5;

string s, s1, s2;

int main()
{
	int a, b;
	cin >> s1 >> s2;
	cin >> a >> b;
	cin >> s;
	if (s == s1)	a--;
	if (s == s2)	b--;
	printf("%d %d", a, b);
	return 0;
}

Measured memory_bytes: 888
#include <iostream>

int main() {

  int a;
  int b;
  int c;

  std::cin >> a >> b >> c;

  int ba = b - a;
  int cb = c - b;

  if (ba == cb) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14


signed main(){
	int n;
	cin >> n;

	vi a(n);
	map <int, int> mp;
	rep(i, n){
		cin >> a[i];
		mp[a[i]]++;
	}

	int ans = 0;
	for(auto itr = mp.begin(); itr != mp.end(); itr++){
		if((*itr).first == (*itr).second)
			continue;
		else if((*itr).first < (*itr).second)
			ans += (*itr).second - (*itr).first;
		else
			ans += (*itr).second;
	}
	cout << ans << endl;

}




Measured memory_bytes: 7040
import itertools

NUM = list(map(int, input().split()))
A = NUM[0]
B = NUM[1]
C = NUM[2]

k = int(input())
flg = False
ref_list = []
nums = [0, 1, 2]
for ref in itertools.product(nums, repeat=k):
  ref_list.append(ref)

for i in range(len(ref_list)):
  cand = ref_list[i]
  num = [A, B, C]
  # print(num)
  for j in cand:
    num[j] = num[j] * 2
    if num[0] < num[1] and num[1] < num[2]:
      print("Yes")
      exit()
  num = [A, B, C]
  # print(num)
print("No")

Measured memory_bytes: 9364
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000000000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void YN(int a){if(a==1)printf("Yes\n");if(a==0)printf("No\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL N,i,j,k,a,b;
  scanf("%lld",&N);
  if(N==2){
    printf("-1\n");
    return 0;
  }
  if(N==3){
    printf("aa.\n..b\n..b\n");
    return 0;
  }
  char S[4][5]={0},T[7][8]={0},ans[1010][1010]={0};
  strcpy(S[0],"aaca"),strcpy(S[1],"bbca"),strcpy(S[2],"acbb"),strcpy(S[3],"acaa");
  rep(i,N)rep(j,N)ans[i][j]='.';
  a=N/4-1,b=N%4+4;
  if(b==4)rep(i,4)rep(j,4)T[i][j]=S[i][j];
  if(b==5)strcpy(T[0],"aabaa"),strcpy(T[1],"b.bc."),strcpy(T[2],"b..cb"),strcpy(T[3],"abb.b"),strcpy(T[4],"accaa");
  if(b==6)strcpy(T[0],"aaca.."),strcpy(T[1],"bbca.."),strcpy(T[2],"..bbca"),strcpy(T[3],"..aaca"),strcpy(T[4],"ab..bb"),strcpy(T[5],"ab..aa");
  if(b==7)strcpy(T[0],"aab...a"),strcpy(T[1],"..b.bba"),strcpy(T[2],"b.aa.a."),strcpy(T[3],"b....ab"),strcpy(T[4],"aa.bb.b"),strcpy(T[5],".baa..a"),strcpy(T[6],".b..bba");
  rep(i,a)rep(j,4)rep(k,4)ans[i*4+j][i*4+k]=S[j][k];
  rep(i,b)rep(j,b)ans[N-b+i][N-b+j]=T[i][j];
  rep(i,N)printf("%s\n",ans[i]);

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


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

int main(){
    int n;
    cin >> n;
    
    int R[n];
    for(int i=0; i<n; i++){
        cin >> R[i];
    }
    
    int minr = R[0];
    int MAX = -1000000000;
    
    for(int i=1; i<n; i++){
        if(R[i-1] < minr){
            minr = R[i-1];
        }
        if((R[i]-minr) > MAX){
            MAX = (R[i]-minr);
        }
    }
    
    cout << MAX << endl;
    
    return 0;
}


Measured memory_bytes: 3872
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digitsum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
int getdigit(ll a) {
	return to_string(a).size();
}
int countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

int main() {
	IOS;
	int n;
	const int INF = 1e5;
	cin >> n;
	map<int,int> mp;
	REP(i, n) {
		int a;
		cin >> a;
		mp[a - 1]++;
		mp[a]++;
		mp[a + 1]++;
	}
	int tmp = 0;
	for (auto it = mp.begin(); it != mp.end(); it++) {
		if (it->second > tmp) {
			tmp = it->second;
		}
	}
	cout << tmp << endl;
}



Measured memory_bytes: 4736
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use num::integer::{gcd, lcm};
#[allow(unused_imports)]
use permutohedron::LexicalPermutation;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(dead_code)]
const MOD: i32 = 1e9 as i32 + 7;

fn main() {
    input!(a: i128, b: f64);
    let mut a: i128 = a;
    let mut b: f64 = (b * 1000.0);
    let mut s = format!("{}", b);
    let mut ss = String::new();
    for i in s.chars() {
        if i == '.' {
            break;
        }
        let x = format!("{}",i);
        ss.push_str(&x);
    }
    let b:i128 = ss.parse().unwrap();
    println!("{}", a*b/1000);
    //let mut ans:i128 = a * b;

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


Measured memory_bytes: 2236
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
using namespace std;
//#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1000050;
//ここまでテンプレ
//立っているbitの数を数える（32bit限定）
int bitcount32(int dw32){
	dw32 = ((dw32 & 0xAAAAAAAA) >>  1) + (dw32 & 0x55555555);
	dw32 = ((dw32 & 0xCCCCCCCC) >>  2) + (dw32 & 0x33333333);
	dw32 = ((dw32 & 0xF0F0F0F0) >>  4) + (dw32 & 0x0F0F0F0F);
	dw32 = ((dw32 & 0xFF00FF00) >>  8) + (dw32 & 0x00FF00FF);
	dw32 = ((dw32 & 0xFFFF0000) >> 16) + (dw32 & 0x0000FFFF);
	return dw32;
}
int main(){
	string T="MARCH";
	ll a[5]={};
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		string S;
		cin>>S;
		for(int j=0;j<5;j++){
			if(S[0]==T[j]){
				a[j]++;
			}
		}
	}
	ll ans=0;
	for(int state=0;state<(1<<5);state++){
		if(bitcount32(state)!=3)
			continue;
		ll temp=1;
		for(int i=0;i<5;i++){
			if(state&(1<<i)){
				temp*=a[i];
			}
		}
		ans+=temp;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256