akhauriyash/Code-Regression huggingface dataset:
//https://atcoder.jp/contests/tenka1-2018-beginner/tasks/tenka1_2018_c
//C - Align
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
int main() {
    ll N; cin>>N;
    deque<ll> an(N);
    deque<ll> orig_an(N);
    for(auto&& a:an){
        cin>>a;
    }
    sort(an.begin(),an.end());
    orig_an=an;

    auto getpop_back = [&]()->ll{
        ll r=-1;
        if(!an.empty()){
            r=*(an.end()-1);
            an.pop_back();
        }
        return r;
    };
    auto getpop_front = [&]()->ll{
        ll r=-1;
        if(!an.empty()){
            r=*an.begin();
            an.pop_front();
        }
        return r;
    };

    deque<ll> res;
    res.push_back(getpop_front());

    bool back_flag=true; //backから
    while(!an.empty()){
        ll a=-1,b=-1;
        if (back_flag){
            a=getpop_back();
            b=getpop_back();
        }else{
            a=getpop_front();
            b=getpop_front();
        }
        if (a>=0) res.push_front(a);
        if (b>=0) res.push_back(b);

        back_flag = !back_flag;
    }
    ll ans=0;
    FOR(i,1,res.size()){
        ans += abs(res.at(i)-res.at(i-1));
    }
    dump(res);
    dump(ans);

    //もう一回?
    an=orig_an;
    deque<ll> res2;
    res2.push_back(getpop_back());
    back_flag=false; //frontから
    while(!an.empty()){
        ll a=-1,b=-1;
        if (back_flag){
            a=getpop_back();
            b=getpop_back();
        }else{
            a=getpop_front();
            b=getpop_front();
        }
        if (a>=0) res2.push_front(a);
        if (b>=0) res2.push_back(b);

        back_flag = !back_flag;
    }
    ll ans2 = 0;
        FOR(i,1,res2.size()){
        ans2 += abs(res2.at(i)-res2.at(i-1));
    }
    dump(res2);
    dump(ans2);

    cout<<max(ans,ans2)<<endl;

    return 0;
}


Measured memory_bytes: 2816
def bubble_sort(A):
    flag = True
    i = 0
    global count
    while flag:
        flag = False
        for j in range(i, len(A)-1):
           if A[j+1] < A[j]:
                A[j], A[j+1] = A[j+1], A[j]
                count += 1
                flag = True
        if not flag:
            i += 1
            flag = True
        if i >= len(A)-1:
            flag = False

n = int(input())
A = list(map(int, input().split()))
count = 0
bubble_sort(A)
print(*A)
print(count)


Measured memory_bytes: 5608
import sys

def main():

    times = []

    for line in sys.stdin:
        line = line.rstrip()
        t = int(line)
        times.append(t)

    times.sort(key=lambda t: t % 10 if t % 10 != 0 else 10, reverse=True)

    # print(times)
    # 下一ケタが0,9,8,...の順に食べていく。1の位は切り上げ

    s = 0
    for t in times[:-1]:
        new_t = t if t % 10 == 0 else (t // 10) * 10 + 10
        s += new_t

    s += times[-1]
    print(s)

    return 0

if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 3064
#include<iostream>
#include<vector>

using namespace std;


int main() {
	int N, i, k;
	vector<int>A;

	cin >> N;
	for (i = 0; i < N; i++) {
		cin >> k;
		A.push_back(k);


	}

	for (i = 1; i < N; i++) {
		k = A[i-1];
		if (A[i-1] > A[i]) {
			A[i-1] = A[i];
			A[i] = k;
			i = 0;
		}
	}

	cout << A[N-1] - A[0];



	return 0;
}



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

using namespace std;

int main(){
    int count0 = 0;
    int count1 = 0;

    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i] == '1')
            count1++;
        else
            count0++;
    }
    if(count1 > count0)
        cout << s.size() - (count1 - count0) << endl;
    else
        cout << s.size() - (count0 - count1) << endl;
}


Measured memory_bytes: 512
S = input()
flag = True

if S.count('a') % 2 == 1:
  flag = False
elif S.count('b') % 2 == 1:
  flag = False
elif S.count('c') % 2 == 1:
  flag = False
elif S.count('d') % 2 == 1:
  flag = False
elif S.count('e') % 2 == 1:
  flag = False
elif S.count('f') % 2 == 1:
  flag = False
elif S.count('g') % 2 == 1:
  flag = False
elif S.count('h') % 2 == 1:
  flag = False
elif S.count('i') % 2 == 1:
  flag = False
elif S.count('j') % 2 == 1:
  flag = False
elif S.count('k') % 2 == 1:
  flag = False
elif S.count('l') % 2 == 1:
  flag = False
elif S.count('m') % 2 == 1:
  flag = False
elif S.count('n') % 2 == 1:
  flag = False
elif S.count('o') % 2 == 1:
  flag = False
elif S.count('p') % 2 == 1:
  flag = False
elif S.count('q') % 2 == 1:
  flag = False
elif S.count('r') % 2 == 1:
  flag = False
elif S.count('s') % 2 == 1:
  flag = False
elif S.count('t') % 2 == 1:
  flag = False
elif S.count('u') % 2 == 1:
  flag = False
elif S.count('v') % 2 == 1:
  flag = False
elif S.count('w') % 2 == 1:
  flag = False
elif S.count('x') % 2 == 1:
  flag = False
elif S.count('y') % 2 == 1:
  flag = False
elif S.count('z') % 2 == 1:
  flag = False

if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9048
#include <stdio.h>
#include <algorithm>
#include <tuple>
#include <functional>

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

constexpr int maxn = 1e5 + 100;
int n, p[maxn] = { 0 }, l[maxn] = { 0 }, r[maxn] = { 0 };
int lcnt(int idx) {
	int count = l[idx];
	if (p[idx - count - 1] < 0)
		count += lcnt(idx - count - 1) + 1;
	return (l[idx] = count);
}
int rcnt(int idx) {
	int count = r[idx];
	if (p[idx + count + 1] < 0)
		count += rcnt(idx + count + 1) + 1;
	return (r[idx] = count);
}

pii o[maxn];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", p + i), o[i - 1] = pii(p[i], i);
	sort(o, o + n);

	ll s = 0;
	for (int i = 0; i + 1 < n; i++) {
		ll num = o[i].first, idx = o[i].second;

		ll l1 = lcnt(idx), l2 = lcnt(idx - l1 - 1);
		ll r1 = rcnt(idx), r2 = rcnt(idx + r1 + 1);

		if (idx - l1 - 1 != 0)
			s += (l2 + 1) * (r1 + 1) * num;
		if (idx + r1 + 1 != n + 1)
			s += (l1 + 1) * (r2 + 1) * num;

		p[idx] = -1;
	}
	printf("%lld\n", s);
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define lli   long long int
#define pb push_back
#define rep(i,s,n) for(lli i=s;i<n;i++)
#define irep(i,n,s) for(lli i=n-1;i>=s;i--)
#define mp make_pair
#define mod 1000000007
using namespace std;


int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio;
    cin.tie(NULL);
    lli i, j, k, m, n;
    // cin >> t;


    cin >> n;
    vector<lli>v(n);
    lli a[n];
    rep(i, 0, n)
    {
        cin >> a[i];
    }
    lli sum = 0;
    for (i = n - 1; i >= 0; i--)
    {
        v[i] = sum;
        sum += a[i];
        sum %= mod;
    }
    lli res = 0;
    for (int i = 0; i < n; i++)
    {
        res += (a[i] * v[i]) % mod;
        res = res % mod;
    }
    cout << res << "\n";








}




Measured memory_bytes: 6364
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st s;
  	ci(s);
  ll a=s.sz;
  bool b=false;  
  for(ll k=(a-2);k>0;k-=2){
    FOR(i,0,k/2){
      if(s[i]!=s[k/2+i]) break;       
      if(i==k/2-1){
        co(k)
        b=true;
      }
    }
    if(b) break;
  }
}

Measured memory_bytes: 256
function main(input) {
  var n = input.split("\n")[0]-0;
  var v = input.split("\n")[1].split(" ");
  var c = input.split("\n")[2].split(" ");
  var ans = 0;
  for(var i=0;i<n;i++){
    var vv = v[i]-0;
    var cc = c[i]-0;
    if(vv>cc) ans += vv-cc;
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)

mod = 10 ** 9 + 7

N = int(input())
vec = [[] for _ in range(N)]
for _ in range(N - 1) :
  A, B = map(int, input().split())
  vec[A-1].append(B-1)
  vec[B-1].append(A-1)

own_size = [0] * N
sub_size = [[] for _ in range(N)]

# pythonのdfs重すぎて自分でstack書かないと通らない。
# く〜〜つらいとこね、これ！！！！
stack = [(0, -1)]
for i in range(N) :
  cur, pre = stack[i]
  for nex in vec[cur] :
    if nex != pre :
      stack.append((nex, cur))

while stack :
  cur, pre = stack.pop()
  if pre != -1 :
    sub_size[pre].append(own_size[cur] + 1)
    own_size[pre] += own_size[cur] + 1
  if own_size[cur] != N - 1 :
    sub_size[cur].append(N - 1 - own_size[cur])

fac = [1]
inv = [1]
div = pow(2, mod - 2, mod)
for _ in range(N) :
  fac.append(fac[-1] * 2 % mod)
  inv.append(inv[-1] * div % mod)

ret = 0
for i in range(N) :
  if len(sub_size[i]) < 2 :
    continue

  a, b = 1, 1
  for ss in sub_size[i] :
    a *= inv[ss]
    b += fac[ss] - 1
    a %= mod
    b %= mod
  ret += (1 - a * b) % mod
  ret %= mod

ret = ret * div % mod

print(ret)

Measured memory_bytes: 120780
#!/usr/bin/env python3


def f(x):
    return x % 2 if x > 0 else 2


def g(x):
    return (x - 1) % 2 if x > 0 else 1


INF = 10**9 + 1

L = int(input())
A = [int(input()) for _ in range(L)]

dp = [[0] * 5] + [[INF] * 5 for _ in range(L)]
for i in range(L):
    dp[i + 1][0] = min(dp[i + 1][0], min(dp[i][:1]) + A[i])
    dp[i + 1][1] = min(dp[i + 1][1], min(dp[i][:2]) + f(A[i]))
    dp[i + 1][2] = min(dp[i + 1][2], min(dp[i][:3]) + g(A[i]))
    dp[i + 1][3] = min(dp[i + 1][3], min(dp[i][:4]) + f(A[i]))
    dp[i + 1][4] = min(dp[i + 1][4], min(dp[i][:5]) + A[i])

print(min(dp[L]))


Measured memory_bytes: 59924
<?php
// VolumeRitsCamp16Day3-A

$number = trim(fgets(STDIN));
$pos  = strpos($number, "?");

$ans = -1;
for ($n = 0; $n < 10; $n++) {
  $number[$pos] = $n;
  if (check_mynumber($number)) {
    if ($ans > -1) {
      echo "MULTIPLE\n";
      exit(0);
    } else {
      $ans = $n;
    }
  }
}
echo "${ans}\n";

function check_mynumber($number)
{
  $sum = 0;
  for ($n = 1; $n <= 11; $n++) {
    $Q = ($n < 7) ? $n+1 : $n-5;
    $P = $number[11-$n];
    $sum += ($P * $Q);
  }

  $a = $sum % 11;
  $check_sum = ($a <= 1) ? 0 : 11 - $a;

  return ($check_sum == $number[11]);
}

Measured memory_bytes: 15496
#include <iostream>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <set>

using namespace std;

int main()
{
    int N;

    cin >> N;

    vector<int> H(N);

    int maxcnt=0,cnt=0;
    for (size_t i = 0; i < N; i++)
    {
        cin >> H[i];
    }

    for (size_t i = 1; i < N; i++)
    {
        if(H[i-1]>=H[i]){
            cnt++;
            if(maxcnt<cnt) maxcnt=cnt;
        }else{
            cnt=0;
        }
//        cerr << H[i-1] << " " << H[i] << " " << cnt << endl;
    }

    cout << maxcnt << endl;
    return 0;
}


Measured memory_bytes: 640
use std::io;
fn main() {
    let border : i64 = 10_i64.pow(18);

    let mut line = String::new();
    io::stdin().read_line(&mut line).expect("");
    let n = line.trim().parse().expect("");

    let mut line = String::new();
    io::stdin().read_line(&mut line).expect("");
    let mut vec : Vec<&str> = line.split_whitespace().collect();
    vec.sort();
    let mut result : i64 = 1;
    for i in 0..n {
        let num : i64 = vec[i].parse().unwrap_or(1);
        match result.checked_mul(num) {
            Some(v) => result = v,
            None => {
                result = -1;
                break;
            },
        };
    }

    if result > border {
        result = -1;
    }

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


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

int bubblesort(vector<int> a, int n) {
    int cnt = 0;
    bool flag = 1;
    while(flag) {
        flag = 0;
        for(int i=n-1; i>0; --i) {
            if(a[i] < a[i-1]) {
                swap(a[i], a[i-1]);
                flag = 1;
                cnt++;
            }
        }
    }
    for(int i=0; i<n; i++) {
        cout << a[i];
        if(i != n - 1) cout << " ";
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}
int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    bubblesort(a, n);
}


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

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

    int one = N % 10;

    switch(one) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
    }
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;
typedef long long ll;

int main() {
    int n,k;
    cin >> n >> k;
    int num[200000];
    for (int i = 0; i < n; i++) {
        cin >> num[i];
    }
    for (int i = k; i < n; i++) {
        bool ans = true;
        ans &= (num[i]-num[i-k]>0);
        cout << ((ans) ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 4344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;


main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    while(a>=b){
        b*= 2;
        k--;
    }
    while(b>=c){
        c*= 2;
        k--;
    }
    if(k>=0) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    if(a-2*b>0){
        cout<<a-2*b<<endl;
    }
    else{
        cout<<0<<endl;
    }
   return 0;
}

Measured memory_bytes: 256
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def s_inpl(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
INF = float("inf")

N = int(input())
a = inpl()

ans = INF
for i in range(-100, 101):
    tmp = sum([ (abs(ai-i))**2 for ai in a])
    if tmp<ans:
        ans = tmp

print(ans)


Measured memory_bytes: 39152
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        int n; cin >> n;
        vi a(n,0);
        ll sum = 0;
        for(int i = 0; i<n; i++){
            cin >> a[i];
            sum+=a[i];
        }
        cout<<sum-n<<endl;

return 0;
}




Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define in insert
#define sz(v) v.size()
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 5;

void solve(){
    int n; cin>>n;
    vi A(n+1),B(n);
    for(int i = 0; i <= n; i++) cin>>A[i];
    for(int i = 0; i < n; i++) cin>>B[i];
    ll ans=0;
    for(int i = 0; i < n; i++){
        if(A[i]>=B[i]) ans+=B[i];
        else{
            ans+=A[i];
            if(A[i+1]>=B[i]-A[i]){
                A[i+1]-=B[i]-A[i];
                ans+=B[i]-A[i];
            }
            else{
                ans+=A[i+1];
                A[i+1]=0;
            }
        }
    }
    cout<<ans;
    
    
}
int main(){
    int T=1;        //! COMMENT IF THERE IS NO TEST CASES
    //cin>>T;             
    for(int i = 0; i < T; i++) solve(); 
}

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

namespace Train {
    class Class2 {
        const string mark = "*";

        static void Main(string[] args) {
            new Class2().solve();
        }
        void solve() {
            List<double[][]> allResult = new List<double[][]>();

            double[][] heatResult = new double[8][];
            for (int i = 0; i < heatResult.Length; i++) {
                heatResult[i] = new double[2];
            }

            for (int num = 0; num < 24; num++) {
                string data = Console.ReadLine();
                string[] spritData = data.Split(' ');

                for (int i = 0; i < 2; i++) {
                    heatResult[(num+1)%8][i] = double.Parse(spritData[i]);
                }
                if ((num+1) % 8 == 0) {
                    allResult.Add((double[][])heatResult.Clone());
                    for (int i = 0; i < heatResult.Length; i++) {
                        heatResult[i] = new double[2];
                    }
                }
            }
            for (int count = 0; count < allResult.Count; count++) {
                Array.Sort(allResult[count],compareArray);
            }

            string[][] finalist = new string[8][];
            for (int i = 0; i < finalist.Length; i++) {
                finalist[i] = new string[2];
            }

            int number = 0;
			for (int count = 0; count < allResult.Count; count++) {
                for (int i = 0; i < 2; i++) {
                    int a = (int)allResult[count][i][0];
                    finalist[number][0] = a.ToString();
                    finalist[number][1] = allResult[count][i][1].ToString("G4");
                    number++;
                }
            }

            double[][] thirds = new double[3][];
            for (int i = 0; i < allResult.Count; i++) {
                thirds[i] = allResult[i][2];
            }
            Array.Sort(thirds,compareArray);
            for (int i = 0; i < 2; i++) {
                int a = (int)(int)thirds[i][0];
                finalist[number][0] = a.ToString();
                finalist[number][1] = thirds[i][1].ToString("G4");
                number++;
            }

            for (int i = 0; i < finalist.Length; i++) {
                Console.WriteLine(finalist[i][0]+" "+finalist[i][1]);
            }
        }

        int compareArray(double[] a, double[] b) {
            if (a[1] > b[1]) {
                return 1;
            } else if (a[1] < b[1]) {
                return -1;
            }
            return 0;
        } 
    }
}

Measured memory_bytes: 9392
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}

int main(){
    ll N,M,K;
    cin>>N>>M>>K;
    v A(N),B(M);
    rep(i,0,N)cin>>A[i];
    rep(i,0,M)cin>>B[i];
    ll sum = 0,books = 0,mb = 0;

    while(books< N){
        if(A[books] + sum <=K){
            sum+=A[books];
            books++;
        }
        else{
            break;
        }
    }
    mb = books;
    ll i = books-1;
    bool ok = true;

    rep(j,0,M){
        while(B[j] + sum > K){
            if(i == -1){
                ok = false;
                break;
            }
            sum-= A[i];
            i--;
            books--;
        }
        sum += B[j];
        books++;
        if(ok)mb = max(mb,books);
    }
    cout<<mb;
    return 0;
}

Measured memory_bytes: 6428
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    ll n;
    cin >> n;
    ll nn = 26;
    ll now = 1;
    ll cnt = 1;
    ll pre = 1;
    for(int i = 0 ;i  < 15; i++){
        pre = now;
        now += nn;
        nn *= 26;
        if( n < now) break;
        cnt++;
    }
    //cout << cnt << endl;
    // cnt == 桁
    string s = "";
    rep(i,cnt){
        s += "a";
    }
    ll div = n - pre;//先頭のidとの差
    /*cout << s << endl;
    cout << n << " " << pre << endl;
    cout << div << endl;*/
    vector<int> v;
    while(div > 0){
        v.push_back(div%26);
        div /= 26;
        //cout << div << endl;
    }
    //v.push_back(div);
    reverse(v.begin(),v.end());
    /*for(auto u : v){
        cout << u << " "; 
    }*/
    int id = v.size()-1;
    for(int i = s.size()-1; i >= 0; i--){
        //cout << "change" <<id << endl;
        if(id < 0) break;
        s[i] = 'a' + v[id];
        //cout << "change" << endl;
        id--;
    }
    cout << s << endl;
    return 0;
}

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

A=list(map(int, input().split()))

for i in range(N):
    if A[i]>i+1:
        print(-1)
        exit()

ans=[]

while A:
    now=0
    for i in range(len(A)):
        if i+1==A[i]:
            now=i
    a=A.pop(now)
    ans.append(a)

ans=ans[::-1]
for a in ans:
    print(a)

Measured memory_bytes: 64168
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0; i < n; i++)
#define REPR(i, n) for(long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(long long i = m; i <= n; i++)
#define FORR(i, m, n) for(long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


int main(){FIN

    ll n,q;cin>>n>>q;
    string s;cin>>s;
    vll v(n,0);

    ll cnt=0;
    REP(i,n){
        if(i>0 && s[i]=='C' && s[i-1]=='A') cnt++;    
        v[i]=cnt;
    }

    REP(i,q){
        ll l,r; cin>>l>>r; 
        l--; r--;
        cout<<v[r]-v[l]<<endl;
    }
    return 0;
}

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

using namespace std;

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll, ll>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

int main()
{
    ll tt = 1, n, m, k = 0, i, j, p, q;
    ll a, b, c, d, h, u, v, x, y, t = 0;
    ll ans = 0;

    ll l = 0, r = 0;
    bool poss = true;

    boost;
    string s; 

    time_t tic, toc;
    tic = clock();

    // cin >> tt;
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> x >> n;
        vi perm(105, 0);
        for(i = 0; i < n; i++){
            cin >> p;
            perm[p] = 1;
        }

        ans = 101;
        for(i = 0; i < 101; i++){
            ll val = 1000;
            if(x + i < sz(perm) and perm[x + i] != 1){
                val = x + i;
            }
            else if(x + i >= sz(perm)){
                val = x + i;
            }
            ans = min(ans, val);
            
            if(x - i >= 0 and perm[x - i] != 1){
                val = x - i;
            }
            else if(x - i < 0){
                val = x - i;
            }
            ans = min(ans, val);
            if(val != 1000) break;
        }
        cout << ans << nl;
    }   
    // cerr << (clock() - tic*1.0) / CLOCKS_PER_SEC << nl;
    return 0;
}

Measured memory_bytes: 3676
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const double PI=3.14159265358979;
int a,b,v,x;
 
int main()
{
	scanf("%d %d %d",&a,&b,&x);
	v=a*a*b;
	double temp1,temp2,temp3,ans;
	if(x>=v/2)
	{
		int dv=v-x;
		temp1=(double)(dv*2)/(a*a);
		temp2=temp1/a;
		temp3=atan(temp2);
		ans=(double)temp3*180/PI;
	}
	else
	{
		temp1=(double)(2*x)/(a*b);
		temp2=b/temp1;
		temp3=atan(temp2);
		ans=(double)temp3*180/PI;
	}
	printf("%.10f",ans);
	return 0;
}

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int X, t;
  cin >> X >> t;
  cout << (X - t > 0 ? X - t : 0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(x)					(x).begin(),(x).end()
#define REP(i, n)				for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF						(int)2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
template<class T>
void deleteJufukuAndSort(vector<T> &vect)
{
	sort(vect.begin(), vect.end());
	vect.erase(unique(vect.begin(), vect.end()), vect.end());
}


int main()
{
	int K, N;
	cin >> N >> K;
	vector<double> p(N);
	REP(i, N) cin >> p[i];

	double ans = 0;
	REP(i, K) {
		ans += (1 + p[i]) / 2;
	}

	double nowVal = ans;
	for (int i = K; i < N; i++)  {
		nowVal = nowVal + (p[i] - p[i - K]) / 2;
		ans = max(nowVal, ans);
	}
    cout << setprecision(10) << ans <<  endl;
    return 0;
}


Measured memory_bytes: 1792
/** @xigua */
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <cstring>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <climits>
#include <bitset>
#include <ctime>
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
const int INF = 1e8 + 5;
const ll inf = 1e15 + 5;
const db eps = 1e-8;
const ll hp = 2333;
const ll base = 1e9+13;

void solve() {
    ll f[100];

    int n;
    while (cin >> n) {
        f[0] = 2, f[1] = 1;
        for (int i = 2; i <= n; i++)
            f[i] = f[i-1] + f[i-2];
        cout << f[n] << endl;
    }
}

int main() {
    int t = 1, cas = 1;
   //memset(dp, 0, sizeof(dp));
   //freopen("in.txt", "r", stdin);
   // freopen("out.txt", "w", stdout);
   // scanf("%d", &t);
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int cmp[100010],r=0,f[10010]={0};
int Ta[110],To[1010],Co[1010],Nt[1010];
void sdfs(int e,int s,int k,int *ta,int *to,int *nt,int *id){
  int i;
  f[s]++;
  for(i=ta[s];i+1;i=nt[i]){
    if(i<e&&k<0&&f[to[i]]<0||i>=e&&k>=0&&!f[to[i]])sdfs(e,to[i],k,ta,to,nt,id);
  }
  k<0?(id[r++]=s):(cmp[s]=k);
}
void scc(int v,int e,int *a,int *b){
  int ta[10010],to[60010],nt[60010],id[10010],i,k;
  for(i=0;i<v;i++)f[i]=ta[i]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    ta[a[i]]=i;
    ta[b[i]]=i+e;
  }
  for(i=k=0;i<v;i++){
    if(f[i]==-1)sdfs(e,i,-1,ta,to,nt,id);
  }
  for(i=r;i;i--){
    if(f[id[i-1]]==0)sdfs(e,id[i-1],id[i-1],ta,to,nt,id);
  }
}
int mca(int v,int e,int k,int *a,int *b,int *c){
  int i,j,t,r,s,p=0,mi[110],q[10010],bk[110]={0};
  for(i=0;i<v;i++)Ta[i]=mi[i]=-1;//??£??\??????????????????
  for(i=0;i<e;i++){
    Nt[i]=Ta[a[i]];
    Co[Ta[a[i]]=i]=c[i];
    bk[a[i]]=bk[To[i]=b[i]]=1;
  }
  for(i=0;i<v;i++)p+=bk[i];
  for(i=0;i<e;i++){//?????????MIN???????±???????
    if(mi[To[i]]==-1||Co[mi[To[i]]]>Co[i])mi[To[i]]=i;
  }
  mi[q[t=0]=k]=-1;
  for(r=1;r-t;t++){
    for(j=Ta[q[t]];j+1;j=Nt[j])mi[q[r++]=To[j]]==j?s+=Co[j]:r--;
  }
  if(r==p)return s;
  for(i=r=0;i<v;i++){
    bk[i]=0;
    for(j=Ta[i];j+1;j=Nt[j]){
      if(mi[b[r]=To[j]]==j)a[r++]=i;
    }
  }
  scc(v,r,a,b);//?????£?????????????§£??§???????????????????????????
  for(i=0;i<v;i++)bk[cmp[i]]++;
  for(i=r=s=0;i<v;i++){
    for(j=Ta[i];j+1;j=Nt[j]){
      if((a[r]=cmp[i])==(b[r]=cmp[To[j]])){
	if(j==mi[To[j]])s+=Co[j];
      }
      else c[r++]=bk[cmp[To[j]]]-1?Co[j]-Co[mi[To[j]]]:Co[j];
    }
  }
  return mca(v,r,k,a,b,c)+s;
}
	 
int main(){
  int n,m,k,i,a[10010],b[10010],c[10010];
  scanf("%d %d %d",&n,&m,&k);
  for(i=0;i<m;i++)scanf("%d %d %d",&a[i],&b[i],&c[i]);
  printf("%d\n",mca(n,m,k,a,b,c));
  return 0;
}

Measured memory_bytes: 692
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let k: usize = s.trim().parse().unwrap();
    s.clear();
    stdin().read_line(&mut s).ok();
    let mut itr = s.split_whitespace().map(|e| e.parse().unwrap());
    let a: usize = itr.next().unwrap();
    let b: usize = itr.next().unwrap();
    let min = (a + k - 1) / k * k;
    let max = b / k * k;

    println!("{}", if min <= max { "OK" } else { "NG" });
}


Measured memory_bytes: 2164
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Measured memory_bytes: 14592
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String[] day = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
		List<String> dayList = Arrays.asList(day);
		int index = dayList.indexOf(scanner.next());
		System.out.println(7 - index);
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;


int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = 0;
  rep(is,1<<h)rep(js,1<<w){
    int cnt = 0;
    rep(i,h)rep(j,w){
      if(is>>i&1) continue;
      if(js>>j&1) continue;
      if(s[i][j]=='#') cnt++;
    }
    if(cnt==k) ans++;
    
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
typedef long long ll;
using namespace std;
ll const MAX = 200005;
ll const INF = 9200000000000000000;
ll a[MAX];
ll b[MAX];
ll f(ll p, ll q) {
	if (q <= 0) {
		return b[p] - 0;
	}
	else {
		return b[p] - b[q];
	}
}

int main() {
	ll n, x;
	cin >> n >> x;
	ll ttl = 0;
	REP(i, 1, n) {
		cin >> a[i];
		ttl += a[i];
		a[i] *= 2;
	}
	ll ans = INF;
	b[0] = 0;
	REP(i, 1, n) {
		b[i] = b[i - 1] + a[i];
	}
	for (ll i = n; i >= 1; i--) {
		ll cnt = 0;
		cnt += x * i;
		ll v = 0;
		cnt += f(n, n - i);
		for (ll j = n; j >= 1; j -= i) {
			cnt += f(j, j - i)*v;
			v++;
			if (cnt > ans) { break; }
		}
		ans = min(cnt, ans);
	}
	ans = ans + n * x + 3 * ttl;
	std::cout << ans << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define pll pair<ll,ll>
#define pii pair<int, int>
#define F first
#define S second
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}


void solve()
{
    ll sum = 0;
    int n; cin>>n;
    REP(i, 1, n)
    {
        REP(j, 1, n)
        {
            REP(k, 1, n)
            {
                int temp = __gcd(i, j);
                sum += __gcd(temp, k);
            }
        }
    }
    cout<<sum;
}

int main()
{
    // clock_t start, end;
    // start = clock();
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    int t = 1;
    // cin>>t;
    while(t-- )
    {
        solve();
        
    }
    // end = clock();
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    // watch(time_taken);
    return 0;
    
}



/*before sub
TEST: 0, 1, equal, -ve, bounds(random and ez)
ERR/WA: loop vars, out of bounds, endl, finish taking inputs, large doubles, larger INF, corr mod, t
RE: double dec, integer overflow(ll or 1LL mult)
*/





Measured memory_bytes: 3652
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#define Debug 0
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

vector<Int> Divisor(Int n) {
    vector<Int> ret;
    for(Int i=1; i*i<=n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n / i);
        }
    }
    return ret;
}

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

}



Measured memory_bytes: 888
import java.util.Scanner;

public class Main{
    private static Scanner scanner = new Scanner(System.in);

    public static void main(String args[]){
        int n = scanner.nextInt();
        int maxNum = powInt(3, n);
        int[] array = new int[n];
        for(int i = 0; i < n; ++i){
            array[i] = scanner.nextInt();
        }

        int ans = 0;
        for(int i = 0; i < maxNum; ++i){
            int[] ternary = getTernary(i, n);
            int[] arrayB = getArrayB(array, ternary, n);

            ans += (hasEven(arrayB))? 1 : 0;
        }

        System.out.println(ans);
        // int[] arrTest = getTernary(73, n);
        // System.out.print("[");
        // for(int i = n - 1; i >= 0; --i){
        //     System.out.print(" " + arrTest[i]);
        // }
        // System.out.println(" ]");

    }

    public static int powInt(int a, int x){
        int res = 1;
        for(int i = 0; i < x; ++i){
            res *= a;
        }
        return res;
    }

    public static int[] getTernary(int decimal, int arraySize){
        int[] res = new int[arraySize];
        for(int i = 0; i < arraySize; ++i){
            res[i] = decimal % 3;
            decimal /= 3;
        }
        return res;
    }

    public static int[] getArrayB(int[] array, int[] ternary, int arraySize){
        int[] res = new int[arraySize];
        for(int i = 0; i < arraySize; ++i){
            res[i] = array[i];
            res[i] += (ternary[i] == 0)? -1 : (ternary[i] == 1)? 0 : 1;
        }
        return res;
    }

    public static boolean hasEven(int[] array){
        for(int num : array){
            if(num % 2 == 0){
                return true;
            }
        }
        return false;
    }
}

Measured memory_bytes: 26836
#include<stdio.h>
int c;
unsigned long long f(unsigned long long a,unsigned long long b){
  if(b==0)return a;
  a%=b;
  c++;
  return f(b,a);
}
int main(){
  unsigned long long a,b,r;
  while(1){
    scanf("%lld %lld",&a,&b);
    if(a==0&&b==0)break;
    c=0;
    if(a>b) r=f(a,b);
    else    r=f(b,a);
    printf("%lld %d\n",r,c);
  }
  return 0;
}

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

 public static void main(String[] args)
 {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] list = new int[n];
        for(int i =0;i<n;i++){
          list[i] = sc.nextInt();
        }
        int first = list[0];
        int min = list[0] - 1;
        String judge = "Yes";
        for(int i=1;i<n;i++){
          if(min <= (list[i] - 1)){
              min = list[i] - 1;
          }else if(min == list[i]){
              min = list[i];
          }else{
              judge = "No";
          }
        }
        
        System.out.println(judge);
      
    }

}

Measured memory_bytes: 52456
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int i,j;
  int n;
  cin>>n;
  rep(i,n){
    string s1,s2;
    cin>>s1>>s2;
    int n1=0,n2=0;
    rep(j,s1.size()){
      if('0'<=s1[j] && s1[j]<='9'){
	int a=s1[j]-'0';
	if(s1[j+1]=='m')n1+=a*1000;
	else if(s1[j+1]=='c')n1+=a*100;
	else if(s1[j+1]=='x')n1+=a*10;
	else if(s1[j+1]=='i')n1+=a;
	j++;
      }else{
	if(s1[j]=='m')n1+=1000;
	else if(s1[j]=='c')n1+=100;
	else if(s1[j]=='x')n1+=10;
	else if(s1[j]=='i')n1+=1;
      }
    }
    rep(j,s2.size()){
      if('0'<=s2[j] && s2[j]<='9'){
	int a=s2[j]-'0';
	if(s2[j+1]=='m')n2+=a*1000;
	else if(s2[j+1]=='c')n2+=a*100;
	else if(s2[j+1]=='x')n2+=a*10;
	else if(s2[j+1]=='i')n2+=a;
	j++;
      }else{
	if(s2[j]=='m')n2+=1000;
	else if(s2[j]=='c')n2+=100;
	else if(s2[j]=='x')n2+=10;
	else if(s2[j]=='i')n2+=1;
      }
    }
    int sum=n1+n2;
    int m,c,x,i;
    i=sum%10;    sum/=10;
    x=sum%10;    sum/=10;
    c=sum%10;    sum/=10;
    m=sum%10;

    if(m>1)cout<<m<<"m";
    else if(m==1)cout<<"m";

    if(c>1)cout<<c<<"c";
    else if(c==1)cout<<"c";

    if(x>1)cout<<x<<"x";
    else if(x==1)cout<<"x";

    if(i>1)cout<<i<<"i";
    else if(i==1)cout<<"i";

    cout<<endl;
  }
}

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


int main(){

  int N;

  cin>>N;

  long long a[100001];

  long long ans=0;

  cin>>a[0];

  ans=a[0];
  
  for(int i=1;i<N;i++){
    cin>>a[i];

    ans=__gcd(ans,a[i]);

    
  }

  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 1024
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    p = list(map(int, input().split()))
    min = p[0]
    ans = 1
    for i in range(1, n):
        if p[i] <= min:
            min = p[i]
            ans += 1
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 69488
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s;
    cin >> s;
    int w;
    cin >> w;
    rep(i, ((int)s.size() + w - 1) / w ) {
        cout << s[i*w];
    }
    cout << endl;
    return 0;
}

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

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

  if(a.size()==b.size()){
    for (int i = 0; i < a.size(); i++) {
      cout << a.at(i) << b.at(i);
    }
    cout << endl;
  }else{
    for (int i = 0; i < b.size(); i++) {
      cout << a.at(i) << b.at(i);
    }
    cout << a.at(a.size()-1) << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int main() {
	string S;
	cin >> S;
	string ans = "";
	for (int i = 0; i < S.size();++i) {
		ans += 'x';
	}
	cout << ans << endl;
}

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

int main(){
   int a,b,c;
   cin >>a>>b>>c;
   if(a+b+c>=22) cout << "bust"<<endl;
   else cout << "win" << endl;
}

Measured memory_bytes: 256
import itertools
n=int(input())
l=list(map(int,input().split()))
s=list(itertools.combinations(l,3))
count=0
for i in s:
	a,b,c=i
	if a+b>c and b+c>a and c+a>b and a!=b and b!=c and c!=a:
		count+=1
print(count)

Measured memory_bytes: 20520
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long k, n;
  cin >> k >> n;
  
  vector<long> a(n+1);
  for(long i=1; i<n+1; i++){
    cin >> a.at(i);
  }
  
  long w=0;
  for(long i=2; i<n+1; i++){
    w=max(w,a.at(i)-a.at(i-1));
  }
  
  w=max(w,k-a.at(n)+a.at(1));
  
  cout << k-w << endl;
  return 0;
}

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

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;

	if (A + B <= 23) {
		cout << A + B << endl;
	}
	else {
		cout << A + B - 24 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

using namespace std;

int main(){
	int self;
	int l,m,n;
	int c;
	bool flag;
	while(1){
		scanf("%d",&l);
		if(l == 0){break;}
		c = 0;
		flag = false;
		for(int i = 0;i < 12; i++){
			scanf("%d %d",&m,&n);
			c += m - n;
			if(!flag && c >= l){
				printf("%d\n",i+1);
				flag = true;
			}
		}
		if(!flag){
			printf("NA\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0