akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<set>
#include<math.h>
#include<list>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
    long D, N;
    cin >> D >> N;

    if(N==100){
        cout << (int)(101 * pow(100, D)) << endl;
    }else{
        cout << (int)(N * pow(100, D)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())
G = [[] for i in range(N)]
deg = [0 for i in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    G[x].append(y)
    deg[y] += 1

stack = []

for u in range(N):
    if deg[u] == 0:
        stack.append(u) #入次数が0のノードをスタックに入れる
topol = []
while len(stack) != 0:
    u = stack.pop()
    topol.append(u)
    for v in G[u]:
        deg[v] -= 1
        if deg[v] == 0:
            stack.append(v)


dp = [0 for i in range(N)]
for u in topol:
    for v in G[u]:
        dp[v] = max(dp[v], dp[u]+1)
res = 0
for i in range(N):
    if res < dp[i]:
        res = dp[i]
print(res)

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2];


void solve()
{
	int k; cin >> k;
	string str; cin >> str;
	n = str.size();
	if ( n <= k  )cout << str << endl;
	else cout << str.substr(0, k) << "..." << endl;

}

int32_t main()
{
	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
typedef long long int lli;
#define pb push_back
#define mp make_pair
#define mod 998244353
#define ff first
#define ss second
#define pi pair<lli,lli>
#define pii pair<pi,lli>
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 1e6 + 5;

int main() {
	IOS
	int T = 1;
	// cin >> T;
	while(T--) 
	{
		int n;
		cin >> n;
		map<lli,lli> hs;
		lli sum = 0;
		lli a[n];
		for(int i=0;i<n;i++)
		{
			cin >> a[i];
			sum+=a[i];
			hs[a[i]]++;
		}
		int q;
		cin >> q;
		while(q--)
		{
			lli x, y;
			cin >> x >> y;
			if(hs.find(x) != hs.end())
			{
				lli c = hs[x];
				lli change = y - x;
				hs[y]+=c;
				hs.erase(x);
				sum = sum + change*c;
			}
			cout << sum << endl;
		}

	}	
	return 0;
}

Measured memory_bytes: 8396
#include<iostream>
#include<sstream>
#include<cmath>
using namespace std;
   
int main(){
string s;
int a,b,c;
while (getline(cin, s ))
{
int SpaceInd = s.find_first_of(" ");
 
std::istringstream iss1(s.substr(0,SpaceInd));
iss1 >> a;
   
std::istringstream iss2(s.substr(SpaceInd+1));
iss2 >> b;
cout<<(int)log10(a+b)+1<<endl;
}
return 0;
}

Measured memory_bytes: 3384
import Control.Monad (replicateM, replicateM_)
import Data.List (find)
import Data.Maybe (fromJust)

main :: IO ()
main = do
  t <- readLn
  let
    h = do
      line <- getLine
      let
        answer = (\(a:b:c:d:_) -> if f a b c d then "Yes" else "No") . map read . words $ line
      putStrLn answer
  replicateM_ t h

getNLine :: IO [String]
getNLine = do
  n <- readLn
  replicateM n getLine

f :: Int -> Int -> Int -> Int -> Bool
f initial buy level restock
  | buy > initial = False -- 即死
  | buy > restock = False -- ジリ貧
  | buy <= level = True -- 絶対死なない
  | otherwise =
    let
      step = gcd buy restock -- mod buy で見ると、購入・補充はこのステップで動く
    in
      buy - step + initial `mod` step <= level


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

using namespace std;

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

    for (int i = 0; i < 3; i++) {
        if (n.at(i) == '1') {
            n.at(i) = '9';
            continue;
        }
        if (n.at(i) == '9') {
            n.at(i) = '1';
        }
    }
    cout << n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

vector<vector<ll> > num(26);

int main(){
    string s,t;
    cin>>s>>t;
    for(ll i=0;i<s.length();i++){
        int n=(int)(s[i]-'a');
        num[n].push_back(i+1);
    }
    ll ans=0;
    ll pre=0;
    for(ll i=0;i<t.length();i++){
        int n=(int)(t[i]-'a');
        if(num[n].empty()){
            cout<<-1<<endl;
            return 0;
        }else if(upper_bound(num[n].begin(),num[n].end(),pre)==num[n].end()){
            pre=*num[n].begin();
            ans+=s.size();
        }else{
            pre=*upper_bound(num[n].begin(),num[n].end(),pre);
        }
    }
    ans+=pre;
    cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;

int main()
{
    int n , m;
    scanf("%d %d",&n,&m);
    int i , k;
    vector<int> vec;
    for(i = 0 ; i < n  ; i++)
    {
        scanf("%d",&k);
        vec.push_back(k);
    }

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

    int ans = 0;
    for(i = 0 ; i < m ; i++)ans += vec[i];
    printf("%d\n",ans);


    return 0;
}


Measured memory_bytes: 3808
arr=[] 
n,m=map(int,input().split()) 
dp=[[0 for j in range(m)] for i in range(n)] 
for i in range(n):
	arr.append(input()) 
dp[0][0]=1 
for i in range(1,n):
	if arr[i][0]!='#':
		dp[i][0]+=dp[i-1][0]
	else:
		break  
for i in range(1,m):
	if arr[0][i]!='#':
		dp[0][i]+=dp[0][i-1]
	else:
		break 


for i in range(1,n):
	for j in range(1,m):
		if arr[i][j]!='#':
			dp[i][j]=dp[i-1][j]+dp[i][j-1]  
mod=10**9+7 
print(dp[-1][-1]%mod)

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

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

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

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

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

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

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

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

use std::collections::HashMap;

fn main() {
    input!{
        n: usize,
        la: [usize; n]
    }
    let mut map: HashMap<usize, usize> = HashMap::new();
    for a in la {
        let value = map.entry(a).or_insert(0);
        *value += 1;
    }

    if map.len() >= 4 {
        println!("No");
        return;
    }

    let mut keys = vec![];
    let mut values = vec![];
    for (key, val) in map.iter() {
        keys.push(*key);
        values.push(*val);
    }

    if map.len() == 1 {
        if keys[0] == 0 {
            println!("Yes");
        }else {
            println!("No");
        }
        return;
    }

    if map.len() == 2 {
        if keys[0] == 0 && values[0] * 2 == values[1] {
            println!("Yes");
            return;
        } else if keys[1] == 0 && values[1] * 2 == values[0] {
            println!("Yes");
            return;
        }
        println!("No");
        return;
    }

    if values[0] != values[1] || values[1] != values[2] {
        println!("No");
        return;
    }
    if keys[0] ^ keys[1] == keys[2] {
        println!("Yes");
        return;
    }
    println!("No");
}


Measured memory_bytes: 12540
#include<bits/stdc++.h>
using namespace std;
string s,t;
int S[100007],T[100007];
int main()
{
	cin>>s>>t;
	int n=s.length(),m=t.length();
	for(int i=0;i<n;i++)S[i+1]=S[i]+(s[i]=='A'?1:2);
	for(int i=0;i<m;i++)T[i+1]=T[i]+(t[i]=='A'?1:2);
	int q;
	cin>>q;
	while(q--)
	{
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		puts(((S[b]-S[a-1])-(T[d]-T[c-1]))%3==0?"YES":"NO");
	}
}

Measured memory_bytes: 4460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1000000001;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  cout << max(a+b, max(a-b, a*b)) <<endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
K = 0
L = 0
#条件分岐
#H = 奇数 W = 奇数
if H == 1:
    K = 1
elif W == 1:
    K = 1
elif H == 2:
    K = W
elif W == 2:
    K = H
else:
    if H%2 == 1 and W%2 == 1:
        K = (H//2+1)*(W//2+1)
        L = (H//2)*(W//2)
    #H = 奇数 W = 偶数
    elif H%2 == 1 and W%2 == 0:
        K = (H//2+1)*(W//2)
        L = (H//2)*(W//2)
    #H = 偶数 W = 奇数
    elif H%2 == 0 and W%2 == 1:
        K = (H//2)*(W//2+1)
        L = (H//2)*(W//2)
    else:
        K = H*(W//2)
        L = 0
print(K+L)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N;cin >> N;
    vector<int> a(N+1);
    vector<int> b(N+1,0);
    vector<int> res;
    FOR(i,1,N+1)cin >> a[i];
    for(int i=N;i>=1;i--){
        int k=2,sum=0;
        while(i*k<=N){
            if(b[i*k])sum++;
            k++;
        }

        if(sum%2==0&&a[i]==1){
            res.push_back(i);
            b[i]++;
        }
        else if(sum%2==1&&a[i]==0){
            res.push_back(i);
            b[i]++;
        }
    }
    cout << res.size() << endl;
    rep(i,res.size())cout << res[i] << endl;
    return 0;
}

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<map>

using namespace std;

const int maxx = 1e5 + 5;
typedef long long ll;

map<char, char> p;

string s;
int a[16];
int b[16];

int main(){
	while(cin >> s){
		int cnt = 0, i;
		for(i = 0; i < s.size(); i++){
			if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
				b[i] = ++cnt;
			}
			else{
				cnt = 0;
				b[i] = 0;
			}
		}
		sort(b, b + s.size(), greater<int>());
		cout << b[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
class Main{
 
    public static void main(String[] args) throws Exception{
         
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int sec = Integer.parseInt(br.readLine());
        int h = sec / 3600;
        int m = (sec % 3600) / 60;
        int s = (sec % 3600) % 60;
 
        System.out.println(h + ":" + m + ":" + s);
 
    }
}

Measured memory_bytes: 24304
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n,m,x; cin>>n>>m>>x;
	int cnt1=0,cnt2=0;
	rep(i,0,m){
		int a; cin>>a;
		if(a<x) cnt1++;
		else cnt2++;
	}
	cout<<min(cnt1,cnt2);
		
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
typedef long long ll;

int main() {
	int n, m; cin >> n >> m;
	vector<int> a(m);
	int dp[10010]; fill(dp, dp + n, -1);
	dp[0] = 0;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	int need[] = { 0, 2,5,5,4,5,6,3,7,6 };
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < m; j++) {
			if (i - need[a[j]] >= 0) {
				dp[i] = max(dp[i], dp[i - need[a[j]]] + 1);
			}
		}
	}
	sort(a.begin(), a.end(), greater<int>());
	string ans;
	for (int j = n; dp[j];) {
		for (int i = 0; i < m; i++) {
			if (j - need[a[i]] >= 0) {
				if (dp[j] == dp[j - need[a[i]]] + 1) {
					j -= need[a[i]];
					ans += a[i] + '0';
					break;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

constexpr int MOD = 1000000007;

int main() {
  int N;
  string S, T;
  cin >> N >> S >> T;
  long ans, pre, i;
  if (S.at(0) == T.at(0)) ans = 3, pre = 1, i = 1;
  if (S.at(0) != T.at(0)) ans = 6, pre = 2, i = 2;
  for (; i < N; i++) {
    if (S.at(i) == T.at(i)) {
      if (pre == 1) ans *= 2;
      ans %= MOD;
      pre = 1;
    }
    if (S.at(i) != T.at(i)) {
      if (pre == 1) ans *= 2;
      if (pre == 2) ans *= 3;
      ans %= MOD;
      pre = 2;
      i++;
    }
  }
  cout << ans << "\n";
}

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

const long long Mod = 1000000007, Base = 1009;
vector<long long> poww;

struct RollingHash {
  long long ssize, maxssize;
  string s;
  vector<long long> hash;
  RollingHash(string inis = "") {
    maxssize = inis.size() + 10;
    init(inis);
  }
  void init(string inis = "") {
    s = inis;
    ssize = s.size();
    sethash();
  }
  void sethash() {
    ssize = s.size();
    hash.assign(ssize + 1, 0);
    for(int i = 0; i < ssize; ++i) {
      if(i != 0) hash[i + 1] = hash[i] * Base % Mod;
      hash[i + 1] += s[i];
      hash[i + 1] %= Mod;
    }
  }
  // [l,r),0-indexed
  long long calchash(int l, int r) {
    long long ans;
    ans = hash[r];
    ans -= hash[l] * poww[r - l] % Mod;
    while(ans < 0) ans += Mod;
    ans %= Mod;

    return ans;
  }
};

long long n;
vector<long long> a, b;
RollingHash rh[3][30];

void solve();

int main() {
  cin >> n;
  poww.assign(3 * n, 0);
  poww[0] = 1;
  for(int i = 1; i < 3 * n; ++i)
    poww[i] = poww[i - 1] * Base % Mod;

  a.resize(n);
  b.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < n; ++i) cin >> b[i];
  solve();
  return 0;
}

void solve() {
  for(int i = 0; i < 30; ++i) {
    string s, t;
    for(int j = 0; j < n; ++j) {
      s += '0' + (a[j] >> i & 1);
      t += '0' + 1 - (a[j] >> i & 1);
    }
    s += s;
    t += t;
    rh[0][i] = RollingHash(s);
    rh[1][i] = RollingHash(t);
  }
  for(int i = 0; i < 30; ++i) {
    string s;
    for(int j = 0; j < n; ++j) s += '0' + (b[j] >> i & 1);
    s;
    rh[2][i] = RollingHash(s);
  }
  for(int i = 0; i < n; ++i) {
    bool ch = 1;
    for(int j = 0; j < 30; ++j)
      if(rh[0][j].calchash(i, i + n) !=
             rh[2][j].calchash(0, n) &&
         rh[1][j].calchash(i, i + n) !=
             rh[2][j].calchash(0, n))
        ch = 0;
    if(ch) cout << i << " " << (a[i] ^ b[0]) << endl;
  }
}

Measured memory_bytes: 277012
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CTravelingSalesmanAroundLake {
public:
    void solve(std::istream &in, std::ostream &out) {
        int k, n;
        in >> k >> n;
        vi A(n);
        in >> A;
        int res = k - A[n - 1] + A[0];
        FOR(i, 1, n) {
            ckmax(res, A[i] - A[i - 1]);
        }
        res = k - res;
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    CTravelingSalesmanAroundLake solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
const int maxs=2e5;
int len,tp=0;
char X[maxs+5],st[maxs+5];
int main()
{
	scanf("%s",X);
	len=strlen(X);
	st[++tp]=X[0];
	for(int i=1;i<len;i++)
	{
		if(X[i]=='T'&&st[tp]=='S') tp--;
		else st[++tp]=X[i];
	}
	printf("%d\n",tp);
	return 0;
} 

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");

		int n = Integer.parseInt(tmpArray[0]);
		int a = Integer.parseInt(tmpArray[1]);
		int b = Integer.parseInt(tmpArray[2]);

		System.out.println(Math.min(n*a, b));
	}

}


Measured memory_bytes: 21716
#include <cstdio>
int read()
{
	int x=0,flag=1;char c;
	while((c=getchar())<'0' || c>'9') if(c=='-') flag=-1;
	while(c>='0' && c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return x*flag;
}
char s[10];
int main()
{
    scanf("%s",s);
    if(s[1]=='B')
        puts("ARC");
    else
        puts("ABC");
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
int main(){
    double a;
    cin >> a;
    cout  << fixed << setprecision(20) <<a*a*3.14159265358979 << " " << flush;
    cout  << fixed << setprecision(20) << 2*3.14159265358979*a << endl;
}



Measured memory_bytes: 3288
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
#include <random>
using namespace std;

/////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	int n, m; cin >> n >> m;
	int sum = 0;
	rep(i, 0, m) {
		int a; cin >> a;
		sum += a;
	}

	cout << ((n - sum >= 0) ? n - sum : -1) << endl;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

struct TopologicalSort {
    vector<vector<int>> E;
    TopologicalSort(int N) { E.resize(N); }
    void add_edge(int a, int b) { E[a].push_back(b); }
    bool visit(int v, vector<int>& order, vector<int>& color) {
        color[v] = 1;
        for (int u : E[v]) {
            if (color[u] == 2) continue; if (color[u] == 1) return false;
            if (!visit(u, order, color)) return false;
        } order.push_back(v); color[v] = 2; return true;
    }
    bool sort(vector<int> &order) {
        int n = E.size(); vector<int> color(n);
        for (int u = 0; u < n; u++)
            if (!color[u] && !visit(u, order, color)) return false;
        reverse(order.begin(), order.end()); return true;
    }
};

int N, M;
vector<int> E[101010];
int dp[101010];
int main(void) {
    cin >> N >> M;
    TopologicalSort ts(N);
    rep(i, 0, M) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        ts.add_edge(x, y);
        E[x].push_back(y);
    }
    vector<int> ord;
    ts.sort(ord);

    fore(cu, ord)
        fore(to, E[cu])
            chmax(dp[to], dp[cu] + 1);
    int ans = 0;
    rep(i, 0, N)
        chmax(ans, dp[i]);
    cout << ans << endl;
};


Measured memory_bytes: 13312
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int w, h;
bool board[110][110];//true????????????????????§?¨?
bool flag[110][110];//true?????????????????????????????????????????¨??¨??\??????????????§???????????§?¨?
bool used[110][110];//bfs???????????¨???????????¢
//y??§?¨?????\???°
int dx_kisuu[6] = {1, 1, 1, 0, -1, 0};
int dy_kisuu[6] = {-1, 0, 1, 1, 0, -1};
//y??§?¨??????¶??°
int dx_gusuu[6] = {0, 1, 0, -1, -1, -1};
int dy_gusuu[6] = {-1, 0, 1, 1, 0, -1};

bool hantei(int nowy, int nowx){//??????????????????
	if(0 <= nowy && nowy <= h + 1 && 0 <= nowx && nowx <= w + 1){
		return true;
	}else{
		return false;
	}
}

int main(void){
	cin >> w >> h;
	//??????????????????????????¨??????0??§??????
	for (int i = 1; i <= h; ++i){
		for (int j = 1; j <= w; ++j){
			cin >> board[i][j];
		}
	}

	queue<pair<int, int> > q;
	q.push(make_pair(0, 0));
	//bfs
	while(!q.empty()){
		pair<int, int> now;//first y second x
		now = q.front(); q.pop();
		if(now.first % 2 == 0){
			rep(i, 6){
				int nowy = now.first  + dy_gusuu[i];
				int nowx = now.second + dx_gusuu[i];
				if(hantei(nowy, nowx)){
					if(!board[nowy][nowx] && !used[nowy][nowx]){
						q.push(make_pair(nowy, nowx));
						flag[nowy][nowx] = true;
						used[nowy][nowx] = true;
					}
				}
			}
		}else{
			rep(i, 6){
				int nowy = now.first  + dy_kisuu[i];
				int nowx = now.second + dx_kisuu[i];
				if(hantei(nowy, nowx)){
					if(!board[nowy][nowx] && !used[nowy][nowx]){
						q.push(make_pair(nowy, nowx));
						flag[nowy][nowx] = true;
						used[nowy][nowx] = true;
					}
				}
			}
		}
	}

	long long sum = 0;
	for (int i = 0; i <= h + 1; ++i){
		for (int j = 0; j <= w + 1; ++j){
			if(flag[i][j]){//flag=true??????????????¨??????board=true?????????(??????)??¨??\?????????????????????????????§????????????
				int tmp = 0;
				if(i % 2 == 0){
					for (int k = 0; k < 6; ++k){
						int nowy = i + dy_gusuu[k], nowx = j + dx_gusuu[k];
						//?????????????????¨??\??????????????´??????????????????????????§??????????????????????????£?????¨???????????¨
						if(board[nowy][nowx] && hantei(nowy, nowx)) sum++;
					}
				}else{
					for (int k = 0; k < 6; ++k){
						int nowy = i + dy_kisuu[k], nowx = j + dx_kisuu[k];
						if(board[nowy][nowx] && hantei(nowy, nowx)) sum++;
					}
				}
			}
		}
	}
	printf("%lld\n", sum);
	return 0;
}

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

int main () {
    int n;
    std::cin >> n;
    std::vector<int> d(n);
    for (int i = 0; i < n; i++) {
        std::cin >> d[i];
    }
    int ans = 0;
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++) {
            ans += d[i] * d[j];

        }
    }

    std::cout << ans << "\n";
}

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

using namespace std;

int main()
{
    int ans=0;
    string s;

    cin >> s;
    
    if( s == "RSS" || s == "SRS" || s =="SSR" || s == "RSR")
        ans = 1;
    else if(s == "RRS" || s =="SRR" )
        ans = 2;
    else if(s =="RRR")
        ans = 3;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
# define ll long long
#define endl "\n"
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	string str;cin>>str;
	if(str[1]=='B')
		cout<<"ARC";
	else
		cout<<"ABC";
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i <= n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}


int main()
{
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    double maxnoudo=-1;
    int ansmizu=0;
    int anssugar=0;
    REP(i,f/(a*100)){
        REP(j,(f-i*a*100)/(b*100)){
            if(i==0&&j==0){
                continue;
            }
            int mizu=a*100*i+b*100*j;
            int maxsugar=min(f-mizu,mizu*e/100);
            int sugar=0;
            REP(z,maxsugar/c){
                int tmp=z*c+((maxsugar-z*c)/d)*d;
                chmax(sugar,tmp);
            }
            if(double(sugar)*100/double(sugar+mizu)>maxnoudo){
                maxnoudo = double(sugar) * 100 / double(sugar + mizu);
                ansmizu=mizu+sugar;
                anssugar=sugar;
            }
        }
    }
    cout << ansmizu << " " << anssugar << endl;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<pair<char, char>> td;
    for (int i = 0; i < q; i++) {
        char t, d;
        cin >> t >> d;
        td.emplace_back(t, d);
    }
    auto sim = [&](int p) -> int {
        char t = s[p];
        for (int i = 0; i < q; i++) {
            if (td[i].first == t) {
                if (td[i].second == 'L') {
                    p--;
                    if (p < 0) return -1;
                    t = s[p];
                } else {
                    p++;
                    if (p >= n) return 1;
                    t = s[p];
                }
            }
        }
        return 0;
    };

    int l = -1, r = n;
    while (l < r - 1) {
        int m = (l + r) / 2;
        if (sim(m) == -1) {
            l = m;
        } else {
            r = m;
        }
    }
    int ans = n - r;
    l = -1, r = n;
    while (l < r - 1) {
        int m = (l + r) / 2;
        if (sim(m) == 1) {
            r = m;
        } else {
            l = m;
        }
    }
    ans -= (n - r);
    cout << ans << endl;
}

Measured memory_bytes: 1100
#include <iostream>

using namespace std;

int main()
{
  int N, L[102] = {};
  cin >> N;
  for(int i = 0; i < N << 1; i++) {
    int K;
    cin >> K;
    ++L[K];
  }
  int ret = 0;
  for(int i = 100; i >= 0; i--) {
    int get = (L[i] + L[i + 1]) >> 1;
    ret += get * i;
    L[i] -= get * 2 - L[i + 1];
  }

  cout << ret << endl;
}

Measured memory_bytes: 640
#!/usr/bin/python3.6
MOD = 10**9 + 7
n = int(input())
a = [int(item) for item in input().split()]

ans = 1
prev = 0
vacant = 0
robot = 0
for item in a:
    vacant += item - prev - 1
    robot += 1
    if vacant <= robot - 2:
        ans *= robot
        ans %= MOD
        robot -= 1
        vacant += 1
    prev = item
for i in range(robot):
    ans *= i+1
    ans %= MOD
print(ans)

Measured memory_bytes: 14052
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	string str1, str2;
	int i;
	cin >> str1 >> str2;
	if (str1.size() > str2.size()) {
		for (i = 0; i < str2.size(); i++) {
			cout << str1[i] << str2[i];
		}
		cout << str1[i] << endl;
	}
	else if (str1.size() == str2.size()) {
		for (i = 0; i < str2.size(); i++) {
			cout << str1[i] << str2[i];
		}
		cout << endl;
	}
	else {
		for (i = 0; i < str1.size(); i++) {
			cout << str2[i] << str1[i];
		}
		cout << str2[i] << endl;
	}
}


Measured memory_bytes: 256
import random
import copy


def main():
    D = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(D)]

    t = [0] * D

    # 貪欲法でまず求める
    penalty = copy.deepcopy(c)
    for i in range(D):
        ind = 0
        tmp = 0
        for j in range(26):
            if penalty[j] + s[i][j] > tmp:
                tmp = penalty[j] + s[i][j]
                ind = j
        penalty[ind] = 0
        t[i] = ind + 1
        for j in range(26):
            penalty[j] += c[j]

    # 適当なtをスワップしてスコアが伸びればそれを採用する
    ans = calc(s, c, t)
    rand = list(range(365))
    for i in range(30000):
        swap = random.sample(rand, 2)
        t[swap[0]], t[swap[1]] = t[swap[1]], t[swap[0]]
        tmp = calc(s, c, t)
        if tmp < ans:
            # 元に戻す
            t[swap[0]], t[swap[1]] = t[swap[1]], t[swap[0]]
        else:
            ans = tmp
    return t


def output(t):
    for tt in t:
        print(tt)


def calc(s, c, t):
    d = [0] * 26

    ans = 0
    days = 0
    for tt in t:
        for i in range(26):
            d[i] += 1
        d[tt-1] = 0
        ans += s[days][tt-1]
        for i in range(26):
            ans -= d[i] * c[i]
        days += 1
        # print(ans)

    return ans


if __name__ == "__main__":
    t = main()
    output(t)


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

int main()
{
    int n;
    cin>>n;
    int arr[n],i,cnt=1,low;
    for(i=0;i<n;i++)
        cin>>arr[i];
    low=arr[0];
    
    for(i=1;i<n;i++)
    {
        if(arr[i]<low)
        {
            cnt++;
            low=arr[i];
        }
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;

class UnionFind {

public :
    int* par;
    int* depth;
    UnionFind(int n);
    virtual ~UnionFind();
    bool same(int x, int y);
    void unite(int x,int y);
    int find(int x);
};

UnionFind::UnionFind(int n)
{
    par = new int[n];
    depth = new int[n];
    for (int i = 0; i < n; i++) {
        par[i] = i;
        depth[i] = 1;
    }
}

UnionFind::~UnionFind()
{
    delete[] par;
    delete[] depth;
}

int UnionFind::find(int x)
{
    if (par[x] == x) {
        return x;
    } else {
        par[x] = find(par[x]);
        return par[x];
    }
}

void UnionFind::unite(int x,int y) 
{
    int rootX, rootY;
    rootX = find(x);
    rootY = find(y);
    if (rootX == rootY) {
        return;
    }

    if (depth[rootX] < depth[rootY]) {
        par[rootX] = rootY;
        depth[rootY] += depth[rootX];
    } else {
        par[rootY] = rootX;
        depth[rootX] += depth[rootY];
    }
}

bool UnionFind::same(int x, int y)
{
    return find(x) == find(y);
}

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> res(n + 1, 0);

    UnionFind u(n + 1);

    for (int i = 0; i < m; i++) {
        int tmpa, tmpb;
        cin >> tmpa >> tmpb;
        res[tmpa]++; res[tmpb]++;
        u.unite(tmpa, tmpb);
    }

    for (int i = 0; i < k; i++) {
        int tmpc, tmpd;
        cin >> tmpc >> tmpd;
        if (u.same(tmpc, tmpd)) {
            res[tmpc]++; res[tmpd]++;
        }
    }

    for (int i = 1; i <= n; i++) {
        cout << u.depth[u.find(i)] - res[i] - 1 << " ";
    }
    cout << endl;
}


Measured memory_bytes: 2048
import collections
class UnionFind:
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.rank = [0]*N
        self.count = 0
    def root(self, a):
        if self.parent[a]==a:
            return a
        else:
            self.parent[a]=self.root(self.parent[a])
            return self.parent[a]
    def size(x):
        return -par[root(x)]

    def is_same(self, a, b):
        return self.root(a)==self.root(b)
    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return

        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1
def main():
    n,m,k=map(int, input().split())
    friend = [0]*n
    fr = UnionFind(n)
    blocklist = [0]*n
    for i in range(m):
        a,b = map(int, input().split())
        fr.unite(a-1,b-1)
        friend[a-1]+=1
        friend[b-1]+=1
    for i in range(k):
        c,d=map(int, input().split())
        if(fr.root(c-1)==fr.root(d-1)):
            blocklist[c-1]+=1
            blocklist[d-1]+=1
    
    res = []
    dd = collections.defaultdict(int)
    for i in range(n):
        dd[fr.root(i)]+=1
    for i in range(n):
        res.append(dd[fr.root(i)]- blocklist[i] - friend[i]-1)
    print(*res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 25920
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const ll M = 1000000007;
vector<ll> fac(3001);
vector<ll> ifac(3001);
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main(void){
    ll n,k;
    cin >> n >> k;
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<3000; i++){
        fac[i+1] = fac[i]*(i+1) % M;
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M;
    }
    if(n == k){
        cout << 1 << endl;
        for(ll i = 0;i < n - 1; i++){
            cout << 0 << endl;
        }
    }
    else{
    for(ll i = 1; i <= k; i++){
        ll ans = 0;
        ans = ((comb(k-1,i-1)%M) * (((((comb(n-k-1,i))%M + (((comb(n-k-1,i-1))%M) * 2)%M)%M + (comb(n-k-1,i-2))%M))%M))%M;
        cout << ans << endl;
    }
    }
    return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	std::string s;
	std::cin >> s;
	std::reverse(s.begin(), s.end());
	for (auto &c : s) c -= '0';
	int n = s.size();
	int sum[n];
	sum[0] = s[0];
	int beki10 = 1;
	for (int i = 1; i < n; i++) {
		beki10 = beki10 * 10 % 2019;
		sum[i] = (sum[i - 1] + beki10 * s[i]) % 2019;
	}
	std::map<int, int> all;
	all[0]++;
	int64_t res = 0;
	for (auto i : sum) res += all[i], all[i]++;
	printf("%" PRId64 "\n", res);
	return 0;
}


Measured memory_bytes: 4572
#include <iostream>
#include <string>
#include <cassert>

using namespace std;

typedef string::iterator Iterator;

void skip(Iterator &it, char c) {
    if(*it != c) {
        cerr << "Expected " << c << " but " << *it << endl;
        assert(false);
    }
    ++it;
}

bool formula(Iterator &it, int vars) {
    if(*it == 'T') {
        ++it;
        return true;
    }
    else if(*it == 'F') {
        ++it;
        return false;
    }
    else if('a' <= *it && *it <= 'k') {
        int idx = *it - 'a';
        ++it;
        return (vars & (1<<idx)) != 0;
    }
    else if(*it == '-') {
        ++it;
        bool operand = formula(it, vars);
        return !operand;
    }
    else if(*it == '(') {
        ++it;
        bool lhs = formula(it, vars);
        int op = -1;
        if(*it == '*') {
            ++it;
            op = 1;
        }
        else if(*it == '+') {
            ++it;
            op = 2;
        }
        else if(*it == '-') {
            ++it;
            if(*it == '>') {
                ++it;
                op = 3;
            }
        }
        bool rhs = formula(it, vars);
        skip(it, ')');
        switch(op) {
            case 1:
                return lhs && rhs;
                break;
            case 2:
                return lhs || rhs;
                break;
            case 3:
                return !(lhs && !rhs);
                break;
            default:
                assert(false);
        }
    }
    assert(false);
}

int main() {
    while(true) {
        string str;
        getline(cin, str);
        if(str == "#") break;

        bool ok = true;
        for(int pat = 0; pat < (1<<11); ++pat) {
            Iterator it = str.begin();
            bool lhs = formula(it, pat);
            skip(it, '=');
            bool rhs = formula(it, pat);
            if(lhs != rhs) {
                ok = false;
                break;
            }
        }

        cout << (ok?"YES":"NO") << endl;
    }

    return 0;
}

Measured memory_bytes: 948
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<int> A(5);
    for(int i=0; i<5; i++)
    {
        cin >> A.at(i);
    }
    for(int i=0; i<5; i++)
    {
        if(A.at(i)==0)
        {
            cout << i+1 << endl;
        }
    }

}

Measured memory_bytes: 3548
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


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


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    A, B, C, K = MAP()
    ans = min(A, K)
    K -= A
    if K > B:
        K -= B
        print(ans - K)
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10608
-- BubbleSort(A)
-- 1 for i = 0 to A.length-1
-- 2     for j = A.length-1 downto i+1
-- 3         if A[j] < A[j-1]
-- 4             swap A[j] and A[j-1]

import qualified Data.Vector         as V
import qualified Data.Vector.Mutable as VM
import Control.Applicative
import Control.Monad.ST
import Control.Monad
import Data.IORef

bubbleSort :: [Int] -> IO ([Int], Int)
bubbleSort xs = do
  aVec <- V.thaw $ V.fromList xs
  let len = length xs - 1
  flag  <- newIORef True
  count <- newIORef 0
  forM_ [0 .. len] $ \i -> do
    f <- readIORef flag
    when f $ do
      writeIORef flag False
      forM_ [len, len - 1 .. (i + 1)] $ \j -> do
        -- v <- V.freeze aVec
        -- print (i, j, v)
        v1 <- VM.read aVec j
        v2 <- VM.read aVec (j - 1)
        when (v1 < v2) $ do
          VM.swap aVec j (j - 1)
          writeIORef flag True
          modifyIORef count (+ 1)
  v <- V.toList <$> V.freeze aVec
  c <- readIORef count
  return (v, c)

main :: IO ()
main = do
  _  <- getLine
  xs <- map read . words <$> getLine
  (ys, c) <- bubbleSort xs
  putStrLn $ unwords $ map show ys
  print c



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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

void solve()
{
    int n;
    cin>>n;
    vector<ll> v(n);
    for(int i=0;i<n;i++) {
        cin>>v[i];
    }
    map<ll,ll> m;
    for(int i=0;i<n;i++) {
        m[(i + 1) -v[i]]++;
    }
    ll ans=0;
    for(int i=0;i<n;i++) {
        if(m[v[i]+i+1]) {
            ans+=m[v[i]+i+1];
        }
    }
    cout<<ans;
}

int main()
{
    fastio;
    int t;
    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        //cout<<newl;
    }

    return 0;
}

Measured memory_bytes: 27468
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>p;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        p.push_back(x);
    }
    sort(p.begin(),p.end());
    int sum=0;
    for(int i=0;i<k;i++)
    {
        sum+=p[i];
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000000000000;
//input
int N,K;


//processing
ld ka;


//dpTable
//int dp[100050];

int main(){
    cin >> N >> K;
    for (int i = 1; i <= N; i++){
        int a = i;
        ld hoge = 1;
        while (a < K){
            a *= 2;
            hoge /= 2;
        }
        ka += hoge;
    }
    cout << fixed << setprecision(10) << ka / N << endl;
    return 0;
}

Measured memory_bytes: 3720
N = int(input())
H = list(map(int, input().split()))

ans = 0
ans_ = 0
t = 0 # 
for H in H:
    #print(ans, ans_)
    if t >= H:
        ans_ += 1
    else:
        ans = max(ans, ans_)
        ans_ = 0
    t = H
ans = max(ans, ans_)
print(ans)



Measured memory_bytes: 20392
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,k;
   cin>>n>>k;
   int dp[n+1];
   for(int i=1;i<=n;i++)
    dp[i]=1e16;
   int a[n+1];
   for(int i=1;i<=n;i++)
    cin>>a[i];
   dp[1]=0;
   for(int i=2;i<=n;i++)
   {
       for(int j=1;j<=k;j++)
       {
           if(i-j>=1)
           {
               dp[i]=min(dp[i],dp[i-j] + abs(a[i] - a[i-j]));
           }
       }
   }
   cout<<dp[n]<<endl;
}


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

int main(){
  int n; cin >> n;
  double num[n];
  for(int i=0;i<n;i++){
    cin >> num[i];
  }
  double total=0;
  double bunbo=0;
  for(int i=0;i<n;i++){
    bunbo += 1/num[i];
   // cout << 1/num[i] << endl;
    //cout << bunbo << endl;
  }
  //cout << bunbo << endl;
  
  cout << 1/bunbo << endl;
}

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


using namespace std;

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

	vector<int> a;
	int wk;


	int max = 0;
	int maxindex;
	int submax = 0;
	for (int i = 0; i < n; i++) {

		cin >> wk;

		a.push_back(wk);

		if (max < wk) {
			max = wk;
			maxindex = i;
		}

	}

	for (int i = 0; i < n; i++) {
		if (i != maxindex) {
			if (submax < a[i]) {
				submax = a[i];
			}
		}
	}

	int output = 0;
	for (int i = 0; i < n; i++) {
		if (i != maxindex) {
			output = max;
		}
		else {
			output = submax;
		}

		cout << output << endl;


	}
	return 0;






}



Measured memory_bytes: 2548