akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
string make_string(T N)
{
    string ret;
    T now = N;
    while (now > 0)
    {
        T x = now % 10;
        ret += (char)('0' + x);
        now /= 10;
    }
    reverse(all(ret));
    return ret;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll M;
    cin >> M;
    vector<ll> d(M), c(M);
    loop(i, M) cin >> d[i] >> c[i];
    ll count = 0, digit = 0;
    loop(i, M)
    {
        count += d[i] * c[i];
        digit += c[i];
    }
    ll ans = (digit - 1) + ((count - 1) / 9);
    putout(ans);
    return 0;
}


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

int main() {
  
  int A,B;
  
  cin >> A >> B;
  
  if(A>=B+2){
    cout << A+A-1;
  }else if(B>=A+2){
    cout << B+B-1;
  }else if(A==B){
    cout << A+B;
  }else if(A==B-1){
    cout << A+B;
  }else{
    cout << A+B;
  }
  
}

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

int main(){

    string s, p;
    cin >> s >> p;
    
    s += s;
    
    for(int i = 0; i < s.length()-p.length(); ++i){
        string t = s.substr(i, p.length());
        if(t == p){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3224
# include <cstdio>
# include <cstring>
# include <algorithm>
using namespace std;

static const int maxn = 36 + 2;

struct Card {
    char s;
    int v;
};

void _out(Card a[], int n) {
    for (int i = 0; i < n-1; i++)
        printf("%c%d ", a[i].s, a[i].v);
    printf("%c%d\n", a[n-1].s, a[n-1].v);
}

void bubbleSort(Card a[], int n) {
    for (int i = 0; i < n; i++) {
        for (int j = n-1; j >= i+1; j--)
            if (a[j].v < a[j-1].v) swap(a[j], a[j-1]);
    }
}

void selectionSort(Card a[], int n) {
    int minj;
    for (int i = 0; i < n; i++) {
        minj = i;
        for (int j = i; j < n; j++) {
            if (a[j].v < a[minj].v)
                minj = j;
        }
        swap(a[i], a[minj]);
    }
}

bool isStable(Card a[], Card b[], int n) {
    bool stable = true;
    for (int i = 0; i < n; i++) {
        if (a[i].s != b[i].s) {
            stable = false;
            break;
        }
    }
    return stable;
}

int main() {
    // freopen("data.in", "r", stdin);
    // freopen("data.out", "w", stdout);
    int n;
    Card b[maxn], s[maxn];
    while (scanf("%d", &n) == 1) {
        char buf[5];
        for (int i = 0; i < n; i++) {
            scanf("%s", buf);
            b[i].s = buf[0];
            b[i].v = buf[1] - '0';
            s[i].s = buf[0];
            s[i].v = buf[1] - '0';
        }
        bubbleSort(b, n);
        _out(b, n); printf("Stable\n");
        selectionSort(s, n);
        _out(s, n);
        if (isStable(b, s, n))
            printf("Stable\n");
        else
            printf("Not stable\n");
    }
    return 0;
}



Measured memory_bytes: 2684
n = int(input())
t, a = list(map(int, input().split()))
hs = list(map(int, input().split()))

min_diff = 100000
min_index = -1
for i, h in enumerate(hs):
    cut_t = t - h * 0.006
    if abs(cut_t - a) < min_diff:
        min_index = i
        min_diff = abs(cut_t - a)
print(min_index + 1)


Measured memory_bytes: 3060
<?php
  
$nd = explode(' ', trim(fgets(STDIN)));
$n = $nd[0];
$d = $nd[1];

for($i=0; $i<$n; $i++){
  $xt = explode(' ', trim(fgets(STDIN)));
  for($j=0; $j<$d; $j++){
    $x[$i][$j] = $xt[$j];
  }
}

$c = 0;
for($i=0; $i<$n; $i++){
  for($j=$i+1; $j<$n; $j++){
    $t = 0;
    for($k=0; $k<$d; $k++){
      $t += ($x[$i][$k] - $x[$j][$k])**2;
    }
    $s = sqrt($t);
    if (ctype_digit(strval($s))) $c++;    
  }
}

echo $c;
  
?>

Measured memory_bytes: 4604
#include<iostream>
using namespace std;
int main(){
    int a, b;
    string op;
    while(1){
      cin>> a >> op >> b;
      if ( op == "+" ) cout<<a+b<<endl;
      else if (op == "-") cout << a-b<<endl;
      else if (op == "*") cout << a*b<<endl;
      else if (op == "/") cout << a/b << endl;
      else if (op == "?") break;
    }
    return 0;
}


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

int main() {
  ll N=0,a=0,b=0,c=0,d=0;
  cin >> N;
  d = N % 10;
  c = (N/10) % 10;
  b = (N/100) % 10;
  a = N/1000;
  if(a+b+c+d == 7){
    cout << a << "+" << b << "+" << c << "+" << d << "=7";
    return 0;
  }
  else if(a-b+c+d == 7){
    cout << a << "-" << b << "+" << c << "+" << d << "=7";
    return 0;
  }
  else if(a+b-c+d == 7){
    cout << a << "+" << b << "-" << c << "+" << d << "=7";
    return 0;
  }
  else if(a+b+c-d == 7){
    cout << a << "+" << b << "+" << c << "-" << d << "=7";
    return 0;
  }
  else if(a-b-c+d == 7){
    cout << a << "-" << b << "-" << c << "+" << d << "=7";
    return 0;
  }
  else if(a-b+c-d == 7){
    cout << a << "-" << b << "+" << c << "-" << d << "=7";
    return 0;
  }
  else if(a+b-c-d == 7){
    cout << a << "+" << b << "-" << c << "-" << d << "=7";
    return 0;
  }
  else{
    cout << a << "-" << b << "-" << c << "-" << d << "=7";
  }
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, K;
	cin >> N >> K;
	int ans = 0;
	rep(i, K, N + 2)
	{
		int l = i * (i - 1) / 2;
		int r = (N)*(N + 1) / 2 - (N - i)*(N - i + 1) / 2;
		ans += r - l+1;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k - 1] << endl;
    return 0;
}


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

int main() {
  int S;
  cin >> S;
 
  if(S == 25){
  cout << "Christmas" << endl;
  }
  
  else if(S == 24){
  cout << "Christmas Eve" << endl;
  }
  
  else if(S == 23){
  cout << "Christmas Eve Eve" << endl;
  }
  
  else if(S == 22){
  cout << "Christmas Eve Eve Eve" << endl;
  }

}


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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)

#define L(x) ((x)*2)
#define R(x) ((x)*2+1)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    os << pai.first << ' ' << pai.second;
	return os;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    rep(i, sz(v)) cout << v[i] << ' ';
    return os;
}

template<typename T, typename V>
istream &operator>>(istream &is, pair<T, V> &pai) {
	is >> pai.first >> pai.second;
	return is;
}

int A, B, K;

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> A >> B >> K;
    for (int i = min(A, B); i > 0; i--) {
        if (A%i == 0 and B%i == 0) {
            if (--K == 0) {
                cout << i;
                return 0;
            }
        }
    }
}   




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

bool is_prime[100001];
void prime(int n){
  for(int i=0;i<=n;i++)is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<=n;i++){
    if(is_prime[i]==true){
      for(int j=2*i;j<=n;j+=i)is_prime[j]=false;
    }
  }
}

int main(){
  int m,a,b;
  prime(100000);
  while(cin>>m>>a>>b,m){
    int p=0,q=0;
    for(int i=1;i*i<=m;i++){
      if(!is_prime[i])continue;
      for(int j=i;j<=m/i + 1;j++){
	if(!is_prime[j])continue;
	if(q*p<i*j && i*j<=m && 
	   a*j<=i*b && 
	   i*b<=b*j){
	  p=j;
	  q=i;
	}
      }
    }
    cout << q << " " << p << endl;
  }
  return 0;
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "Yes" : "No" ) << '\n' ;
#define mxn 100005
using namespace std;

void solve(){
    int n;
    cin >> n;
    if(n == 1){
        cout << "0";return;
    }
    int ans = 1,ans2 = 1,ans3 = 1;
    for(int i = 1; i <= n; i++){
        ans *= 10LL;
        ans %= mod;
        ans2 *= 9LL;
        ans2 %= mod;
        ans3 *= 8LL;
        ans3 %= mod;
    }
    int f = 0;
    ans2 = (2 * ans2) % mod;
    f = (ans - ans2 + mod) % mod;
    f = (f + ans3) % mod; 
    cout << f << '\n';
}

int32_t main()
{
    FLASH
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 3652
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
// https://qiita.com/EqualL2/items/6e3de4d1d09e2e5f3611
ll euclidean_gcd(ll a, ll b)
{
    return b != 0 ? euclidean_gcd(b, a % b) : a;
} 

int main(){
    ll n,k;
    ll a[100010];
    std::cin >> n>>k;
    
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        if(a[i] == k){
            std::cout << "POSSIBLE" << std::endl;
            return 0;
        }
    }
    ll gcd = a[0];
    for (int i = 0; i < n; i++) {
        gcd = euclidean_gcd(gcd,a[i]);
    }
    sort(a,a+n);
    ll in = distance(a,lower_bound(a,a+n,k));
    if( in == n ){
        std::cout << "IMPOSSIBLE" << std::endl;
        return 0;
    }
    for (int i = 0; i < n; i++) {
        if(a[i]>k){
            if( (a[i]-k - gcd) >= 0 && (a[i]-k - gcd)%gcd == 0 ){
                std::cout << "POSSIBLE" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "IMPOSSIBLE" << std::endl;
}


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

import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys


def S():
    return sys.stdin.readline().rstrip()


def I():
    return int(sys.stdin.readline().rstrip())


def LI():
    return list(map(int, sys.stdin.readline().rstrip().split()))


def LS():
    return list(sys.stdin.readline().rstrip().split())


def main():
    s = S()
    t = S()
    t2 = t[:-1]
    if len(s) >= 1 and len(s) <= 10 and s == t2:
        print("Yes")
    else:
        print("No")


main()


Measured memory_bytes: 27196
n = int(input())
A = list(map(int, input().split()))

from collections import defaultdict
d = defaultdict(lambda: (n, 0))
for i, a in enumerate(A):
    min_id, cnt = d[a]
    d[a] = (min(min_id, i), cnt+1)

B = list(d.items())
B.sort()

#print(B)

ans = [0]*n
while True:
    a1, (m1, c1) = B.pop()
    if not B:
        ans[m1] += c1*a1
        break
    a2, (m2, c2) = B[-1]
    ans[m1] += c1*(a1-a2)
    B[-1] = (a2, (min(m1, m2), c1+c2))

print(*ans, sep='\n')

Measured memory_bytes: 35860
// BWOTSHEWCHB

#include <bits/stdc++.h>

using namespace std ;

#define pb push_back
#define in insert
#define X first
#define Y second

const int MAXN = 1e6 + 69 , MOD = 1e9 + 7 ; 

int n , arr[MAXN] , dp[MAXN] ;

int32_t main() {
	ios::sync_with_stdio(false) ;
	cin.tie(0) ; cout.tie(0) ;
	cin >> n ;
	for ( int i = 1 ; i <= n ; i ++ )
		cin >> arr[i] , dp[i] = 1e9 ;
	dp[1] = 0 ;
	for ( int i = 2 ; i <= n ; i ++ ) {
		if ( i - 1 > 0 )
			dp[i] = min(dp[i] , dp[i - 1] + abs(arr[i] - arr[i - 1])) ;
		if ( i - 2 > 0 )
			dp[i] = min(dp[i] , dp[i - 2] + abs(arr[i] - arr[i - 2])) ;
	}
	cout << dp[n] << "\n" ;
}


Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	int N,K;
	string S;
	cin >> N >> K;
	cin >> S;
	--K;
	if(S[K] == 'A' ){
		S[K] = 'a';
	}else if(S[K] == 'B'){
		S[K] = 'b';
	}else{
		S[K] = 'c';
	}
	
	cout<< S<< endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {


    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];

        Map<Long,Long> m = new HashMap<>();

        long sum = 0;
        for (int i = 0; i < N; i++) {
            long num = sc.nextInt();
            sum += num;
            if(m.containsKey(num)){
                m.put(num,m.get(num)+1);
            }else{
                m.put(num,1L);
            }
        }
        int Q = sc.nextInt();

        for (int i = 0; i < Q ; i++) {
            long from = sc.nextInt();
            long to = sc.nextInt();

            if(m.containsKey(from)){
                long n = (long)m.get(from);
                sum = sum - n * from + n * to;

                if(m.containsKey(to)){
                    m.put(to,m.get(to)+n);
                }else{
                    m.put(to,n);
                }
                m.put(from,0L);
            }else{

            }
            System.out.println(sum);
        }

    }

}

Measured memory_bytes: 68896
#include<stdio.h>
 
int main(void){
 
int n,a,b,c,i;
 
long d=0;
 
b=-1000000;
 
c=1000000;
 
scanf("%d",&n);
 
for(a=0;a<n;a++){
 
scanf("%d",&i);
 
if(b<i){
 
b=i;
 
}
 
if(c>i){
 
c=i;
 
}
 
d+=i;
 
}
 
printf("%d %d %ld\n",c,b,d);
 
return 0;
 
}
 

 

Measured memory_bytes: 600
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	string s;
	int cnt = 0;
	for (int i = a; i <= b; ++i) {
		int s = i / 10000;
		int t = i / 1000 % 10;
		int u = i / 10 % 10;
		int v = i % 10;
		if (s == v && t == u) ++cnt;
	}
	cout << cnt << endl;
	return 0;
} 

Measured memory_bytes: 256
let print_array a =
  Array.iteri (fun i s -> Printf.printf (if i = 0 then "%s" else " %s") s) a;
  print_newline ()

let swap i j a = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp

let bubble_sort a n cmp =
  let rec bubble j flag =
    if j <= 0 then doit flag
    else if cmp a.(j - 1) a.(j) <= 0 then bubble (j - 1) flag
    else (swap j (j - 1) a; bubble (j - 1) true)
  and doit flag =
    if not flag then ()
    else bubble (n - 1) false
  in
  doit true

let selection_sort a n cmp =
  let rec select j minj =
    if j >= n then minj
    else select (j + 1) (if cmp a.(j) a.(minj) < 0 then j else minj)
  in
  let rec doit i =
    if i >= n then ()
    else begin
      let minj = select i i in
      if minj <> i then swap i minj a;
      doit (i + 1)
    end
  in
  doit 0

let cmp_card x y =
  let num_of_char c = Char.code c - Char.code '0' in
  compare (num_of_char x.[1]) (num_of_char y.[1])

let stable_p a b n =
  let rec doit i =
    if i >= n then true
    else if a.(i) <> b.(i) then false
    else doit (i + 1)
  in
  doit 0

let () =
  let n = read_int () in
  let a = Array.of_list (Str.split (Str.regexp " ") (read_line ())) in
  let b = Array.copy a in
  bubble_sort a n cmp_card;
  selection_sort b n cmp_card;
  print_array a;
  print_endline "Stable";
  print_array b;
  print_endline (if stable_p a b n then "Stable" else "Not stable")

Measured memory_bytes: 2212
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        List<Long> hills = new ArrayList<>();
        try (Scanner scanner = new Scanner(System.in)) {
            while (scanner.hasNextLong()) {
                hills.add(scanner.nextLong());
            }
        }
        hills.stream().sorted(Comparator.reverseOrder()).limit(3).forEach(System.out::println);
    }
}

Measured memory_bytes: 32056
#include <bits/stdc++.h>
#define inf 1e10
using namespace std;

struct data {
  long long x[2], y[2], dis;
  bool turn;
};
bool operator<(const data &l, const data &r) {
  if(l.dis != r.dis) return l.dis > r.dis;
  return 0;
}

vector<vector<char>> s;
long long dis[66][33][66][33][2] = {0};
long long h, w;
priority_queue<data> pq;

bool ch(data now);
long long solve();

int main() {
  while(1) {
    cin >> w >> h;
    if(w + h == 0) break;
    for(int i = 0; i < h; ++i)
      for(int j = 0; j < w; ++j)
        for(int k = 0; k < h; ++k)
          for(int l = 0; l < w; ++l)
            for(int m = 0; m < 2; ++m)
              dis[i][j][k][l][m] = inf;
    s.resize(h);
    for(int i = 0; i < h; ++i) s[i].resize(w);
    for(int i = 0; i < h; ++i)
      for(int j = 0; j < w; ++j) cin >> s[i][j];
    cout << solve() << endl;
    while(pq.size() > 0) pq.pop();
  }
  return 0;
}

long long solve() {
  long long ans = inf;
  vector<long long> lst;
  for(int i = 0; i < w; ++i)
    if(s[h - 1][i] == 'S') {
      data now;
      now.x[0] = now.x[1] = h - 1;
      now.y[0] = now.y[1] = i;
      now.dis = 0;
      now.turn = 0;
      pq.push(now);
      now.turn = 1;
      pq.push(now);
    }

  while(!pq.empty()) {
    data now = pq.top();
    pq.pop();
    if(now.dis >= dis[now.x[0]][now.y[0]][now.x[1]]
                     [now.y[1]][now.turn])
      continue;
    dis[now.x[0]][now.y[0]][now.x[1]][now.y[1]][now.turn] =
        now.dis;
    for(int i = -2; i <= 2; ++i)
      for(int j = 1; j <= 3; ++j) {
        data nextd = now;
        nextd.turn = !now.turn;
        nextd.x[now.turn] = nextd.x[nextd.turn] + i;
        nextd.y[now.turn] =
            nextd.y[nextd.turn] + j - nextd.turn * 2 * j;
        if(!ch(nextd)) continue;
        if(s[nextd.x[now.turn]][nextd.y[now.turn]] >= '0' &&
           s[nextd.x[now.turn]][nextd.y[now.turn]] <= '9') {
          nextd.dis +=
              s[nextd.x[now.turn]][nextd.y[now.turn]] - '0';
          pq.push(nextd);
        }
        if(s[nextd.x[now.turn]][nextd.y[now.turn]] == 'S')
          pq.push(nextd);
        if(s[nextd.x[now.turn]][nextd.y[now.turn]] == 'T')
          ans = min(ans, nextd.dis);
      }
  }
  if(ans == inf) return -1;
  return ans;
}

bool ch(data now) {
  for(int i = 0; i < 2; ++i)
    if(now.x[i] < 0 || now.x[i] >= h || now.y[i] < 0 ||
       now.y[i] >= w)
      return 0;
  int mdis =
      abs(now.x[0] - now.x[1]) + abs(now.y[0] - now.y[1]);
  return now.y[0] < now.y[1] && mdis <= 3;
}


Measured memory_bytes: 65252
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long

const int N=100005;
const int MOD=1e9+7;
 

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
 
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/


int n;
cin>>n;
int arr[n];
for(int i=0;i<n-1;i++)
{
	cin>>arr[i];
}
int count[n]={0};
for(int i=0;i<n-1;i++)
{
	count[arr[i]]++;
}

for(int i=1;i<n;i++)
{
	cout<<count[i]<<endl;
}
cout<<0<<endl;


}

Measured memory_bytes: 6780
import sys

N=int(input())
x=[0 for i in range(N)]
y=[0 for i in range(N)]
h=[0 for i in range(N)]
for i in range(N):
    x[i],y[i],h[i]=map(int,input().split())

cx=0
cy=0
H=0
for i in range(0,101):
    for j in range(0,101):
        flag=0
        cx=i
        cy=j
        for k in range(N):
            if h[k]!=0:
                H=h[k]+abs(cx-x[k])+abs(cy-y[k])
                break
        for k in range(N):
            test=max(0,H-abs(cx-x[k])-abs(cy-y[k]))
            if test!=h[k]:
                flag=1
                break
        if flag==0:
            print(cx,cy,H)
            sys.exit()

Measured memory_bytes: 43116
N, K = map(int, input().split())
S = input()

nums = []
now = 1
cnt = 0
for i in range(N):
  if S[i] == str(now):
    cnt += 1
  else:
    nums.append(cnt)
    now = 1 - now
    cnt = 1
if cnt != 0:
  nums.append(cnt)

if len(nums) % 2 == 0:
  nums.append(0)

add = 2 * K + 1

sums = [0 for _ in range(len(nums) + 1)]
for i in range(len(nums)):
  sums[i + 1] = sums[i] + nums[i]

ans = 0
for i in range(len(nums)):
  if i % 2 == 1:
    continue
  
  left = i
  right = min(i + add, len(nums))
  tmp = sums[right] - sums[left]

  ans = max(tmp, ans)

print(ans)

Measured memory_bytes: 8004
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

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

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//227
	string s;
	cin>>s;
	ll sum = 0;
	int last = 0;
	if(s[0]=='>'){last = 1;sum=1;}
	REP(i,0,s.length()-1) {
		ll cnt = 1;
		REP(j,i+1,s.length()-1)if(s[j]!=s[i])break;else cnt++;
		if(last==0) {
			sum+=cnt*(cnt+1)/2;
			last = cnt;
		} else {
			if(last<=cnt) {
				sum-=last;
				sum+=cnt*(cnt+1)/2;
			} else {
				sum+=cnt*(cnt+1)/2;
				sum-=cnt;
			}
			last = 0;
		}
		i+=cnt-1;
	}
	cout<<sum;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3812
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <complex>
using namespace std;

typedef complex<double> pt;

pt read_pt()
{
    double x, y;
    cin >> x >> y;
    return pt(x, y);
}

int main()
{
    cin.tie(0);

    pt st = read_pt();
    pt go = read_pt();

    int n;
    cin >> n;

    vector<pair<pt, double>> bs(n);

    for (auto &b: bs) {
        b.first = read_pt();
        cin >> b.second;
    }

    bs.emplace_back(st, 0);
    bs.emplace_back(go, 0);

    vector<vector<double>> g(bs.size(), vector<double>(bs.size(), -1));

    for (int i = 0; i < bs.size(); i++) {
        for (int j = 0; j < bs.size(); j++) {
            g[i][j] = max(0.0 , abs(bs[i].first - bs[j].first) - bs[i].second - bs[j].second);
        }
    }

    set<pair<double, int>> q;
    q.insert(make_pair(0, n));

    vector<double> tbl(bs.size(), -1);

    while (q.size()) {
        double d = q.begin()->first;
        int pos = q.begin()->second;
        q.erase(q.begin());

        if (tbl[pos] >= 0)
            continue;
        tbl[pos] = d;

        if (pos == n + 1) {
            printf("%.12f\n", d);
            return 0;
        }

        for (int i = 0; i < g[pos].size(); i++) {
            double nd = d + g[pos][i];
            if (tbl[i] >= 0)
                continue;
            q.insert(make_pair(nd, i));
        }
    }

    return 0;
}

Measured memory_bytes: 39168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, ans = 0;
  cin >> n;
  vector<int> p(n);
  REP(i, n) {
    cin >> p[i];
    p[i]--;
  }
  for (int i = 0, cnt = 0; i < n; i++) {
    if (i == p[i]) cnt++;
    if (i != p[i] && cnt > 0) {
      ans++;
      cnt = 0;
    }
    if (cnt == 2) {
      cnt = 0;
      ans++;
    }
    if (i == n - 1 && cnt > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3716
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int menber, quorum;
    while(cin >> menber >> quorum, menber||quorum){
        int plan[105] = {0}, max = 0;
        rep(i, menber){
            int data;
            cin >> data;
            rep(j, data){
                int inp;
                cin >> inp;
                plan[inp]++;
                if(max < plan[inp]) max = plan[inp];
            }
        }
        int limit = sizeof(plan) / sizeof(plan[0]);
        int ans = 0;
        rep(i, limit){
            if(plan[i] == max && max >= quorum){
                ans = i;
                break;
            }
            if(plan[i] == quorum){
                ans = i;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1160
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rf = lambda: map(float, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
n = ri()
print(s[::n])

Measured memory_bytes: 27132
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = 998244353; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

struct UnionFindTree {
    vector<int> parent, rank;
    int operator [](int x) { return find(x); }
    void build(int n) { parent.assign(n, -1); rank.assign(n, 0); }
    int find(int x) { return parent[x] < 0 ? x : (parent[x] = find(parent[x])); }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -parent[find(x)]; }
    bool unite(int x, int y) {
        if ((x = find(x)) == (y = find(y))) return 0;
        rank[x] = max(rank[x], rank[y] + 1); parent[x] += parent[y]; parent[y] = x; return 1;
    }
    bool uniteByRank(int x, int y) {
        if ((x = find(x)) == (y = find(y))) return 0; else if (rank[x] < rank[y]) swap(x, y);
        else if (rank[x] == rank[y]) rank[x]++; parent[x] += parent[y]; parent[y] = x; return 1;
    }
    bool uniteBySize(int x, int y) {
        if ((x = find(x)) == (y = find(y))) return 0; else if (size(x) < size(y)) swap(x, y);
        rank[x] = max(rank[x], rank[y] + 1); parent[x] += parent[y]; parent[y] = x; return 1;
    }
};

int main() {
    int W, H;
    cin >> W >> H;
    vector<int> P(W), Q(H);
    rep(i, W) cin >> P[i];
    rep(i, H) cin >> Q[i];

    vector<pair<int, int>> A(W + H);
    rep(i, W) {
        A[i] = { P[i], i };
    }
    rep(i, H) {
        A[W + i] = { Q[i], W + i };
    }
    sort(all(A));

    int xg = W + 1, yg = H + 1;
    ll ans = 0;
    for (auto&& a : A) {
        if (a.second < W) {
            ans += (ll)a.first * yg;
            xg--;
        }
        else {
            ans += (ll)a.first * xg;
            yg--;
        }
    }

    write(ans);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 998244353;
int dist[100100];
int d[100100];
int main() {
	int n;
	cin >> n;
	ll ans = 1;
	
	rep(i,n) cin >> d[i];
	if (d[0] != 0) ans = 0;
	dist[d[0]]++;
	sort(d,d+n);
	for (int i = 1; i < n; i++)
	{
		if (d[i] == 0) ans = 0;
		else {
			ans *= dist[d[i]-1];
			ans %= MOD;
			dist[d[i]]++;
		}
	}

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

Measured memory_bytes: 4292
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define amari(x) ((x) % 1000000007)

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end());
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>());
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin();
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin();

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

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

  int h, w;

  cin >> h >> w;

  char a[h][w];
  vector<string> s(h);

  fillString(s, h);

  rep(i, h) {
    rep(j, w) {
      a[i][j] = s[i][j];
    }
  }

  int x = 0;
  int y = 0;

  while (true) {
    a[y][x] = '.';
    if (x < w-1 && a[y][x+1] == '#') {
      x++;
    } else if (y < h-1 && a[y+1][x] == '#') {
      y++;
    } else {
      break;
    }
  }

  bool res = true;
  rep(i, h) {
    rep(j, w) {
      res = res && (a[i][j] == '.');
    }
  }

  if (res) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }

  return 0;
}


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

const int MAX_N = 100;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	
	string str;
	cin >> str;
	
	int ans = 0;
	for(int i = 0; i < n; ++i){
		string str2;
		cin >> str2;
		bool check = false;
		for(int j = 0; j < str2.size(); ++j){
			if(str[0] == str2[j]){
				for(int space = 1; space < str2.size(); ++space){
					int l = 1;
					for(int k = j + space; k < str2.size(); k += space){
						if(str[l] == str2[k]){
							++l;
						}
						else { break; }
						if(l == str.size()){
							check = true;
							break;
						}
					}
					if(check){ break; }
				}
			}
			if(check){ break; }
		}
		if(check){
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    double t,x; cin>>t>>x;
    cout<<t/x<<endl;
}


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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll i, j, n;
	string s;
	cin >> s;
	ll ans = 0;
	for (i = 0; i < s.size (); ++i)
		ans += s[i] - '0';
	if (ans%9 == 0) cout << "Yes\n";
	else cout << "No\n";


	return 0;
}



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

int main() {
    int n, t;
    cin >> n >> t;
    int tm[n];
    for (int i = 0; i < n; i++) cin >> tm[i];
    ll ans = 0;
    for (int i = 0; i < n - 1; i++) {
        ans += min(t, tm[i + 1] - tm[i]);
    }
    ans += t;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
N=int(input())
table=[]
def f(cx,cy,h,x,y):
    return max(h-abs(x-cx)-abs(y-cy),0)
for i in range(N):
    x,y,h=map(int,input().split())
    table.append((x,y,h))
for cx in range(101):
    for cy in range(101):
        n=0
        h=0
        while n<N:
            x,y,z=table[n]
            if z>0:
                h=z+abs(cx-x)+abs(cy-y)
                break
            n+=1
        flag=True
        for x,y,z in table:
            if f(cx,cy,h,x,y)!=z:
                flag=False
                break
        if flag:
            print(cx,cy,h)
            sys.exit()
                
            

Measured memory_bytes: 43116
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

void swap(int a,int b) {
	int tmp = a;
	a = b;
	b = tmp;
}

int main(void) {
	ll A,B,C;

	cin >> A >> B >> C;
	
	swap(A,B);

	swap(A,C);

	cout << A<<endl;
	cout << B << endl;
	cout << C << endl;

	return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


void solve(ll N, string s) {
    for (int i = 0; i < 4; i++) {
        string t = string(s.size(), '?');
        t[0] = "SW"[i & 1];
        t[N - 1] = "SW"[i >> 1 & 1];
        for (int j = 0; j < N; j++) {
            char p = t[(j - 1 + N) % N];
            if ((s[j] == 'o') ^ (t[j] == 'W')) {
                t[(j + 1) % N] = p;
            } else {
                t[(j + 1) % N] = "SW"[p != 'W'];
            }
        }
        bool ok = true;
        for (int j = 0; j < N; j++) {
            char prv = t[(j - 1 + N) % N];
            char nxt = t[(j + 1) % N];
            if ((s[j] == 'o') ^ (t[j] == 'W')) {
                ok &= prv == nxt;
            } else {
                ok &= prv != nxt;
            }
        }
        if (ok) {
            cout << t << endl;
            return;
        }
    }
    cout << -1 << endl;
}


void main_(istream &cin) {
    ll N;
    string s;
    cin >> N;
    cin >> s;
    solve(N, s);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





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

int main(){
    int n;
    cin >> n;
    int a[n];
    long long ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    //昇順
    int j = 0, cnt = 1;
    for(int i = 0; i < n-1; i++){
        ans += a[j];
        cnt++;
        if(cnt == 2){
            j++;
            cnt = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
int main(){
  
    string a,b,u;
    int c,d;
    cin>>a>>b>>c>>d>>u;
    if(a==u){
        c--;
    }
    else{
        d--;
    }
    cout<<c<<" "<<d;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
s = input()
G = [[] for _ in range(n)]
A = [0]*n
B = [0]*n
for _ in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  if a==b:
    G[a].append(b)
    if s[b] == "A":
      A[a] += 1
    else:
      B[a] += 1
  else:
    G[a].append(b)
    G[b].append(a)
    if s[b] == "A":
      A[a] += 1
    else:
      B[a] += 1
    if s[a] == "A":
      A[b] += 1
    else:
      B[b] += 1
stack = []
cnt = 0
for i in range(n):
  if (not A[i]) or (not B[i]):
    stack.append(i)
while stack:
  v = stack.pop()
  cnt += 1
  if s[v] == "A":
    for nv in G[v]:
      A[nv] -= 1
      if B[nv] > 0 and A[nv] == 0:
        stack.append(nv)
  else:
    for nv in G[v]:
      B[nv] -= 1
      if A[nv] > 0 and B[nv] == 0:
        stack.append(nv)
if cnt == n:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 44392
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
char mat[2010][2010];
int n,m,S1[2010][2010],S2[2010][2010],S3[2010][2010];
void pre(int S[2010][2010]){
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			S[i][j]+=S[i-1][j]+S[i][j-1]-S[i-1][j-1];
}
int get(int S[2010][2010],int x1,int y1,int x2,int y2){
	return S[x2][y2]+S[x1-1][y1-1]-S[x2][y1-1]-S[x1-1][y2];
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	n=gi(),m=gi();int Q=gi();
	for(int i=1;i<=n;++i)scanf("%s",mat[i]+1);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			if(mat[i][j]=='1')
				S1[i][j]=1,S2[i][j]=mat[i][j+1]=='1',S3[i][j]=mat[i+1][j]=='1';
	pre(S1),pre(S2),pre(S3);
	while(Q--){
		int x1=gi(),y1=gi(),x2=gi(),y2=gi();
		printf("%d\n",get(S1,x1,y1,x2,y2)-get(S2,x1,y1,x2,y2-1)-get(S3,x1,y1,x2-1,y2));
	}
	return 0;
}


Measured memory_bytes: 53120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int com;
		String result = "";
		if(a > b) {
			com = b;
			for(int i = 0;i < a;i++) {
				result += String.valueOf(com);
			}
		}else {
			com = a;
			for(int i = 0;i < b;i++) {
				result += String.valueOf(com);
			}
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int N, H, amx, sum, ans;
priority_queue<int> pq;
int main(){
	scanf("%d %d", &N, &H);
	for(int i = 0; i < N; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		pq.push(b);
		amx = max(a, amx);
	}
	while(!pq.empty()){
		if(pq.top() < amx)	break;
		sum += pq.top();
		pq.pop();
		ans++;
		if(sum >= H){
			printf("%d\n", ans);
			return 0;
		}
	}
	ans += ceil(1.0 * (H - sum) / amx);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

ll x[1000], y[1000], z[1000];
ll value[8][1000];

int main() {
    int N, M;
    cin >> N >> M;
    REP(i, N) cin >> x[i] >> y[i] >> z[i];

    int op[2] = {1, -1};
    REP(i, N) REP(j, 1 << 3) {
        value[j][i] += op[((j >> 2) & 1)] * x[i];
        value[j][i] += op[((j >> 1) & 1)] * y[i];
        value[j][i] += op[j & 1] * z[i];
    }
    REP(i, 1 << 3) sort(value[i], value[i] + N);

    ll ans = -10000000000000000;
    REP(i, 1 << 3) {
        ll tmp = 0;
        REP(j, M) tmp += value[i][N - j - 1];
        ans = max(ans, tmp);
    }

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

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

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

using namespace std;
using lint=long long;

struct trie{
	trie* l;
	trie* r;
	trie():l(nullptr),r(nullptr){}
};

void add(int i,const string& s,trie* t){
	if(i==s.length()) return;

	if(s[i]=='0'){
		if(!t->l) t->l=new trie;
		add(i+1,s,t->l);
	}
	else{
		if(!t->r) t->r=new trie;
		add(i+1,s,t->r);
	}
}

lint L;

lint grundy(int i,trie* t){
	if(i==L) return 0;

	if(!t){
		lint h=L-i,res=1;
		while(h%2==0){ h/=2; res*=2; }
		return res;
	}
	else{
		return grundy(i+1,t->l)^grundy(i+1,t->r);
	}
}

int main(){
// experiment
/*
	int g[100];
	g[1]=1;
	for(int i=2;i<70;i++){
		set<int> S{0};
		int x=0;
		for(int j=i-1;j>0;j--){
			x^=g[j];
			S.emplace(x);
		}
		for(int j=0;;j++){
			if(S.count(j)==0){
				g[i]=j;
				break;
			}
		}
	}
	rep(i,70) printf("g[%2d] = %2d\n",i,g[i]);
	return 0;
*/
	trie root;

	int n; cin>>n>>L;
	rep(i,n){
		string s; cin>>s;
		add(0,s,&root);
	}

	cout<<(grundy(0,root.l)^grundy(0,root.r)?"Alice":"Bob")<<endl;

	return 0;
}


Measured memory_bytes: 6656
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N, y;

int main()
{
	in >> N;
	rep(i, N)
	{
		char c;
		in >> c;
		if (c == 'Y')
		{
			out << "Four" << std::endl;
			return 0;
		}
	}
	out << "Three" << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,a,b,c,d,e,f,g,h,i,j,k,w,ok,ng,l,q,ans;
ll x[500005],y[500005],z[500005];
ll dp[3005][3005];
char s[500005],t[500005];
bool flag,dame;

int main(){
    cin >> n;
	cin >> s;
	dp[1][1] = 1;
	for(i=2;i<=n;i++){
		for(j=1;j<=i;j++){
			if(s[i-2] == '<'){
				dp[i][j] = dp[i-1][j-1];
			}else{
				dp[i][j] = (dp[i-1][i-1] - dp[i-1][j-1] + mod) % mod;
			}
			dp[i][j] += dp[i][j-1];
			dp[i][j] %= mod;
		}
	}
	ans = 0;
	for(i=1;i<=n;i++){
		for(j=1;j<=i;j++){
		//	pe(dp[i][j]);
		}
		//el;
	}
	ans = dp[n][n];
	p(ans);

	return 0;
}

Measured memory_bytes: 94848